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

/**
 * OmsorgCore.Api
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.14.0
 */

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

namespace OmsorgCoreClient\Api;

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

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

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

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

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

    /** @var string[] $contentTypes **/
    public const contentTypes = [
        'apiAuthChangePasswordPost' => [
            'application/json',
            'text/json',
            'application/*+json',
        ],
        'apiAuthForgotPasswordRequestPost' => [
            'application/json',
            'text/json',
            'application/*+json',
        ],
        'apiAuthForgotPasswordResetPost' => [
            'application/json',
            'text/json',
            'application/*+json',
        ],
        'apiAuthForgotPasswordVerifyPost' => [
            'application/json',
            'text/json',
            'application/*+json',
        ],
        'apiAuthLoginPost' => [
            'application/json',
            'text/json',
            'application/*+json',
        ],
        'apiAuthLogoutPost' => [
            'application/json',
            'text/json',
            'application/*+json',
        ],
        'apiAuthMeGet' => [
            'application/json',
        ],
        'apiAuthPasswordPolicyGet' => [
            'application/json',
        ],
        'apiAuthRefreshPost' => [
            'application/json',
            'text/json',
            'application/*+json',
        ],
    ];

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

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

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

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

    /**
     * Operation apiAuthChangePasswordPost
     *
     * @param  \OmsorgCoreClient\Model\ChangePasswordRequest|null $change_password_request change_password_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthChangePasswordPost'] to see the possible values for this operation
     *
     * @throws \OmsorgCoreClient\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return void
     */
    public function apiAuthChangePasswordPost($change_password_request = null, string $contentType = self::contentTypes['apiAuthChangePasswordPost'][0])
    {
        $this->apiAuthChangePasswordPostWithHttpInfo($change_password_request, $contentType);
    }

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

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

            $statusCode = $response->getStatusCode();


            return [null, $statusCode, $response->getHeaders()];
        } catch (ApiException $e) {
            switch ($e->getCode()) {
            }
        

            throw $e;
        }
    }

    /**
     * Operation apiAuthChangePasswordPostAsync
     *
     * @param  \OmsorgCoreClient\Model\ChangePasswordRequest|null $change_password_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthChangePasswordPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthChangePasswordPostAsync($change_password_request = null, string $contentType = self::contentTypes['apiAuthChangePasswordPost'][0])
    {
        return $this->apiAuthChangePasswordPostAsyncWithHttpInfo($change_password_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation apiAuthChangePasswordPostAsyncWithHttpInfo
     *
     * @param  \OmsorgCoreClient\Model\ChangePasswordRequest|null $change_password_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthChangePasswordPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthChangePasswordPostAsyncWithHttpInfo($change_password_request = null, string $contentType = self::contentTypes['apiAuthChangePasswordPost'][0])
    {
        $returnType = '';
        $request = $this->apiAuthChangePasswordPostRequest($change_password_request, $contentType);

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

    /**
     * Create request for operation 'apiAuthChangePasswordPost'
     *
     * @param  \OmsorgCoreClient\Model\ChangePasswordRequest|null $change_password_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthChangePasswordPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function apiAuthChangePasswordPostRequest($change_password_request = null, string $contentType = self::contentTypes['apiAuthChangePasswordPost'][0])
    {



        $resourcePath = '/api/auth/change-password';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;





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

        // for model (json/xml)
        if (isset($change_password_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($change_password_request));
            } else {
                $httpBody = $change_password_request;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

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

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

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

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

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

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

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

            $statusCode = $response->getStatusCode();


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

            

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

            return $this->handleResponseWithDataType(
                '\OmsorgCoreClient\Model\ForgotPasswordRequestResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OmsorgCoreClient\Model\ForgotPasswordRequestResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation apiAuthForgotPasswordRequestPostAsync
     *
     * @param  \OmsorgCoreClient\Model\ForgotPasswordRequestRequest|null $forgot_password_request_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthForgotPasswordRequestPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthForgotPasswordRequestPostAsync($forgot_password_request_request = null, string $contentType = self::contentTypes['apiAuthForgotPasswordRequestPost'][0])
    {
        return $this->apiAuthForgotPasswordRequestPostAsyncWithHttpInfo($forgot_password_request_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation apiAuthForgotPasswordRequestPostAsyncWithHttpInfo
     *
     * @param  \OmsorgCoreClient\Model\ForgotPasswordRequestRequest|null $forgot_password_request_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthForgotPasswordRequestPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthForgotPasswordRequestPostAsyncWithHttpInfo($forgot_password_request_request = null, string $contentType = self::contentTypes['apiAuthForgotPasswordRequestPost'][0])
    {
        $returnType = '\OmsorgCoreClient\Model\ForgotPasswordRequestResponse';
        $request = $this->apiAuthForgotPasswordRequestPostRequest($forgot_password_request_request, $contentType);

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

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

    /**
     * Create request for operation 'apiAuthForgotPasswordRequestPost'
     *
     * @param  \OmsorgCoreClient\Model\ForgotPasswordRequestRequest|null $forgot_password_request_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthForgotPasswordRequestPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function apiAuthForgotPasswordRequestPostRequest($forgot_password_request_request = null, string $contentType = self::contentTypes['apiAuthForgotPasswordRequestPost'][0])
    {



        $resourcePath = '/api/auth/forgot-password/request';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;





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

        // for model (json/xml)
        if (isset($forgot_password_request_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($forgot_password_request_request));
            } else {
                $httpBody = $forgot_password_request_request;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

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

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

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

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

    /**
     * Operation apiAuthForgotPasswordResetPost
     *
     * @param  \OmsorgCoreClient\Model\ForgotPasswordResetRequest|null $forgot_password_reset_request forgot_password_reset_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthForgotPasswordResetPost'] to see the possible values for this operation
     *
     * @throws \OmsorgCoreClient\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return void
     */
    public function apiAuthForgotPasswordResetPost($forgot_password_reset_request = null, string $contentType = self::contentTypes['apiAuthForgotPasswordResetPost'][0])
    {
        $this->apiAuthForgotPasswordResetPostWithHttpInfo($forgot_password_reset_request, $contentType);
    }

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

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

            $statusCode = $response->getStatusCode();


            return [null, $statusCode, $response->getHeaders()];
        } catch (ApiException $e) {
            switch ($e->getCode()) {
            }
        

            throw $e;
        }
    }

    /**
     * Operation apiAuthForgotPasswordResetPostAsync
     *
     * @param  \OmsorgCoreClient\Model\ForgotPasswordResetRequest|null $forgot_password_reset_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthForgotPasswordResetPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthForgotPasswordResetPostAsync($forgot_password_reset_request = null, string $contentType = self::contentTypes['apiAuthForgotPasswordResetPost'][0])
    {
        return $this->apiAuthForgotPasswordResetPostAsyncWithHttpInfo($forgot_password_reset_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation apiAuthForgotPasswordResetPostAsyncWithHttpInfo
     *
     * @param  \OmsorgCoreClient\Model\ForgotPasswordResetRequest|null $forgot_password_reset_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthForgotPasswordResetPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthForgotPasswordResetPostAsyncWithHttpInfo($forgot_password_reset_request = null, string $contentType = self::contentTypes['apiAuthForgotPasswordResetPost'][0])
    {
        $returnType = '';
        $request = $this->apiAuthForgotPasswordResetPostRequest($forgot_password_reset_request, $contentType);

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

    /**
     * Create request for operation 'apiAuthForgotPasswordResetPost'
     *
     * @param  \OmsorgCoreClient\Model\ForgotPasswordResetRequest|null $forgot_password_reset_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthForgotPasswordResetPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function apiAuthForgotPasswordResetPostRequest($forgot_password_reset_request = null, string $contentType = self::contentTypes['apiAuthForgotPasswordResetPost'][0])
    {



        $resourcePath = '/api/auth/forgot-password/reset';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;





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

        // for model (json/xml)
        if (isset($forgot_password_reset_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($forgot_password_reset_request));
            } else {
                $httpBody = $forgot_password_reset_request;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

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

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

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

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

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

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

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

            $statusCode = $response->getStatusCode();


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

            

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

            return $this->handleResponseWithDataType(
                '\OmsorgCoreClient\Model\ForgotPasswordVerifyResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OmsorgCoreClient\Model\ForgotPasswordVerifyResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation apiAuthForgotPasswordVerifyPostAsync
     *
     * @param  \OmsorgCoreClient\Model\ForgotPasswordVerifyRequest|null $forgot_password_verify_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthForgotPasswordVerifyPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthForgotPasswordVerifyPostAsync($forgot_password_verify_request = null, string $contentType = self::contentTypes['apiAuthForgotPasswordVerifyPost'][0])
    {
        return $this->apiAuthForgotPasswordVerifyPostAsyncWithHttpInfo($forgot_password_verify_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation apiAuthForgotPasswordVerifyPostAsyncWithHttpInfo
     *
     * @param  \OmsorgCoreClient\Model\ForgotPasswordVerifyRequest|null $forgot_password_verify_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthForgotPasswordVerifyPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthForgotPasswordVerifyPostAsyncWithHttpInfo($forgot_password_verify_request = null, string $contentType = self::contentTypes['apiAuthForgotPasswordVerifyPost'][0])
    {
        $returnType = '\OmsorgCoreClient\Model\ForgotPasswordVerifyResponse';
        $request = $this->apiAuthForgotPasswordVerifyPostRequest($forgot_password_verify_request, $contentType);

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

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

    /**
     * Create request for operation 'apiAuthForgotPasswordVerifyPost'
     *
     * @param  \OmsorgCoreClient\Model\ForgotPasswordVerifyRequest|null $forgot_password_verify_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthForgotPasswordVerifyPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function apiAuthForgotPasswordVerifyPostRequest($forgot_password_verify_request = null, string $contentType = self::contentTypes['apiAuthForgotPasswordVerifyPost'][0])
    {



        $resourcePath = '/api/auth/forgot-password/verify';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;





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

        // for model (json/xml)
        if (isset($forgot_password_verify_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($forgot_password_verify_request));
            } else {
                $httpBody = $forgot_password_verify_request;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

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

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

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

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

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

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

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

            $statusCode = $response->getStatusCode();


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

            

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

            return $this->handleResponseWithDataType(
                '\OmsorgCoreClient\Model\LoginResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OmsorgCoreClient\Model\LoginResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation apiAuthLoginPostAsync
     *
     * @param  \OmsorgCoreClient\Model\LoginRequest|null $login_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthLoginPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthLoginPostAsync($login_request = null, string $contentType = self::contentTypes['apiAuthLoginPost'][0])
    {
        return $this->apiAuthLoginPostAsyncWithHttpInfo($login_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation apiAuthLoginPostAsyncWithHttpInfo
     *
     * @param  \OmsorgCoreClient\Model\LoginRequest|null $login_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthLoginPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthLoginPostAsyncWithHttpInfo($login_request = null, string $contentType = self::contentTypes['apiAuthLoginPost'][0])
    {
        $returnType = '\OmsorgCoreClient\Model\LoginResponse';
        $request = $this->apiAuthLoginPostRequest($login_request, $contentType);

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

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

    /**
     * Create request for operation 'apiAuthLoginPost'
     *
     * @param  \OmsorgCoreClient\Model\LoginRequest|null $login_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthLoginPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function apiAuthLoginPostRequest($login_request = null, string $contentType = self::contentTypes['apiAuthLoginPost'][0])
    {



        $resourcePath = '/api/auth/login';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;





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

        // for model (json/xml)
        if (isset($login_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($login_request));
            } else {
                $httpBody = $login_request;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

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

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

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

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

    /**
     * Operation apiAuthLogoutPost
     *
     * @param  \OmsorgCoreClient\Model\LogoutRequest|null $logout_request logout_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthLogoutPost'] to see the possible values for this operation
     *
     * @throws \OmsorgCoreClient\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return void
     */
    public function apiAuthLogoutPost($logout_request = null, string $contentType = self::contentTypes['apiAuthLogoutPost'][0])
    {
        $this->apiAuthLogoutPostWithHttpInfo($logout_request, $contentType);
    }

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

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

            $statusCode = $response->getStatusCode();


            return [null, $statusCode, $response->getHeaders()];
        } catch (ApiException $e) {
            switch ($e->getCode()) {
            }
        

            throw $e;
        }
    }

    /**
     * Operation apiAuthLogoutPostAsync
     *
     * @param  \OmsorgCoreClient\Model\LogoutRequest|null $logout_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthLogoutPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthLogoutPostAsync($logout_request = null, string $contentType = self::contentTypes['apiAuthLogoutPost'][0])
    {
        return $this->apiAuthLogoutPostAsyncWithHttpInfo($logout_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation apiAuthLogoutPostAsyncWithHttpInfo
     *
     * @param  \OmsorgCoreClient\Model\LogoutRequest|null $logout_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthLogoutPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthLogoutPostAsyncWithHttpInfo($logout_request = null, string $contentType = self::contentTypes['apiAuthLogoutPost'][0])
    {
        $returnType = '';
        $request = $this->apiAuthLogoutPostRequest($logout_request, $contentType);

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

    /**
     * Create request for operation 'apiAuthLogoutPost'
     *
     * @param  \OmsorgCoreClient\Model\LogoutRequest|null $logout_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthLogoutPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function apiAuthLogoutPostRequest($logout_request = null, string $contentType = self::contentTypes['apiAuthLogoutPost'][0])
    {



        $resourcePath = '/api/auth/logout';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;





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

        // for model (json/xml)
        if (isset($logout_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($logout_request));
            } else {
                $httpBody = $logout_request;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

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

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

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

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

    /**
     * Operation apiAuthMeGet
     *
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthMeGet'] to see the possible values for this operation
     *
     * @throws \OmsorgCoreClient\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \OmsorgCoreClient\Model\MeResponse
     */
    public function apiAuthMeGet(string $contentType = self::contentTypes['apiAuthMeGet'][0])
    {
        list($response) = $this->apiAuthMeGetWithHttpInfo($contentType);
        return $response;
    }

    /**
     * Operation apiAuthMeGetWithHttpInfo
     *
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthMeGet'] to see the possible values for this operation
     *
     * @throws \OmsorgCoreClient\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \OmsorgCoreClient\Model\MeResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function apiAuthMeGetWithHttpInfo(string $contentType = self::contentTypes['apiAuthMeGet'][0])
    {
        $request = $this->apiAuthMeGetRequest($contentType);

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

            $statusCode = $response->getStatusCode();


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

            

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

            return $this->handleResponseWithDataType(
                '\OmsorgCoreClient\Model\MeResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OmsorgCoreClient\Model\MeResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation apiAuthMeGetAsync
     *
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthMeGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthMeGetAsync(string $contentType = self::contentTypes['apiAuthMeGet'][0])
    {
        return $this->apiAuthMeGetAsyncWithHttpInfo($contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation apiAuthMeGetAsyncWithHttpInfo
     *
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthMeGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthMeGetAsyncWithHttpInfo(string $contentType = self::contentTypes['apiAuthMeGet'][0])
    {
        $returnType = '\OmsorgCoreClient\Model\MeResponse';
        $request = $this->apiAuthMeGetRequest($contentType);

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

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

    /**
     * Create request for operation 'apiAuthMeGet'
     *
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthMeGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function apiAuthMeGetRequest(string $contentType = self::contentTypes['apiAuthMeGet'][0])
    {


        $resourcePath = '/api/auth/me';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;





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

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

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

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

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

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

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

    /**
     * Operation apiAuthPasswordPolicyGet
     *
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthPasswordPolicyGet'] to see the possible values for this operation
     *
     * @throws \OmsorgCoreClient\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \OmsorgCoreClient\Model\PasswordPolicyResponse
     */
    public function apiAuthPasswordPolicyGet(string $contentType = self::contentTypes['apiAuthPasswordPolicyGet'][0])
    {
        list($response) = $this->apiAuthPasswordPolicyGetWithHttpInfo($contentType);
        return $response;
    }

    /**
     * Operation apiAuthPasswordPolicyGetWithHttpInfo
     *
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthPasswordPolicyGet'] to see the possible values for this operation
     *
     * @throws \OmsorgCoreClient\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \OmsorgCoreClient\Model\PasswordPolicyResponse, HTTP status code, HTTP response headers (array of strings)
     */
    public function apiAuthPasswordPolicyGetWithHttpInfo(string $contentType = self::contentTypes['apiAuthPasswordPolicyGet'][0])
    {
        $request = $this->apiAuthPasswordPolicyGetRequest($contentType);

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

            $statusCode = $response->getStatusCode();


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

            

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

            return $this->handleResponseWithDataType(
                '\OmsorgCoreClient\Model\PasswordPolicyResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OmsorgCoreClient\Model\PasswordPolicyResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation apiAuthPasswordPolicyGetAsync
     *
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthPasswordPolicyGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthPasswordPolicyGetAsync(string $contentType = self::contentTypes['apiAuthPasswordPolicyGet'][0])
    {
        return $this->apiAuthPasswordPolicyGetAsyncWithHttpInfo($contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation apiAuthPasswordPolicyGetAsyncWithHttpInfo
     *
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthPasswordPolicyGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthPasswordPolicyGetAsyncWithHttpInfo(string $contentType = self::contentTypes['apiAuthPasswordPolicyGet'][0])
    {
        $returnType = '\OmsorgCoreClient\Model\PasswordPolicyResponse';
        $request = $this->apiAuthPasswordPolicyGetRequest($contentType);

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

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

    /**
     * Create request for operation 'apiAuthPasswordPolicyGet'
     *
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthPasswordPolicyGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function apiAuthPasswordPolicyGetRequest(string $contentType = self::contentTypes['apiAuthPasswordPolicyGet'][0])
    {


        $resourcePath = '/api/auth/password-policy';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;





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

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

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

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

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

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

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

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

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

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

            $statusCode = $response->getStatusCode();


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

            

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

            return $this->handleResponseWithDataType(
                '\OmsorgCoreClient\Model\LoginResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OmsorgCoreClient\Model\LoginResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation apiAuthRefreshPostAsync
     *
     * @param  \OmsorgCoreClient\Model\RefreshRequest|null $refresh_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthRefreshPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthRefreshPostAsync($refresh_request = null, string $contentType = self::contentTypes['apiAuthRefreshPost'][0])
    {
        return $this->apiAuthRefreshPostAsyncWithHttpInfo($refresh_request, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation apiAuthRefreshPostAsyncWithHttpInfo
     *
     * @param  \OmsorgCoreClient\Model\RefreshRequest|null $refresh_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthRefreshPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function apiAuthRefreshPostAsyncWithHttpInfo($refresh_request = null, string $contentType = self::contentTypes['apiAuthRefreshPost'][0])
    {
        $returnType = '\OmsorgCoreClient\Model\LoginResponse';
        $request = $this->apiAuthRefreshPostRequest($refresh_request, $contentType);

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

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

    /**
     * Create request for operation 'apiAuthRefreshPost'
     *
     * @param  \OmsorgCoreClient\Model\RefreshRequest|null $refresh_request (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['apiAuthRefreshPost'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function apiAuthRefreshPostRequest($refresh_request = null, string $contentType = self::contentTypes['apiAuthRefreshPost'][0])
    {



        $resourcePath = '/api/auth/refresh';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;





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

        // for model (json/xml)
        if (isset($refresh_request)) {
            if (stripos($headers['Content-Type'], 'application/json') !== false) {
                # if Content-Type contains "application/json", json_encode the body
                $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($refresh_request));
            } else {
                $httpBody = $refresh_request;
            }
        } elseif (count($formParams) > 0) {
            if ($multipart) {
                $multipartContents = [];
                foreach ($formParams as $formParamName => $formParamValue) {
                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
                    foreach ($formParamValueItems as $formParamValueItem) {
                        $multipartContents[] = [
                            'name' => $formParamName,
                            'contents' => $formParamValueItem
                        ];
                    }
                }
                // for HTTP post (form)
                $httpBody = new MultipartStream($multipartContents);

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

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

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

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

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

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

        return $options;
    }

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

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

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

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