<?php 
// phpcs:ignoreFile WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
// phpcs:ignoreFile WordPress.WP.AlternativeFunctions.file_system_operations_fwrite
// phpcs:ignoreFile WordPress.WP.AlternativeFunctions.file_system_operations_fclose
// phpcs:ignoreFile WordPress.WP.AlternativeFunctions.file_system_operations_fopen
// phpcs:ignoreFile WordPress.Security.EscapeOutput.ExceptionNotEscaped            

/**
 * ShipmentApi
 * PHP version 7.4
 *
 * @category Class
 * @package  PPLCZCPL
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * CPL
 *
 * **Changelog**    * 2024-08-22 - SPRJ-13791 - validace PRTE / PRBC externích čísel - nelze použít najednou    - /shipment/batch    * 2024-07-01 - SPRJ-13838 - přidání    - /customer/address    * 2023-11-23 - SPRJ-12703 - CPL - /shipment - timestamp    - /shipment - Rozšíření výstupu o LastUpdateDate.    * 2023-07-13 - SPRJ-11888 - přidání    - /codelist/status - číselník statusů    * 2023-07-13 - SPRJ-11953 - přidání    - /order/cancel - storno objednávky
 *
 * The version of the OpenAPI document: v1
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 6.0.1
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace PPLCZCPL\Api;

use PPLCZVendor\GuzzleHttp\Client;
use PPLCZVendor\GuzzleHttp\ClientInterface;
use PPLCZVendor\GuzzleHttp\Exception\ConnectException;
use PPLCZVendor\GuzzleHttp\Exception\RequestException;
use PPLCZVendor\GuzzleHttp\Psr7\MultipartStream;
use PPLCZVendor\GuzzleHttp\Psr7\Request;
use PPLCZVendor\GuzzleHttp\RequestOptions;
use PPLCZCPL\ApiException;
use PPLCZCPL\Configuration;
use PPLCZCPL\HeaderSelector;
use PPLCZCPL\ObjectSerializerPpl;

/**
 * ShipmentApi Class Doc Comment
 *
 * @category Class
 * @package  PPLCZCPL
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */
class ShipmentApi
{
    /**
     * @var ClientInterface
     */
    protected $client;

    /**
     * @var Configuration
     */
    protected $config;

    /**
     * @var HeaderSelector
     */
    protected $headerSelector;

    /**
     * @var int Host index
     */
    protected $hostIndex;

    /**
     * @param ClientInterface $client
     * @param Configuration   $config
     * @param HeaderSelector  $selector
     * @param int             $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
     */
    public function __construct(?ClientInterface $client = null, ?Configuration $config = null, ?HeaderSelector $selector = null, $hostIndex = 0) {
        $this->client = $client ?: new Client();
        $this->config = $config ?: new Configuration();
        $this->headerSelector = $selector ?: new HeaderSelector();
        $this->hostIndex = $hostIndex;
    }

    /**
     * Set the host index
     *
     * @param int $hostIndex Host index (required)
     */
    public function setHostIndex($hostIndex): void
    {
        $this->hostIndex = $hostIndex;
    }

    /**
     * Get the host index
     *
     * @return int Host index
     */
    public function getHostIndex()
    {
        return $this->hostIndex;
    }

    /**
     * @return Configuration
     */
    public function getConfig()
    {
        return $this->config;
    }

    /**
     * Operation shipmentGet
     *
     * Slouží k získání informací (trackingu) k zásilce
     *
     * @param  int $limit limit (required)
     * @param  int $offset offset (required)
     * @param  string[] $shipment_numbers ShipmentNumbers (optional)
     * @param  string[] $invoice_numbers InvoiceNumbers (optional)
     * @param  string[] $customer_references CustomerReferences (optional)
     * @param  string[] $variable_symbols VariableSymbols (optional)
     * @param  \DateTime $date_from DateFrom (optional)
     * @param  \DateTime $date_to DateTo (optional)
     * @param  EpsApiMyApi2WebModelsShipmentShipmentStates $shipment_states ShipmentStates (optional)
     * @param  string $accept_language Language specification, default language: cs-CZ (optional)
     * @param  string $x_correlation_id Correlation Id of request (optional)
     * @param  XLogLevelSchema $x_log_level The forced log level (optional)
     *
     * @throws \PPLCZCPL\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentShipmentModel[]|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel
     */
    public function shipmentGet($limit, $offset, $shipment_numbers = null, $invoice_numbers = null, $customer_references = null, $variable_symbols = null, $date_from = null, $date_to = null, $shipment_states = null, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        list($response) = $this->shipmentGetWithHttpInfo($limit, $offset, $shipment_numbers, $invoice_numbers, $customer_references, $variable_symbols, $date_from, $date_to, $shipment_states, $accept_language, $x_correlation_id, $x_log_level);
        return $response;
    }

