<?php
/**
 * FulfillmentsApi
 * PHP version 8.1
 *
 * @category Class
 * @package  Vend202601
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * API 2026-01
 *
 * Lightspeed Retail (X-Series) API.
 *
 * The version of the OpenAPI document: 2026-01
 * Contact: x-series.api@lightspeedhq.com
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.20.0
 */

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

namespace Vend202601\Api;

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Vend202601\ApiException;
use Vend202601\Configuration;
use Vend202601\FormDataProcessor;
use Vend202601\HeaderSelector;
use Vend202601\ObjectSerializer;

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

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

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

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

    /** @var string[] $contentTypes **/
    public const contentTypes = [
        'fulfillSale' => [
            'application/json',
        ],
        'getFulfillmentSummary' => [
            'application/json',
        ],
        'getFulfillmentsBySaleID' => [
            'application/json',
        ],
        'postFulfillLineItems' => [
            'application/json',
        ],
        'postFulfillSale' => [
            'application/json',
        ],
        'postPackLineItems' => [
            'application/json',
        ],
        'postPickLineItems' => [
            'application/json',
        ],
    ];

    /**
     * @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,
        int $hostIndex = 0
    ) {
        $this->client = $client ?: new Client();
        $this->config = $config ?: Configuration::getDefaultConfiguration();
        $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 fulfillSale
     *
     * Fulfil a sale
     *
     * @param  string $sale_id The sale id (required)
     * @param  \Vend202601\Model\FulfillSaleRequest $fulfill_sale_request fulfill_sale_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['fulfillSale'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \Vend202601\Model\FulfillmentResponse
     */
    public function fulfillSale($sale_id, $fulfill_sale_request, string $contentType = self::contentTypes['fulfillSale'][0])
    {
        list($response) = $this->fulfillSaleWithHttpInfo($sale_id, $fulfill_sale_request, $contentType);
        return $response;
    }

    /**
     * Operation fulfillSaleWithHttpInfo
     *
     * Fulfil a sale
     *
     * @param  string $sale_id The sale id (required)
     * @param  \Vend202601\Model\FulfillSaleRequest $fulfill_sale_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['fulfillSale'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \Vend202601\Model\FulfillmentResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function fulfillSaleWithHttpInfo($sale_id, $fulfill_sale_request, string $contentType = self::contentTypes['fulfillSale'][0])
    {
        $request = $this->fulfillSaleRequest($sale_id, $fulfill_sale_request, $contentType);

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


            switch($statusCode) {
                case 200:
                    return $this->handleResponseWithDataType(
                        '\Vend202601\Model\FulfillmentResponse',
                        $request,
                        $response,
                    );
            }

            

            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 $this->handleResponseWithDataType(
                '\Vend202601\Model\FulfillmentResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\FulfillmentResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation fulfillSaleAsync
     *
     * Fulfil a sale
     *
     * @param  string $sale_id The sale id (required)
     * @param  \Vend202601\Model\FulfillSaleRequest $fulfill_sale_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['fulfillSale'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function fulfillSaleAsync($sale_id, $fulfill_sale_request, string $contentType = self::contentTypes['fulfillSale'][0])
    {
        return $this->fulfillSaleAsyncWithHttpInfo($sale_id, $fulfill_sale_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation fulfillSaleAsyncWithHttpInfo
     *
     * Fulfil a sale
     *
     * @param  string $sale_id The sale id (required)
     * @param  \Vend202601\Model\FulfillSaleRequest $fulfill_sale_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['fulfillSale'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function fulfillSaleAsyncWithHttpInfo($sale_id, $fulfill_sale_request, string $contentType = self::contentTypes['fulfillSale'][0])
    {
        $returnType = '\Vend202601\Model\FulfillmentResponse';
        $request = $this->fulfillSaleRequest($sale_id, $fulfill_sale_request, $contentType);

        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 [
                        ObjectSerializer::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 'fulfillSale'
     *
     * @param  string $sale_id The sale id (required)
     * @param  \Vend202601\Model\FulfillSaleRequest $fulfill_sale_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['fulfillSale'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function fulfillSaleRequest($sale_id, $fulfill_sale_request, string $contentType = self::contentTypes['fulfillSale'][0])
    {

        // verify the required parameter 'sale_id' is set
        if ($sale_id === null || (is_array($sale_id) && count($sale_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $sale_id when calling fulfillSale'
            );
        }

        // verify the required parameter 'fulfill_sale_request' is set
        if ($fulfill_sale_request === null || (is_array($fulfill_sale_request) && count($fulfill_sale_request) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $fulfill_sale_request when calling fulfillSale'
            );
        }


        $resourcePath = '/sales/{sale_id}/fulfill';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



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


        $headers = $this->headerSelector->selectHeaders(
            ['application/json', ],
            $contentType,
            $multipart
        );

        // for model (json/xml)
        if (isset($fulfill_sale_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fulfill_sale_request));
            } else {
                $httpBody = $fulfill_sale_request;
            }
        } 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 (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the form parameters
                $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams);
            }
        }

        // this endpoint requires Bearer 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
        );

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

    /**
     * Operation getFulfillmentSummary
     *
     * Get Fulfillments Summary
     *
     * @param  string[]|null $outlet_id Filter by outlet IDs (can be specified multiple times) (optional)
     * @param  string[]|null $sale_id Filter by sale IDs (can be specified multiple times) (optional)
     * @param  string[]|null $fulfillment_type Filter by fulfillment types (can be specified multiple times) (optional)
     * @param  string[]|null $fulfillment_state Filter by fulfillment states (can be specified multiple times) (optional)
     * @param  int|null $page_number Page number for pagination (1-based) (optional, default to 1)
     * @param  int|null $page_size Number of items per page (optional, default to 10)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentSummary'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \Vend202601\Model\FulfillmentSummaryResponse
     */
    public function getFulfillmentSummary($outlet_id = null, $sale_id = null, $fulfillment_type = null, $fulfillment_state = null, $page_number = 1, $page_size = 10, string $contentType = self::contentTypes['getFulfillmentSummary'][0])
    {
        list($response) = $this->getFulfillmentSummaryWithHttpInfo($outlet_id, $sale_id, $fulfillment_type, $fulfillment_state, $page_number, $page_size, $contentType);
        return $response;
    }

    /**
     * Operation getFulfillmentSummaryWithHttpInfo
     *
     * Get Fulfillments Summary
     *
     * @param  string[]|null $outlet_id Filter by outlet IDs (can be specified multiple times) (optional)
     * @param  string[]|null $sale_id Filter by sale IDs (can be specified multiple times) (optional)
     * @param  string[]|null $fulfillment_type Filter by fulfillment types (can be specified multiple times) (optional)
     * @param  string[]|null $fulfillment_state Filter by fulfillment states (can be specified multiple times) (optional)
     * @param  int|null $page_number Page number for pagination (1-based) (optional, default to 1)
     * @param  int|null $page_size Number of items per page (optional, default to 10)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentSummary'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \Vend202601\Model\FulfillmentSummaryResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function getFulfillmentSummaryWithHttpInfo($outlet_id = null, $sale_id = null, $fulfillment_type = null, $fulfillment_state = null, $page_number = 1, $page_size = 10, string $contentType = self::contentTypes['getFulfillmentSummary'][0])
    {
        $request = $this->getFulfillmentSummaryRequest($outlet_id, $sale_id, $fulfillment_type, $fulfillment_state, $page_number, $page_size, $contentType);

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


            switch($statusCode) {
                case 200:
                    return $this->handleResponseWithDataType(
                        '\Vend202601\Model\FulfillmentSummaryResponse',
                        $request,
                        $response,
                    );
            }

            

            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 $this->handleResponseWithDataType(
                '\Vend202601\Model\FulfillmentSummaryResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\FulfillmentSummaryResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation getFulfillmentSummaryAsync
     *
     * Get Fulfillments Summary
     *
     * @param  string[]|null $outlet_id Filter by outlet IDs (can be specified multiple times) (optional)
     * @param  string[]|null $sale_id Filter by sale IDs (can be specified multiple times) (optional)
     * @param  string[]|null $fulfillment_type Filter by fulfillment types (can be specified multiple times) (optional)
     * @param  string[]|null $fulfillment_state Filter by fulfillment states (can be specified multiple times) (optional)
     * @param  int|null $page_number Page number for pagination (1-based) (optional, default to 1)
     * @param  int|null $page_size Number of items per page (optional, default to 10)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentSummary'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getFulfillmentSummaryAsync($outlet_id = null, $sale_id = null, $fulfillment_type = null, $fulfillment_state = null, $page_number = 1, $page_size = 10, string $contentType = self::contentTypes['getFulfillmentSummary'][0])
    {
        return $this->getFulfillmentSummaryAsyncWithHttpInfo($outlet_id, $sale_id, $fulfillment_type, $fulfillment_state, $page_number, $page_size, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getFulfillmentSummaryAsyncWithHttpInfo
     *
     * Get Fulfillments Summary
     *
     * @param  string[]|null $outlet_id Filter by outlet IDs (can be specified multiple times) (optional)
     * @param  string[]|null $sale_id Filter by sale IDs (can be specified multiple times) (optional)
     * @param  string[]|null $fulfillment_type Filter by fulfillment types (can be specified multiple times) (optional)
     * @param  string[]|null $fulfillment_state Filter by fulfillment states (can be specified multiple times) (optional)
     * @param  int|null $page_number Page number for pagination (1-based) (optional, default to 1)
     * @param  int|null $page_size Number of items per page (optional, default to 10)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentSummary'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getFulfillmentSummaryAsyncWithHttpInfo($outlet_id = null, $sale_id = null, $fulfillment_type = null, $fulfillment_state = null, $page_number = 1, $page_size = 10, string $contentType = self::contentTypes['getFulfillmentSummary'][0])
    {
        $returnType = '\Vend202601\Model\FulfillmentSummaryResponse';
        $request = $this->getFulfillmentSummaryRequest($outlet_id, $sale_id, $fulfillment_type, $fulfillment_state, $page_number, $page_size, $contentType);

        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 [
                        ObjectSerializer::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 'getFulfillmentSummary'
     *
     * @param  string[]|null $outlet_id Filter by outlet IDs (can be specified multiple times) (optional)
     * @param  string[]|null $sale_id Filter by sale IDs (can be specified multiple times) (optional)
     * @param  string[]|null $fulfillment_type Filter by fulfillment types (can be specified multiple times) (optional)
     * @param  string[]|null $fulfillment_state Filter by fulfillment states (can be specified multiple times) (optional)
     * @param  int|null $page_number Page number for pagination (1-based) (optional, default to 1)
     * @param  int|null $page_size Number of items per page (optional, default to 10)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentSummary'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function getFulfillmentSummaryRequest($outlet_id = null, $sale_id = null, $fulfillment_type = null, $fulfillment_state = null, $page_number = 1, $page_size = 10, string $contentType = self::contentTypes['getFulfillmentSummary'][0])
    {





        if ($page_number !== null && $page_number < 1) {
            throw new \InvalidArgumentException('invalid value for "$page_number" when calling FulfillmentsApi.getFulfillmentSummary, must be bigger than or equal to 1.');
        }
        
        if ($page_size !== null && $page_size > 100) {
            throw new \InvalidArgumentException('invalid value for "$page_size" when calling FulfillmentsApi.getFulfillmentSummary, must be smaller than or equal to 100.');
        }
        if ($page_size !== null && $page_size < 1) {
            throw new \InvalidArgumentException('invalid value for "$page_size" when calling FulfillmentsApi.getFulfillmentSummary, must be bigger than or equal to 1.');
        }
        

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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $outlet_id,
            'outlet_id', // param base name
            'array', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $sale_id,
            'sale_id', // param base name
            'array', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $fulfillment_type,
            'fulfillment_type', // param base name
            'array', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $fulfillment_state,
            'fulfillment_state', // param base name
            'array', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $page_number,
            'page_number', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $page_size,
            'page_size', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);




        $headers = $this->headerSelector->selectHeaders(
            ['application/json', ],
            $contentType,
            $multipart
        );

        // 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 (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the form parameters
                $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams);
            }
        }

        // this endpoint requires Bearer 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
        );

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

    /**
     * Operation getFulfillmentsBySaleID
     *
     * List Sale Fulfillments
     *
     * @param  string $sale_id The sale id (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentsBySaleID'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \Vend202601\Model\FulfillmentsResponse
     */
    public function getFulfillmentsBySaleID($sale_id, string $contentType = self::contentTypes['getFulfillmentsBySaleID'][0])
    {
        list($response) = $this->getFulfillmentsBySaleIDWithHttpInfo($sale_id, $contentType);
        return $response;
    }

    /**
     * Operation getFulfillmentsBySaleIDWithHttpInfo
     *
     * List Sale Fulfillments
     *
     * @param  string $sale_id The sale id (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentsBySaleID'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \Vend202601\Model\FulfillmentsResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function getFulfillmentsBySaleIDWithHttpInfo($sale_id, string $contentType = self::contentTypes['getFulfillmentsBySaleID'][0])
    {
        $request = $this->getFulfillmentsBySaleIDRequest($sale_id, $contentType);

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


            switch($statusCode) {
                case 200:
                    return $this->handleResponseWithDataType(
                        '\Vend202601\Model\FulfillmentsResponse',
                        $request,
                        $response,
                    );
            }

            

            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 $this->handleResponseWithDataType(
                '\Vend202601\Model\FulfillmentsResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\FulfillmentsResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation getFulfillmentsBySaleIDAsync
     *
     * List Sale Fulfillments
     *
     * @param  string $sale_id The sale id (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentsBySaleID'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getFulfillmentsBySaleIDAsync($sale_id, string $contentType = self::contentTypes['getFulfillmentsBySaleID'][0])
    {
        return $this->getFulfillmentsBySaleIDAsyncWithHttpInfo($sale_id, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getFulfillmentsBySaleIDAsyncWithHttpInfo
     *
     * List Sale Fulfillments
     *
     * @param  string $sale_id The sale id (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentsBySaleID'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getFulfillmentsBySaleIDAsyncWithHttpInfo($sale_id, string $contentType = self::contentTypes['getFulfillmentsBySaleID'][0])
    {
        $returnType = '\Vend202601\Model\FulfillmentsResponse';
        $request = $this->getFulfillmentsBySaleIDRequest($sale_id, $contentType);

        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 [
                        ObjectSerializer::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 'getFulfillmentsBySaleID'
     *
     * @param  string $sale_id The sale id (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentsBySaleID'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function getFulfillmentsBySaleIDRequest($sale_id, string $contentType = self::contentTypes['getFulfillmentsBySaleID'][0])
    {

        // verify the required parameter 'sale_id' is set
        if ($sale_id === null || (is_array($sale_id) && count($sale_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $sale_id when calling getFulfillmentsBySaleID'
            );
        }


        $resourcePath = '/sales/{sale_id}/fulfillments';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



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


        $headers = $this->headerSelector->selectHeaders(
            ['application/json', ],
            $contentType,
            $multipart
        );

        // 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 (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the form parameters
                $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams);
            }
        }

        // this endpoint requires Bearer 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
        );

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

    /**
     * Operation postFulfillLineItems
     *
     * Fulfill line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\FulfillLineItemsRequest $fulfill_line_items_request fulfill_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postFulfillLineItems'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \Vend202601\Model\FulfillLineItemsResponse
     */
    public function postFulfillLineItems($fulfillment_id, $fulfill_line_items_request, string $contentType = self::contentTypes['postFulfillLineItems'][0])
    {
        list($response) = $this->postFulfillLineItemsWithHttpInfo($fulfillment_id, $fulfill_line_items_request, $contentType);
        return $response;
    }

    /**
     * Operation postFulfillLineItemsWithHttpInfo
     *
     * Fulfill line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\FulfillLineItemsRequest $fulfill_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postFulfillLineItems'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \Vend202601\Model\FulfillLineItemsResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function postFulfillLineItemsWithHttpInfo($fulfillment_id, $fulfill_line_items_request, string $contentType = self::contentTypes['postFulfillLineItems'][0])
    {
        $request = $this->postFulfillLineItemsRequest($fulfillment_id, $fulfill_line_items_request, $contentType);

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


            switch($statusCode) {
                case 200:
                    return $this->handleResponseWithDataType(
                        '\Vend202601\Model\FulfillLineItemsResponse',
                        $request,
                        $response,
                    );
            }

            

            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 $this->handleResponseWithDataType(
                '\Vend202601\Model\FulfillLineItemsResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\FulfillLineItemsResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation postFulfillLineItemsAsync
     *
     * Fulfill line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\FulfillLineItemsRequest $fulfill_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postFulfillLineItems'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postFulfillLineItemsAsync($fulfillment_id, $fulfill_line_items_request, string $contentType = self::contentTypes['postFulfillLineItems'][0])
    {
        return $this->postFulfillLineItemsAsyncWithHttpInfo($fulfillment_id, $fulfill_line_items_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation postFulfillLineItemsAsyncWithHttpInfo
     *
     * Fulfill line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\FulfillLineItemsRequest $fulfill_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postFulfillLineItems'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postFulfillLineItemsAsyncWithHttpInfo($fulfillment_id, $fulfill_line_items_request, string $contentType = self::contentTypes['postFulfillLineItems'][0])
    {
        $returnType = '\Vend202601\Model\FulfillLineItemsResponse';
        $request = $this->postFulfillLineItemsRequest($fulfillment_id, $fulfill_line_items_request, $contentType);

        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 [
                        ObjectSerializer::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 'postFulfillLineItems'
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\FulfillLineItemsRequest $fulfill_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postFulfillLineItems'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function postFulfillLineItemsRequest($fulfillment_id, $fulfill_line_items_request, string $contentType = self::contentTypes['postFulfillLineItems'][0])
    {

        // verify the required parameter 'fulfillment_id' is set
        if ($fulfillment_id === null || (is_array($fulfillment_id) && count($fulfillment_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $fulfillment_id when calling postFulfillLineItems'
            );
        }

        // verify the required parameter 'fulfill_line_items_request' is set
        if ($fulfill_line_items_request === null || (is_array($fulfill_line_items_request) && count($fulfill_line_items_request) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $fulfill_line_items_request when calling postFulfillLineItems'
            );
        }


        $resourcePath = '/fulfillments/{fulfillment_id}/fulfill';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



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


        $headers = $this->headerSelector->selectHeaders(
            ['application/json', ],
            $contentType,
            $multipart
        );

        // for model (json/xml)
        if (isset($fulfill_line_items_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fulfill_line_items_request));
            } else {
                $httpBody = $fulfill_line_items_request;
            }
        } 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 (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the form parameters
                $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams);
            }
        }

        // this endpoint requires Bearer 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
        );

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

    /**
     * Operation postFulfillSale
     *
     * Fulfill a Sale
     *
     * @param  \Vend202601\Model\FulfillSaleRequest|null $fulfill_sale_request fulfill_sale_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postFulfillSale'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \Vend202601\Model\FulfillSaleResponse
     */
    public function postFulfillSale($fulfill_sale_request = null, string $contentType = self::contentTypes['postFulfillSale'][0])
    {
        list($response) = $this->postFulfillSaleWithHttpInfo($fulfill_sale_request, $contentType);
        return $response;
    }

    /**
     * Operation postFulfillSaleWithHttpInfo
     *
     * Fulfill a Sale
     *
     * @param  \Vend202601\Model\FulfillSaleRequest|null $fulfill_sale_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postFulfillSale'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \Vend202601\Model\FulfillSaleResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function postFulfillSaleWithHttpInfo($fulfill_sale_request = null, string $contentType = self::contentTypes['postFulfillSale'][0])
    {
        $request = $this->postFulfillSaleRequest($fulfill_sale_request, $contentType);

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


            switch($statusCode) {
                case 200:
                    return $this->handleResponseWithDataType(
                        '\Vend202601\Model\FulfillSaleResponse',
                        $request,
                        $response,
                    );
            }

            

            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 $this->handleResponseWithDataType(
                '\Vend202601\Model\FulfillSaleResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\FulfillSaleResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation postFulfillSaleAsync
     *
     * Fulfill a Sale
     *
     * @param  \Vend202601\Model\FulfillSaleRequest|null $fulfill_sale_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postFulfillSale'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postFulfillSaleAsync($fulfill_sale_request = null, string $contentType = self::contentTypes['postFulfillSale'][0])
    {
        return $this->postFulfillSaleAsyncWithHttpInfo($fulfill_sale_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation postFulfillSaleAsyncWithHttpInfo
     *
     * Fulfill a Sale
     *
     * @param  \Vend202601\Model\FulfillSaleRequest|null $fulfill_sale_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postFulfillSale'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postFulfillSaleAsyncWithHttpInfo($fulfill_sale_request = null, string $contentType = self::contentTypes['postFulfillSale'][0])
    {
        $returnType = '\Vend202601\Model\FulfillSaleResponse';
        $request = $this->postFulfillSaleRequest($fulfill_sale_request, $contentType);

        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 [
                        ObjectSerializer::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 'postFulfillSale'
     *
     * @param  \Vend202601\Model\FulfillSaleRequest|null $fulfill_sale_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postFulfillSale'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function postFulfillSaleRequest($fulfill_sale_request = null, string $contentType = self::contentTypes['postFulfillSale'][0])
    {



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





        $headers = $this->headerSelector->selectHeaders(
            ['application/json', ],
            $contentType,
            $multipart
        );

        // for model (json/xml)
        if (isset($fulfill_sale_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fulfill_sale_request));
            } else {
                $httpBody = $fulfill_sale_request;
            }
        } 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 (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the form parameters
                $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams);
            }
        }

        // this endpoint requires Bearer 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
        );

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

    /**
     * Operation postPackLineItems
     *
     * Partial Pack line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\PackLineItemsRequest $pack_line_items_request pack_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postPackLineItems'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \Vend202601\Model\PackLineItemsResponse
     */
    public function postPackLineItems($fulfillment_id, $pack_line_items_request, string $contentType = self::contentTypes['postPackLineItems'][0])
    {
        list($response) = $this->postPackLineItemsWithHttpInfo($fulfillment_id, $pack_line_items_request, $contentType);
        return $response;
    }

    /**
     * Operation postPackLineItemsWithHttpInfo
     *
     * Partial Pack line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\PackLineItemsRequest $pack_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postPackLineItems'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \Vend202601\Model\PackLineItemsResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function postPackLineItemsWithHttpInfo($fulfillment_id, $pack_line_items_request, string $contentType = self::contentTypes['postPackLineItems'][0])
    {
        $request = $this->postPackLineItemsRequest($fulfillment_id, $pack_line_items_request, $contentType);

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


            switch($statusCode) {
                case 200:
                    return $this->handleResponseWithDataType(
                        '\Vend202601\Model\PackLineItemsResponse',
                        $request,
                        $response,
                    );
            }

            

            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 $this->handleResponseWithDataType(
                '\Vend202601\Model\PackLineItemsResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PackLineItemsResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation postPackLineItemsAsync
     *
     * Partial Pack line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\PackLineItemsRequest $pack_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postPackLineItems'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postPackLineItemsAsync($fulfillment_id, $pack_line_items_request, string $contentType = self::contentTypes['postPackLineItems'][0])
    {
        return $this->postPackLineItemsAsyncWithHttpInfo($fulfillment_id, $pack_line_items_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation postPackLineItemsAsyncWithHttpInfo
     *
     * Partial Pack line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\PackLineItemsRequest $pack_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postPackLineItems'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postPackLineItemsAsyncWithHttpInfo($fulfillment_id, $pack_line_items_request, string $contentType = self::contentTypes['postPackLineItems'][0])
    {
        $returnType = '\Vend202601\Model\PackLineItemsResponse';
        $request = $this->postPackLineItemsRequest($fulfillment_id, $pack_line_items_request, $contentType);

        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 [
                        ObjectSerializer::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 'postPackLineItems'
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\PackLineItemsRequest $pack_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postPackLineItems'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function postPackLineItemsRequest($fulfillment_id, $pack_line_items_request, string $contentType = self::contentTypes['postPackLineItems'][0])
    {

        // verify the required parameter 'fulfillment_id' is set
        if ($fulfillment_id === null || (is_array($fulfillment_id) && count($fulfillment_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $fulfillment_id when calling postPackLineItems'
            );
        }

        // verify the required parameter 'pack_line_items_request' is set
        if ($pack_line_items_request === null || (is_array($pack_line_items_request) && count($pack_line_items_request) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $pack_line_items_request when calling postPackLineItems'
            );
        }


        $resourcePath = '/fulfillments/{fulfillment_id}/pack';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



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


        $headers = $this->headerSelector->selectHeaders(
            ['application/json', ],
            $contentType,
            $multipart
        );

        // for model (json/xml)
        if (isset($pack_line_items_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pack_line_items_request));
            } else {
                $httpBody = $pack_line_items_request;
            }
        } 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 (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the form parameters
                $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams);
            }
        }

        // this endpoint requires Bearer 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
        );

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

    /**
     * Operation postPickLineItems
     *
     * Partial Pick line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\PickLineItemsRequest $pick_line_items_request pick_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postPickLineItems'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \Vend202601\Model\PickLineItemsResponse
     */
    public function postPickLineItems($fulfillment_id, $pick_line_items_request, string $contentType = self::contentTypes['postPickLineItems'][0])
    {
        list($response) = $this->postPickLineItemsWithHttpInfo($fulfillment_id, $pick_line_items_request, $contentType);
        return $response;
    }

    /**
     * Operation postPickLineItemsWithHttpInfo
     *
     * Partial Pick line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\PickLineItemsRequest $pick_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postPickLineItems'] to see the possible values for this operation
     *
     * @throws \Vend202601\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \Vend202601\Model\PickLineItemsResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function postPickLineItemsWithHttpInfo($fulfillment_id, $pick_line_items_request, string $contentType = self::contentTypes['postPickLineItems'][0])
    {
        $request = $this->postPickLineItemsRequest($fulfillment_id, $pick_line_items_request, $contentType);

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


            switch($statusCode) {
                case 200:
                    return $this->handleResponseWithDataType(
                        '\Vend202601\Model\PickLineItemsResponse',
                        $request,
                        $response,
                    );
            }

            

            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 $this->handleResponseWithDataType(
                '\Vend202601\Model\PickLineItemsResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PickLineItemsResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation postPickLineItemsAsync
     *
     * Partial Pick line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\PickLineItemsRequest $pick_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postPickLineItems'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postPickLineItemsAsync($fulfillment_id, $pick_line_items_request, string $contentType = self::contentTypes['postPickLineItems'][0])
    {
        return $this->postPickLineItemsAsyncWithHttpInfo($fulfillment_id, $pick_line_items_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation postPickLineItemsAsyncWithHttpInfo
     *
     * Partial Pick line items within a sale
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\PickLineItemsRequest $pick_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postPickLineItems'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function postPickLineItemsAsyncWithHttpInfo($fulfillment_id, $pick_line_items_request, string $contentType = self::contentTypes['postPickLineItems'][0])
    {
        $returnType = '\Vend202601\Model\PickLineItemsResponse';
        $request = $this->postPickLineItemsRequest($fulfillment_id, $pick_line_items_request, $contentType);

        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 [
                        ObjectSerializer::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 'postPickLineItems'
     *
     * @param  string $fulfillment_id The unique identifier of the fulfillment (required)
     * @param  \Vend202601\Model\PickLineItemsRequest $pick_line_items_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postPickLineItems'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function postPickLineItemsRequest($fulfillment_id, $pick_line_items_request, string $contentType = self::contentTypes['postPickLineItems'][0])
    {

        // verify the required parameter 'fulfillment_id' is set
        if ($fulfillment_id === null || (is_array($fulfillment_id) && count($fulfillment_id) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $fulfillment_id when calling postPickLineItems'
            );
        }

        // verify the required parameter 'pick_line_items_request' is set
        if ($pick_line_items_request === null || (is_array($pick_line_items_request) && count($pick_line_items_request) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $pick_line_items_request when calling postPickLineItems'
            );
        }


        $resourcePath = '/fulfillments/{fulfillment_id}/pick';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



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


        $headers = $this->headerSelector->selectHeaders(
            ['application/json', ],
            $contentType,
            $multipart
        );

        // for model (json/xml)
        if (isset($pick_line_items_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pick_line_items_request));
            } else {
                $httpBody = $pick_line_items_request;
            }
        } 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 (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the form parameters
                $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
            } else {
                // for HTTP post (form)
                $httpBody = ObjectSerializer::buildQuery($formParams);
            }
        }

        // this endpoint requires Bearer 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
        );

        $operationHost = $this->config->getHost();
        $query = ObjectSerializer::buildQuery($queryParams);
        return new Request(
            'POST',
            $operationHost . $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());
            }
        }

        if ($this->config->getCertFile()) {
            $options[RequestOptions::CERT] = $this->config->getCertFile();
        }

        if ($this->config->getKeyFile()) {
            $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile();
        }

        return $options;
    }

    private function handleResponseWithDataType(
        string $dataType,
        RequestInterface $request,
        ResponseInterface $response
    ): array {
        if ($dataType === '\SplFileObject') {
            $content = $response->getBody(); //stream goes to serializer
        } else {
            $content = (string) $response->getBody();
            if ($dataType !== 'string') {
                try {
                    $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
                } catch (\JsonException $exception) {
                    throw new ApiException(
                        sprintf(
                            'Error JSON decoding server response (%s)',
                            $request->getUri()
                        ),
                        $response->getStatusCode(),
                        $response->getHeaders(),
                        $content
                    );
                }
            }
        }

        return [
            ObjectSerializer::deserialize($content, $dataType, []),
            $response->getStatusCode(),
            $response->getHeaders()
        ];
    }

    private function responseWithinRangeCode(
        string $rangeCode,
        int $statusCode
    ): bool {
        $left = (int) ($rangeCode[0].'00');
        $right = (int) ($rangeCode[0].'99');

        return $statusCode >= $left && $statusCode <= $right;
    }
}
