text:
<?php
/**
 * TaxApi
 * PHP version 5
 *
 * @category Class
 * @package  ultracart\v2
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */

/**
 * UltraCart Rest API V2
 *
 * UltraCart REST API Version 2
 *
 * OpenAPI spec version: 2.0.0
 * Contact: support@ultracart.com
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 * Swagger Codegen version: 2.4.15-SNAPSHOT
 */

/**
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen
 * Do not edit the class manually.
 */

namespace ultracart\v2\api;

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use ultracart\v2\ApiException;
use ultracart\v2\Configuration;
use ultracart\v2\HeaderSelector;
use ultracart\v2\ObjectSerializer;

/**
 * TaxApi Class Doc Comment
 *
 * @category Class
 * @package  ultracart\v2
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */
class TaxApi
{
    /**
     * @var ClientInterface
     */
    protected $client;

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

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

    /**
     * @param ClientInterface $client
     * @param Configuration   $config
     * @param HeaderSelector  $selector
     */
    public function __construct(
        ClientInterface $client = null,
        Configuration $config = null,
        HeaderSelector $selector = null
    ) {
        $this->client = $client ?: new Client();
        $this->config = $config ?: new Configuration();
        $this->headerSelector = $selector ?: new HeaderSelector();
    }

    /**
     * @param string $simple_key api key
     * @param int $max_retry_seconds 0 to disable, else the maximum number of seconds to wait and automatically retry when rate limit is hit
     * @param string $verify passed to Guzzle to enable/disable ssl verify
     */
    public static function usingApiKey( $simple_key, $max_retry_seconds = 0, $verify = true) {
        $config = new Configuration();
        $config->setApiKey('x-ultracart-simple-key', $simple_key);
        $config->setMaxRetrySeconds($max_retry_seconds);

        $client = new Client(['verify' => $verify, 'debug' => false]);
        $headerSelector = new HeaderSelector(/* leave null for version tied to this sdk version */);
        $api = new TaxApi($client, $config, $headerSelector);
        return $api;
    }

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

    /**
     * Operation deleteTaxProviderSelfCity
     *
     * Deletes a Self tax provider city
     *
     * @param  string $city The city being deleted. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return void
     */
    public function deleteTaxProviderSelfCity($city, $tax_city)
    {
        $this->deleteTaxProviderSelfCityWithHttpInfo($city, $tax_city);
    }

    /**
     * Operation deleteTaxProviderSelfCityWithHttpInfo
     *
     * Deletes a Self tax provider city
     *
     * @param  string $city The city being deleted. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of null, HTTP status code, HTTP response headers (array of strings)
     */
    public function deleteTaxProviderSelfCityWithHttpInfo($city, $tax_city)
    {
        $this->deleteTaxProviderSelfCityWithHttpInfoRetry(true ,   $city,   $tax_city);
    }

