<?php

/**
 * TravelRuleApi
 * PHP version 8.1.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */

/**
 * Binance Wallet REST API.
 *
 * OpenAPI Specification for the Binance Wallet REST API
 *
 * The version of the OpenAPI document: 1.0.0
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.12.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 Binance\Client\Wallet\Api;

use Binance\Client\Wallet\Model\BrokerWithdrawRequest;
use Binance\Client\Wallet\Model\BrokerWithdrawResponse;
use Binance\Client\Wallet\Model\DepositHistoryTravelRuleResponse;
use Binance\Client\Wallet\Model\FetchAddressVerificationListResponse;
use Binance\Client\Wallet\Model\OnboardedVaspListResponse;
use Binance\Client\Wallet\Model\SubmitDepositQuestionnaireRequest;
use Binance\Client\Wallet\Model\SubmitDepositQuestionnaireResponse;
use Binance\Client\Wallet\Model\SubmitDepositQuestionnaireTravelRuleRequest;
use Binance\Client\Wallet\Model\SubmitDepositQuestionnaireTravelRuleResponse;
use Binance\Client\Wallet\Model\WithdrawHistoryV1Response;
use Binance\Client\Wallet\Model\WithdrawHistoryV2Response;
use Binance\Client\Wallet\Model\WithdrawTravelRuleRequest;
use Binance\Client\Wallet\Model\WithdrawTravelRuleResponse;
use Binance\Common\ApiException;
use Binance\Common\Auth\SignerFactory;
use Binance\Common\Auth\SignerInterface;
use Binance\Common\CommonUtils;
use Binance\Common\Configuration\ClientConfiguration;
use Binance\Common\Dtos\ApiResponse;
use Binance\Common\HeaderSelector;
use Binance\Common\HttpClient;
use Binance\Common\ObjectSerializer;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Utils;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

/**
 * TravelRuleApi Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */
class TravelRuleApi
{
    /** @var string[] */
    public const contentTypes = [
        'brokerWithdraw' => ['application/x-www-form-urlencoded'],
        'depositHistoryTravelRule' => ['application/x-www-form-urlencoded'],
        'fetchAddressVerificationList' => ['application/x-www-form-urlencoded'],
        'onboardedVaspList' => ['application/x-www-form-urlencoded'],
        'submitDepositQuestionnaire' => ['application/x-www-form-urlencoded'],
        'submitDepositQuestionnaireTravelRule' => ['application/x-www-form-urlencoded'],
        'withdrawHistoryV1' => ['application/x-www-form-urlencoded'],
        'withdrawHistoryV2' => ['application/x-www-form-urlencoded'],
        'withdrawTravelRule' => ['application/x-www-form-urlencoded'],
    ];
    private const HAS_TIME_UNIT = false;

    /**
     * @var ClientInterface
     */
    protected $client;

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

    /**
     * Summary of clientConfig.
     *
     * @var ClientConfiguration
     */
    protected $clientConfig;

    /**
     * Summary of signer.
     *
     * @var SignerInterface
     */
    protected $signer;

    /**
     * userAgent for HTTP requests.
     *
     * @var string
     */
    private $userAgent;

    public function __construct(
        ?ClientConfiguration $clientConfig = new ClientConfiguration(),
        ?ClientInterface $client = null,
        ?HeaderSelector $selector = null,
    ) {
        $this->clientConfig = $clientConfig;
        $this->client = $client ?: new HttpClient($clientConfig);
        $this->headerSelector = $selector ?: new HeaderSelector();
        if (!empty($clientConfig->getSignatureConfiguration())) {
            $this->signer = SignerFactory::getSigner($clientConfig->getSignatureConfiguration());
        }
        $this->userAgent = CommonUtils::getUserAgent('wallet');
    }

