<?php
/**
 * PriceBooksApi
 * 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.21.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;

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

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

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

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

    /** @var string[] $contentTypes **/
    public const contentTypes = [
        'addPriceBookProducts' => [
            'application/json',
        ],
        'createPriceBookV3' => [
            'application/json',
        ],
        'deletePriceBookProducts' => [
            'application/json',
        ],
        'getPriceBookByIDV3' => [
            'application/json',
        ],
        'getPriceBookProductsForPriceBook' => [
            'application/json',
        ],
        'listPriceBookProducts' => [
            'application/json',
        ],
        'listPriceBooksV3' => [
            'application/json',
        ],
        'updatePriceBookProducts' => [
            'application/json',
        ],
        'updatePriceBookProductsWithPutOp' => [
            'application/json',
        ],
        'updatePriceBookV3' => [
            '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 addPriceBookProducts
     *
     * Add the products to a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['addPriceBookProducts'] 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\PriceBookProductsUpdateResponse
     */
    public function addPriceBookProducts($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['addPriceBookProducts'][0])
    {
        list($response) = $this->addPriceBookProductsWithHttpInfo($price_book_id, $price_book_product_collection, $contentType);
        return $response;
    }

    /**
     * Operation addPriceBookProductsWithHttpInfo
     *
     * Add the products to a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['addPriceBookProducts'] 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\PriceBookProductsUpdateResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function addPriceBookProductsWithHttpInfo($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['addPriceBookProducts'][0])
    {
        $request = $this->addPriceBookProductsRequest($price_book_id, $price_book_product_collection, $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\PriceBookProductsUpdateResponse',
                        $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\PriceBookProductsUpdateResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PriceBookProductsUpdateResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation addPriceBookProductsAsync
     *
     * Add the products to a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['addPriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function addPriceBookProductsAsync($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['addPriceBookProducts'][0])
    {
        return $this->addPriceBookProductsAsyncWithHttpInfo($price_book_id, $price_book_product_collection, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation addPriceBookProductsAsyncWithHttpInfo
     *
     * Add the products to a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['addPriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function addPriceBookProductsAsyncWithHttpInfo($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['addPriceBookProducts'][0])
    {
        $returnType = '\Vend202601\Model\PriceBookProductsUpdateResponse';
        $request = $this->addPriceBookProductsRequest($price_book_id, $price_book_product_collection, $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 'addPriceBookProducts'
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['addPriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function addPriceBookProductsRequest($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['addPriceBookProducts'][0])
    {

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

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


        $resourcePath = '/price_books/{price_book_id}/products';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



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


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

        // for model (json/xml)
        if (isset($price_book_product_collection)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($price_book_product_collection));
            } else {
                $httpBody = $price_book_product_collection;
            }
        } 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 createPriceBookV3
     *
     * Create a single price book
     *
     * @param  \Vend202601\Model\PriceBookCreateRequest $price_book_create_request price_book_create_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['createPriceBookV3'] 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\PriceBookCreateResponse
     */
    public function createPriceBookV3($price_book_create_request, string $contentType = self::contentTypes['createPriceBookV3'][0])
    {
        list($response) = $this->createPriceBookV3WithHttpInfo($price_book_create_request, $contentType);
        return $response;
    }

    /**
     * Operation createPriceBookV3WithHttpInfo
     *
     * Create a single price book
     *
     * @param  \Vend202601\Model\PriceBookCreateRequest $price_book_create_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['createPriceBookV3'] 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\PriceBookCreateResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function createPriceBookV3WithHttpInfo($price_book_create_request, string $contentType = self::contentTypes['createPriceBookV3'][0])
    {
        $request = $this->createPriceBookV3Request($price_book_create_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\PriceBookCreateResponse',
                        $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\PriceBookCreateResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PriceBookCreateResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation createPriceBookV3Async
     *
     * Create a single price book
     *
     * @param  \Vend202601\Model\PriceBookCreateRequest $price_book_create_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['createPriceBookV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function createPriceBookV3Async($price_book_create_request, string $contentType = self::contentTypes['createPriceBookV3'][0])
    {
        return $this->createPriceBookV3AsyncWithHttpInfo($price_book_create_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation createPriceBookV3AsyncWithHttpInfo
     *
     * Create a single price book
     *
     * @param  \Vend202601\Model\PriceBookCreateRequest $price_book_create_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['createPriceBookV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function createPriceBookV3AsyncWithHttpInfo($price_book_create_request, string $contentType = self::contentTypes['createPriceBookV3'][0])
    {
        $returnType = '\Vend202601\Model\PriceBookCreateResponse';
        $request = $this->createPriceBookV3Request($price_book_create_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 'createPriceBookV3'
     *
     * @param  \Vend202601\Model\PriceBookCreateRequest $price_book_create_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['createPriceBookV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function createPriceBookV3Request($price_book_create_request, string $contentType = self::contentTypes['createPriceBookV3'][0])
    {

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


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





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

        // for model (json/xml)
        if (isset($price_book_create_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($price_book_create_request));
            } else {
                $httpBody = $price_book_create_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 deletePriceBookProducts
     *
     * Delete some entries for a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductIdCollection $price_book_product_id_collection price_book_product_id_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['deletePriceBookProducts'] 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\PriceBookProductsUpdateResponse
     */
    public function deletePriceBookProducts($price_book_id, $price_book_product_id_collection, string $contentType = self::contentTypes['deletePriceBookProducts'][0])
    {
        list($response) = $this->deletePriceBookProductsWithHttpInfo($price_book_id, $price_book_product_id_collection, $contentType);
        return $response;
    }

    /**
     * Operation deletePriceBookProductsWithHttpInfo
     *
     * Delete some entries for a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductIdCollection $price_book_product_id_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['deletePriceBookProducts'] 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\PriceBookProductsUpdateResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function deletePriceBookProductsWithHttpInfo($price_book_id, $price_book_product_id_collection, string $contentType = self::contentTypes['deletePriceBookProducts'][0])
    {
        $request = $this->deletePriceBookProductsRequest($price_book_id, $price_book_product_id_collection, $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\PriceBookProductsUpdateResponse',
                        $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\PriceBookProductsUpdateResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PriceBookProductsUpdateResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation deletePriceBookProductsAsync
     *
     * Delete some entries for a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductIdCollection $price_book_product_id_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['deletePriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deletePriceBookProductsAsync($price_book_id, $price_book_product_id_collection, string $contentType = self::contentTypes['deletePriceBookProducts'][0])
    {
        return $this->deletePriceBookProductsAsyncWithHttpInfo($price_book_id, $price_book_product_id_collection, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation deletePriceBookProductsAsyncWithHttpInfo
     *
     * Delete some entries for a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductIdCollection $price_book_product_id_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['deletePriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deletePriceBookProductsAsyncWithHttpInfo($price_book_id, $price_book_product_id_collection, string $contentType = self::contentTypes['deletePriceBookProducts'][0])
    {
        $returnType = '\Vend202601\Model\PriceBookProductsUpdateResponse';
        $request = $this->deletePriceBookProductsRequest($price_book_id, $price_book_product_id_collection, $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 'deletePriceBookProducts'
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductIdCollection $price_book_product_id_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['deletePriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function deletePriceBookProductsRequest($price_book_id, $price_book_product_id_collection, string $contentType = self::contentTypes['deletePriceBookProducts'][0])
    {

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

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


        $resourcePath = '/price_books/{price_book_id}/products';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



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


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

        // for model (json/xml)
        if (isset($price_book_product_id_collection)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($price_book_product_id_collection));
            } else {
                $httpBody = $price_book_product_id_collection;
            }
        } 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(
            'DELETE',
            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getPriceBookByIDV3
     *
     * Get a single price book
     *
     * @param  string $id The price book id (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getPriceBookByIDV3'] 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\PriceBookResponse
     */
    public function getPriceBookByIDV3($id, string $contentType = self::contentTypes['getPriceBookByIDV3'][0])
    {
        list($response) = $this->getPriceBookByIDV3WithHttpInfo($id, $contentType);
        return $response;
    }

    /**
     * Operation getPriceBookByIDV3WithHttpInfo
     *
     * Get a single price book
     *
     * @param  string $id The price book id (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getPriceBookByIDV3'] 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\PriceBookResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function getPriceBookByIDV3WithHttpInfo($id, string $contentType = self::contentTypes['getPriceBookByIDV3'][0])
    {
        $request = $this->getPriceBookByIDV3Request($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\PriceBookResponse',
                        $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\PriceBookResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PriceBookResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation getPriceBookByIDV3Async
     *
     * Get a single price book
     *
     * @param  string $id The price book id (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getPriceBookByIDV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getPriceBookByIDV3Async($id, string $contentType = self::contentTypes['getPriceBookByIDV3'][0])
    {
        return $this->getPriceBookByIDV3AsyncWithHttpInfo($id, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getPriceBookByIDV3AsyncWithHttpInfo
     *
     * Get a single price book
     *
     * @param  string $id The price book id (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getPriceBookByIDV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getPriceBookByIDV3AsyncWithHttpInfo($id, string $contentType = self::contentTypes['getPriceBookByIDV3'][0])
    {
        $returnType = '\Vend202601\Model\PriceBookResponse';
        $request = $this->getPriceBookByIDV3Request($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 'getPriceBookByIDV3'
     *
     * @param  string $id The price book id (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getPriceBookByIDV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function getPriceBookByIDV3Request($id, string $contentType = self::contentTypes['getPriceBookByIDV3'][0])
    {

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


        $resourcePath = '/price_books/{id}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



        // path params
        if ($id !== null) {
            $resourcePath = str_replace(
                '{' . 'id' . '}',
                ObjectSerializer::toPathValue($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 getPriceBookProductsForPriceBook
     *
     * List price book products per price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  string|null $product_ids The product ids (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getPriceBookProductsForPriceBook'] 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\PriceBookProductCollection
     */
    public function getPriceBookProductsForPriceBook($price_book_id, $product_ids = null, string $contentType = self::contentTypes['getPriceBookProductsForPriceBook'][0])
    {
        list($response) = $this->getPriceBookProductsForPriceBookWithHttpInfo($price_book_id, $product_ids, $contentType);
        return $response;
    }

    /**
     * Operation getPriceBookProductsForPriceBookWithHttpInfo
     *
     * List price book products per price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  string|null $product_ids The product ids (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getPriceBookProductsForPriceBook'] 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\PriceBookProductCollection, HTTP status code, HTTP response headers (array of strings)
     */
    public function getPriceBookProductsForPriceBookWithHttpInfo($price_book_id, $product_ids = null, string $contentType = self::contentTypes['getPriceBookProductsForPriceBook'][0])
    {
        $request = $this->getPriceBookProductsForPriceBookRequest($price_book_id, $product_ids, $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\PriceBookProductCollection',
                        $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\PriceBookProductCollection',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PriceBookProductCollection',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation getPriceBookProductsForPriceBookAsync
     *
     * List price book products per price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  string|null $product_ids The product ids (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getPriceBookProductsForPriceBook'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getPriceBookProductsForPriceBookAsync($price_book_id, $product_ids = null, string $contentType = self::contentTypes['getPriceBookProductsForPriceBook'][0])
    {
        return $this->getPriceBookProductsForPriceBookAsyncWithHttpInfo($price_book_id, $product_ids, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getPriceBookProductsForPriceBookAsyncWithHttpInfo
     *
     * List price book products per price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  string|null $product_ids The product ids (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getPriceBookProductsForPriceBook'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getPriceBookProductsForPriceBookAsyncWithHttpInfo($price_book_id, $product_ids = null, string $contentType = self::contentTypes['getPriceBookProductsForPriceBook'][0])
    {
        $returnType = '\Vend202601\Model\PriceBookProductCollection';
        $request = $this->getPriceBookProductsForPriceBookRequest($price_book_id, $product_ids, $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 'getPriceBookProductsForPriceBook'
     *
     * @param  string $price_book_id The price book id (required)
     * @param  string|null $product_ids The product ids (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getPriceBookProductsForPriceBook'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function getPriceBookProductsForPriceBookRequest($price_book_id, $product_ids = null, string $contentType = self::contentTypes['getPriceBookProductsForPriceBook'][0])
    {

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



        $resourcePath = '/price_books/{price_book_id}/products';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $product_ids,
            'product_ids', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);


        // path params
        if ($price_book_id !== null) {
            $resourcePath = str_replace(
                '{' . 'price_book_id' . '}',
                ObjectSerializer::toPathValue($price_book_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 listPriceBookProducts
     *
     * List price book products
     *
     * @param  int|null $after The lower limit for the version numbers to be included in the response. (optional)
     * @param  int|null $before The upper limit for the version numbers to be included in the response. (optional)
     * @param  int|null $page_size The maximum number of items to be returned in the response. (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['listPriceBookProducts'] 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\PriceBookProductCollection
     */
    public function listPriceBookProducts($after = null, $before = null, $page_size = null, string $contentType = self::contentTypes['listPriceBookProducts'][0])
    {
        list($response) = $this->listPriceBookProductsWithHttpInfo($after, $before, $page_size, $contentType);
        return $response;
    }

    /**
     * Operation listPriceBookProductsWithHttpInfo
     *
     * List price book products
     *
     * @param  int|null $after The lower limit for the version numbers to be included in the response. (optional)
     * @param  int|null $before The upper limit for the version numbers to be included in the response. (optional)
     * @param  int|null $page_size The maximum number of items to be returned in the response. (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['listPriceBookProducts'] 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\PriceBookProductCollection, HTTP status code, HTTP response headers (array of strings)
     */
    public function listPriceBookProductsWithHttpInfo($after = null, $before = null, $page_size = null, string $contentType = self::contentTypes['listPriceBookProducts'][0])
    {
        $request = $this->listPriceBookProductsRequest($after, $before, $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\PriceBookProductCollection',
                        $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\PriceBookProductCollection',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PriceBookProductCollection',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation listPriceBookProductsAsync
     *
     * List price book products
     *
     * @param  int|null $after The lower limit for the version numbers to be included in the response. (optional)
     * @param  int|null $before The upper limit for the version numbers to be included in the response. (optional)
     * @param  int|null $page_size The maximum number of items to be returned in the response. (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['listPriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function listPriceBookProductsAsync($after = null, $before = null, $page_size = null, string $contentType = self::contentTypes['listPriceBookProducts'][0])
    {
        return $this->listPriceBookProductsAsyncWithHttpInfo($after, $before, $page_size, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation listPriceBookProductsAsyncWithHttpInfo
     *
     * List price book products
     *
     * @param  int|null $after The lower limit for the version numbers to be included in the response. (optional)
     * @param  int|null $before The upper limit for the version numbers to be included in the response. (optional)
     * @param  int|null $page_size The maximum number of items to be returned in the response. (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['listPriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function listPriceBookProductsAsyncWithHttpInfo($after = null, $before = null, $page_size = null, string $contentType = self::contentTypes['listPriceBookProducts'][0])
    {
        $returnType = '\Vend202601\Model\PriceBookProductCollection';
        $request = $this->listPriceBookProductsRequest($after, $before, $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 'listPriceBookProducts'
     *
     * @param  int|null $after The lower limit for the version numbers to be included in the response. (optional)
     * @param  int|null $before The upper limit for the version numbers to be included in the response. (optional)
     * @param  int|null $page_size The maximum number of items to be returned in the response. (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['listPriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function listPriceBookProductsRequest($after = null, $before = null, $page_size = null, string $contentType = self::contentTypes['listPriceBookProducts'][0])
    {





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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $after,
            'after', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $before,
            'before', // 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 listPriceBooksV3
     *
     * List price books
     *
     * @param  int|null $after The lower limit for the version numbers to be included in the response. (optional)
     * @param  int|null $before The upper limit for the version numbers to be included in the response. (optional)
     * @param  int|null $page_size The maximum number of items to be returned in the response. (optional)
     * @param  string|null $order Field used to sort the results. (optional)
     * @param  string|null $direction Sort results direction. ASC or DESC. (optional)
     * @param  bool|null $deleted Include (true) or exclude (false) deleted price books. Default value is false. (optional)
     * @param  string|null $customer_group_id Filter the list and show only price books linked to the specified Customer Group. (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['listPriceBooksV3'] 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\PriceBookCollection
     */
    public function listPriceBooksV3($after = null, $before = null, $page_size = null, $order = null, $direction = null, $deleted = null, $customer_group_id = null, string $contentType = self::contentTypes['listPriceBooksV3'][0])
    {
        list($response) = $this->listPriceBooksV3WithHttpInfo($after, $before, $page_size, $order, $direction, $deleted, $customer_group_id, $contentType);
        return $response;
    }

    /**
     * Operation listPriceBooksV3WithHttpInfo
     *
     * List price books
     *
     * @param  int|null $after The lower limit for the version numbers to be included in the response. (optional)
     * @param  int|null $before The upper limit for the version numbers to be included in the response. (optional)
     * @param  int|null $page_size The maximum number of items to be returned in the response. (optional)
     * @param  string|null $order Field used to sort the results. (optional)
     * @param  string|null $direction Sort results direction. ASC or DESC. (optional)
     * @param  bool|null $deleted Include (true) or exclude (false) deleted price books. Default value is false. (optional)
     * @param  string|null $customer_group_id Filter the list and show only price books linked to the specified Customer Group. (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['listPriceBooksV3'] 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\PriceBookCollection, HTTP status code, HTTP response headers (array of strings)
     */
    public function listPriceBooksV3WithHttpInfo($after = null, $before = null, $page_size = null, $order = null, $direction = null, $deleted = null, $customer_group_id = null, string $contentType = self::contentTypes['listPriceBooksV3'][0])
    {
        $request = $this->listPriceBooksV3Request($after, $before, $page_size, $order, $direction, $deleted, $customer_group_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\PriceBookCollection',
                        $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\PriceBookCollection',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PriceBookCollection',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation listPriceBooksV3Async
     *
     * List price books
     *
     * @param  int|null $after The lower limit for the version numbers to be included in the response. (optional)
     * @param  int|null $before The upper limit for the version numbers to be included in the response. (optional)
     * @param  int|null $page_size The maximum number of items to be returned in the response. (optional)
     * @param  string|null $order Field used to sort the results. (optional)
     * @param  string|null $direction Sort results direction. ASC or DESC. (optional)
     * @param  bool|null $deleted Include (true) or exclude (false) deleted price books. Default value is false. (optional)
     * @param  string|null $customer_group_id Filter the list and show only price books linked to the specified Customer Group. (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['listPriceBooksV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function listPriceBooksV3Async($after = null, $before = null, $page_size = null, $order = null, $direction = null, $deleted = null, $customer_group_id = null, string $contentType = self::contentTypes['listPriceBooksV3'][0])
    {
        return $this->listPriceBooksV3AsyncWithHttpInfo($after, $before, $page_size, $order, $direction, $deleted, $customer_group_id, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation listPriceBooksV3AsyncWithHttpInfo
     *
     * List price books
     *
     * @param  int|null $after The lower limit for the version numbers to be included in the response. (optional)
     * @param  int|null $before The upper limit for the version numbers to be included in the response. (optional)
     * @param  int|null $page_size The maximum number of items to be returned in the response. (optional)
     * @param  string|null $order Field used to sort the results. (optional)
     * @param  string|null $direction Sort results direction. ASC or DESC. (optional)
     * @param  bool|null $deleted Include (true) or exclude (false) deleted price books. Default value is false. (optional)
     * @param  string|null $customer_group_id Filter the list and show only price books linked to the specified Customer Group. (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['listPriceBooksV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function listPriceBooksV3AsyncWithHttpInfo($after = null, $before = null, $page_size = null, $order = null, $direction = null, $deleted = null, $customer_group_id = null, string $contentType = self::contentTypes['listPriceBooksV3'][0])
    {
        $returnType = '\Vend202601\Model\PriceBookCollection';
        $request = $this->listPriceBooksV3Request($after, $before, $page_size, $order, $direction, $deleted, $customer_group_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 'listPriceBooksV3'
     *
     * @param  int|null $after The lower limit for the version numbers to be included in the response. (optional)
     * @param  int|null $before The upper limit for the version numbers to be included in the response. (optional)
     * @param  int|null $page_size The maximum number of items to be returned in the response. (optional)
     * @param  string|null $order Field used to sort the results. (optional)
     * @param  string|null $direction Sort results direction. ASC or DESC. (optional)
     * @param  bool|null $deleted Include (true) or exclude (false) deleted price books. Default value is false. (optional)
     * @param  string|null $customer_group_id Filter the list and show only price books linked to the specified Customer Group. (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['listPriceBooksV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function listPriceBooksV3Request($after = null, $before = null, $page_size = null, $order = null, $direction = null, $deleted = null, $customer_group_id = null, string $contentType = self::contentTypes['listPriceBooksV3'][0])
    {









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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $after,
            'after', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $before,
            'before', // 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
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $order,
            'order', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $direction,
            'direction', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $deleted,
            'deleted', // param base name
            'boolean', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $customer_group_id,
            'customer_group_id', // param base name
            'string', // 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 updatePriceBookProducts
     *
     * Update the products in a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookProducts'] 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\PriceBookProductsUpdateResponse
     */
    public function updatePriceBookProducts($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['updatePriceBookProducts'][0])
    {
        list($response) = $this->updatePriceBookProductsWithHttpInfo($price_book_id, $price_book_product_collection, $contentType);
        return $response;
    }

    /**
     * Operation updatePriceBookProductsWithHttpInfo
     *
     * Update the products in a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookProducts'] 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\PriceBookProductsUpdateResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function updatePriceBookProductsWithHttpInfo($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['updatePriceBookProducts'][0])
    {
        $request = $this->updatePriceBookProductsRequest($price_book_id, $price_book_product_collection, $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\PriceBookProductsUpdateResponse',
                        $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\PriceBookProductsUpdateResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PriceBookProductsUpdateResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation updatePriceBookProductsAsync
     *
     * Update the products in a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updatePriceBookProductsAsync($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['updatePriceBookProducts'][0])
    {
        return $this->updatePriceBookProductsAsyncWithHttpInfo($price_book_id, $price_book_product_collection, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updatePriceBookProductsAsyncWithHttpInfo
     *
     * Update the products in a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updatePriceBookProductsAsyncWithHttpInfo($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['updatePriceBookProducts'][0])
    {
        $returnType = '\Vend202601\Model\PriceBookProductsUpdateResponse';
        $request = $this->updatePriceBookProductsRequest($price_book_id, $price_book_product_collection, $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 'updatePriceBookProducts'
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookProducts'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function updatePriceBookProductsRequest($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['updatePriceBookProducts'][0])
    {

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

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


        $resourcePath = '/price_books/{price_book_id}/products';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



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


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

        // for model (json/xml)
        if (isset($price_book_product_collection)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($price_book_product_collection));
            } else {
                $httpBody = $price_book_product_collection;
            }
        } 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(
            'PATCH',
            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updatePriceBookProductsWithPutOp
     *
     * Update the products in a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookProductsWithPutOp'] 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\PriceBookProductsUpdateResponse
     */
    public function updatePriceBookProductsWithPutOp($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['updatePriceBookProductsWithPutOp'][0])
    {
        list($response) = $this->updatePriceBookProductsWithPutOpWithHttpInfo($price_book_id, $price_book_product_collection, $contentType);
        return $response;
    }

    /**
     * Operation updatePriceBookProductsWithPutOpWithHttpInfo
     *
     * Update the products in a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookProductsWithPutOp'] 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\PriceBookProductsUpdateResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function updatePriceBookProductsWithPutOpWithHttpInfo($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['updatePriceBookProductsWithPutOp'][0])
    {
        $request = $this->updatePriceBookProductsWithPutOpRequest($price_book_id, $price_book_product_collection, $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\PriceBookProductsUpdateResponse',
                        $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\PriceBookProductsUpdateResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PriceBookProductsUpdateResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation updatePriceBookProductsWithPutOpAsync
     *
     * Update the products in a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookProductsWithPutOp'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updatePriceBookProductsWithPutOpAsync($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['updatePriceBookProductsWithPutOp'][0])
    {
        return $this->updatePriceBookProductsWithPutOpAsyncWithHttpInfo($price_book_id, $price_book_product_collection, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updatePriceBookProductsWithPutOpAsyncWithHttpInfo
     *
     * Update the products in a price book
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookProductsWithPutOp'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updatePriceBookProductsWithPutOpAsyncWithHttpInfo($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['updatePriceBookProductsWithPutOp'][0])
    {
        $returnType = '\Vend202601\Model\PriceBookProductsUpdateResponse';
        $request = $this->updatePriceBookProductsWithPutOpRequest($price_book_id, $price_book_product_collection, $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 'updatePriceBookProductsWithPutOp'
     *
     * @param  string $price_book_id The price book id (required)
     * @param  \Vend202601\Model\PriceBookProductCollection $price_book_product_collection (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookProductsWithPutOp'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function updatePriceBookProductsWithPutOpRequest($price_book_id, $price_book_product_collection, string $contentType = self::contentTypes['updatePriceBookProductsWithPutOp'][0])
    {

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

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


        $resourcePath = '/price_books/{price_book_id}/products';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



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


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

        // for model (json/xml)
        if (isset($price_book_product_collection)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($price_book_product_collection));
            } else {
                $httpBody = $price_book_product_collection;
            }
        } 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(
            'PUT',
            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updatePriceBookV3
     *
     * Update a single price book
     *
     * @param  string $id The price book id (required)
     * @param  \Vend202601\Model\PriceBookUpdateRequest $price_book_update_request price_book_update_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookV3'] 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\PriceBookCreateResponse
     */
    public function updatePriceBookV3($id, $price_book_update_request, string $contentType = self::contentTypes['updatePriceBookV3'][0])
    {
        list($response) = $this->updatePriceBookV3WithHttpInfo($id, $price_book_update_request, $contentType);
        return $response;
    }

    /**
     * Operation updatePriceBookV3WithHttpInfo
     *
     * Update a single price book
     *
     * @param  string $id The price book id (required)
     * @param  \Vend202601\Model\PriceBookUpdateRequest $price_book_update_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookV3'] 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\PriceBookCreateResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function updatePriceBookV3WithHttpInfo($id, $price_book_update_request, string $contentType = self::contentTypes['updatePriceBookV3'][0])
    {
        $request = $this->updatePriceBookV3Request($id, $price_book_update_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\PriceBookCreateResponse',
                        $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\PriceBookCreateResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Vend202601\Model\PriceBookCreateResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation updatePriceBookV3Async
     *
     * Update a single price book
     *
     * @param  string $id The price book id (required)
     * @param  \Vend202601\Model\PriceBookUpdateRequest $price_book_update_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updatePriceBookV3Async($id, $price_book_update_request, string $contentType = self::contentTypes['updatePriceBookV3'][0])
    {
        return $this->updatePriceBookV3AsyncWithHttpInfo($id, $price_book_update_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updatePriceBookV3AsyncWithHttpInfo
     *
     * Update a single price book
     *
     * @param  string $id The price book id (required)
     * @param  \Vend202601\Model\PriceBookUpdateRequest $price_book_update_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updatePriceBookV3AsyncWithHttpInfo($id, $price_book_update_request, string $contentType = self::contentTypes['updatePriceBookV3'][0])
    {
        $returnType = '\Vend202601\Model\PriceBookCreateResponse';
        $request = $this->updatePriceBookV3Request($id, $price_book_update_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 'updatePriceBookV3'
     *
     * @param  string $id The price book id (required)
     * @param  \Vend202601\Model\PriceBookUpdateRequest $price_book_update_request (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['updatePriceBookV3'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function updatePriceBookV3Request($id, $price_book_update_request, string $contentType = self::contentTypes['updatePriceBookV3'][0])
    {

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

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


        $resourcePath = '/price_books/{id}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;



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


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

        // for model (json/xml)
        if (isset($price_book_update_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($price_book_update_request));
            } else {
                $httpBody = $price_book_update_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(
            'PUT',
            $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;
    }
}
