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

/**
 * FinFeedAPI Stock REST API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: v1
 * Contact: support@apibricks.io
 * 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 OpenAPI\Client\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 OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\FormDataProcessor;
use OpenAPI\Client\HeaderSelector;
use OpenAPI\Client\ObjectSerializer;

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

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

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

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

    /** @var string[] $contentTypes **/
    public const contentTypes = [
        'v1NativeIexAdminMessagesSymbolGet' => [
            'application/json',
        ],
        'v1NativeIexAdminSystemEventGet' => [
            'application/json',
        ],
        'v1NativeIexLevel1QuoteSymbolGet' => [
            'application/json',
        ],
        'v1NativeIexLevel2PriceLevelUpdateSymbolGet' => [
            'application/json',
        ],
        'v1NativeIexLevel3OrderBookSymbolGet' => [
            'application/json',
        ],
        'v1NativeIexTradeSymbolGet' => [
            '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 v1NativeIexAdminMessagesSymbolGet
     *
     * Get Admin Messages
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexAdminMessagesSymbolGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \OpenAPI\Client\Model\AdminAdminMessageModel[]
     */
    public function v1NativeIexAdminMessagesSymbolGet($symbol, $date, string $contentType = self::contentTypes['v1NativeIexAdminMessagesSymbolGet'][0])
    {
        list($response) = $this->v1NativeIexAdminMessagesSymbolGetWithHttpInfo($symbol, $date, $contentType);
        return $response;
    }

    /**
     * Operation v1NativeIexAdminMessagesSymbolGetWithHttpInfo
     *
     * Get Admin Messages
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexAdminMessagesSymbolGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \OpenAPI\Client\Model\AdminAdminMessageModel[], HTTP status code, HTTP response headers (array of strings)
     */
    public function v1NativeIexAdminMessagesSymbolGetWithHttpInfo($symbol, $date, string $contentType = self::contentTypes['v1NativeIexAdminMessagesSymbolGet'][0])
    {
        $request = $this->v1NativeIexAdminMessagesSymbolGetRequest($symbol, $date, $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(
                        '\OpenAPI\Client\Model\AdminAdminMessageModel[]',
                        $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(
                '\OpenAPI\Client\Model\AdminAdminMessageModel[]',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OpenAPI\Client\Model\AdminAdminMessageModel[]',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation v1NativeIexAdminMessagesSymbolGetAsync
     *
     * Get Admin Messages
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexAdminMessagesSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexAdminMessagesSymbolGetAsync($symbol, $date, string $contentType = self::contentTypes['v1NativeIexAdminMessagesSymbolGet'][0])
    {
        return $this->v1NativeIexAdminMessagesSymbolGetAsyncWithHttpInfo($symbol, $date, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation v1NativeIexAdminMessagesSymbolGetAsyncWithHttpInfo
     *
     * Get Admin Messages
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexAdminMessagesSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexAdminMessagesSymbolGetAsyncWithHttpInfo($symbol, $date, string $contentType = self::contentTypes['v1NativeIexAdminMessagesSymbolGet'][0])
    {
        $returnType = '\OpenAPI\Client\Model\AdminAdminMessageModel[]';
        $request = $this->v1NativeIexAdminMessagesSymbolGetRequest($symbol, $date, $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 'v1NativeIexAdminMessagesSymbolGet'
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexAdminMessagesSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function v1NativeIexAdminMessagesSymbolGetRequest($symbol, $date, string $contentType = self::contentTypes['v1NativeIexAdminMessagesSymbolGet'][0])
    {

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

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


        $resourcePath = '/v1/native/iex/admin/messages/{symbol}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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


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


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

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

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

        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('Authorization');
        if ($apiKey !== null) {
            $headers['Authorization'] = $apiKey;
        }
        // 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 v1NativeIexAdminSystemEventGet
     *
     * Get System Events
     *
     * @param  \DateTime $date Date in format YYYY-MM-DD (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexAdminSystemEventGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \OpenAPI\Client\Model\AdminSystemEventModel[]
     */
    public function v1NativeIexAdminSystemEventGet($date, string $contentType = self::contentTypes['v1NativeIexAdminSystemEventGet'][0])
    {
        list($response) = $this->v1NativeIexAdminSystemEventGetWithHttpInfo($date, $contentType);
        return $response;
    }

    /**
     * Operation v1NativeIexAdminSystemEventGetWithHttpInfo
     *
     * Get System Events
     *
     * @param  \DateTime $date Date in format YYYY-MM-DD (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexAdminSystemEventGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \OpenAPI\Client\Model\AdminSystemEventModel[], HTTP status code, HTTP response headers (array of strings)
     */
    public function v1NativeIexAdminSystemEventGetWithHttpInfo($date, string $contentType = self::contentTypes['v1NativeIexAdminSystemEventGet'][0])
    {
        $request = $this->v1NativeIexAdminSystemEventGetRequest($date, $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(
                        '\OpenAPI\Client\Model\AdminSystemEventModel[]',
                        $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(
                '\OpenAPI\Client\Model\AdminSystemEventModel[]',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OpenAPI\Client\Model\AdminSystemEventModel[]',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation v1NativeIexAdminSystemEventGetAsync
     *
     * Get System Events
     *
     * @param  \DateTime $date Date in format YYYY-MM-DD (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexAdminSystemEventGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexAdminSystemEventGetAsync($date, string $contentType = self::contentTypes['v1NativeIexAdminSystemEventGet'][0])
    {
        return $this->v1NativeIexAdminSystemEventGetAsyncWithHttpInfo($date, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation v1NativeIexAdminSystemEventGetAsyncWithHttpInfo
     *
     * Get System Events
     *
     * @param  \DateTime $date Date in format YYYY-MM-DD (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexAdminSystemEventGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexAdminSystemEventGetAsyncWithHttpInfo($date, string $contentType = self::contentTypes['v1NativeIexAdminSystemEventGet'][0])
    {
        $returnType = '\OpenAPI\Client\Model\AdminSystemEventModel[]';
        $request = $this->v1NativeIexAdminSystemEventGetRequest($date, $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 'v1NativeIexAdminSystemEventGet'
     *
     * @param  \DateTime $date Date in format YYYY-MM-DD (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexAdminSystemEventGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function v1NativeIexAdminSystemEventGetRequest($date, string $contentType = self::contentTypes['v1NativeIexAdminSystemEventGet'][0])
    {

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


        $resourcePath = '/v1/native/iex/admin/system-event';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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




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

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

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

        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('Authorization');
        if ($apiKey !== null) {
            $headers['Authorization'] = $apiKey;
        }
        // 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 v1NativeIexLevel1QuoteSymbolGet
     *
     * Get Level-1 Quotes
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel1QuoteSymbolGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \OpenAPI\Client\Model\Level1QuoteUpdateModel[]
     */
    public function v1NativeIexLevel1QuoteSymbolGet($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel1QuoteSymbolGet'][0])
    {
        list($response) = $this->v1NativeIexLevel1QuoteSymbolGetWithHttpInfo($symbol, $date, $contentType);
        return $response;
    }

    /**
     * Operation v1NativeIexLevel1QuoteSymbolGetWithHttpInfo
     *
     * Get Level-1 Quotes
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel1QuoteSymbolGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \OpenAPI\Client\Model\Level1QuoteUpdateModel[], HTTP status code, HTTP response headers (array of strings)
     */
    public function v1NativeIexLevel1QuoteSymbolGetWithHttpInfo($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel1QuoteSymbolGet'][0])
    {
        $request = $this->v1NativeIexLevel1QuoteSymbolGetRequest($symbol, $date, $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(
                        '\OpenAPI\Client\Model\Level1QuoteUpdateModel[]',
                        $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(
                '\OpenAPI\Client\Model\Level1QuoteUpdateModel[]',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OpenAPI\Client\Model\Level1QuoteUpdateModel[]',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation v1NativeIexLevel1QuoteSymbolGetAsync
     *
     * Get Level-1 Quotes
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel1QuoteSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexLevel1QuoteSymbolGetAsync($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel1QuoteSymbolGet'][0])
    {
        return $this->v1NativeIexLevel1QuoteSymbolGetAsyncWithHttpInfo($symbol, $date, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation v1NativeIexLevel1QuoteSymbolGetAsyncWithHttpInfo
     *
     * Get Level-1 Quotes
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel1QuoteSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexLevel1QuoteSymbolGetAsyncWithHttpInfo($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel1QuoteSymbolGet'][0])
    {
        $returnType = '\OpenAPI\Client\Model\Level1QuoteUpdateModel[]';
        $request = $this->v1NativeIexLevel1QuoteSymbolGetRequest($symbol, $date, $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 'v1NativeIexLevel1QuoteSymbolGet'
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel1QuoteSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function v1NativeIexLevel1QuoteSymbolGetRequest($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel1QuoteSymbolGet'][0])
    {

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

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


        $resourcePath = '/v1/native/iex/level1-quote/{symbol}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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


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


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

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

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

        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('Authorization');
        if ($apiKey !== null) {
            $headers['Authorization'] = $apiKey;
        }
        // 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 v1NativeIexLevel2PriceLevelUpdateSymbolGet
     *
     * Get Level-2 Price Level Book
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel2PriceLevelUpdateSymbolGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \OpenAPI\Client\Model\Level2PriceLevelUpdateModel[]
     */
    public function v1NativeIexLevel2PriceLevelUpdateSymbolGet($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel2PriceLevelUpdateSymbolGet'][0])
    {
        list($response) = $this->v1NativeIexLevel2PriceLevelUpdateSymbolGetWithHttpInfo($symbol, $date, $contentType);
        return $response;
    }

    /**
     * Operation v1NativeIexLevel2PriceLevelUpdateSymbolGetWithHttpInfo
     *
     * Get Level-2 Price Level Book
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel2PriceLevelUpdateSymbolGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \OpenAPI\Client\Model\Level2PriceLevelUpdateModel[], HTTP status code, HTTP response headers (array of strings)
     */
    public function v1NativeIexLevel2PriceLevelUpdateSymbolGetWithHttpInfo($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel2PriceLevelUpdateSymbolGet'][0])
    {
        $request = $this->v1NativeIexLevel2PriceLevelUpdateSymbolGetRequest($symbol, $date, $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(
                        '\OpenAPI\Client\Model\Level2PriceLevelUpdateModel[]',
                        $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(
                '\OpenAPI\Client\Model\Level2PriceLevelUpdateModel[]',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OpenAPI\Client\Model\Level2PriceLevelUpdateModel[]',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation v1NativeIexLevel2PriceLevelUpdateSymbolGetAsync
     *
     * Get Level-2 Price Level Book
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel2PriceLevelUpdateSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexLevel2PriceLevelUpdateSymbolGetAsync($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel2PriceLevelUpdateSymbolGet'][0])
    {
        return $this->v1NativeIexLevel2PriceLevelUpdateSymbolGetAsyncWithHttpInfo($symbol, $date, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation v1NativeIexLevel2PriceLevelUpdateSymbolGetAsyncWithHttpInfo
     *
     * Get Level-2 Price Level Book
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel2PriceLevelUpdateSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexLevel2PriceLevelUpdateSymbolGetAsyncWithHttpInfo($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel2PriceLevelUpdateSymbolGet'][0])
    {
        $returnType = '\OpenAPI\Client\Model\Level2PriceLevelUpdateModel[]';
        $request = $this->v1NativeIexLevel2PriceLevelUpdateSymbolGetRequest($symbol, $date, $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 'v1NativeIexLevel2PriceLevelUpdateSymbolGet'
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel2PriceLevelUpdateSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function v1NativeIexLevel2PriceLevelUpdateSymbolGetRequest($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel2PriceLevelUpdateSymbolGet'][0])
    {

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

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


        $resourcePath = '/v1/native/iex/level2-price-level-update/{symbol}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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


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


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

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

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

        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('Authorization');
        if ($apiKey !== null) {
            $headers['Authorization'] = $apiKey;
        }
        // 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 v1NativeIexLevel3OrderBookSymbolGet
     *
     * Get Level-3 Order Book
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel3OrderBookSymbolGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \OpenAPI\Client\Model\Level3OrderBookModel[]
     */
    public function v1NativeIexLevel3OrderBookSymbolGet($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel3OrderBookSymbolGet'][0])
    {
        list($response) = $this->v1NativeIexLevel3OrderBookSymbolGetWithHttpInfo($symbol, $date, $contentType);
        return $response;
    }

    /**
     * Operation v1NativeIexLevel3OrderBookSymbolGetWithHttpInfo
     *
     * Get Level-3 Order Book
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel3OrderBookSymbolGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \OpenAPI\Client\Model\Level3OrderBookModel[], HTTP status code, HTTP response headers (array of strings)
     */
    public function v1NativeIexLevel3OrderBookSymbolGetWithHttpInfo($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel3OrderBookSymbolGet'][0])
    {
        $request = $this->v1NativeIexLevel3OrderBookSymbolGetRequest($symbol, $date, $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(
                        '\OpenAPI\Client\Model\Level3OrderBookModel[]',
                        $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(
                '\OpenAPI\Client\Model\Level3OrderBookModel[]',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OpenAPI\Client\Model\Level3OrderBookModel[]',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation v1NativeIexLevel3OrderBookSymbolGetAsync
     *
     * Get Level-3 Order Book
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel3OrderBookSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexLevel3OrderBookSymbolGetAsync($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel3OrderBookSymbolGet'][0])
    {
        return $this->v1NativeIexLevel3OrderBookSymbolGetAsyncWithHttpInfo($symbol, $date, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation v1NativeIexLevel3OrderBookSymbolGetAsyncWithHttpInfo
     *
     * Get Level-3 Order Book
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel3OrderBookSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexLevel3OrderBookSymbolGetAsyncWithHttpInfo($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel3OrderBookSymbolGet'][0])
    {
        $returnType = '\OpenAPI\Client\Model\Level3OrderBookModel[]';
        $request = $this->v1NativeIexLevel3OrderBookSymbolGetRequest($symbol, $date, $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 'v1NativeIexLevel3OrderBookSymbolGet'
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexLevel3OrderBookSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function v1NativeIexLevel3OrderBookSymbolGetRequest($symbol, $date, string $contentType = self::contentTypes['v1NativeIexLevel3OrderBookSymbolGet'][0])
    {

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

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


        $resourcePath = '/v1/native/iex/level3-order-book/{symbol}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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


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


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

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

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

        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('Authorization');
        if ($apiKey !== null) {
            $headers['Authorization'] = $apiKey;
        }
        // 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 v1NativeIexTradeSymbolGet
     *
     * Get Trades
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexTradeSymbolGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return \OpenAPI\Client\Model\TradeTradeModel[]
     */
    public function v1NativeIexTradeSymbolGet($symbol, $date, string $contentType = self::contentTypes['v1NativeIexTradeSymbolGet'][0])
    {
        list($response) = $this->v1NativeIexTradeSymbolGetWithHttpInfo($symbol, $date, $contentType);
        return $response;
    }

    /**
     * Operation v1NativeIexTradeSymbolGetWithHttpInfo
     *
     * Get Trades
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexTradeSymbolGet'] to see the possible values for this operation
     *
     * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     * @return array of \OpenAPI\Client\Model\TradeTradeModel[], HTTP status code, HTTP response headers (array of strings)
     */
    public function v1NativeIexTradeSymbolGetWithHttpInfo($symbol, $date, string $contentType = self::contentTypes['v1NativeIexTradeSymbolGet'][0])
    {
        $request = $this->v1NativeIexTradeSymbolGetRequest($symbol, $date, $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(
                        '\OpenAPI\Client\Model\TradeTradeModel[]',
                        $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(
                '\OpenAPI\Client\Model\TradeTradeModel[]',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\OpenAPI\Client\Model\TradeTradeModel[]',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);
                    throw $e;
            }
        

            throw $e;
        }
    }

    /**
     * Operation v1NativeIexTradeSymbolGetAsync
     *
     * Get Trades
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexTradeSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexTradeSymbolGetAsync($symbol, $date, string $contentType = self::contentTypes['v1NativeIexTradeSymbolGet'][0])
    {
        return $this->v1NativeIexTradeSymbolGetAsyncWithHttpInfo($symbol, $date, $contentType)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }

    /**
     * Operation v1NativeIexTradeSymbolGetAsyncWithHttpInfo
     *
     * Get Trades
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexTradeSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Promise\PromiseInterface
     */
    public function v1NativeIexTradeSymbolGetAsyncWithHttpInfo($symbol, $date, string $contentType = self::contentTypes['v1NativeIexTradeSymbolGet'][0])
    {
        $returnType = '\OpenAPI\Client\Model\TradeTradeModel[]';
        $request = $this->v1NativeIexTradeSymbolGetRequest($symbol, $date, $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 'v1NativeIexTradeSymbolGet'
     *
     * @param  string $symbol The symbol identifier (required)
     * @param  \DateTime $date Optional date in format YYYY-MM-DD (defaults to latest available data) (required)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['v1NativeIexTradeSymbolGet'] to see the possible values for this operation
     *
     * @throws \InvalidArgumentException
     * @return \GuzzleHttp\Psr7\Request
     */
    public function v1NativeIexTradeSymbolGetRequest($symbol, $date, string $contentType = self::contentTypes['v1NativeIexTradeSymbolGet'][0])
    {

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

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


        $resourcePath = '/v1/native/iex/trade/{symbol}';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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


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


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

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

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

        // this endpoint requires API key authentication
        $apiKey = $this->config->getApiKeyWithPrefix('Authorization');
        if ($apiKey !== null) {
            $headers['Authorization'] = $apiKey;
        }
        // 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
        );
    }

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