<?php
namespace Podeli\Payment\Methods;

use Podeli\Payment\Client;

abstract class BaseMethod
{
    const HTTP_METHOD = 'POST';

    const PATH = '';

    protected $client = null;
    protected $correlationId = '';

    public function __construct(Client $client)
    {
        $this->client = $client;
    }

    public function setCorrelationId(string $correlationId)
    {
        $this->correlationId = $correlationId;
        return $this;
    }

    public function execute()
    {
        $path = $this->getPath();
        $data = $this->getData();
        $response = $this->client->execute($path, $data, static::HTTP_METHOD, $this->correlationId);
        return $this->processResponse($response);
    }

    abstract function getPath();

    abstract function getData();

    public function processResponse($response)
    {
        return $response;
    }
}