    /**
     * Operation deleteTaxProviderSelfCityWithHttpInfoRetry
     *
     * Deletes a Self tax provider city
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $city The city being deleted. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of null, HTTP status code, HTTP response headers (array of strings)
     */
    public function deleteTaxProviderSelfCityWithHttpInfoRetry($retry ,  $city,  $tax_city)
    {
        $returnType = '';
        $request = $this->deleteTaxProviderSelfCityRequest($city, $tax_city);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        $this->deleteTaxProviderSelfCityWithHttpInfoRetry(false ,   $city,   $tax_city);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation deleteTaxProviderSelfCityAsync
     *
     * Deletes a Self tax provider city
     *
     * @param  string $city The city being deleted. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteTaxProviderSelfCityAsync($city, $tax_city)
    {
        return $this->deleteTaxProviderSelfCityAsyncWithHttpInfo($city, $tax_city)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation deleteTaxProviderSelfCityAsyncWithHttpInfo
     *
     * Deletes a Self tax provider city
     *
     * @param  string $city The city being deleted. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteTaxProviderSelfCityAsyncWithHttpInfo($city, $tax_city)
    {
        $returnType = '';
        $request = $this->deleteTaxProviderSelfCityRequest($city, $tax_city);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    return [null, $response->getStatusCode(), $response->getHeaders()];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'deleteTaxProviderSelfCity'
     *
     * @param  string $city The city being deleted. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function deleteTaxProviderSelfCityRequest($city, $tax_city)
    {
        // verify the required parameter 'city' is set
        if ($city === null || (is_array($city) && count($city) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $city when calling deleteTaxProviderSelfCity'
            );
        }
        // verify the required parameter 'tax_city' is set
        if ($tax_city === null || (is_array($tax_city) && count($tax_city) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_city when calling deleteTaxProviderSelfCity'
            );
        }

        $resourcePath = '/tax/providers/self/city/{city}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;
        if (isset($tax_city)) {
            $_tempBody = $tax_city;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'DELETE',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation deleteTaxProviderSelfCountry
     *
     * Deletes a Self tax provider country
     *
     * @param  string $country_code The country code being deleted. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return void
     */
    public function deleteTaxProviderSelfCountry($country_code, $tax_country)
    {
        $this->deleteTaxProviderSelfCountryWithHttpInfo($country_code, $tax_country);
    }

    /**
     * Operation deleteTaxProviderSelfCountryWithHttpInfo
     *
     * Deletes a Self tax provider country
     *
     * @param  string $country_code The country code being deleted. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of null, HTTP status code, HTTP response headers (array of strings)
     */
    public function deleteTaxProviderSelfCountryWithHttpInfo($country_code, $tax_country)
    {
        $this->deleteTaxProviderSelfCountryWithHttpInfoRetry(true ,   $country_code,   $tax_country);
    }

    /**
     * Operation deleteTaxProviderSelfCountryWithHttpInfoRetry
     *
     * Deletes a Self tax provider country
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $country_code The country code being deleted. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of null, HTTP status code, HTTP response headers (array of strings)
     */
    public function deleteTaxProviderSelfCountryWithHttpInfoRetry($retry ,  $country_code,  $tax_country)
    {
        $returnType = '';
        $request = $this->deleteTaxProviderSelfCountryRequest($country_code, $tax_country);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        $this->deleteTaxProviderSelfCountryWithHttpInfoRetry(false ,   $country_code,   $tax_country);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation deleteTaxProviderSelfCountryAsync
     *
     * Deletes a Self tax provider country
     *
     * @param  string $country_code The country code being deleted. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteTaxProviderSelfCountryAsync($country_code, $tax_country)
    {
        return $this->deleteTaxProviderSelfCountryAsyncWithHttpInfo($country_code, $tax_country)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation deleteTaxProviderSelfCountryAsyncWithHttpInfo
     *
     * Deletes a Self tax provider country
     *
     * @param  string $country_code The country code being deleted. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteTaxProviderSelfCountryAsyncWithHttpInfo($country_code, $tax_country)
    {
        $returnType = '';
        $request = $this->deleteTaxProviderSelfCountryRequest($country_code, $tax_country);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    return [null, $response->getStatusCode(), $response->getHeaders()];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'deleteTaxProviderSelfCountry'
     *
     * @param  string $country_code The country code being deleted. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function deleteTaxProviderSelfCountryRequest($country_code, $tax_country)
    {
        // verify the required parameter 'country_code' is set
        if ($country_code === null || (is_array($country_code) && count($country_code) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $country_code when calling deleteTaxProviderSelfCountry'
            );
        }
        // verify the required parameter 'tax_country' is set
        if ($tax_country === null || (is_array($tax_country) && count($tax_country) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_country when calling deleteTaxProviderSelfCountry'
            );
        }

        $resourcePath = '/tax/providers/self/country/{countryCode}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;
        if (isset($tax_country)) {
            $_tempBody = $tax_country;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'DELETE',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation deleteTaxProviderSelfCounty
     *
     * Deletes a Self tax provider county
     *
     * @param  string $county The county being deleted. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return void
     */
    public function deleteTaxProviderSelfCounty($county, $tax_county)
    {
        $this->deleteTaxProviderSelfCountyWithHttpInfo($county, $tax_county);
    }

    /**
     * Operation deleteTaxProviderSelfCountyWithHttpInfo
     *
     * Deletes a Self tax provider county
     *
     * @param  string $county The county being deleted. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of null, HTTP status code, HTTP response headers (array of strings)
     */
    public function deleteTaxProviderSelfCountyWithHttpInfo($county, $tax_county)
    {
        $this->deleteTaxProviderSelfCountyWithHttpInfoRetry(true ,   $county,   $tax_county);
    }

    /**
     * Operation deleteTaxProviderSelfCountyWithHttpInfoRetry
     *
     * Deletes a Self tax provider county
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $county The county being deleted. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of null, HTTP status code, HTTP response headers (array of strings)
     */
    public function deleteTaxProviderSelfCountyWithHttpInfoRetry($retry ,  $county,  $tax_county)
    {
        $returnType = '';
        $request = $this->deleteTaxProviderSelfCountyRequest($county, $tax_county);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        $this->deleteTaxProviderSelfCountyWithHttpInfoRetry(false ,   $county,   $tax_county);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation deleteTaxProviderSelfCountyAsync
     *
     * Deletes a Self tax provider county
     *
     * @param  string $county The county being deleted. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteTaxProviderSelfCountyAsync($county, $tax_county)
    {
        return $this->deleteTaxProviderSelfCountyAsyncWithHttpInfo($county, $tax_county)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation deleteTaxProviderSelfCountyAsyncWithHttpInfo
     *
     * Deletes a Self tax provider county
     *
     * @param  string $county The county being deleted. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteTaxProviderSelfCountyAsyncWithHttpInfo($county, $tax_county)
    {
        $returnType = '';
        $request = $this->deleteTaxProviderSelfCountyRequest($county, $tax_county);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    return [null, $response->getStatusCode(), $response->getHeaders()];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'deleteTaxProviderSelfCounty'
     *
     * @param  string $county The county being deleted. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function deleteTaxProviderSelfCountyRequest($county, $tax_county)
    {
        // verify the required parameter 'county' is set
        if ($county === null || (is_array($county) && count($county) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $county when calling deleteTaxProviderSelfCounty'
            );
        }
        // verify the required parameter 'tax_county' is set
        if ($tax_county === null || (is_array($tax_county) && count($tax_county) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_county when calling deleteTaxProviderSelfCounty'
            );
        }

        $resourcePath = '/tax/providers/self/county/{county}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;
        if (isset($tax_county)) {
            $_tempBody = $tax_county;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'DELETE',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation deleteTaxProviderSelfPostalCode
     *
     * Deletes a Self tax provider postalCode
     *
     * @param  string $postal_code The postal code being deleted. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return void
     */
    public function deleteTaxProviderSelfPostalCode($postal_code, $tax_postal_code)
    {
        $this->deleteTaxProviderSelfPostalCodeWithHttpInfo($postal_code, $tax_postal_code);
    }

    /**
     * Operation deleteTaxProviderSelfPostalCodeWithHttpInfo
     *
     * Deletes a Self tax provider postalCode
     *
     * @param  string $postal_code The postal code being deleted. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of null, HTTP status code, HTTP response headers (array of strings)
     */
    public function deleteTaxProviderSelfPostalCodeWithHttpInfo($postal_code, $tax_postal_code)
    {
        $this->deleteTaxProviderSelfPostalCodeWithHttpInfoRetry(true ,   $postal_code,   $tax_postal_code);
    }

    /**
     * Operation deleteTaxProviderSelfPostalCodeWithHttpInfoRetry
     *
     * Deletes a Self tax provider postalCode
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $postal_code The postal code being deleted. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of null, HTTP status code, HTTP response headers (array of strings)
     */
    public function deleteTaxProviderSelfPostalCodeWithHttpInfoRetry($retry ,  $postal_code,  $tax_postal_code)
    {
        $returnType = '';
        $request = $this->deleteTaxProviderSelfPostalCodeRequest($postal_code, $tax_postal_code);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        $this->deleteTaxProviderSelfPostalCodeWithHttpInfoRetry(false ,   $postal_code,   $tax_postal_code);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation deleteTaxProviderSelfPostalCodeAsync
     *
     * Deletes a Self tax provider postalCode
     *
     * @param  string $postal_code The postal code being deleted. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteTaxProviderSelfPostalCodeAsync($postal_code, $tax_postal_code)
    {
        return $this->deleteTaxProviderSelfPostalCodeAsyncWithHttpInfo($postal_code, $tax_postal_code)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation deleteTaxProviderSelfPostalCodeAsyncWithHttpInfo
     *
     * Deletes a Self tax provider postalCode
     *
     * @param  string $postal_code The postal code being deleted. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteTaxProviderSelfPostalCodeAsyncWithHttpInfo($postal_code, $tax_postal_code)
    {
        $returnType = '';
        $request = $this->deleteTaxProviderSelfPostalCodeRequest($postal_code, $tax_postal_code);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    return [null, $response->getStatusCode(), $response->getHeaders()];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'deleteTaxProviderSelfPostalCode'
     *
     * @param  string $postal_code The postal code being deleted. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function deleteTaxProviderSelfPostalCodeRequest($postal_code, $tax_postal_code)
    {
        // verify the required parameter 'postal_code' is set
        if ($postal_code === null || (is_array($postal_code) && count($postal_code) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $postal_code when calling deleteTaxProviderSelfPostalCode'
            );
        }
        // verify the required parameter 'tax_postal_code' is set
        if ($tax_postal_code === null || (is_array($tax_postal_code) && count($tax_postal_code) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_postal_code when calling deleteTaxProviderSelfPostalCode'
            );
        }

        $resourcePath = '/tax/providers/self/postalCode/{postal_code}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;
        if (isset($tax_postal_code)) {
            $_tempBody = $tax_postal_code;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'DELETE',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation deleteTaxProviderSelfState
     *
     * Deletes a Self tax provider state
     *
     * @param  string $state_code The state code being deleted. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return void
     */
    public function deleteTaxProviderSelfState($state_code, $tax_state)
    {
        $this->deleteTaxProviderSelfStateWithHttpInfo($state_code, $tax_state);
    }

    /**
     * Operation deleteTaxProviderSelfStateWithHttpInfo
     *
     * Deletes a Self tax provider state
     *
     * @param  string $state_code The state code being deleted. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of null, HTTP status code, HTTP response headers (array of strings)
     */
    public function deleteTaxProviderSelfStateWithHttpInfo($state_code, $tax_state)
    {
        $this->deleteTaxProviderSelfStateWithHttpInfoRetry(true ,   $state_code,   $tax_state);
    }

    /**
     * Operation deleteTaxProviderSelfStateWithHttpInfoRetry
     *
     * Deletes a Self tax provider state
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $state_code The state code being deleted. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be deleted (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of null, HTTP status code, HTTP response headers (array of strings)
     */
    public function deleteTaxProviderSelfStateWithHttpInfoRetry($retry ,  $state_code,  $tax_state)
    {
        $returnType = '';
        $request = $this->deleteTaxProviderSelfStateRequest($state_code, $tax_state);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        $this->deleteTaxProviderSelfStateWithHttpInfoRetry(false ,   $state_code,   $tax_state);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation deleteTaxProviderSelfStateAsync
     *
     * Deletes a Self tax provider state
     *
     * @param  string $state_code The state code being deleted. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteTaxProviderSelfStateAsync($state_code, $tax_state)
    {
        return $this->deleteTaxProviderSelfStateAsyncWithHttpInfo($state_code, $tax_state)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation deleteTaxProviderSelfStateAsyncWithHttpInfo
     *
     * Deletes a Self tax provider state
     *
     * @param  string $state_code The state code being deleted. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function deleteTaxProviderSelfStateAsyncWithHttpInfo($state_code, $tax_state)
    {
        $returnType = '';
        $request = $this->deleteTaxProviderSelfStateRequest($state_code, $tax_state);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    return [null, $response->getStatusCode(), $response->getHeaders()];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'deleteTaxProviderSelfState'
     *
     * @param  string $state_code The state code being deleted. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be deleted (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function deleteTaxProviderSelfStateRequest($state_code, $tax_state)
    {
        // verify the required parameter 'state_code' is set
        if ($state_code === null || (is_array($state_code) && count($state_code) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $state_code when calling deleteTaxProviderSelfState'
            );
        }
        // verify the required parameter 'tax_state' is set
        if ($tax_state === null || (is_array($tax_state) && count($tax_state) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_state when calling deleteTaxProviderSelfState'
            );
        }

        $resourcePath = '/tax/providers/self/state/{stateCode}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;
        if (isset($tax_state)) {
            $_tempBody = $tax_state;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'DELETE',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getTaxProviderAvalara
     *
     * Retrieve the Avalara tax provider
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderAvalara
     */
    public function getTaxProviderAvalara()
    {
        list($response) = $this->getTaxProviderAvalaraWithHttpInfo();
        return $response;
    }

    /**
     * Operation getTaxProviderAvalaraWithHttpInfo
     *
     * Retrieve the Avalara tax provider
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderAvalara, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderAvalaraWithHttpInfo()
    {
        return $this->getTaxProviderAvalaraWithHttpInfoRetry(true );
    }

    /**
     * Operation getTaxProviderAvalaraWithHttpInfoRetry
     *
     * Retrieve the Avalara tax provider
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderAvalara, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderAvalaraWithHttpInfoRetry($retry )
    {
        $returnType = '\ultracart\v2\models\TaxProviderAvalara';
        $request = $this->getTaxProviderAvalaraRequest();

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProviderAvalaraWithHttpInfoRetry(false );
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderAvalara',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProviderAvalaraAsync
     *
     * Retrieve the Avalara tax provider
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderAvalaraAsync()
    {
        return $this->getTaxProviderAvalaraAsyncWithHttpInfo()
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProviderAvalaraAsyncWithHttpInfo
     *
     * Retrieve the Avalara tax provider
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderAvalaraAsyncWithHttpInfo()
    {
        $returnType = '\ultracart\v2\models\TaxProviderAvalara';
        $request = $this->getTaxProviderAvalaraRequest();

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviderAvalara'
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProviderAvalaraRequest()
    {

        $resourcePath = '/tax/providers/avalara';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

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

    /**
     * Operation getTaxProviderAvalaraCompanies
     *
     * Returns Avalara Tax companies configured by the merchant
     *
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderAvalaraCompaniesResult
     */
    public function getTaxProviderAvalaraCompanies($tax_provider_avalara)
    {
        list($response) = $this->getTaxProviderAvalaraCompaniesWithHttpInfo($tax_provider_avalara);
        return $response;
    }

    /**
     * Operation getTaxProviderAvalaraCompaniesWithHttpInfo
     *
     * Returns Avalara Tax companies configured by the merchant
     *
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderAvalaraCompaniesResult, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderAvalaraCompaniesWithHttpInfo($tax_provider_avalara)
    {
        return $this->getTaxProviderAvalaraCompaniesWithHttpInfoRetry(true ,   $tax_provider_avalara);
    }

    /**
     * Operation getTaxProviderAvalaraCompaniesWithHttpInfoRetry
     *
     * Returns Avalara Tax companies configured by the merchant
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderAvalaraCompaniesResult, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderAvalaraCompaniesWithHttpInfoRetry($retry ,  $tax_provider_avalara)
    {
        $returnType = '\ultracart\v2\models\TaxProviderAvalaraCompaniesResult';
        $request = $this->getTaxProviderAvalaraCompaniesRequest($tax_provider_avalara);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProviderAvalaraCompaniesWithHttpInfoRetry(false ,   $tax_provider_avalara);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderAvalaraCompaniesResult',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProviderAvalaraCompaniesAsync
     *
     * Returns Avalara Tax companies configured by the merchant
     *
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderAvalaraCompaniesAsync($tax_provider_avalara)
    {
        return $this->getTaxProviderAvalaraCompaniesAsyncWithHttpInfo($tax_provider_avalara)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProviderAvalaraCompaniesAsyncWithHttpInfo
     *
     * Returns Avalara Tax companies configured by the merchant
     *
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderAvalaraCompaniesAsyncWithHttpInfo($tax_provider_avalara)
    {
        $returnType = '\ultracart\v2\models\TaxProviderAvalaraCompaniesResult';
        $request = $this->getTaxProviderAvalaraCompaniesRequest($tax_provider_avalara);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviderAvalaraCompanies'
     *
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProviderAvalaraCompaniesRequest($tax_provider_avalara)
    {
        // verify the required parameter 'tax_provider_avalara' is set
        if ($tax_provider_avalara === null || (is_array($tax_provider_avalara) && count($tax_provider_avalara) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_provider_avalara when calling getTaxProviderAvalaraCompanies'
            );
        }

        $resourcePath = '/tax/providers/avalara/companies';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;
        if (isset($tax_provider_avalara)) {
            $_tempBody = $tax_provider_avalara;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation getTaxProviderAvalaraTest
     *
     * Attempts to connect to Avalara and returns back the response
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderTestResult
     */
    public function getTaxProviderAvalaraTest()
    {
        list($response) = $this->getTaxProviderAvalaraTestWithHttpInfo();
        return $response;
    }

    /**
     * Operation getTaxProviderAvalaraTestWithHttpInfo
     *
     * Attempts to connect to Avalara and returns back the response
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderTestResult, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderAvalaraTestWithHttpInfo()
    {
        return $this->getTaxProviderAvalaraTestWithHttpInfoRetry(true );
    }

    /**
     * Operation getTaxProviderAvalaraTestWithHttpInfoRetry
     *
     * Attempts to connect to Avalara and returns back the response
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderTestResult, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderAvalaraTestWithHttpInfoRetry($retry )
    {
        $returnType = '\ultracart\v2\models\TaxProviderTestResult';
        $request = $this->getTaxProviderAvalaraTestRequest();

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProviderAvalaraTestWithHttpInfoRetry(false );
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderTestResult',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProviderAvalaraTestAsync
     *
     * Attempts to connect to Avalara and returns back the response
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderAvalaraTestAsync()
    {
        return $this->getTaxProviderAvalaraTestAsyncWithHttpInfo()
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProviderAvalaraTestAsyncWithHttpInfo
     *
     * Attempts to connect to Avalara and returns back the response
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderAvalaraTestAsyncWithHttpInfo()
    {
        $returnType = '\ultracart\v2\models\TaxProviderTestResult';
        $request = $this->getTaxProviderAvalaraTestRequest();

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviderAvalaraTest'
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProviderAvalaraTestRequest()
    {

        $resourcePath = '/tax/providers/avalara/test';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

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

    /**
     * Operation getTaxProviderSelf
     *
     * Retrieve the Self tax provider
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderSelf
     */
    public function getTaxProviderSelf()
    {
        list($response) = $this->getTaxProviderSelfWithHttpInfo();
        return $response;
    }

    /**
     * Operation getTaxProviderSelfWithHttpInfo
     *
     * Retrieve the Self tax provider
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSelf, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderSelfWithHttpInfo()
    {
        return $this->getTaxProviderSelfWithHttpInfoRetry(true );
    }

    /**
     * Operation getTaxProviderSelfWithHttpInfoRetry
     *
     * Retrieve the Self tax provider
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSelf, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderSelfWithHttpInfoRetry($retry )
    {
        $returnType = '\ultracart\v2\models\TaxProviderSelf';
        $request = $this->getTaxProviderSelfRequest();

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProviderSelfWithHttpInfoRetry(false );
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderSelf',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProviderSelfAsync
     *
     * Retrieve the Self tax provider
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderSelfAsync()
    {
        return $this->getTaxProviderSelfAsyncWithHttpInfo()
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProviderSelfAsyncWithHttpInfo
     *
     * Retrieve the Self tax provider
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderSelfAsyncWithHttpInfo()
    {
        $returnType = '\ultracart\v2\models\TaxProviderSelf';
        $request = $this->getTaxProviderSelfRequest();

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviderSelf'
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProviderSelfRequest()
    {

        $resourcePath = '/tax/providers/self';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

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

    /**
     * Operation getTaxProviderSelfCountries
     *
     * Retrieve the Self tax provider countries
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderSelfCountriesResponse
     */
    public function getTaxProviderSelfCountries()
    {
        list($response) = $this->getTaxProviderSelfCountriesWithHttpInfo();
        return $response;
    }

    /**
     * Operation getTaxProviderSelfCountriesWithHttpInfo
     *
     * Retrieve the Self tax provider countries
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSelfCountriesResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderSelfCountriesWithHttpInfo()
    {
        return $this->getTaxProviderSelfCountriesWithHttpInfoRetry(true );
    }

    /**
     * Operation getTaxProviderSelfCountriesWithHttpInfoRetry
     *
     * Retrieve the Self tax provider countries
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSelfCountriesResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderSelfCountriesWithHttpInfoRetry($retry )
    {
        $returnType = '\ultracart\v2\models\TaxProviderSelfCountriesResponse';
        $request = $this->getTaxProviderSelfCountriesRequest();

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProviderSelfCountriesWithHttpInfoRetry(false );
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderSelfCountriesResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProviderSelfCountriesAsync
     *
     * Retrieve the Self tax provider countries
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderSelfCountriesAsync()
    {
        return $this->getTaxProviderSelfCountriesAsyncWithHttpInfo()
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProviderSelfCountriesAsyncWithHttpInfo
     *
     * Retrieve the Self tax provider countries
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderSelfCountriesAsyncWithHttpInfo()
    {
        $returnType = '\ultracart\v2\models\TaxProviderSelfCountriesResponse';
        $request = $this->getTaxProviderSelfCountriesRequest();

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviderSelfCountries'
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProviderSelfCountriesRequest()
    {

        $resourcePath = '/tax/providers/self/countries';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

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

    /**
     * Operation getTaxProviderSelfRegionsByCountryCode
     *
     * Retrieve the Self tax provider regions for a given country code
     *
     * @param  string $country_code The country code regions desired. (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderSelfRegionsResponse
     */
    public function getTaxProviderSelfRegionsByCountryCode($country_code)
    {
        list($response) = $this->getTaxProviderSelfRegionsByCountryCodeWithHttpInfo($country_code);
        return $response;
    }

    /**
     * Operation getTaxProviderSelfRegionsByCountryCodeWithHttpInfo
     *
     * Retrieve the Self tax provider regions for a given country code
     *
     * @param  string $country_code The country code regions desired. (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSelfRegionsResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderSelfRegionsByCountryCodeWithHttpInfo($country_code)
    {
        return $this->getTaxProviderSelfRegionsByCountryCodeWithHttpInfoRetry(true ,   $country_code);
    }

    /**
     * Operation getTaxProviderSelfRegionsByCountryCodeWithHttpInfoRetry
     *
     * Retrieve the Self tax provider regions for a given country code
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $country_code The country code regions desired. (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSelfRegionsResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderSelfRegionsByCountryCodeWithHttpInfoRetry($retry ,  $country_code)
    {
        $returnType = '\ultracart\v2\models\TaxProviderSelfRegionsResponse';
        $request = $this->getTaxProviderSelfRegionsByCountryCodeRequest($country_code);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProviderSelfRegionsByCountryCodeWithHttpInfoRetry(false ,   $country_code);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderSelfRegionsResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProviderSelfRegionsByCountryCodeAsync
     *
     * Retrieve the Self tax provider regions for a given country code
     *
     * @param  string $country_code The country code regions desired. (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderSelfRegionsByCountryCodeAsync($country_code)
    {
        return $this->getTaxProviderSelfRegionsByCountryCodeAsyncWithHttpInfo($country_code)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProviderSelfRegionsByCountryCodeAsyncWithHttpInfo
     *
     * Retrieve the Self tax provider regions for a given country code
     *
     * @param  string $country_code The country code regions desired. (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderSelfRegionsByCountryCodeAsyncWithHttpInfo($country_code)
    {
        $returnType = '\ultracart\v2\models\TaxProviderSelfRegionsResponse';
        $request = $this->getTaxProviderSelfRegionsByCountryCodeRequest($country_code);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviderSelfRegionsByCountryCode'
     *
     * @param  string $country_code The country code regions desired. (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProviderSelfRegionsByCountryCodeRequest($country_code)
    {
        // verify the required parameter 'country_code' is set
        if ($country_code === null || (is_array($country_code) && count($country_code) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $country_code when calling getTaxProviderSelfRegionsByCountryCode'
            );
        }

        $resourcePath = '/tax/providers/self/regions/{countryCode}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

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

    /**
     * Operation getTaxProviderSovos
     *
     * Retrieve the Sovos tax provider
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderSovos
     */
    public function getTaxProviderSovos()
    {
        list($response) = $this->getTaxProviderSovosWithHttpInfo();
        return $response;
    }

    /**
     * Operation getTaxProviderSovosWithHttpInfo
     *
     * Retrieve the Sovos tax provider
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSovos, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderSovosWithHttpInfo()
    {
        return $this->getTaxProviderSovosWithHttpInfoRetry(true );
    }

    /**
     * Operation getTaxProviderSovosWithHttpInfoRetry
     *
     * Retrieve the Sovos tax provider
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSovos, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderSovosWithHttpInfoRetry($retry )
    {
        $returnType = '\ultracart\v2\models\TaxProviderSovos';
        $request = $this->getTaxProviderSovosRequest();

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProviderSovosWithHttpInfoRetry(false );
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderSovos',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProviderSovosAsync
     *
     * Retrieve the Sovos tax provider
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderSovosAsync()
    {
        return $this->getTaxProviderSovosAsyncWithHttpInfo()
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProviderSovosAsyncWithHttpInfo
     *
     * Retrieve the Sovos tax provider
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderSovosAsyncWithHttpInfo()
    {
        $returnType = '\ultracart\v2\models\TaxProviderSovos';
        $request = $this->getTaxProviderSovosRequest();

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviderSovos'
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProviderSovosRequest()
    {

        $resourcePath = '/tax/providers/sovos';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

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

    /**
     * Operation getTaxProviderSovosTest
     *
     * Attempts to connect to Sovos and returns back the response
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderTestResult
     */
    public function getTaxProviderSovosTest()
    {
        list($response) = $this->getTaxProviderSovosTestWithHttpInfo();
        return $response;
    }

    /**
     * Operation getTaxProviderSovosTestWithHttpInfo
     *
     * Attempts to connect to Sovos and returns back the response
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderTestResult, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderSovosTestWithHttpInfo()
    {
        return $this->getTaxProviderSovosTestWithHttpInfoRetry(true );
    }

    /**
     * Operation getTaxProviderSovosTestWithHttpInfoRetry
     *
     * Attempts to connect to Sovos and returns back the response
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderTestResult, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderSovosTestWithHttpInfoRetry($retry )
    {
        $returnType = '\ultracart\v2\models\TaxProviderTestResult';
        $request = $this->getTaxProviderSovosTestRequest();

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProviderSovosTestWithHttpInfoRetry(false );
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderTestResult',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProviderSovosTestAsync
     *
     * Attempts to connect to Sovos and returns back the response
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderSovosTestAsync()
    {
        return $this->getTaxProviderSovosTestAsyncWithHttpInfo()
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProviderSovosTestAsyncWithHttpInfo
     *
     * Attempts to connect to Sovos and returns back the response
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderSovosTestAsyncWithHttpInfo()
    {
        $returnType = '\ultracart\v2\models\TaxProviderTestResult';
        $request = $this->getTaxProviderSovosTestRequest();

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviderSovosTest'
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProviderSovosTestRequest()
    {

        $resourcePath = '/tax/providers/sovos/test';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

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

    /**
     * Operation getTaxProviderTaxJar
     *
     * Retrieve the TaxJar tax provider
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderTaxJar
     */
    public function getTaxProviderTaxJar()
    {
        list($response) = $this->getTaxProviderTaxJarWithHttpInfo();
        return $response;
    }

    /**
     * Operation getTaxProviderTaxJarWithHttpInfo
     *
     * Retrieve the TaxJar tax provider
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderTaxJar, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderTaxJarWithHttpInfo()
    {
        return $this->getTaxProviderTaxJarWithHttpInfoRetry(true );
    }

    /**
     * Operation getTaxProviderTaxJarWithHttpInfoRetry
     *
     * Retrieve the TaxJar tax provider
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderTaxJar, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderTaxJarWithHttpInfoRetry($retry )
    {
        $returnType = '\ultracart\v2\models\TaxProviderTaxJar';
        $request = $this->getTaxProviderTaxJarRequest();

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProviderTaxJarWithHttpInfoRetry(false );
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderTaxJar',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProviderTaxJarAsync
     *
     * Retrieve the TaxJar tax provider
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderTaxJarAsync()
    {
        return $this->getTaxProviderTaxJarAsyncWithHttpInfo()
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProviderTaxJarAsyncWithHttpInfo
     *
     * Retrieve the TaxJar tax provider
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderTaxJarAsyncWithHttpInfo()
    {
        $returnType = '\ultracart\v2\models\TaxProviderTaxJar';
        $request = $this->getTaxProviderTaxJarRequest();

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviderTaxJar'
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProviderTaxJarRequest()
    {

        $resourcePath = '/tax/providers/taxjar';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

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

    /**
     * Operation getTaxProviderTaxJarTest
     *
     * Attempts to connect to TaxJar and returns back the response
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderTestResult
     */
    public function getTaxProviderTaxJarTest()
    {
        list($response) = $this->getTaxProviderTaxJarTestWithHttpInfo();
        return $response;
    }

    /**
     * Operation getTaxProviderTaxJarTestWithHttpInfo
     *
     * Attempts to connect to TaxJar and returns back the response
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderTestResult, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderTaxJarTestWithHttpInfo()
    {
        return $this->getTaxProviderTaxJarTestWithHttpInfoRetry(true );
    }

    /**
     * Operation getTaxProviderTaxJarTestWithHttpInfoRetry
     *
     * Attempts to connect to TaxJar and returns back the response
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderTestResult, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderTaxJarTestWithHttpInfoRetry($retry )
    {
        $returnType = '\ultracart\v2\models\TaxProviderTestResult';
        $request = $this->getTaxProviderTaxJarTestRequest();

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProviderTaxJarTestWithHttpInfoRetry(false );
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderTestResult',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProviderTaxJarTestAsync
     *
     * Attempts to connect to TaxJar and returns back the response
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderTaxJarTestAsync()
    {
        return $this->getTaxProviderTaxJarTestAsyncWithHttpInfo()
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProviderTaxJarTestAsyncWithHttpInfo
     *
     * Attempts to connect to TaxJar and returns back the response
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderTaxJarTestAsyncWithHttpInfo()
    {
        $returnType = '\ultracart\v2\models\TaxProviderTestResult';
        $request = $this->getTaxProviderTaxJarTestRequest();

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviderTaxJarTest'
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProviderTaxJarTestRequest()
    {

        $resourcePath = '/tax/providers/taxjar/test';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

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

    /**
     * Operation getTaxProviderUltraCart
     *
     * Retrieve the UltraCart tax provider
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderUltraCart
     */
    public function getTaxProviderUltraCart()
    {
        list($response) = $this->getTaxProviderUltraCartWithHttpInfo();
        return $response;
    }

    /**
     * Operation getTaxProviderUltraCartWithHttpInfo
     *
     * Retrieve the UltraCart tax provider
     *
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderUltraCart, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderUltraCartWithHttpInfo()
    {
        return $this->getTaxProviderUltraCartWithHttpInfoRetry(true );
    }

    /**
     * Operation getTaxProviderUltraCartWithHttpInfoRetry
     *
     * Retrieve the UltraCart tax provider
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderUltraCart, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProviderUltraCartWithHttpInfoRetry($retry )
    {
        $returnType = '\ultracart\v2\models\TaxProviderUltraCart';
        $request = $this->getTaxProviderUltraCartRequest();

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProviderUltraCartWithHttpInfoRetry(false );
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderUltraCart',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProviderUltraCartAsync
     *
     * Retrieve the UltraCart tax provider
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderUltraCartAsync()
    {
        return $this->getTaxProviderUltraCartAsyncWithHttpInfo()
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProviderUltraCartAsyncWithHttpInfo
     *
     * Retrieve the UltraCart tax provider
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProviderUltraCartAsyncWithHttpInfo()
    {
        $returnType = '\ultracart\v2\models\TaxProviderUltraCart';
        $request = $this->getTaxProviderUltraCartRequest();

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviderUltraCart'
     *
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProviderUltraCartRequest()
    {

        $resourcePath = '/tax/providers/ultracart';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

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

    /**
     * Operation getTaxProviders
     *
     * Retrieve tax methods
     *
     * @param  int $_limit The maximum number of records to return on this one API call. (Max 200) (optional, default to 100)
     * @param  int $_offset Pagination of the record set.  Offset is a zero based index. (optional, default to 0)
     * @param  string $_expand The object expansion to perform on the result.  See documentation for examples (optional)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProvidersResponse
     */
    public function getTaxProviders($_limit = '100', $_offset = '0', $_expand = null)
    {
        list($response) = $this->getTaxProvidersWithHttpInfo($_limit, $_offset, $_expand);
        return $response;
    }

    /**
     * Operation getTaxProvidersWithHttpInfo
     *
     * Retrieve tax methods
     *
     * @param  int $_limit The maximum number of records to return on this one API call. (Max 200) (optional, default to 100)
     * @param  int $_offset Pagination of the record set.  Offset is a zero based index. (optional, default to 0)
     * @param  string $_expand The object expansion to perform on the result.  See documentation for examples (optional)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProvidersResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProvidersWithHttpInfo($_limit = '100', $_offset = '0', $_expand = null)
    {
        return $this->getTaxProvidersWithHttpInfoRetry(true ,   $_limit,   $_offset,   $_expand);
    }

    /**
     * Operation getTaxProvidersWithHttpInfoRetry
     *
     * Retrieve tax methods
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  int $_limit The maximum number of records to return on this one API call. (Max 200) (optional, default to 100)
     * @param  int $_offset Pagination of the record set.  Offset is a zero based index. (optional, default to 0)
     * @param  string $_expand The object expansion to perform on the result.  See documentation for examples (optional)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProvidersResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function getTaxProvidersWithHttpInfoRetry($retry ,  $_limit = '100',  $_offset = '0',  $_expand = null)
    {
        $returnType = '\ultracart\v2\models\TaxProvidersResponse';
        $request = $this->getTaxProvidersRequest($_limit, $_offset, $_expand);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->getTaxProvidersWithHttpInfoRetry(false ,   $_limit,   $_offset,   $_expand);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProvidersResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation getTaxProvidersAsync
     *
     * Retrieve tax methods
     *
     * @param  int $_limit The maximum number of records to return on this one API call. (Max 200) (optional, default to 100)
     * @param  int $_offset Pagination of the record set.  Offset is a zero based index. (optional, default to 0)
     * @param  string $_expand The object expansion to perform on the result.  See documentation for examples (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProvidersAsync($_limit = '100', $_offset = '0', $_expand = null)
    {
        return $this->getTaxProvidersAsyncWithHttpInfo($_limit, $_offset, $_expand)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation getTaxProvidersAsyncWithHttpInfo
     *
     * Retrieve tax methods
     *
     * @param  int $_limit The maximum number of records to return on this one API call. (Max 200) (optional, default to 100)
     * @param  int $_offset Pagination of the record set.  Offset is a zero based index. (optional, default to 0)
     * @param  string $_expand The object expansion to perform on the result.  See documentation for examples (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function getTaxProvidersAsyncWithHttpInfo($_limit = '100', $_offset = '0', $_expand = null)
    {
        $returnType = '\ultracart\v2\models\TaxProvidersResponse';
        $request = $this->getTaxProvidersRequest($_limit, $_offset, $_expand);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'getTaxProviders'
     *
     * @param  int $_limit The maximum number of records to return on this one API call. (Max 200) (optional, default to 100)
     * @param  int $_offset Pagination of the record set.  Offset is a zero based index. (optional, default to 0)
     * @param  string $_expand The object expansion to perform on the result.  See documentation for examples (optional)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function getTaxProvidersRequest($_limit = '100', $_offset = '0', $_expand = null)
    {

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

        // query params
        if ($_limit !== null) {
            $queryParams['_limit'] = ObjectSerializer::toQueryValue($_limit);
        }
        // query params
        if ($_offset !== null) {
            $queryParams['_offset'] = ObjectSerializer::toQueryValue($_offset);
        }
        // query params
        if ($_expand !== null) {
            $queryParams['_expand'] = ObjectSerializer::toQueryValue($_expand);
        }

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

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

    /**
     * Operation setActiveTaxProvider
     *
     * Toggle a tax provider to active
     *
     * @param  string $provider_name The tax provider to set active. (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderActivateResult
     */
    public function setActiveTaxProvider($provider_name)
    {
        list($response) = $this->setActiveTaxProviderWithHttpInfo($provider_name);
        return $response;
    }

    /**
     * Operation setActiveTaxProviderWithHttpInfo
     *
     * Toggle a tax provider to active
     *
     * @param  string $provider_name The tax provider to set active. (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderActivateResult, HTTP status code, HTTP response headers (array of strings)
     */
    public function setActiveTaxProviderWithHttpInfo($provider_name)
    {
        return $this->setActiveTaxProviderWithHttpInfoRetry(true ,   $provider_name);
    }

    /**
     * Operation setActiveTaxProviderWithHttpInfoRetry
     *
     * Toggle a tax provider to active
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $provider_name The tax provider to set active. (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderActivateResult, HTTP status code, HTTP response headers (array of strings)
     */
    public function setActiveTaxProviderWithHttpInfoRetry($retry ,  $provider_name)
    {
        $returnType = '\ultracart\v2\models\TaxProviderActivateResult';
        $request = $this->setActiveTaxProviderRequest($provider_name);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->setActiveTaxProviderWithHttpInfoRetry(false ,   $provider_name);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderActivateResult',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation setActiveTaxProviderAsync
     *
     * Toggle a tax provider to active
     *
     * @param  string $provider_name The tax provider to set active. (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function setActiveTaxProviderAsync($provider_name)
    {
        return $this->setActiveTaxProviderAsyncWithHttpInfo($provider_name)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation setActiveTaxProviderAsyncWithHttpInfo
     *
     * Toggle a tax provider to active
     *
     * @param  string $provider_name The tax provider to set active. (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function setActiveTaxProviderAsyncWithHttpInfo($provider_name)
    {
        $returnType = '\ultracart\v2\models\TaxProviderActivateResult';
        $request = $this->setActiveTaxProviderRequest($provider_name);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'setActiveTaxProvider'
     *
     * @param  string $provider_name The tax provider to set active. (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function setActiveTaxProviderRequest($provider_name)
    {
        // verify the required parameter 'provider_name' is set
        if ($provider_name === null || (is_array($provider_name) && count($provider_name) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $provider_name when calling setActiveTaxProvider'
            );
        }

        $resourcePath = '/tax/providers/setActive/{providerName}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateTaxProviderAvalara
     *
     * Update the Avalara tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderAvalara
     */
    public function updateTaxProviderAvalara($tax_provider_avalara)
    {
        list($response) = $this->updateTaxProviderAvalaraWithHttpInfo($tax_provider_avalara);
        return $response;
    }

    /**
     * Operation updateTaxProviderAvalaraWithHttpInfo
     *
     * Update the Avalara tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderAvalara, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderAvalaraWithHttpInfo($tax_provider_avalara)
    {
        return $this->updateTaxProviderAvalaraWithHttpInfoRetry(true ,   $tax_provider_avalara);
    }

    /**
     * Operation updateTaxProviderAvalaraWithHttpInfoRetry
     *
     * Update the Avalara tax provider
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderAvalara, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderAvalaraWithHttpInfoRetry($retry ,  $tax_provider_avalara)
    {
        $returnType = '\ultracart\v2\models\TaxProviderAvalara';
        $request = $this->updateTaxProviderAvalaraRequest($tax_provider_avalara);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->updateTaxProviderAvalaraWithHttpInfoRetry(false ,   $tax_provider_avalara);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderAvalara',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation updateTaxProviderAvalaraAsync
     *
     * Update the Avalara tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderAvalaraAsync($tax_provider_avalara)
    {
        return $this->updateTaxProviderAvalaraAsyncWithHttpInfo($tax_provider_avalara)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateTaxProviderAvalaraAsyncWithHttpInfo
     *
     * Update the Avalara tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderAvalaraAsyncWithHttpInfo($tax_provider_avalara)
    {
        $returnType = '\ultracart\v2\models\TaxProviderAvalara';
        $request = $this->updateTaxProviderAvalaraRequest($tax_provider_avalara);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'updateTaxProviderAvalara'
     *
     * @param  \ultracart\v2\models\TaxProviderAvalara $tax_provider_avalara TaxProviderAvalara object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function updateTaxProviderAvalaraRequest($tax_provider_avalara)
    {
        // verify the required parameter 'tax_provider_avalara' is set
        if ($tax_provider_avalara === null || (is_array($tax_provider_avalara) && count($tax_provider_avalara) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_provider_avalara when calling updateTaxProviderAvalara'
            );
        }

        $resourcePath = '/tax/providers/avalara';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;
        if (isset($tax_provider_avalara)) {
            $_tempBody = $tax_provider_avalara;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateTaxProviderSelf
     *
     * Update the Self tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderSelf $tax_provider_self TaxProviderSelf object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderSelf
     */
    public function updateTaxProviderSelf($tax_provider_self)
    {
        list($response) = $this->updateTaxProviderSelfWithHttpInfo($tax_provider_self);
        return $response;
    }

    /**
     * Operation updateTaxProviderSelfWithHttpInfo
     *
     * Update the Self tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderSelf $tax_provider_self TaxProviderSelf object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSelf, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfWithHttpInfo($tax_provider_self)
    {
        return $this->updateTaxProviderSelfWithHttpInfoRetry(true ,   $tax_provider_self);
    }

    /**
     * Operation updateTaxProviderSelfWithHttpInfoRetry
     *
     * Update the Self tax provider
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  \ultracart\v2\models\TaxProviderSelf $tax_provider_self TaxProviderSelf object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSelf, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfWithHttpInfoRetry($retry ,  $tax_provider_self)
    {
        $returnType = '\ultracart\v2\models\TaxProviderSelf';
        $request = $this->updateTaxProviderSelfRequest($tax_provider_self);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->updateTaxProviderSelfWithHttpInfoRetry(false ,   $tax_provider_self);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderSelf',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation updateTaxProviderSelfAsync
     *
     * Update the Self tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderSelf $tax_provider_self TaxProviderSelf object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfAsync($tax_provider_self)
    {
        return $this->updateTaxProviderSelfAsyncWithHttpInfo($tax_provider_self)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateTaxProviderSelfAsyncWithHttpInfo
     *
     * Update the Self tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderSelf $tax_provider_self TaxProviderSelf object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfAsyncWithHttpInfo($tax_provider_self)
    {
        $returnType = '\ultracart\v2\models\TaxProviderSelf';
        $request = $this->updateTaxProviderSelfRequest($tax_provider_self);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'updateTaxProviderSelf'
     *
     * @param  \ultracart\v2\models\TaxProviderSelf $tax_provider_self TaxProviderSelf object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function updateTaxProviderSelfRequest($tax_provider_self)
    {
        // verify the required parameter 'tax_provider_self' is set
        if ($tax_provider_self === null || (is_array($tax_provider_self) && count($tax_provider_self) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_provider_self when calling updateTaxProviderSelf'
            );
        }

        $resourcePath = '/tax/providers/self';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;
        if (isset($tax_provider_self)) {
            $_tempBody = $tax_provider_self;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateTaxProviderSelfCity
     *
     * Updates a Self tax provider city
     *
     * @param  string $city The city being updated. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxCity
     */
    public function updateTaxProviderSelfCity($city, $tax_city)
    {
        list($response) = $this->updateTaxProviderSelfCityWithHttpInfo($city, $tax_city);
        return $response;
    }

    /**
     * Operation updateTaxProviderSelfCityWithHttpInfo
     *
     * Updates a Self tax provider city
     *
     * @param  string $city The city being updated. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxCity, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfCityWithHttpInfo($city, $tax_city)
    {
        return $this->updateTaxProviderSelfCityWithHttpInfoRetry(true ,   $city,   $tax_city);
    }

    /**
     * Operation updateTaxProviderSelfCityWithHttpInfoRetry
     *
     * Updates a Self tax provider city
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $city The city being updated. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxCity, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfCityWithHttpInfoRetry($retry ,  $city,  $tax_city)
    {
        $returnType = '\ultracart\v2\models\TaxCity';
        $request = $this->updateTaxProviderSelfCityRequest($city, $tax_city);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->updateTaxProviderSelfCityWithHttpInfoRetry(false ,   $city,   $tax_city);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxCity',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation updateTaxProviderSelfCityAsync
     *
     * Updates a Self tax provider city
     *
     * @param  string $city The city being updated. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfCityAsync($city, $tax_city)
    {
        return $this->updateTaxProviderSelfCityAsyncWithHttpInfo($city, $tax_city)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateTaxProviderSelfCityAsyncWithHttpInfo
     *
     * Updates a Self tax provider city
     *
     * @param  string $city The city being updated. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfCityAsyncWithHttpInfo($city, $tax_city)
    {
        $returnType = '\ultracart\v2\models\TaxCity';
        $request = $this->updateTaxProviderSelfCityRequest($city, $tax_city);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'updateTaxProviderSelfCity'
     *
     * @param  string $city The city being updated. (required)
     * @param  \ultracart\v2\models\TaxCity $tax_city tax city to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function updateTaxProviderSelfCityRequest($city, $tax_city)
    {
        // verify the required parameter 'city' is set
        if ($city === null || (is_array($city) && count($city) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $city when calling updateTaxProviderSelfCity'
            );
        }
        // verify the required parameter 'tax_city' is set
        if ($tax_city === null || (is_array($tax_city) && count($tax_city) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_city when calling updateTaxProviderSelfCity'
            );
        }

        $resourcePath = '/tax/providers/self/city/{city}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;
        if (isset($tax_city)) {
            $_tempBody = $tax_city;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateTaxProviderSelfCountry
     *
     * Updates a Self tax provider country
     *
     * @param  string $country_code The country code being updated. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxCountry
     */
    public function updateTaxProviderSelfCountry($country_code, $tax_country)
    {
        list($response) = $this->updateTaxProviderSelfCountryWithHttpInfo($country_code, $tax_country);
        return $response;
    }

    /**
     * Operation updateTaxProviderSelfCountryWithHttpInfo
     *
     * Updates a Self tax provider country
     *
     * @param  string $country_code The country code being updated. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxCountry, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfCountryWithHttpInfo($country_code, $tax_country)
    {
        return $this->updateTaxProviderSelfCountryWithHttpInfoRetry(true ,   $country_code,   $tax_country);
    }

    /**
     * Operation updateTaxProviderSelfCountryWithHttpInfoRetry
     *
     * Updates a Self tax provider country
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $country_code The country code being updated. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxCountry, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfCountryWithHttpInfoRetry($retry ,  $country_code,  $tax_country)
    {
        $returnType = '\ultracart\v2\models\TaxCountry';
        $request = $this->updateTaxProviderSelfCountryRequest($country_code, $tax_country);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->updateTaxProviderSelfCountryWithHttpInfoRetry(false ,   $country_code,   $tax_country);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxCountry',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation updateTaxProviderSelfCountryAsync
     *
     * Updates a Self tax provider country
     *
     * @param  string $country_code The country code being updated. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfCountryAsync($country_code, $tax_country)
    {
        return $this->updateTaxProviderSelfCountryAsyncWithHttpInfo($country_code, $tax_country)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateTaxProviderSelfCountryAsyncWithHttpInfo
     *
     * Updates a Self tax provider country
     *
     * @param  string $country_code The country code being updated. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfCountryAsyncWithHttpInfo($country_code, $tax_country)
    {
        $returnType = '\ultracart\v2\models\TaxCountry';
        $request = $this->updateTaxProviderSelfCountryRequest($country_code, $tax_country);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'updateTaxProviderSelfCountry'
     *
     * @param  string $country_code The country code being updated. (required)
     * @param  \ultracart\v2\models\TaxCountry $tax_country tax country to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function updateTaxProviderSelfCountryRequest($country_code, $tax_country)
    {
        // verify the required parameter 'country_code' is set
        if ($country_code === null || (is_array($country_code) && count($country_code) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $country_code when calling updateTaxProviderSelfCountry'
            );
        }
        // verify the required parameter 'tax_country' is set
        if ($tax_country === null || (is_array($tax_country) && count($tax_country) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_country when calling updateTaxProviderSelfCountry'
            );
        }

        $resourcePath = '/tax/providers/self/country/{countryCode}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;
        if (isset($tax_country)) {
            $_tempBody = $tax_country;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateTaxProviderSelfCounty
     *
     * Updates a Self tax provider county
     *
     * @param  string $county The county being updated. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxCounty
     */
    public function updateTaxProviderSelfCounty($county, $tax_county)
    {
        list($response) = $this->updateTaxProviderSelfCountyWithHttpInfo($county, $tax_county);
        return $response;
    }

    /**
     * Operation updateTaxProviderSelfCountyWithHttpInfo
     *
     * Updates a Self tax provider county
     *
     * @param  string $county The county being updated. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxCounty, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfCountyWithHttpInfo($county, $tax_county)
    {
        return $this->updateTaxProviderSelfCountyWithHttpInfoRetry(true ,   $county,   $tax_county);
    }

    /**
     * Operation updateTaxProviderSelfCountyWithHttpInfoRetry
     *
     * Updates a Self tax provider county
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $county The county being updated. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxCounty, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfCountyWithHttpInfoRetry($retry ,  $county,  $tax_county)
    {
        $returnType = '\ultracart\v2\models\TaxCounty';
        $request = $this->updateTaxProviderSelfCountyRequest($county, $tax_county);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->updateTaxProviderSelfCountyWithHttpInfoRetry(false ,   $county,   $tax_county);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxCounty',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation updateTaxProviderSelfCountyAsync
     *
     * Updates a Self tax provider county
     *
     * @param  string $county The county being updated. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfCountyAsync($county, $tax_county)
    {
        return $this->updateTaxProviderSelfCountyAsyncWithHttpInfo($county, $tax_county)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateTaxProviderSelfCountyAsyncWithHttpInfo
     *
     * Updates a Self tax provider county
     *
     * @param  string $county The county being updated. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfCountyAsyncWithHttpInfo($county, $tax_county)
    {
        $returnType = '\ultracart\v2\models\TaxCounty';
        $request = $this->updateTaxProviderSelfCountyRequest($county, $tax_county);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'updateTaxProviderSelfCounty'
     *
     * @param  string $county The county being updated. (required)
     * @param  \ultracart\v2\models\TaxCounty $tax_county tax county to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function updateTaxProviderSelfCountyRequest($county, $tax_county)
    {
        // verify the required parameter 'county' is set
        if ($county === null || (is_array($county) && count($county) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $county when calling updateTaxProviderSelfCounty'
            );
        }
        // verify the required parameter 'tax_county' is set
        if ($tax_county === null || (is_array($tax_county) && count($tax_county) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_county when calling updateTaxProviderSelfCounty'
            );
        }

        $resourcePath = '/tax/providers/self/county/{county}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;
        if (isset($tax_county)) {
            $_tempBody = $tax_county;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateTaxProviderSelfPostalCode
     *
     * Updates a Self tax provider postalCode
     *
     * @param  string $postal_code The postal code being updated. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxPostalCode
     */
    public function updateTaxProviderSelfPostalCode($postal_code, $tax_postal_code)
    {
        list($response) = $this->updateTaxProviderSelfPostalCodeWithHttpInfo($postal_code, $tax_postal_code);
        return $response;
    }

    /**
     * Operation updateTaxProviderSelfPostalCodeWithHttpInfo
     *
     * Updates a Self tax provider postalCode
     *
     * @param  string $postal_code The postal code being updated. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxPostalCode, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfPostalCodeWithHttpInfo($postal_code, $tax_postal_code)
    {
        return $this->updateTaxProviderSelfPostalCodeWithHttpInfoRetry(true ,   $postal_code,   $tax_postal_code);
    }

    /**
     * Operation updateTaxProviderSelfPostalCodeWithHttpInfoRetry
     *
     * Updates a Self tax provider postalCode
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $postal_code The postal code being updated. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxPostalCode, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfPostalCodeWithHttpInfoRetry($retry ,  $postal_code,  $tax_postal_code)
    {
        $returnType = '\ultracart\v2\models\TaxPostalCode';
        $request = $this->updateTaxProviderSelfPostalCodeRequest($postal_code, $tax_postal_code);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->updateTaxProviderSelfPostalCodeWithHttpInfoRetry(false ,   $postal_code,   $tax_postal_code);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxPostalCode',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation updateTaxProviderSelfPostalCodeAsync
     *
     * Updates a Self tax provider postalCode
     *
     * @param  string $postal_code The postal code being updated. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfPostalCodeAsync($postal_code, $tax_postal_code)
    {
        return $this->updateTaxProviderSelfPostalCodeAsyncWithHttpInfo($postal_code, $tax_postal_code)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateTaxProviderSelfPostalCodeAsyncWithHttpInfo
     *
     * Updates a Self tax provider postalCode
     *
     * @param  string $postal_code The postal code being updated. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfPostalCodeAsyncWithHttpInfo($postal_code, $tax_postal_code)
    {
        $returnType = '\ultracart\v2\models\TaxPostalCode';
        $request = $this->updateTaxProviderSelfPostalCodeRequest($postal_code, $tax_postal_code);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'updateTaxProviderSelfPostalCode'
     *
     * @param  string $postal_code The postal code being updated. (required)
     * @param  \ultracart\v2\models\TaxPostalCode $tax_postal_code tax postal code to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function updateTaxProviderSelfPostalCodeRequest($postal_code, $tax_postal_code)
    {
        // verify the required parameter 'postal_code' is set
        if ($postal_code === null || (is_array($postal_code) && count($postal_code) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $postal_code when calling updateTaxProviderSelfPostalCode'
            );
        }
        // verify the required parameter 'tax_postal_code' is set
        if ($tax_postal_code === null || (is_array($tax_postal_code) && count($tax_postal_code) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_postal_code when calling updateTaxProviderSelfPostalCode'
            );
        }

        $resourcePath = '/tax/providers/self/postalCode/{postal_code}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;
        if (isset($tax_postal_code)) {
            $_tempBody = $tax_postal_code;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateTaxProviderSelfState
     *
     * Updates a Self tax provider state
     *
     * @param  string $state_code The state code being updated. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxState
     */
    public function updateTaxProviderSelfState($state_code, $tax_state)
    {
        list($response) = $this->updateTaxProviderSelfStateWithHttpInfo($state_code, $tax_state);
        return $response;
    }

    /**
     * Operation updateTaxProviderSelfStateWithHttpInfo
     *
     * Updates a Self tax provider state
     *
     * @param  string $state_code The state code being updated. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxState, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfStateWithHttpInfo($state_code, $tax_state)
    {
        return $this->updateTaxProviderSelfStateWithHttpInfoRetry(true ,   $state_code,   $tax_state);
    }

    /**
     * Operation updateTaxProviderSelfStateWithHttpInfoRetry
     *
     * Updates a Self tax provider state
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  string $state_code The state code being updated. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be updated (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxState, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSelfStateWithHttpInfoRetry($retry ,  $state_code,  $tax_state)
    {
        $returnType = '\ultracart\v2\models\TaxState';
        $request = $this->updateTaxProviderSelfStateRequest($state_code, $tax_state);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->updateTaxProviderSelfStateWithHttpInfoRetry(false ,   $state_code,   $tax_state);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxState',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation updateTaxProviderSelfStateAsync
     *
     * Updates a Self tax provider state
     *
     * @param  string $state_code The state code being updated. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfStateAsync($state_code, $tax_state)
    {
        return $this->updateTaxProviderSelfStateAsyncWithHttpInfo($state_code, $tax_state)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateTaxProviderSelfStateAsyncWithHttpInfo
     *
     * Updates a Self tax provider state
     *
     * @param  string $state_code The state code being updated. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSelfStateAsyncWithHttpInfo($state_code, $tax_state)
    {
        $returnType = '\ultracart\v2\models\TaxState';
        $request = $this->updateTaxProviderSelfStateRequest($state_code, $tax_state);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'updateTaxProviderSelfState'
     *
     * @param  string $state_code The state code being updated. (required)
     * @param  \ultracart\v2\models\TaxState $tax_state tax state to be updated (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function updateTaxProviderSelfStateRequest($state_code, $tax_state)
    {
        // verify the required parameter 'state_code' is set
        if ($state_code === null || (is_array($state_code) && count($state_code) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $state_code when calling updateTaxProviderSelfState'
            );
        }
        // verify the required parameter 'tax_state' is set
        if ($tax_state === null || (is_array($tax_state) && count($tax_state) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_state when calling updateTaxProviderSelfState'
            );
        }

        $resourcePath = '/tax/providers/self/state/{stateCode}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        // body params
        $_tempBody = null;
        if (isset($tax_state)) {
            $_tempBody = $tax_state;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateTaxProviderSovos
     *
     * Update the Sovos tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderSovos $tax_provider_sovos TaxProviderSovos object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderSovos
     */
    public function updateTaxProviderSovos($tax_provider_sovos)
    {
        list($response) = $this->updateTaxProviderSovosWithHttpInfo($tax_provider_sovos);
        return $response;
    }

    /**
     * Operation updateTaxProviderSovosWithHttpInfo
     *
     * Update the Sovos tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderSovos $tax_provider_sovos TaxProviderSovos object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSovos, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSovosWithHttpInfo($tax_provider_sovos)
    {
        return $this->updateTaxProviderSovosWithHttpInfoRetry(true ,   $tax_provider_sovos);
    }

    /**
     * Operation updateTaxProviderSovosWithHttpInfoRetry
     *
     * Update the Sovos tax provider
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  \ultracart\v2\models\TaxProviderSovos $tax_provider_sovos TaxProviderSovos object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderSovos, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderSovosWithHttpInfoRetry($retry ,  $tax_provider_sovos)
    {
        $returnType = '\ultracart\v2\models\TaxProviderSovos';
        $request = $this->updateTaxProviderSovosRequest($tax_provider_sovos);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->updateTaxProviderSovosWithHttpInfoRetry(false ,   $tax_provider_sovos);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderSovos',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation updateTaxProviderSovosAsync
     *
     * Update the Sovos tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderSovos $tax_provider_sovos TaxProviderSovos object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSovosAsync($tax_provider_sovos)
    {
        return $this->updateTaxProviderSovosAsyncWithHttpInfo($tax_provider_sovos)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateTaxProviderSovosAsyncWithHttpInfo
     *
     * Update the Sovos tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderSovos $tax_provider_sovos TaxProviderSovos object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderSovosAsyncWithHttpInfo($tax_provider_sovos)
    {
        $returnType = '\ultracart\v2\models\TaxProviderSovos';
        $request = $this->updateTaxProviderSovosRequest($tax_provider_sovos);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'updateTaxProviderSovos'
     *
     * @param  \ultracart\v2\models\TaxProviderSovos $tax_provider_sovos TaxProviderSovos object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function updateTaxProviderSovosRequest($tax_provider_sovos)
    {
        // verify the required parameter 'tax_provider_sovos' is set
        if ($tax_provider_sovos === null || (is_array($tax_provider_sovos) && count($tax_provider_sovos) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_provider_sovos when calling updateTaxProviderSovos'
            );
        }

        $resourcePath = '/tax/providers/sovos';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;
        if (isset($tax_provider_sovos)) {
            $_tempBody = $tax_provider_sovos;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateTaxProviderTaxJar
     *
     * Update the TaxJar tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderTaxJar $tax_provider_tax_jar TaxProviderTaxJar object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderTaxJar
     */
    public function updateTaxProviderTaxJar($tax_provider_tax_jar)
    {
        list($response) = $this->updateTaxProviderTaxJarWithHttpInfo($tax_provider_tax_jar);
        return $response;
    }

    /**
     * Operation updateTaxProviderTaxJarWithHttpInfo
     *
     * Update the TaxJar tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderTaxJar $tax_provider_tax_jar TaxProviderTaxJar object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderTaxJar, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderTaxJarWithHttpInfo($tax_provider_tax_jar)
    {
        return $this->updateTaxProviderTaxJarWithHttpInfoRetry(true ,   $tax_provider_tax_jar);
    }

    /**
     * Operation updateTaxProviderTaxJarWithHttpInfoRetry
     *
     * Update the TaxJar tax provider
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  \ultracart\v2\models\TaxProviderTaxJar $tax_provider_tax_jar TaxProviderTaxJar object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderTaxJar, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderTaxJarWithHttpInfoRetry($retry ,  $tax_provider_tax_jar)
    {
        $returnType = '\ultracart\v2\models\TaxProviderTaxJar';
        $request = $this->updateTaxProviderTaxJarRequest($tax_provider_tax_jar);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->updateTaxProviderTaxJarWithHttpInfoRetry(false ,   $tax_provider_tax_jar);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderTaxJar',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation updateTaxProviderTaxJarAsync
     *
     * Update the TaxJar tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderTaxJar $tax_provider_tax_jar TaxProviderTaxJar object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderTaxJarAsync($tax_provider_tax_jar)
    {
        return $this->updateTaxProviderTaxJarAsyncWithHttpInfo($tax_provider_tax_jar)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateTaxProviderTaxJarAsyncWithHttpInfo
     *
     * Update the TaxJar tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderTaxJar $tax_provider_tax_jar TaxProviderTaxJar object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderTaxJarAsyncWithHttpInfo($tax_provider_tax_jar)
    {
        $returnType = '\ultracart\v2\models\TaxProviderTaxJar';
        $request = $this->updateTaxProviderTaxJarRequest($tax_provider_tax_jar);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'updateTaxProviderTaxJar'
     *
     * @param  \ultracart\v2\models\TaxProviderTaxJar $tax_provider_tax_jar TaxProviderTaxJar object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function updateTaxProviderTaxJarRequest($tax_provider_tax_jar)
    {
        // verify the required parameter 'tax_provider_tax_jar' is set
        if ($tax_provider_tax_jar === null || (is_array($tax_provider_tax_jar) && count($tax_provider_tax_jar) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_provider_tax_jar when calling updateTaxProviderTaxJar'
            );
        }

        $resourcePath = '/tax/providers/taxjar';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;
        if (isset($tax_provider_tax_jar)) {
            $_tempBody = $tax_provider_tax_jar;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation updateTaxProviderUltraCart
     *
     * Update the UltraCart tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderUltraCart $tax_provider_ultracart TaxProviderUltraCart object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \ultracart\v2\models\TaxProviderUltraCart
     */
    public function updateTaxProviderUltraCart($tax_provider_ultracart)
    {
        list($response) = $this->updateTaxProviderUltraCartWithHttpInfo($tax_provider_ultracart);
        return $response;
    }

    /**
     * Operation updateTaxProviderUltraCartWithHttpInfo
     *
     * Update the UltraCart tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderUltraCart $tax_provider_ultracart TaxProviderUltraCart object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderUltraCart, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderUltraCartWithHttpInfo($tax_provider_ultracart)
    {
        return $this->updateTaxProviderUltraCartWithHttpInfoRetry(true ,   $tax_provider_ultracart);
    }

    /**
     * Operation updateTaxProviderUltraCartWithHttpInfoRetry
     *
     * Update the UltraCart tax provider
     *
     * @param boolean $retry should this method retry the call if a rate limit is triggered (required)
     * @param  \ultracart\v2\models\TaxProviderUltraCart $tax_provider_ultracart TaxProviderUltraCart object (required)
     *
     * @throws \ultracart\v2\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return array of \ultracart\v2\models\TaxProviderUltraCart, HTTP status code, HTTP response headers (array of strings)
     */
    public function updateTaxProviderUltraCartWithHttpInfoRetry($retry ,  $tax_provider_ultracart)
    {
        $returnType = '\ultracart\v2\models\TaxProviderUltraCart';
        $request = $this->updateTaxProviderUltraCartRequest($tax_provider_ultracart);

        try {
            $options = $this->createHttpClientOption();
            try {
                $response = $this->client->send($request, $options);
            } catch (RequestException $e) {

                if($e->getResponse()) {
                    $response = $e->getResponse();
                    $statusCode = $response->getStatusCode();
                    $retryAfter = 0;
                    $headers = $response->getHeaders();
                    if (array_key_exists('Retry-After', $headers)) {
                        $retryAfter = intval($headers['Retry-After'][0]);
                    }

                    if ($statusCode == 429 && $retry && $retryAfter > 0 && $retryAfter <= $this->config->getMaxRetrySeconds()) {
                        sleep($retryAfter);
                        return $this->updateTaxProviderUltraCartWithHttpInfoRetry(false ,   $tax_provider_ultracart);
                    }
                }

                throw new ApiException(
                    "[{$e->getCode()}] {$e->getMessage()}",
                    $e->getCode(),
                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
                    $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
                );
            }

            $responseBody = $response->getBody();
            if ($returnType === '\SplFileObject') {
                $content = $responseBody; //stream goes to serializer
            } else {
                $content = $responseBody->getContents();
                if ($returnType !== 'string') {
                    $content = json_decode($content);
                }
            }

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

        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\TaxProviderUltraCart',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 401:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 410:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
                case 500:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\ultracart\v2\models\ErrorResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    break;
            }
            throw $e;
        }
    }

    /**
     * Operation updateTaxProviderUltraCartAsync
     *
     * Update the UltraCart tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderUltraCart $tax_provider_ultracart TaxProviderUltraCart object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderUltraCartAsync($tax_provider_ultracart)
    {
        return $this->updateTaxProviderUltraCartAsyncWithHttpInfo($tax_provider_ultracart)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation updateTaxProviderUltraCartAsyncWithHttpInfo
     *
     * Update the UltraCart tax provider
     *
     * @param  \ultracart\v2\models\TaxProviderUltraCart $tax_provider_ultracart TaxProviderUltraCart object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function updateTaxProviderUltraCartAsyncWithHttpInfo($tax_provider_ultracart)
    {
        $returnType = '\ultracart\v2\models\TaxProviderUltraCart';
        $request = $this->updateTaxProviderUltraCartRequest($tax_provider_ultracart);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    $responseBody = $response->getBody();
                    if ($returnType === '\SplFileObject') {
                        $content = $responseBody; //stream goes to serializer
                    } else {
                        $content = $responseBody->getContents();
                        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(),
                        $response->getBody()
                    );
                }
            );
    }

    /**
     * Create request for operation 'updateTaxProviderUltraCart'
     *
     * @param  \ultracart\v2\models\TaxProviderUltraCart $tax_provider_ultracart TaxProviderUltraCart object (required)
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function updateTaxProviderUltraCartRequest($tax_provider_ultracart)
    {
        // verify the required parameter 'tax_provider_ultracart' is set
        if ($tax_provider_ultracart === null || (is_array($tax_provider_ultracart) && count($tax_provider_ultracart) === 0)) {
            throw new \InvalidArgumentException(
                'Missing the required parameter $tax_provider_ultracart when calling updateTaxProviderUltraCart'
            );
        }

        $resourcePath = '/tax/providers/ultracart';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // body params
        $_tempBody = null;
        if (isset($tax_provider_ultracart)) {
            $_tempBody = $tax_provider_ultracart;
        }

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

        // for model (json/xml)
        if (isset($_tempBody)) {
            // $_tempBody is the method argument, if present
            $httpBody = $_tempBody;

            if($headers['Content-Type'] === 'application/json') {
                // \stdClass has no __toString(), so we should encode it manually
                if ($httpBody instanceof \stdClass) {
                    $httpBody = \GuzzleHttp\json_encode($httpBody);
                }
                // array has no __toString(), so we should encode it manually
                if(is_array($httpBody)) {
                    $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
                }
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $multipartContents[] = [
                        'name' => $formParamName,
                        'contents' => $formParamValue
                    ];
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

            } else {
                // for HTTP post (form)
                $httpBody = \GuzzleHttp\Psr7\build_query($formParams);
            }
        }

        // this endpoint requires OAuth (access token)
        if ($this->config->getAccessToken() !== null) {
            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
        }
        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('x-ultracart-simple-key');
        if ($apiKey !== null) {
            $headers['x-ultracart-simple-key'] = $apiKey;
        }

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

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

        $query = \GuzzleHttp\Psr7\build_query($queryParams);
        return new Request(
            'POST',
            $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

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

        return $options;
    }
}