<?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            

/**
 * ShipmentBatchApi
 * 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;

/**
 * ShipmentBatchApi Class Doc Comment
 *
 * @category Class
 * @package  PPLCZCPL
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */
class ShipmentBatchApi
{
    /**
     * @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 createShipments
     *
     * Slouží k vytvoření zásilky. Odpověď je v header (Location)
     *
     * @param  \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchCreateShipmentBatchModel $eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model The request data (required)
     * @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 void
     */
    public function createShipments($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        $this->createShipmentsWithHttpInfo($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model, $accept_language, $x_correlation_id, $x_log_level);
    }

    /**
     * Operation createShipmentsWithHttpInfo
     *
     * Slouží k vytvoření zásilky. Odpověď je v header (Location)
     *
     * @param  \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchCreateShipmentBatchModel $eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model The request data (required)
     * @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 null, HTTP status code, HTTP response headers (array of strings)
     */
    public function createShipmentsWithHttpInfo($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        $request = $this->createShipmentsRequest($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model, $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()
                );
            }

            return [null, $statusCode, $response->getHeaders()];

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 400:
                    $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 createShipmentsAsync
     *
     * Slouží k vytvoření zásilky. Odpověď je v header (Location)
     *
     * @param  \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchCreateShipmentBatchModel $eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model The request data (required)
     * @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 createShipmentsAsync($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        return $this->createShipmentsAsyncWithHttpInfo($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model, $accept_language, $x_correlation_id, $x_log_level)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation createShipmentsAsyncWithHttpInfo
     *
     * Slouží k vytvoření zásilky. Odpověď je v header (Location)
     *
     * @param  \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchCreateShipmentBatchModel $eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model The request data (required)
     * @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 createShipmentsAsyncWithHttpInfo($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        $returnType = '';
        $request = $this->createShipmentsRequest($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model, $accept_language, $x_correlation_id, $x_log_level);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    return [null, $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 'createShipments'
     *
     * @param  \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchCreateShipmentBatchModel $eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model The request data (required)
     * @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 createShipmentsRequest($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        // verify the required parameter 'eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model' is set
        if ($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model === null || (is_array($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model) && count($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model when calling createShipments'
            );
        }

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


        // 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/problem+json']
            );
        } else {
            $headers = $this->headerSelector->selectHeaders(
                ['application/problem+json'],
                ['application/json-patch+json', 'application/json', 'text/json', 'application/*+json']
            );
        }

        // for model (json/xml)
        if (isset($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model)) {
            if ($headers['Content-Type'] === 'application/json') {
                $httpBody = wp_json_encode(ObjectSerializerPpl::sanitizeForSerialization($eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model));
            } else {
                $httpBody = $eps_api_my_api2_web_models_shipment_batch_create_shipment_batch_model;
            }
        } elseif (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(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getShipmentBatch
     *
     * Slouží k získání stavu importu zásilky
     *
     * @param  string $batch_id The batch id (required)
     * @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)
     * @param  GetShipmentBatchOrderByParameter $order_by Sort items by defined fields. For multiple sorting use field names separated by comma. Use \&quot;-\&quot; to descendant order (eg.: OrderBy&#x3D;field1,-field2).  Orderable fields: **ShipmentNumber, ReferenceId**, see also schema **Eps.Api.MyApi2.Web.Controllers.ShipmentBatchController.GetShipmentBatch.OrderBy.enum** (optional)
     *
     * @throws \PPLCZCPL\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchShipmentBatchResultModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel
     */
    public function getShipmentBatch($batch_id, $accept_language = null, $x_correlation_id = null, $x_log_level = null, $order_by = null)
    {
        list($response) = $this->getShipmentBatchWithHttpInfo($batch_id, $accept_language, $x_correlation_id, $x_log_level, $order_by);
        return $response;
    }

    /**
     * Operation getShipmentBatchWithHttpInfo
     *
     * Slouží k získání stavu importu zásilky
     *
     * @param  string $batch_id The batch id (required)
     * @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)
     * @param  GetShipmentBatchOrderByParameter $order_by Sort items by defined fields. For multiple sorting use field names separated by comma. Use \&quot;-\&quot; to descendant order (eg.: OrderBy&#x3D;field1,-field2).  Orderable fields: **ShipmentNumber, ReferenceId**, see also schema **Eps.Api.MyApi2.Web.Controllers.ShipmentBatchController.GetShipmentBatch.OrderBy.enum** (optional)
     *
     * @throws \PPLCZCPL\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchShipmentBatchResultModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel, HTTP status code, HTTP response headers (array of strings)
     */
    public function getShipmentBatchWithHttpInfo($batch_id, $accept_language = null, $x_correlation_id = null, $x_log_level = null, $order_by = null)
    {
        $request = $this->getShipmentBatchRequest($batch_id, $accept_language, $x_correlation_id, $x_log_level, $order_by);

        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\EpsApiMyApi2WebModelsShipmentBatchShipmentBatchResultModel' === '\SplFileObject') {
                        $content = $response->getBody(); //stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('\PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchShipmentBatchResultModel' !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializerPpl::deserialize($content, '\PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchShipmentBatchResultModel', []),
                        $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\EpsApiMyApi2WebModelsShipmentBatchShipmentBatchResultModel';
            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\EpsApiMyApi2WebModelsShipmentBatchShipmentBatchResultModel',
                        $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 getShipmentBatchAsync
     *
     * Slouží k získání stavu importu zásilky
     *
     * @param  string $batch_id The batch id (required)
     * @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)
     * @param  GetShipmentBatchOrderByParameter $order_by Sort items by defined fields. For multiple sorting use field names separated by comma. Use \&quot;-\&quot; to descendant order (eg.: OrderBy&#x3D;field1,-field2).  Orderable fields: **ShipmentNumber, ReferenceId**, see also schema **Eps.Api.MyApi2.Web.Controllers.ShipmentBatchController.GetShipmentBatch.OrderBy.enum** (optional)
     *
     * @throws \InvalidArgumentException
     * @return \PPLCZVendor\GuzzleHttp\Promise\PromiseInterface
     */
    public function getShipmentBatchAsync($batch_id, $accept_language = null, $x_correlation_id = null, $x_log_level = null, $order_by = null)
    {
        return $this->getShipmentBatchAsyncWithHttpInfo($batch_id, $accept_language, $x_correlation_id, $x_log_level, $order_by)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getShipmentBatchAsyncWithHttpInfo
     *
     * Slouží k získání stavu importu zásilky
     *
     * @param  string $batch_id The batch id (required)
     * @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)
     * @param  GetShipmentBatchOrderByParameter $order_by Sort items by defined fields. For multiple sorting use field names separated by comma. Use \&quot;-\&quot; to descendant order (eg.: OrderBy&#x3D;field1,-field2).  Orderable fields: **ShipmentNumber, ReferenceId**, see also schema **Eps.Api.MyApi2.Web.Controllers.ShipmentBatchController.GetShipmentBatch.OrderBy.enum** (optional)
     *
     * @throws \InvalidArgumentException
     * @return \PPLCZVendor\GuzzleHttp\Promise\PromiseInterface
     */
    public function getShipmentBatchAsyncWithHttpInfo($batch_id, $accept_language = null, $x_correlation_id = null, $x_log_level = null, $order_by = null)
    {
        $returnType = '\PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchShipmentBatchResultModel';
        $request = $this->getShipmentBatchRequest($batch_id, $accept_language, $x_correlation_id, $x_log_level, $order_by);

        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 'getShipmentBatch'
     *
     * @param  string $batch_id The batch id (required)
     * @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)
     * @param  GetShipmentBatchOrderByParameter $order_by Sort items by defined fields. For multiple sorting use field names separated by comma. Use \&quot;-\&quot; to descendant order (eg.: OrderBy&#x3D;field1,-field2).  Orderable fields: **ShipmentNumber, ReferenceId**, see also schema **Eps.Api.MyApi2.Web.Controllers.ShipmentBatchController.GetShipmentBatch.OrderBy.enum** (optional)
     *
     * @throws \InvalidArgumentException
     * @return \PPLCZVendor\GuzzleHttp\Psr7\Request
     */
    public function getShipmentBatchRequest($batch_id, $accept_language = null, $x_correlation_id = null, $x_log_level = null, $order_by = null)
    {
        // verify the required parameter 'batch_id' is set
        if ($batch_id === null || (is_array($batch_id) && count($batch_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $batch_id when calling getShipmentBatch'
            );
        }

        $resourcePath = '/shipment/batch/{batchId}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $order_by,
            'OrderBy', // param base name
            'AnyOfEpsApiMyApi2WebControllersShipmentBatchControllerGetShipmentBatchOrderByEnumString', // openApiType
            'form', // style
            true, // explode
            false // 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);
        }

        // path params
        if ($batch_id !== null) {
            $resourcePath = str_replace(
                '{' . 'batchId' . '}',
                ObjectSerializerPpl::toPathValue($batch_id),
                $resourcePath
            );
        }


        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
        );
    }

    /**
     * Operation getShipmentBatchLabel
     *
     * BatchId z předchozí metody. Odpovědí je URL (hromadné nebo k jednotlivému balíku) pro stažení vygenerované etikety.
     *
     * @param  string $batch_id The batch id (required)
     * @param  int $limit The limit (required)
     * @param  int $offset The offset (required)
     * @param  EpsApiMyApi2BusinessEnumsConstPageSize $page_size PageSize (optional)
     * @param  int $position Position (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)
     * @param  GetShipmentBatchLabelOrderByParameter $order_by Sort items by defined fields. For multiple sorting use field names separated by comma. Use \&quot;-\&quot; to descendant order (eg.: OrderBy&#x3D;field1,-field2).  Orderable fields: **ShipmentNumber, ReferenceId**, see also schema **Eps.Api.MyApi2.Web.Controllers.ShipmentBatchController.GetShipmentBatchLabel.OrderBy.enum** (optional)
     *
     * @throws \PPLCZCPL\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \SplFileObject|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel
     */
    public function getShipmentBatchLabel($batch_id, $limit, $offset, $page_size = null, $position = null, $accept_language = null, $x_correlation_id = null, $x_log_level = null, $order_by = null)
    {
        list($response) = $this->getShipmentBatchLabelWithHttpInfo($batch_id, $limit, $offset, $page_size, $position, $accept_language, $x_correlation_id, $x_log_level, $order_by);
        return $response;
    }

    /**
     * Operation getShipmentBatchLabelWithHttpInfo
     *
     * BatchId z předchozí metody. Odpovědí je URL (hromadné nebo k jednotlivému balíku) pro stažení vygenerované etikety.
     *
     * @param  string $batch_id The batch id (required)
     * @param  int $limit The limit (required)
     * @param  int $offset The offset (required)
     * @param  EpsApiMyApi2BusinessEnumsConstPageSize $page_size PageSize (optional)
     * @param  int $position Position (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)
     * @param  GetShipmentBatchLabelOrderByParameter $order_by Sort items by defined fields. For multiple sorting use field names separated by comma. Use \&quot;-\&quot; to descendant order (eg.: OrderBy&#x3D;field1,-field2).  Orderable fields: **ShipmentNumber, ReferenceId**, see also schema **Eps.Api.MyApi2.Web.Controllers.ShipmentBatchController.GetShipmentBatchLabel.OrderBy.enum** (optional)
     *
     * @throws \PPLCZCPL\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \SplFileObject|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel|\PPLCZCPL\Model\EpsApiInfrastructureWebApiModelProblemJsonModel, HTTP status code, HTTP response headers (array of strings)
     */
    public function getShipmentBatchLabelWithHttpInfo($batch_id, $limit, $offset, $page_size = null, $position = null, $accept_language = null, $x_correlation_id = null, $x_log_level = null, $order_by = null)
    {
        $request = $this->getShipmentBatchLabelRequest($batch_id, $limit, $offset, $page_size, $position, $accept_language, $x_correlation_id, $x_log_level, $order_by);

        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 ('\SplFileObject' === '\SplFileObject') {
                        $content = $response->getBody(); //stream goes to serializer
                    } else {
                        $content = (string) $response->getBody();
                        if ('\SplFileObject' !== 'string') {
                            $content = json_decode($content);
                        }
                    }

                    return [
                        ObjectSerializerPpl::deserialize($content, '\SplFileObject', []),
                        $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 = '\SplFileObject';
            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(),
                        '\SplFileObject',
                        $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 getShipmentBatchLabelAsync
     *
     * BatchId z předchozí metody. Odpovědí je URL (hromadné nebo k jednotlivému balíku) pro stažení vygenerované etikety.
     *
     * @param  string $batch_id The batch id (required)
     * @param  int $limit The limit (required)
     * @param  int $offset The offset (required)
     * @param  EpsApiMyApi2BusinessEnumsConstPageSize $page_size PageSize (optional)
     * @param  int $position Position (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)
     * @param  GetShipmentBatchLabelOrderByParameter $order_by Sort items by defined fields. For multiple sorting use field names separated by comma. Use \&quot;-\&quot; to descendant order (eg.: OrderBy&#x3D;field1,-field2).  Orderable fields: **ShipmentNumber, ReferenceId**, see also schema **Eps.Api.MyApi2.Web.Controllers.ShipmentBatchController.GetShipmentBatchLabel.OrderBy.enum** (optional)
     *
     * @throws \InvalidArgumentException
     * @return \PPLCZVendor\GuzzleHttp\Promise\PromiseInterface
     */
    public function getShipmentBatchLabelAsync($batch_id, $limit, $offset, $page_size = null, $position = null, $accept_language = null, $x_correlation_id = null, $x_log_level = null, $order_by = null)
    {
        return $this->getShipmentBatchLabelAsyncWithHttpInfo($batch_id, $limit, $offset, $page_size, $position, $accept_language, $x_correlation_id, $x_log_level, $order_by)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getShipmentBatchLabelAsyncWithHttpInfo
     *
     * BatchId z předchozí metody. Odpovědí je URL (hromadné nebo k jednotlivému balíku) pro stažení vygenerované etikety.
     *
     * @param  string $batch_id The batch id (required)
     * @param  int $limit The limit (required)
     * @param  int $offset The offset (required)
     * @param  EpsApiMyApi2BusinessEnumsConstPageSize $page_size PageSize (optional)
     * @param  int $position Position (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)
     * @param  GetShipmentBatchLabelOrderByParameter $order_by Sort items by defined fields. For multiple sorting use field names separated by comma. Use \&quot;-\&quot; to descendant order (eg.: OrderBy&#x3D;field1,-field2).  Orderable fields: **ShipmentNumber, ReferenceId**, see also schema **Eps.Api.MyApi2.Web.Controllers.ShipmentBatchController.GetShipmentBatchLabel.OrderBy.enum** (optional)
     *
     * @throws \InvalidArgumentException
     * @return \PPLCZVendor\GuzzleHttp\Promise\PromiseInterface
     */
    public function getShipmentBatchLabelAsyncWithHttpInfo($batch_id, $limit, $offset, $page_size = null, $position = null, $accept_language = null, $x_correlation_id = null, $x_log_level = null, $order_by = null)
    {
        $returnType = '\SplFileObject';
        $request = $this->getShipmentBatchLabelRequest($batch_id, $limit, $offset, $page_size, $position, $accept_language, $x_correlation_id, $x_log_level, $order_by);

        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 'getShipmentBatchLabel'
     *
     * @param  string $batch_id The batch id (required)
     * @param  int $limit The limit (required)
     * @param  int $offset The offset (required)
     * @param  EpsApiMyApi2BusinessEnumsConstPageSize $page_size PageSize (optional)
     * @param  int $position Position (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)
     * @param  GetShipmentBatchLabelOrderByParameter $order_by Sort items by defined fields. For multiple sorting use field names separated by comma. Use \&quot;-\&quot; to descendant order (eg.: OrderBy&#x3D;field1,-field2).  Orderable fields: **ShipmentNumber, ReferenceId**, see also schema **Eps.Api.MyApi2.Web.Controllers.ShipmentBatchController.GetShipmentBatchLabel.OrderBy.enum** (optional)
     *
     * @throws \InvalidArgumentException
     * @return \PPLCZVendor\GuzzleHttp\Psr7\Request
     */
    public function getShipmentBatchLabelRequest($batch_id, $limit, $offset, $page_size = null, $position = null, $accept_language = null, $x_correlation_id = null, $x_log_level = null, $order_by = null)
    {
        // verify the required parameter 'batch_id' is set
        if ($batch_id === null || (is_array($batch_id) && count($batch_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $batch_id when calling getShipmentBatchLabel'
            );
        }
        // 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 getShipmentBatchLabel'
            );
        }
        if ($limit > 200) {
            throw new \InvalidArgumentException('invalid value for "$limit" when calling ShipmentBatchApi.getShipmentBatchLabel, must be smaller than or equal to 200.');
        }
        if ($limit < 1) {
            throw new \InvalidArgumentException('invalid value for "$limit" when calling ShipmentBatchApi.getShipmentBatchLabel, 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 getShipmentBatchLabel'
            );
        }
        if ($offset > 2147483647) {
            throw new \InvalidArgumentException('invalid value for "$offset" when calling ShipmentBatchApi.getShipmentBatchLabel, must be smaller than or equal to 2147483647.');
        }
        if ($offset < 0) {
            throw new \InvalidArgumentException('invalid value for "$offset" when calling ShipmentBatchApi.getShipmentBatchLabel, must be bigger than or equal to 0.');
        }

        if ($position !== null && $position > 4) {
            throw new \InvalidArgumentException('invalid value for "$position" when calling ShipmentBatchApi.getShipmentBatchLabel, must be smaller than or equal to 4.');
        }
        if ($position !== null && $position < 1) {
            throw new \InvalidArgumentException('invalid value for "$position" when calling ShipmentBatchApi.getShipmentBatchLabel, must be bigger than or equal to 1.');
        }


        $resourcePath = '/shipment/batch/{batchId}/label';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $page_size,
            'PageSize', // param base name
            'EpsApiMyApi2BusinessEnumsConstPageSize', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $position,
            'Position', // param base name
            'integer', // 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
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializerPpl::toQueryValue(
            $order_by,
            'OrderBy', // param base name
            'AnyOfEpsApiMyApi2WebControllersShipmentBatchControllerGetShipmentBatchLabelOrderByEnumString', // openApiType
            'form', // style
            true, // explode
            false // 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);
        }

        // path params
        if ($batch_id !== null) {
            $resourcePath = str_replace(
                '{' . 'batchId' . '}',
                ObjectSerializerPpl::toPathValue($batch_id),
                $resourcePath
            );
        }


        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
        );
    }

    /**
     * Operation updateShipmentBatch
     *
     * Slouží k úpravě sady zásilek
     *
     * @param  string $batch_id The batch id (required)
     * @param  \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchUpdateShipmentBatchModel $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model The request data (required)
     * @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 void
     */
    public function updateShipmentBatch($batch_id, $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        $this->updateShipmentBatchWithHttpInfo($batch_id, $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model, $accept_language, $x_correlation_id, $x_log_level);
    }

    /**
     * Operation updateShipmentBatchWithHttpInfo
     *
     * Slouží k úpravě sady zásilek
     *
     * @param  string $batch_id The batch id (required)
     * @param  \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchUpdateShipmentBatchModel $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model The request data (required)
     * @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 null, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateShipmentBatchWithHttpInfo($batch_id, $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        $request = $this->updateShipmentBatchRequest($batch_id, $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model, $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()
                );
            }

            return [null, $statusCode, $response->getHeaders()];

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 400:
                    $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 updateShipmentBatchAsync
     *
     * Slouží k úpravě sady zásilek
     *
     * @param  string $batch_id The batch id (required)
     * @param  \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchUpdateShipmentBatchModel $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model The request data (required)
     * @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 updateShipmentBatchAsync($batch_id, $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        return $this->updateShipmentBatchAsyncWithHttpInfo($batch_id, $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model, $accept_language, $x_correlation_id, $x_log_level)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateShipmentBatchAsyncWithHttpInfo
     *
     * Slouží k úpravě sady zásilek
     *
     * @param  string $batch_id The batch id (required)
     * @param  \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchUpdateShipmentBatchModel $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model The request data (required)
     * @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 updateShipmentBatchAsyncWithHttpInfo($batch_id, $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        $returnType = '';
        $request = $this->updateShipmentBatchRequest($batch_id, $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model, $accept_language, $x_correlation_id, $x_log_level);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    return [null, $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 'updateShipmentBatch'
     *
     * @param  string $batch_id The batch id (required)
     * @param  \PPLCZCPL\Model\EpsApiMyApi2WebModelsShipmentBatchUpdateShipmentBatchModel $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model The request data (required)
     * @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 updateShipmentBatchRequest($batch_id, $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model, $accept_language = null, $x_correlation_id = null, $x_log_level = null)
    {
        // verify the required parameter 'batch_id' is set
        if ($batch_id === null || (is_array($batch_id) && count($batch_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $batch_id when calling updateShipmentBatch'
            );
        }
        // verify the required parameter 'eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model' is set
        if ($eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model === null || (is_array($eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model) && count($eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model when calling updateShipmentBatch'
            );
        }

        $resourcePath = '/shipment/batch/{batchId}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;


        // 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);
        }

        // path params
        if ($batch_id !== null) {
            $resourcePath = str_replace(
                '{' . 'batchId' . '}',
                ObjectSerializerPpl::toPathValue($batch_id),
                $resourcePath
            );
        }


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

        // for model (json/xml)
        if (isset($eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model)) {
            if ($headers['Content-Type'] === 'application/json') {
                $httpBody = wp_json_encode(ObjectSerializerPpl::sanitizeForSerialization($eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model));
            } else {
                $httpBody = $eps_api_my_api2_web_models_shipment_batch_update_shipment_batch_model;
            }
        } elseif (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(
            'PUT',
            $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;
    }
}
