<?php

namespace IpagWoocommerce;

abstract class AbstractEndpointParser implements EndpointParserInterface
{
    protected $endpoint = '';

    protected ?TransformerInterface $requestTransformer;
    protected ?TransformerInterface $responseTransformer;

    public function getEndpoint(): string
    {
        if (!isset($this->endpoint)) {
            throw new \Exception("Endpoint not defined in parser");
        }

        return $this->endpoint;
    }

    public static function createMyself(): EndpointParserInterface
    {
        return new static();
    }

    protected function injectLatestAPIHeaders(array &$request)
    {
        $request['headers']['x-api-version'] = 2;
        $request['headers']['Accept'] = 'application/json';
        $request['headers']['Content-Type'] = 'application/json';
    }
}