    /**
     * Operation brokerWithdraw.
     *
     * Broker Withdraw (for brokers of local entities that require travel rule) (USER_DATA)
     *
     * @param BrokerWithdrawRequest $brokerWithdrawRequest brokerWithdrawRequest (required)
     *
     * @return ApiResponse<BrokerWithdrawResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function brokerWithdraw($brokerWithdrawRequest): ApiResponse
    {
        return $this->brokerWithdrawWithHttpInfo($brokerWithdrawRequest);
    }

    /**
     * Operation brokerWithdrawWithHttpInfo.
     *
     * Broker Withdraw (for brokers of local entities that require travel rule) (USER_DATA)
     *
     * @param BrokerWithdrawRequest $brokerWithdrawRequest (required)
     *
     * @return ApiResponse<BrokerWithdrawResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function brokerWithdrawWithHttpInfo($brokerWithdrawRequest): ApiResponse
    {
        $request = $this->brokerWithdrawRequest($brokerWithdrawRequest);

        try {
            try {
                $response = $this->client->send($request, []);
            } 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(
                        '\Binance\Client\Wallet\Model\BrokerWithdrawResponse',
                        $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(
                '\Binance\Client\Wallet\Model\BrokerWithdrawResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\BrokerWithdrawResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'brokerWithdraw'.
     *
     * @param BrokerWithdrawRequest $brokerWithdrawRequest (required)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function brokerWithdrawRequest($brokerWithdrawRequest)
    {
        $contentType = self::contentTypes['brokerWithdraw'][0];

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

        $resourcePath = '/sapi/v1/localentity/broker/withdraw/apply';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        $getters = $brokerWithdrawRequest::getters();
        $formParams = [];
        foreach ($getters as $property => $getter) {
            $value = $brokerWithdrawRequest->{$getter}();
            if (!empty($value)) {
                $formParams[$property] = $brokerWithdrawRequest->{$getter}();
            }
        }

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

        $defaultHeaders = [];
        $defaultHeaders['User-Agent'] = $this->userAgent;

        if (self::HAS_TIME_UNIT && !empty($this->clientConfig->getTimeUnit())) {
            $defaultHeaders['X-MBX-TIME-UNIT'] = $this->clientConfig->getTimeUnit();
        }

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

        $operationHost = $this->clientConfig->getUrl();

        $queryParams['timestamp'] = $this->getTimestamp();
        $query = ObjectSerializer::buildQuery($queryParams);
        $queryParams['signature'] = $this->signer->sign($query.$httpBody);
        $headers['X-MBX-APIKEY'] = $this->clientConfig->getSignatureConfiguration()->getApiKey();
        $query = ObjectSerializer::buildQuery($queryParams);

        return new Request(
            'POST',
            $operationHost.$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation depositHistoryTravelRule.
     *
     * Deposit History (for local entities that required travel rule) (supporting network) (USER_DATA)
     *
     * @param null|string $trId                 Comma(,) separated list of travel rule record Ids. (optional)
     * @param null|string $txId                 txId (optional)
     * @param null|string $tranId               Comma(,) separated list of wallet tran Ids. (optional)
     * @param null|string $network              network (optional)
     * @param null|string $coin                 coin (optional)
     * @param null|int    $travelRuleStatus     0:Completed,1:Pending,2:Failed (optional)
     * @param null|bool   $pendingQuestionnaire true: Only return records that pending deposit questionnaire. false/not provided: return all records. (optional)
     * @param null|int    $startTime            startTime (optional)
     * @param null|int    $endTime              endTime (optional)
     * @param null|int    $offset               Default: 0 (optional)
     * @param null|int    $limit                min 7, max 30, default 7 (optional)
     *
     * @return ApiResponse<DepositHistoryTravelRuleResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function depositHistoryTravelRule($trId = null, $txId = null, $tranId = null, $network = null, $coin = null, $travelRuleStatus = null, $pendingQuestionnaire = null, $startTime = null, $endTime = null, $offset = null, $limit = null): ApiResponse
    {
        return $this->depositHistoryTravelRuleWithHttpInfo($trId, $txId, $tranId, $network, $coin, $travelRuleStatus, $pendingQuestionnaire, $startTime, $endTime, $offset, $limit);
    }

    /**
     * Operation depositHistoryTravelRuleWithHttpInfo.
     *
     * Deposit History (for local entities that required travel rule) (supporting network) (USER_DATA)
     *
     * @param null|string $trId                 Comma(,) separated list of travel rule record Ids. (optional)
     * @param null|string $txId                 (optional)
     * @param null|string $tranId               Comma(,) separated list of wallet tran Ids. (optional)
     * @param null|string $network              (optional)
     * @param null|string $coin                 (optional)
     * @param null|int    $travelRuleStatus     0:Completed,1:Pending,2:Failed (optional)
     * @param null|bool   $pendingQuestionnaire true: Only return records that pending deposit questionnaire. false/not provided: return all records. (optional)
     * @param null|int    $startTime            (optional)
     * @param null|int    $endTime              (optional)
     * @param null|int    $offset               Default: 0 (optional)
     * @param null|int    $limit                min 7, max 30, default 7 (optional)
     *
     * @return ApiResponse<DepositHistoryTravelRuleResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function depositHistoryTravelRuleWithHttpInfo($trId = null, $txId = null, $tranId = null, $network = null, $coin = null, $travelRuleStatus = null, $pendingQuestionnaire = null, $startTime = null, $endTime = null, $offset = null, $limit = null): ApiResponse
    {
        $request = $this->depositHistoryTravelRuleRequest($trId, $txId, $tranId, $network, $coin, $travelRuleStatus, $pendingQuestionnaire, $startTime, $endTime, $offset, $limit);

        try {
            try {
                $response = $this->client->send($request, []);
            } 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(
                        '\Binance\Client\Wallet\Model\DepositHistoryTravelRuleResponse',
                        $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(
                '\Binance\Client\Wallet\Model\DepositHistoryTravelRuleResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\DepositHistoryTravelRuleResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'depositHistoryTravelRule'.
     *
     * @param null|string $trId                 Comma(,) separated list of travel rule record Ids. (optional)
     * @param null|string $txId                 (optional)
     * @param null|string $tranId               Comma(,) separated list of wallet tran Ids. (optional)
     * @param null|string $network              (optional)
     * @param null|string $coin                 (optional)
     * @param null|int    $travelRuleStatus     0:Completed,1:Pending,2:Failed (optional)
     * @param null|bool   $pendingQuestionnaire true: Only return records that pending deposit questionnaire. false/not provided: return all records. (optional)
     * @param null|int    $startTime            (optional)
     * @param null|int    $endTime              (optional)
     * @param null|int    $offset               Default: 0 (optional)
     * @param null|int    $limit                min 7, max 30, default 7 (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function depositHistoryTravelRuleRequest($trId = null, $txId = null, $tranId = null, $network = null, $coin = null, $travelRuleStatus = null, $pendingQuestionnaire = null, $startTime = null, $endTime = null, $offset = null, $limit = null)
    {
        $contentType = self::contentTypes['depositHistoryTravelRule'][0];

        $resourcePath = '/sapi/v1/localentity/deposit/history';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $trId,
            'trId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $txId,
            'txId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $tranId,
            'tranId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $network,
            'network', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $coin,
            'coin', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $travelRuleStatus,
            'travelRuleStatus', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pendingQuestionnaire,
            'pendingQuestionnaire', // param base name
            'boolean', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $startTime,
            'startTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $endTime,
            'endTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $offset,
            'offset', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $limit,
            'limit', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);

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

        $defaultHeaders = [];
        $defaultHeaders['User-Agent'] = $this->userAgent;

        if (self::HAS_TIME_UNIT && !empty($this->clientConfig->getTimeUnit())) {
            $defaultHeaders['X-MBX-TIME-UNIT'] = $this->clientConfig->getTimeUnit();
        }

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

        $operationHost = $this->clientConfig->getUrl();

        $queryParams['timestamp'] = $this->getTimestamp();
        $query = ObjectSerializer::buildQuery($queryParams);
        $queryParams['signature'] = $this->signer->sign($query.$httpBody);
        $headers['X-MBX-APIKEY'] = $this->clientConfig->getSignatureConfiguration()->getApiKey();
        $query = ObjectSerializer::buildQuery($queryParams);

        return new Request(
            'GET',
            $operationHost.$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation fetchAddressVerificationList.
     *
     * Fetch address verification list (USER_DATA)
     *
     * @return ApiResponse<FetchAddressVerificationListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function fetchAddressVerificationList(): ApiResponse
    {
        return $this->fetchAddressVerificationListWithHttpInfo();
    }

    /**
     * Operation fetchAddressVerificationListWithHttpInfo.
     *
     * Fetch address verification list (USER_DATA)
     *
     * @return ApiResponse<FetchAddressVerificationListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function fetchAddressVerificationListWithHttpInfo(): ApiResponse
    {
        $request = $this->fetchAddressVerificationListRequest();

        try {
            try {
                $response = $this->client->send($request, []);
            } 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(
                        '\Binance\Client\Wallet\Model\FetchAddressVerificationListResponse',
                        $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(
                '\Binance\Client\Wallet\Model\FetchAddressVerificationListResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\FetchAddressVerificationListResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'fetchAddressVerificationList'.
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function fetchAddressVerificationListRequest()
    {
        $contentType = self::contentTypes['fetchAddressVerificationList'][0];

        $resourcePath = '/sapi/v1/addressVerify/list';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        $defaultHeaders = [];
        $defaultHeaders['User-Agent'] = $this->userAgent;

        if (self::HAS_TIME_UNIT && !empty($this->clientConfig->getTimeUnit())) {
            $defaultHeaders['X-MBX-TIME-UNIT'] = $this->clientConfig->getTimeUnit();
        }

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

        $operationHost = $this->clientConfig->getUrl();

        $queryParams['timestamp'] = $this->getTimestamp();
        $query = ObjectSerializer::buildQuery($queryParams);
        $queryParams['signature'] = $this->signer->sign($query.$httpBody);
        $headers['X-MBX-APIKEY'] = $this->clientConfig->getSignatureConfiguration()->getApiKey();
        $query = ObjectSerializer::buildQuery($queryParams);

        return new Request(
            'GET',
            $operationHost.$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation onboardedVaspList.
     *
     * Onboarded VASP list (for local entities that require travel rule) (supporting network) (USER_DATA)
     *
     * @return ApiResponse<OnboardedVaspListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function onboardedVaspList(): ApiResponse
    {
        return $this->onboardedVaspListWithHttpInfo();
    }

    /**
     * Operation onboardedVaspListWithHttpInfo.
     *
     * Onboarded VASP list (for local entities that require travel rule) (supporting network) (USER_DATA)
     *
     * @return ApiResponse<OnboardedVaspListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function onboardedVaspListWithHttpInfo(): ApiResponse
    {
        $request = $this->onboardedVaspListRequest();

        try {
            try {
                $response = $this->client->send($request, []);
            } 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(
                        '\Binance\Client\Wallet\Model\OnboardedVaspListResponse',
                        $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(
                '\Binance\Client\Wallet\Model\OnboardedVaspListResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\OnboardedVaspListResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'onboardedVaspList'.
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function onboardedVaspListRequest()
    {
        $contentType = self::contentTypes['onboardedVaspList'][0];

        $resourcePath = '/sapi/v1/localentity/vasp';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        $defaultHeaders = [];
        $defaultHeaders['User-Agent'] = $this->userAgent;

        if (self::HAS_TIME_UNIT && !empty($this->clientConfig->getTimeUnit())) {
            $defaultHeaders['X-MBX-TIME-UNIT'] = $this->clientConfig->getTimeUnit();
        }

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

        $operationHost = $this->clientConfig->getUrl();

        $queryParams['timestamp'] = $this->getTimestamp();
        $query = ObjectSerializer::buildQuery($queryParams);
        $queryParams['signature'] = $this->signer->sign($query.$httpBody);
        $headers['X-MBX-APIKEY'] = $this->clientConfig->getSignatureConfiguration()->getApiKey();
        $query = ObjectSerializer::buildQuery($queryParams);

        return new Request(
            'GET',
            $operationHost.$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation submitDepositQuestionnaire.
     *
     * Submit Deposit Questionnaire (For local entities that require travel rule) (supporting network) (USER_DATA)
     *
     * @param SubmitDepositQuestionnaireRequest $submitDepositQuestionnaireRequest submitDepositQuestionnaireRequest (required)
     *
     * @return ApiResponse<SubmitDepositQuestionnaireResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function submitDepositQuestionnaire($submitDepositQuestionnaireRequest): ApiResponse
    {
        return $this->submitDepositQuestionnaireWithHttpInfo($submitDepositQuestionnaireRequest);
    }

    /**
     * Operation submitDepositQuestionnaireWithHttpInfo.
     *
     * Submit Deposit Questionnaire (For local entities that require travel rule) (supporting network) (USER_DATA)
     *
     * @param SubmitDepositQuestionnaireRequest $submitDepositQuestionnaireRequest (required)
     *
     * @return ApiResponse<SubmitDepositQuestionnaireResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function submitDepositQuestionnaireWithHttpInfo($submitDepositQuestionnaireRequest): ApiResponse
    {
        $request = $this->submitDepositQuestionnaireRequest($submitDepositQuestionnaireRequest);

        try {
            try {
                $response = $this->client->send($request, []);
            } 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(
                        '\Binance\Client\Wallet\Model\SubmitDepositQuestionnaireResponse',
                        $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(
                '\Binance\Client\Wallet\Model\SubmitDepositQuestionnaireResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\SubmitDepositQuestionnaireResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'submitDepositQuestionnaire'.
     *
     * @param SubmitDepositQuestionnaireRequest $submitDepositQuestionnaireRequest (required)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function submitDepositQuestionnaireRequest($submitDepositQuestionnaireRequest)
    {
        $contentType = self::contentTypes['submitDepositQuestionnaire'][0];

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

        $resourcePath = '/sapi/v1/localentity/broker/deposit/provide-info';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        $getters = $submitDepositQuestionnaireRequest::getters();
        $formParams = [];
        foreach ($getters as $property => $getter) {
            $value = $submitDepositQuestionnaireRequest->{$getter}();
            if (!empty($value)) {
                $formParams[$property] = $submitDepositQuestionnaireRequest->{$getter}();
            }
        }

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

        $defaultHeaders = [];
        $defaultHeaders['User-Agent'] = $this->userAgent;

        if (self::HAS_TIME_UNIT && !empty($this->clientConfig->getTimeUnit())) {
            $defaultHeaders['X-MBX-TIME-UNIT'] = $this->clientConfig->getTimeUnit();
        }

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

        $operationHost = $this->clientConfig->getUrl();

        $queryParams['timestamp'] = $this->getTimestamp();
        $query = ObjectSerializer::buildQuery($queryParams);
        $queryParams['signature'] = $this->signer->sign($query.$httpBody);
        $headers['X-MBX-APIKEY'] = $this->clientConfig->getSignatureConfiguration()->getApiKey();
        $query = ObjectSerializer::buildQuery($queryParams);

        return new Request(
            'PUT',
            $operationHost.$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation submitDepositQuestionnaireTravelRule.
     *
     * Submit Deposit Questionnaire (For local entities that require travel rule) (supporting network) (USER_DATA)
     *
     * @param SubmitDepositQuestionnaireTravelRuleRequest $submitDepositQuestionnaireTravelRuleRequest submitDepositQuestionnaireTravelRuleRequest (required)
     *
     * @return ApiResponse<SubmitDepositQuestionnaireTravelRuleResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function submitDepositQuestionnaireTravelRule($submitDepositQuestionnaireTravelRuleRequest): ApiResponse
    {
        return $this->submitDepositQuestionnaireTravelRuleWithHttpInfo($submitDepositQuestionnaireTravelRuleRequest);
    }

    /**
     * Operation submitDepositQuestionnaireTravelRuleWithHttpInfo.
     *
     * Submit Deposit Questionnaire (For local entities that require travel rule) (supporting network) (USER_DATA)
     *
     * @param SubmitDepositQuestionnaireTravelRuleRequest $submitDepositQuestionnaireTravelRuleRequest (required)
     *
     * @return ApiResponse<SubmitDepositQuestionnaireTravelRuleResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function submitDepositQuestionnaireTravelRuleWithHttpInfo($submitDepositQuestionnaireTravelRuleRequest): ApiResponse
    {
        $request = $this->submitDepositQuestionnaireTravelRuleRequest($submitDepositQuestionnaireTravelRuleRequest);

        try {
            try {
                $response = $this->client->send($request, []);
            } 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(
                        '\Binance\Client\Wallet\Model\SubmitDepositQuestionnaireTravelRuleResponse',
                        $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(
                '\Binance\Client\Wallet\Model\SubmitDepositQuestionnaireTravelRuleResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\SubmitDepositQuestionnaireTravelRuleResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'submitDepositQuestionnaireTravelRule'.
     *
     * @param SubmitDepositQuestionnaireTravelRuleRequest $submitDepositQuestionnaireTravelRuleRequest (required)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function submitDepositQuestionnaireTravelRuleRequest($submitDepositQuestionnaireTravelRuleRequest)
    {
        $contentType = self::contentTypes['submitDepositQuestionnaireTravelRule'][0];

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

        $resourcePath = '/sapi/v1/localentity/deposit/provide-info';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        $getters = $submitDepositQuestionnaireTravelRuleRequest::getters();
        $formParams = [];
        foreach ($getters as $property => $getter) {
            $value = $submitDepositQuestionnaireTravelRuleRequest->{$getter}();
            if (!empty($value)) {
                $formParams[$property] = $submitDepositQuestionnaireTravelRuleRequest->{$getter}();
            }
        }

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

        $defaultHeaders = [];
        $defaultHeaders['User-Agent'] = $this->userAgent;

        if (self::HAS_TIME_UNIT && !empty($this->clientConfig->getTimeUnit())) {
            $defaultHeaders['X-MBX-TIME-UNIT'] = $this->clientConfig->getTimeUnit();
        }

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

        $operationHost = $this->clientConfig->getUrl();

        $queryParams['timestamp'] = $this->getTimestamp();
        $query = ObjectSerializer::buildQuery($queryParams);
        $queryParams['signature'] = $this->signer->sign($query.$httpBody);
        $headers['X-MBX-APIKEY'] = $this->clientConfig->getSignatureConfiguration()->getApiKey();
        $query = ObjectSerializer::buildQuery($queryParams);

        return new Request(
            'PUT',
            $operationHost.$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation withdrawHistoryV1.
     *
     * Withdraw History (for local entities that require travel rule) (supporting network) (USER_DATA)
     *
     * @param null|string $trId             Comma(,) separated list of travel rule record Ids. (optional)
     * @param null|string $txId             txId (optional)
     * @param null|string $withdrawOrderId  client side id for withdrawal, if provided in POST &#x60;/sapi/v1/capital/withdraw/apply&#x60;, can be used here for query. (optional)
     * @param null|string $network          network (optional)
     * @param null|string $coin             coin (optional)
     * @param null|int    $travelRuleStatus 0:Completed,1:Pending,2:Failed (optional)
     * @param null|int    $offset           Default: 0 (optional)
     * @param null|int    $limit            min 7, max 30, default 7 (optional)
     * @param null|int    $startTime        startTime (optional)
     * @param null|int    $endTime          endTime (optional)
     * @param null|int    $recvWindow       recvWindow (optional)
     *
     * @return ApiResponse<WithdrawHistoryV1Response>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function withdrawHistoryV1($trId = null, $txId = null, $withdrawOrderId = null, $network = null, $coin = null, $travelRuleStatus = null, $offset = null, $limit = null, $startTime = null, $endTime = null, $recvWindow = null): ApiResponse
    {
        return $this->withdrawHistoryV1WithHttpInfo($trId, $txId, $withdrawOrderId, $network, $coin, $travelRuleStatus, $offset, $limit, $startTime, $endTime, $recvWindow);
    }

    /**
     * Operation withdrawHistoryV1WithHttpInfo.
     *
     * Withdraw History (for local entities that require travel rule) (supporting network) (USER_DATA)
     *
     * @param null|string $trId             Comma(,) separated list of travel rule record Ids. (optional)
     * @param null|string $txId             (optional)
     * @param null|string $withdrawOrderId  client side id for withdrawal, if provided in POST &#x60;/sapi/v1/capital/withdraw/apply&#x60;, can be used here for query. (optional)
     * @param null|string $network          (optional)
     * @param null|string $coin             (optional)
     * @param null|int    $travelRuleStatus 0:Completed,1:Pending,2:Failed (optional)
     * @param null|int    $offset           Default: 0 (optional)
     * @param null|int    $limit            min 7, max 30, default 7 (optional)
     * @param null|int    $startTime        (optional)
     * @param null|int    $endTime          (optional)
     * @param null|int    $recvWindow       (optional)
     *
     * @return ApiResponse<WithdrawHistoryV1Response>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function withdrawHistoryV1WithHttpInfo($trId = null, $txId = null, $withdrawOrderId = null, $network = null, $coin = null, $travelRuleStatus = null, $offset = null, $limit = null, $startTime = null, $endTime = null, $recvWindow = null): ApiResponse
    {
        $request = $this->withdrawHistoryV1Request($trId, $txId, $withdrawOrderId, $network, $coin, $travelRuleStatus, $offset, $limit, $startTime, $endTime, $recvWindow);

        try {
            try {
                $response = $this->client->send($request, []);
            } 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(
                        '\Binance\Client\Wallet\Model\WithdrawHistoryV1Response',
                        $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(
                '\Binance\Client\Wallet\Model\WithdrawHistoryV1Response',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\WithdrawHistoryV1Response',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'withdrawHistoryV1'.
     *
     * @param null|string $trId             Comma(,) separated list of travel rule record Ids. (optional)
     * @param null|string $txId             (optional)
     * @param null|string $withdrawOrderId  client side id for withdrawal, if provided in POST &#x60;/sapi/v1/capital/withdraw/apply&#x60;, can be used here for query. (optional)
     * @param null|string $network          (optional)
     * @param null|string $coin             (optional)
     * @param null|int    $travelRuleStatus 0:Completed,1:Pending,2:Failed (optional)
     * @param null|int    $offset           Default: 0 (optional)
     * @param null|int    $limit            min 7, max 30, default 7 (optional)
     * @param null|int    $startTime        (optional)
     * @param null|int    $endTime          (optional)
     * @param null|int    $recvWindow       (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function withdrawHistoryV1Request($trId = null, $txId = null, $withdrawOrderId = null, $network = null, $coin = null, $travelRuleStatus = null, $offset = null, $limit = null, $startTime = null, $endTime = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['withdrawHistoryV1'][0];

        $resourcePath = '/sapi/v1/localentity/withdraw/history';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $trId,
            'trId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $txId,
            'txId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $withdrawOrderId,
            'withdrawOrderId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $network,
            'network', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $coin,
            'coin', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $travelRuleStatus,
            'travelRuleStatus', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $offset,
            'offset', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $limit,
            'limit', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $startTime,
            'startTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $endTime,
            'endTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $recvWindow,
            'recvWindow', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);

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

        $defaultHeaders = [];
        $defaultHeaders['User-Agent'] = $this->userAgent;

        if (self::HAS_TIME_UNIT && !empty($this->clientConfig->getTimeUnit())) {
            $defaultHeaders['X-MBX-TIME-UNIT'] = $this->clientConfig->getTimeUnit();
        }

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

        $operationHost = $this->clientConfig->getUrl();

        $queryParams['timestamp'] = $this->getTimestamp();
        $query = ObjectSerializer::buildQuery($queryParams);
        $queryParams['signature'] = $this->signer->sign($query.$httpBody);
        $headers['X-MBX-APIKEY'] = $this->clientConfig->getSignatureConfiguration()->getApiKey();
        $query = ObjectSerializer::buildQuery($queryParams);

        return new Request(
            'GET',
            $operationHost.$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation withdrawHistoryV2.
     *
     * Withdraw History V2 (for local entities that require travel rule) (supporting network) (USER_DATA)
     *
     * @param null|string $trId             Comma(,) separated list of travel rule record Ids. (optional)
     * @param null|string $txId             txId (optional)
     * @param null|string $withdrawOrderId  client side id for withdrawal, if provided in POST &#x60;/sapi/v1/capital/withdraw/apply&#x60;, can be used here for query. (optional)
     * @param null|string $network          network (optional)
     * @param null|string $coin             coin (optional)
     * @param null|int    $travelRuleStatus 0:Completed,1:Pending,2:Failed (optional)
     * @param null|int    $offset           Default: 0 (optional)
     * @param null|int    $limit            min 7, max 30, default 7 (optional)
     * @param null|int    $startTime        startTime (optional)
     * @param null|int    $endTime          endTime (optional)
     * @param null|int    $recvWindow       recvWindow (optional)
     *
     * @return ApiResponse<WithdrawHistoryV2Response>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function withdrawHistoryV2($trId = null, $txId = null, $withdrawOrderId = null, $network = null, $coin = null, $travelRuleStatus = null, $offset = null, $limit = null, $startTime = null, $endTime = null, $recvWindow = null): ApiResponse
    {
        return $this->withdrawHistoryV2WithHttpInfo($trId, $txId, $withdrawOrderId, $network, $coin, $travelRuleStatus, $offset, $limit, $startTime, $endTime, $recvWindow);
    }

    /**
     * Operation withdrawHistoryV2WithHttpInfo.
     *
     * Withdraw History V2 (for local entities that require travel rule) (supporting network) (USER_DATA)
     *
     * @param null|string $trId             Comma(,) separated list of travel rule record Ids. (optional)
     * @param null|string $txId             (optional)
     * @param null|string $withdrawOrderId  client side id for withdrawal, if provided in POST &#x60;/sapi/v1/capital/withdraw/apply&#x60;, can be used here for query. (optional)
     * @param null|string $network          (optional)
     * @param null|string $coin             (optional)
     * @param null|int    $travelRuleStatus 0:Completed,1:Pending,2:Failed (optional)
     * @param null|int    $offset           Default: 0 (optional)
     * @param null|int    $limit            min 7, max 30, default 7 (optional)
     * @param null|int    $startTime        (optional)
     * @param null|int    $endTime          (optional)
     * @param null|int    $recvWindow       (optional)
     *
     * @return ApiResponse<WithdrawHistoryV2Response>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function withdrawHistoryV2WithHttpInfo($trId = null, $txId = null, $withdrawOrderId = null, $network = null, $coin = null, $travelRuleStatus = null, $offset = null, $limit = null, $startTime = null, $endTime = null, $recvWindow = null): ApiResponse
    {
        $request = $this->withdrawHistoryV2Request($trId, $txId, $withdrawOrderId, $network, $coin, $travelRuleStatus, $offset, $limit, $startTime, $endTime, $recvWindow);

        try {
            try {
                $response = $this->client->send($request, []);
            } 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(
                        '\Binance\Client\Wallet\Model\WithdrawHistoryV2Response',
                        $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(
                '\Binance\Client\Wallet\Model\WithdrawHistoryV2Response',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\WithdrawHistoryV2Response',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'withdrawHistoryV2'.
     *
     * @param null|string $trId             Comma(,) separated list of travel rule record Ids. (optional)
     * @param null|string $txId             (optional)
     * @param null|string $withdrawOrderId  client side id for withdrawal, if provided in POST &#x60;/sapi/v1/capital/withdraw/apply&#x60;, can be used here for query. (optional)
     * @param null|string $network          (optional)
     * @param null|string $coin             (optional)
     * @param null|int    $travelRuleStatus 0:Completed,1:Pending,2:Failed (optional)
     * @param null|int    $offset           Default: 0 (optional)
     * @param null|int    $limit            min 7, max 30, default 7 (optional)
     * @param null|int    $startTime        (optional)
     * @param null|int    $endTime          (optional)
     * @param null|int    $recvWindow       (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function withdrawHistoryV2Request($trId = null, $txId = null, $withdrawOrderId = null, $network = null, $coin = null, $travelRuleStatus = null, $offset = null, $limit = null, $startTime = null, $endTime = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['withdrawHistoryV2'][0];

        $resourcePath = '/sapi/v2/localentity/withdraw/history';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $trId,
            'trId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $txId,
            'txId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $withdrawOrderId,
            'withdrawOrderId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $network,
            'network', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $coin,
            'coin', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $travelRuleStatus,
            'travelRuleStatus', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $offset,
            'offset', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $limit,
            'limit', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $startTime,
            'startTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $endTime,
            'endTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $recvWindow,
            'recvWindow', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);

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

        $defaultHeaders = [];
        $defaultHeaders['User-Agent'] = $this->userAgent;

        if (self::HAS_TIME_UNIT && !empty($this->clientConfig->getTimeUnit())) {
            $defaultHeaders['X-MBX-TIME-UNIT'] = $this->clientConfig->getTimeUnit();
        }

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

        $operationHost = $this->clientConfig->getUrl();

        $queryParams['timestamp'] = $this->getTimestamp();
        $query = ObjectSerializer::buildQuery($queryParams);
        $queryParams['signature'] = $this->signer->sign($query.$httpBody);
        $headers['X-MBX-APIKEY'] = $this->clientConfig->getSignatureConfiguration()->getApiKey();
        $query = ObjectSerializer::buildQuery($queryParams);

        return new Request(
            'GET',
            $operationHost.$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Operation withdrawTravelRule.
     *
     * Withdraw (for local entities that require travel rule) (USER_DATA)
     *
     * @param WithdrawTravelRuleRequest $withdrawTravelRuleRequest withdrawTravelRuleRequest (required)
     *
     * @return ApiResponse<WithdrawTravelRuleResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function withdrawTravelRule($withdrawTravelRuleRequest): ApiResponse
    {
        return $this->withdrawTravelRuleWithHttpInfo($withdrawTravelRuleRequest);
    }

    /**
     * Operation withdrawTravelRuleWithHttpInfo.
     *
     * Withdraw (for local entities that require travel rule) (USER_DATA)
     *
     * @param WithdrawTravelRuleRequest $withdrawTravelRuleRequest (required)
     *
     * @return ApiResponse<WithdrawTravelRuleResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function withdrawTravelRuleWithHttpInfo($withdrawTravelRuleRequest): ApiResponse
    {
        $request = $this->withdrawTravelRuleRequest($withdrawTravelRuleRequest);

        try {
            try {
                $response = $this->client->send($request, []);
            } 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(
                        '\Binance\Client\Wallet\Model\WithdrawTravelRuleResponse',
                        $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(
                '\Binance\Client\Wallet\Model\WithdrawTravelRuleResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\WithdrawTravelRuleResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'withdrawTravelRule'.
     *
     * @param WithdrawTravelRuleRequest $withdrawTravelRuleRequest (required)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function withdrawTravelRuleRequest($withdrawTravelRuleRequest)
    {
        $contentType = self::contentTypes['withdrawTravelRule'][0];

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

        $resourcePath = '/sapi/v1/localentity/withdraw/apply';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        $getters = $withdrawTravelRuleRequest::getters();
        $formParams = [];
        foreach ($getters as $property => $getter) {
            $value = $withdrawTravelRuleRequest->{$getter}();
            if (!empty($value)) {
                $formParams[$property] = $withdrawTravelRuleRequest->{$getter}();
            }
        }

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

        $defaultHeaders = [];
        $defaultHeaders['User-Agent'] = $this->userAgent;

        if (self::HAS_TIME_UNIT && !empty($this->clientConfig->getTimeUnit())) {
            $defaultHeaders['X-MBX-TIME-UNIT'] = $this->clientConfig->getTimeUnit();
        }

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

        $operationHost = $this->clientConfig->getUrl();

        $queryParams['timestamp'] = $this->getTimestamp();
        $query = ObjectSerializer::buildQuery($queryParams);
        $queryParams['signature'] = $this->signer->sign($query.$httpBody);
        $headers['X-MBX-APIKEY'] = $this->clientConfig->getSignatureConfiguration()->getApiKey();
        $query = ObjectSerializer::buildQuery($queryParams);

        return new Request(
            'POST',
            $operationHost.$resourcePath.($query ? "?{$query}" : ''),
            $headers,
            $httpBody
        );
    }

    /**
     * Summary of getTimestamp.
     */
    public function getTimestamp(): string
    {
        return date_create()->format('Uv');
    }

    private function handleResponseWithDataType(
        string $dataType,
        RequestInterface $request,
        ResponseInterface $response
    ): ApiResponse {
        if ('\SplFileObject' === $dataType) {
            $content = $response->getBody(); // stream goes to serializer
        } else {
            $content = (string) $response->getBody();
            if ('string' !== $dataType) {
                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
                    );
                }
            }
        }

        $rateLimits = CommonUtils::getRateLimits($response->getStatusCode(), $response->getHeaders());

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

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

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