    /**
     * Operation shipmentGetWithHttpInfo
     *
     * Slouží k získání informací (trackingu) k zásilce
     *
     * @param  int $limit (required)
     * @param  int $offset (required)
     * @param  string[] $shipment_numbers ShipmentNumbers (optional)
     * @param  string[] $invoice_numbers InvoiceNumbers (optional)
     * @param  string[] $customer_references CustomerReferences (optional)
     * @param  string[] $variable_symbols VariableSymbols (optional)
     * @param  \DateTime $date_from DateFrom (optional)
     * @param  \DateTime $date_to DateTo (optional)
     * @param  EpsApiMyApi2WebModelsShipmentShipmentStates $shipment_states ShipmentStates (optional)
     * @param  string $accept_language Language specification, default language: cs-CZ (optional)
     * @param  string $x_correlation_id Correlation Id of request (optional)
     * @param  XLogLevelSchema $x_log_level The forced log level (optional)
     *
     * @throws \PPLCZCPL\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentShipmentModel[]|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel, HTTP status code, HTTP response headers (array of strings)
     */
    public function shipmentGetWithHttpInfo($limit, $offset, $shipment_numbers = null, $invoice_numbers = null, $customer_references = null, $variable_symbols = null, $date_from = null, $date_to = null, $shipment_states = null, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        $request = $this->shipmentGetRequest($limit, $offset, $shipment_numbers, $invoice_numbers, $customer_references, $variable_symbols, $date_from, $date_to, $shipment_states, $accept_language, $x_correlation_id, $x_log_level);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
                );
            } catch (ConnectException $e) {
                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    (int) $e->getCode(),
                    null,
                    null
                );
            }

            $statusCode = $response->getStatusCode();

            if ($statusCode < 200 || $statusCode > 299) {
                throw new ApiException(
                    sprintf(
                        '[%d] Error connecting to the API (%s)',
                        $statusCode,
                        (string) $request->getUri()
                    ),
                    $statusCode,
                    $response->getHeaders(),
                    (string) $response->getBody()
                );
            }

            switch($statusCode) {
                case 200:
                    if ('\PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentShipmentModel[]' === '\SplFileObject') {
                        $content = $response->getBody(); //stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('\PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentShipmentModel[]' !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializerPpl::deserialize($content, '\PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentShipmentModel[]', []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                case 400:
                    if ('\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel' === '\SplFileObject') {
                        $content = $response->getBody(); //stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel' !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializerPpl::deserialize($content, '\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel', []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                case 404:
                    if ('\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel' === '\SplFileObject') {
                        $content = $response->getBody(); //stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel' !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializerPpl::deserialize($content, '\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel', []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                case 500:
                    if ('\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel' === '\SplFileObject') {
                        $content = $response->getBody(); //stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel' !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializerPpl::deserialize($content, '\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel', []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                case 503:
                    if ('\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel' === '\SplFileObject') {
                        $content = $response->getBody(); //stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel' !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializerPpl::deserialize($content, '\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel', []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
            }

            $returnType = '\PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentShipmentModel[]';
            if ($returnType === '\SplFileObject') {
                $content = $response->getBody(); //stream goes to serializer
            } else {
                $content = (string) $response->getBody();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

            return [
                ObjectSerializerPpl::deserialize($content, $returnType, []),
                $response->getStatusCode(),
                $response->getHeaders()
            ];

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializerPpl::deserialize(
                        $e->getResponseBody(),
                        '\PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentShipmentModel[]',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializerPpl::deserialize(
                        $e->getResponseBody(),
                        '\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 404:
                    $data = ObjectSerializerPpl::deserialize(
                        $e->getResponseBody(),
                        '\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializerPpl::deserialize(
                        $e->getResponseBody(),
                        '\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 503:
                    $data = ObjectSerializerPpl::deserialize(
                        $e->getResponseBody(),
                        '\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation shipmentGetAsync
     *
     * Slouží k získání informací (trackingu) k zásilce
     *
     * @param  int $limit (required)
     * @param  int $offset (required)
     * @param  string[] $shipment_numbers ShipmentNumbers (optional)
     * @param  string[] $invoice_numbers InvoiceNumbers (optional)
     * @param  string[] $customer_references CustomerReferences (optional)
     * @param  string[] $variable_symbols VariableSymbols (optional)
     * @param  \DateTime $date_from DateFrom (optional)
     * @param  \DateTime $date_to DateTo (optional)
     * @param  EpsApiMyApi2WebModelsShipmentShipmentStates $shipment_states ShipmentStates (optional)
     * @param  string $accept_language Language specification, default language: cs-CZ (optional)
     * @param  string $x_correlation_id Correlation Id of request (optional)
     * @param  XLogLevelSchema $x_log_level The forced log level (optional)
     *
     * @throws \InvalidArgumentException
     * @return \PPLCZVendor\GuzzleHttp\Promise\PromiseInterface
     */
    public function shipmentGetAsync($limit, $offset, $shipment_numbers = null, $invoice_numbers = null, $customer_references = null, $variable_symbols = null, $date_from = null, $date_to = null, $shipment_states = null, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        return $this->shipmentGetAsyncWithHttpInfo($limit, $offset, $shipment_numbers, $invoice_numbers, $customer_references, $variable_symbols, $date_from, $date_to, $shipment_states, $accept_language, $x_correlation_id, $x_log_level)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation shipmentGetAsyncWithHttpInfo
     *
     * Slouží k získání informací (trackingu) k zásilce
     *
     * @param  int $limit (required)
     * @param  int $offset (required)
     * @param  string[] $shipment_numbers ShipmentNumbers (optional)
     * @param  string[] $invoice_numbers InvoiceNumbers (optional)
     * @param  string[] $customer_references CustomerReferences (optional)
     * @param  string[] $variable_symbols VariableSymbols (optional)
     * @param  \DateTime $date_from DateFrom (optional)
     * @param  \DateTime $date_to DateTo (optional)
     * @param  EpsApiMyApi2WebModelsShipmentShipmentStates $shipment_states ShipmentStates (optional)
     * @param  string $accept_language Language specification, default language: cs-CZ (optional)
     * @param  string $x_correlation_id Correlation Id of request (optional)
     * @param  XLogLevelSchema $x_log_level The forced log level (optional)
     *
     * @throws \InvalidArgumentException
     * @return \PPLCZVendor\GuzzleHttp\Promise\PromiseInterface
     */
    public function shipmentGetAsyncWithHttpInfo($limit, $offset, $shipment_numbers = null, $invoice_numbers = null, $customer_references = null, $variable_symbols = null, $date_from = null, $date_to = null, $shipment_states = null, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        $returnType = '\PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentShipmentModel[]';
        $request = $this->shipmentGetRequest($limit, $offset, $shipment_numbers, $invoice_numbers, $customer_references, $variable_symbols, $date_from, $date_to, $shipment_states, $accept_language, $x_correlation_id, $x_log_level);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    if ($returnType === '\SplFileObject') {
                        $content = $response->getBody(); //stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ($returnType !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializerPpl::deserialize($content, $returnType, []),
                        $response->getStatusCode(),
                        $response->getHeaders()
                    ];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        (string) $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'shipmentGet'
     *
     * @param  int $limit (required)
     * @param  int $offset (required)
     * @param  string[] $shipment_numbers ShipmentNumbers (optional)
     * @param  string[] $invoice_numbers InvoiceNumbers (optional)
     * @param  string[] $customer_references CustomerReferences (optional)
     * @param  string[] $variable_symbols VariableSymbols (optional)
     * @param  \DateTime $date_from DateFrom (optional)
     * @param  \DateTime $date_to DateTo (optional)
     * @param  EpsApiMyApi2WebModelsShipmentShipmentStates $shipment_states ShipmentStates (optional)
     * @param  string $accept_language Language specification, default language: cs-CZ (optional)
     * @param  string $x_correlation_id Correlation Id of request (optional)
     * @param  XLogLevelSchema $x_log_level The forced log level (optional)
     *
     * @throws \InvalidArgumentException
     * @return \PPLCZVendor\GuzzleHttp\Psr7\Request
     */
    public function shipmentGetRequest($limit, $offset, $shipment_numbers = null, $invoice_numbers = null, $customer_references = null, $variable_symbols = null, $date_from = null, $date_to = null, $shipment_states = null, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        // verify the required parameter 'limit' is set
        if ($limit === null || (is_array($limit) && count($limit) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $limit when calling shipmentGet'
            );
        }
        if ($limit > 1000) {
            throw new \InvalidArgumentException('invalid value for "$limit" when calling ShipmentApi.shipmentGet, must be smaller than or equal to 1000.');
        }
        if ($limit < 1) {
            throw new \InvalidArgumentException('invalid value for "$limit" when calling ShipmentApi.shipmentGet, must be bigger than or equal to 1.');
        }

        // verify the required parameter 'offset' is set
        if ($offset === null || (is_array($offset) && count($offset) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $offset when calling shipmentGet'
            );
        }
        if ($offset > 2147483647) {
            throw new \InvalidArgumentException('invalid value for "$offset" when calling ShipmentApi.shipmentGet, must be smaller than or equal to 2147483647.');
        }
        if ($offset < 0) {
            throw new \InvalidArgumentException('invalid value for "$offset" when calling ShipmentApi.shipmentGet, must be bigger than or equal to 0.');
        }

        if ($shipment_numbers !== null && count($shipment_numbers) > 50) {
            throw new \InvalidArgumentException('invalid value for "$shipment_numbers" when calling ShipmentApi.shipmentGet, number of items must be less than or equal to 50.');
        }

        if ($invoice_numbers !== null && count($invoice_numbers) > 50) {
            throw new \InvalidArgumentException('invalid value for "$invoice_numbers" when calling ShipmentApi.shipmentGet, number of items must be less than or equal to 50.');
        }

        if ($customer_references !== null && count($customer_references) > 50) {
            throw new \InvalidArgumentException('invalid value for "$customer_references" when calling ShipmentApi.shipmentGet, number of items must be less than or equal to 50.');
        }

        if ($variable_symbols !== null && count($variable_symbols) > 50) {
            throw new \InvalidArgumentException('invalid value for "$variable_symbols" when calling ShipmentApi.shipmentGet, number of items must be less than or equal to 50.');
        }


        $resourcePath = '/shipment';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $shipment_numbers,
            'ShipmentNumbers', // param base name
            'array', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $invoice_numbers,
            'InvoiceNumbers', // param base name
            'array', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $customer_references,
            'CustomerReferences', // param base name
            'array', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $variable_symbols,
            'VariableSymbols', // param base name
            'array', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $date_from,
            'DateFrom', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $date_to,
            'DateTo', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $shipment_states,
            'ShipmentStates', // param base name
            'EpsApiMyApi2WebModelsShipmentShipmentStates', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $limit,
            'Limit', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $offset,
            'Offset', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);

        // header params
        if ($accept_language !== null) {
            $headerParams['Accept-Language'] = ObjectSerializerPpl::toHeaderValue($accept_language);
        }
        // header params
        if ($x_correlation_id !== null) {
            $headerParams['X-Correlation-ID'] = ObjectSerializerPpl::toHeaderValue($x_correlation_id);
        }
        // header params
        if ($x_log_level !== null) {
            $headerParams['X-LogLevel'] = ObjectSerializerPpl::toHeaderValue($x_log_level);
        }



        if ($multipart) {
            $headers = $this->headerSelector->selectHeadersForMultipart(
                ['application/json', 'text/json', 'application/problem+json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/json', 'text/json', 'application/problem+json'],
                []
            );
        }

        // for model (json/xml)
        if (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

            } elseif ($headers['Content-Type'] === 'application/json') {
                $httpBody = wp_json_encode($formParams);

            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializerPpl::buildQuery($formParams);
            }
        }

        // this endpoint requires Bearer (JWT) authentication (access token)
        if (!empty($this->config->getAccessToken())) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }

        $defaultHeaders = [];
        if ($this->config->getUserAgent()) {
            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
        }

        $headers = array_merge(
            $defaultHeaders,
            $headerParams,
            $headers
        );

        $query = ObjectSerializerPpl::buildQuery($queryParams);
        return new Request(
            'GET',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Create http client option
     *
     * @throws \RuntimeException on file opening failure
     * @return array of http client options
     */
    protected function createHttpClientOption()
    {
        $options = [];
        if ($this->config->getDebug()) {
            $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
            if (!$options[RequestOptions::DEBUG]) {
                throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
            }
        }

        return $options;
    }
}
