<?php

/**
 * AssetApi
 * 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\AssetDetailResponse;
use Binance\Client\Wallet\Model\AssetDividendRecordResponse;
use Binance\Client\Wallet\Model\DustlogResponse;
use Binance\Client\Wallet\Model\DustTransferRequest;
use Binance\Client\Wallet\Model\DustTransferResponse;
use Binance\Client\Wallet\Model\FundingWalletRequest;
use Binance\Client\Wallet\Model\FundingWalletResponse;
use Binance\Client\Wallet\Model\GetAssetsThatCanBeConvertedIntoBnbRequest;
use Binance\Client\Wallet\Model\GetAssetsThatCanBeConvertedIntoBnbResponse;
use Binance\Client\Wallet\Model\GetCloudMiningPaymentAndRefundHistoryResponse;
use Binance\Client\Wallet\Model\GetOpenSymbolListResponse;
use Binance\Client\Wallet\Model\QueryUserDelegationHistoryResponse;
use Binance\Client\Wallet\Model\QueryUserUniversalTransferHistoryResponse;
use Binance\Client\Wallet\Model\QueryUserWalletBalanceResponse;
use Binance\Client\Wallet\Model\ToggleBnbBurnOnSpotTradeAndMarginInterestRequest;
use Binance\Client\Wallet\Model\ToggleBnbBurnOnSpotTradeAndMarginInterestResponse;
use Binance\Client\Wallet\Model\TradeFeeResponse;
use Binance\Client\Wallet\Model\UserAssetRequest;
use Binance\Client\Wallet\Model\UserAssetResponse;
use Binance\Client\Wallet\Model\UserUniversalTransferRequest;
use Binance\Client\Wallet\Model\UserUniversalTransferResponse;
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\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;

/**
 * AssetApi Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */
class AssetApi
{
    /** @var string[] */
    public const contentTypes = [
        'assetDetail' => ['application/x-www-form-urlencoded'],
        'assetDividendRecord' => ['application/x-www-form-urlencoded'],
        'dustTransfer' => ['application/x-www-form-urlencoded'],
        'dustlog' => ['application/x-www-form-urlencoded'],
        'fundingWallet' => ['application/x-www-form-urlencoded'],
        'getAssetsThatCanBeConvertedIntoBnb' => ['application/x-www-form-urlencoded'],
        'getCloudMiningPaymentAndRefundHistory' => ['application/x-www-form-urlencoded'],
        'getOpenSymbolList' => ['application/x-www-form-urlencoded'],
        'queryUserDelegationHistory' => ['application/x-www-form-urlencoded'],
        'queryUserUniversalTransferHistory' => ['application/x-www-form-urlencoded'],
        'queryUserWalletBalance' => ['application/x-www-form-urlencoded'],
        'toggleBnbBurnOnSpotTradeAndMarginInterest' => ['application/x-www-form-urlencoded'],
        'tradeFee' => ['application/x-www-form-urlencoded'],
        'userAsset' => ['application/x-www-form-urlencoded'],
        'userUniversalTransfer' => ['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 assetDetail.
     *
     * Asset Detail (USER_DATA)
     *
     * @param null|int $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<AssetDetailResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function assetDetail($recvWindow = null): ApiResponse
    {
        return $this->assetDetailWithHttpInfo($recvWindow);
    }

    /**
     * Operation assetDetailWithHttpInfo.
     *
     * Asset Detail (USER_DATA)
     *
     * @param null|int $recvWindow (optional)
     *
     * @return ApiResponse<AssetDetailResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function assetDetailWithHttpInfo($recvWindow = null): ApiResponse
    {
        $request = $this->assetDetailRequest($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\AssetDetailResponse',
                        $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\AssetDetailResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\AssetDetailResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'assetDetail'.
     *
     * @param null|int $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function assetDetailRequest($recvWindow = null)
    {
        $contentType = self::contentTypes['assetDetail'][0];

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

        // 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 assetDividendRecord.
     *
     * Asset Dividend Record (USER_DATA)
     *
     * @param null|string $asset      asset (optional)
     * @param null|int    $startTime  startTime (optional)
     * @param null|int    $endTime    endTime (optional)
     * @param null|int    $limit      min 7, max 30, default 7 (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<AssetDividendRecordResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function assetDividendRecord($asset = null, $startTime = null, $endTime = null, $limit = null, $recvWindow = null): ApiResponse
    {
        return $this->assetDividendRecordWithHttpInfo($asset, $startTime, $endTime, $limit, $recvWindow);
    }

    /**
     * Operation assetDividendRecordWithHttpInfo.
     *
     * Asset Dividend Record (USER_DATA)
     *
     * @param null|string $asset      (optional)
     * @param null|int    $startTime  (optional)
     * @param null|int    $endTime    (optional)
     * @param null|int    $limit      min 7, max 30, default 7 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<AssetDividendRecordResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function assetDividendRecordWithHttpInfo($asset = null, $startTime = null, $endTime = null, $limit = null, $recvWindow = null): ApiResponse
    {
        $request = $this->assetDividendRecordRequest($asset, $startTime, $endTime, $limit, $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\AssetDividendRecordResponse',
                        $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\AssetDividendRecordResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\AssetDividendRecordResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'assetDividendRecord'.
     *
     * @param null|string $asset      (optional)
     * @param null|int    $startTime  (optional)
     * @param null|int    $endTime    (optional)
     * @param null|int    $limit      min 7, max 30, default 7 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function assetDividendRecordRequest($asset = null, $startTime = null, $endTime = null, $limit = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['assetDividendRecord'][0];

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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $asset,
            'asset', // param base name
            'string', // 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(
            $limit,
            'limit', // 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 dustTransfer.
     *
     * Dust Transfer (USER_DATA)
     *
     * @param DustTransferRequest $dustTransferRequest dustTransferRequest (required)
     *
     * @return ApiResponse<DustTransferResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function dustTransfer($dustTransferRequest): ApiResponse
    {
        return $this->dustTransferWithHttpInfo($dustTransferRequest);
    }

    /**
     * Operation dustTransferWithHttpInfo.
     *
     * Dust Transfer (USER_DATA)
     *
     * @param DustTransferRequest $dustTransferRequest (required)
     *
     * @return ApiResponse<DustTransferResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function dustTransferWithHttpInfo($dustTransferRequest): ApiResponse
    {
        $request = $this->dustTransferRequest($dustTransferRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

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

        $getters = $dustTransferRequest::getters();
        $formParams = [];
        foreach ($getters as $property => $getter) {
            $value = $dustTransferRequest->{$getter}();
            if (!empty($value)) {
                $formParams[$property] = $dustTransferRequest->{$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($dustTransferRequest)) {
            if (false !== stripos($headers['Content-Type'], 'application/json')) {
                // if Content-Type contains "application/json", json_encode the body
                $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($dustTransferRequest));
            } else {
                $httpBody = $dustTransferRequest;
            }
        }

        $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 dustlog.
     *
     * DustLog(USER_DATA)
     *
     * @param null|int $startTime  startTime (optional)
     * @param null|int $endTime    endTime (optional)
     * @param null|int $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<DustlogResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function dustlog($startTime = null, $endTime = null, $recvWindow = null): ApiResponse
    {
        return $this->dustlogWithHttpInfo($startTime, $endTime, $recvWindow);
    }

    /**
     * Operation dustlogWithHttpInfo.
     *
     * DustLog(USER_DATA)
     *
     * @param null|int $startTime  (optional)
     * @param null|int $endTime    (optional)
     * @param null|int $recvWindow (optional)
     *
     * @return ApiResponse<DustlogResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function dustlogWithHttpInfo($startTime = null, $endTime = null, $recvWindow = null): ApiResponse
    {
        $request = $this->dustlogRequest($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\DustlogResponse',
                        $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\DustlogResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\DustlogResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'dustlog'.
     *
     * @param null|int $startTime  (optional)
     * @param null|int $endTime    (optional)
     * @param null|int $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function dustlogRequest($startTime = null, $endTime = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['dustlog'][0];

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

        // 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 fundingWallet.
     *
     * Funding Wallet (USER_DATA)
     *
     * @param FundingWalletRequest $fundingWalletRequest fundingWalletRequest (required)
     *
     * @return ApiResponse<FundingWalletResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function fundingWallet($fundingWalletRequest): ApiResponse
    {
        return $this->fundingWalletWithHttpInfo($fundingWalletRequest);
    }

    /**
     * Operation fundingWalletWithHttpInfo.
     *
     * Funding Wallet (USER_DATA)
     *
     * @param FundingWalletRequest $fundingWalletRequest (required)
     *
     * @return ApiResponse<FundingWalletResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function fundingWalletWithHttpInfo($fundingWalletRequest): ApiResponse
    {
        $request = $this->fundingWalletRequest($fundingWalletRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

        $resourcePath = '/sapi/v1/asset/get-funding-asset';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        $getters = $fundingWalletRequest::getters();
        $formParams = [];
        foreach ($getters as $property => $getter) {
            $value = $fundingWalletRequest->{$getter}();
            if (!empty($value)) {
                $formParams[$property] = $fundingWalletRequest->{$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($fundingWalletRequest)) {
            if (false !== stripos($headers['Content-Type'], 'application/json')) {
                // if Content-Type contains "application/json", json_encode the body
                $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($fundingWalletRequest));
            } else {
                $httpBody = $fundingWalletRequest;
            }
        }

        $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 getAssetsThatCanBeConvertedIntoBnb.
     *
     * Get Assets That Can Be Converted Into BNB (USER_DATA)
     *
     * @param GetAssetsThatCanBeConvertedIntoBnbRequest $getAssetsThatCanBeConvertedIntoBnbRequest getAssetsThatCanBeConvertedIntoBnbRequest (required)
     *
     * @return ApiResponse<GetAssetsThatCanBeConvertedIntoBnbResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getAssetsThatCanBeConvertedIntoBnb($getAssetsThatCanBeConvertedIntoBnbRequest): ApiResponse
    {
        return $this->getAssetsThatCanBeConvertedIntoBnbWithHttpInfo($getAssetsThatCanBeConvertedIntoBnbRequest);
    }

    /**
     * Operation getAssetsThatCanBeConvertedIntoBnbWithHttpInfo.
     *
     * Get Assets That Can Be Converted Into BNB (USER_DATA)
     *
     * @param GetAssetsThatCanBeConvertedIntoBnbRequest $getAssetsThatCanBeConvertedIntoBnbRequest (required)
     *
     * @return ApiResponse<GetAssetsThatCanBeConvertedIntoBnbResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getAssetsThatCanBeConvertedIntoBnbWithHttpInfo($getAssetsThatCanBeConvertedIntoBnbRequest): ApiResponse
    {
        $request = $this->getAssetsThatCanBeConvertedIntoBnbRequest($getAssetsThatCanBeConvertedIntoBnbRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

        $resourcePath = '/sapi/v1/asset/dust-btc';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        $getters = $getAssetsThatCanBeConvertedIntoBnbRequest::getters();
        $formParams = [];
        foreach ($getters as $property => $getter) {
            $value = $getAssetsThatCanBeConvertedIntoBnbRequest->{$getter}();
            if (!empty($value)) {
                $formParams[$property] = $getAssetsThatCanBeConvertedIntoBnbRequest->{$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($getAssetsThatCanBeConvertedIntoBnbRequest)) {
            if (false !== stripos($headers['Content-Type'], 'application/json')) {
                // if Content-Type contains "application/json", json_encode the body
                $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($getAssetsThatCanBeConvertedIntoBnbRequest));
            } else {
                $httpBody = $getAssetsThatCanBeConvertedIntoBnbRequest;
            }
        }

        $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 getCloudMiningPaymentAndRefundHistory.
     *
     * Get Cloud-Mining payment and refund history (USER_DATA)
     *
     * @param int         $startTime    startTime (required)
     * @param int         $endTime      endTime (required)
     * @param null|int    $tranId       The transaction id (optional)
     * @param null|string $clientTranId The unique flag (optional)
     * @param null|string $asset        asset (optional)
     * @param null|int    $current      current page, default 1, the min value is 1 (optional)
     * @param null|int    $size         page size, default 10, the max value is 100 (optional)
     *
     * @return ApiResponse<GetCloudMiningPaymentAndRefundHistoryResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getCloudMiningPaymentAndRefundHistory($startTime, $endTime, $tranId = null, $clientTranId = null, $asset = null, $current = null, $size = null): ApiResponse
    {
        return $this->getCloudMiningPaymentAndRefundHistoryWithHttpInfo($startTime, $endTime, $tranId, $clientTranId, $asset, $current, $size);
    }

    /**
     * Operation getCloudMiningPaymentAndRefundHistoryWithHttpInfo.
     *
     * Get Cloud-Mining payment and refund history (USER_DATA)
     *
     * @param int         $startTime    (required)
     * @param int         $endTime      (required)
     * @param null|int    $tranId       The transaction id (optional)
     * @param null|string $clientTranId The unique flag (optional)
     * @param null|string $asset        (optional)
     * @param null|int    $current      current page, default 1, the min value is 1 (optional)
     * @param null|int    $size         page size, default 10, the max value is 100 (optional)
     *
     * @return ApiResponse<GetCloudMiningPaymentAndRefundHistoryResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getCloudMiningPaymentAndRefundHistoryWithHttpInfo($startTime, $endTime, $tranId = null, $clientTranId = null, $asset = null, $current = null, $size = null): ApiResponse
    {
        $request = $this->getCloudMiningPaymentAndRefundHistoryRequest($startTime, $endTime, $tranId, $clientTranId, $asset, $current, $size);

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

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'getCloudMiningPaymentAndRefundHistory'.
     *
     * @param int         $startTime    (required)
     * @param int         $endTime      (required)
     * @param null|int    $tranId       The transaction id (optional)
     * @param null|string $clientTranId The unique flag (optional)
     * @param null|string $asset        (optional)
     * @param null|int    $current      current page, default 1, the min value is 1 (optional)
     * @param null|int    $size         page size, default 10, the max value is 100 (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function getCloudMiningPaymentAndRefundHistoryRequest($startTime, $endTime, $tranId = null, $clientTranId = null, $asset = null, $current = null, $size = null)
    {
        $contentType = self::contentTypes['getCloudMiningPaymentAndRefundHistory'][0];

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

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

        $resourcePath = '/sapi/v1/asset/ledger-transfer/cloud-mining/queryByPage';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $tranId,
            'tranId', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $clientTranId,
            'clientTranId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $asset,
            'asset', // param base name
            'string', // 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
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $endTime,
            'endTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $current,
            'current', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $size,
            'size', // 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 getOpenSymbolList.
     *
     * Get Open Symbol List (MARKET_DATA)
     *
     * @return ApiResponse<GetOpenSymbolListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOpenSymbolList(): ApiResponse
    {
        return $this->getOpenSymbolListWithHttpInfo();
    }

    /**
     * Operation getOpenSymbolListWithHttpInfo.
     *
     * Get Open Symbol List (MARKET_DATA)
     *
     * @return ApiResponse<GetOpenSymbolListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOpenSymbolListWithHttpInfo(): ApiResponse
    {
        $request = $this->getOpenSymbolListRequest();

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

                    throw $e;
            }

            throw $e;
        }
    }

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

        $resourcePath = '/sapi/v1/spot/open-symbol-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();

        $query = ObjectSerializer::buildQuery($queryParams);

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

    /**
     * Operation queryUserDelegationHistory.
     *
     * Query User Delegation History(For Master Account)(USER_DATA)
     *
     * @param string      $email      email (required)
     * @param int         $startTime  startTime (required)
     * @param int         $endTime    endTime (required)
     * @param null|string $type       Delegate/Undelegate (optional)
     * @param null|string $asset      asset (optional)
     * @param null|int    $current    current page, default 1, the min value is 1 (optional)
     * @param null|int    $size       page size, default 10, the max value is 100 (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<QueryUserDelegationHistoryResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function queryUserDelegationHistory($email, $startTime, $endTime, $type = null, $asset = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        return $this->queryUserDelegationHistoryWithHttpInfo($email, $startTime, $endTime, $type, $asset, $current, $size, $recvWindow);
    }

    /**
     * Operation queryUserDelegationHistoryWithHttpInfo.
     *
     * Query User Delegation History(For Master Account)(USER_DATA)
     *
     * @param string      $email      (required)
     * @param int         $startTime  (required)
     * @param int         $endTime    (required)
     * @param null|string $type       Delegate/Undelegate (optional)
     * @param null|string $asset      (optional)
     * @param null|int    $current    current page, default 1, the min value is 1 (optional)
     * @param null|int    $size       page size, default 10, the max value is 100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<QueryUserDelegationHistoryResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function queryUserDelegationHistoryWithHttpInfo($email, $startTime, $endTime, $type = null, $asset = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        $request = $this->queryUserDelegationHistoryRequest($email, $startTime, $endTime, $type, $asset, $current, $size, $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\QueryUserDelegationHistoryResponse',
                        $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\QueryUserDelegationHistoryResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\QueryUserDelegationHistoryResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'queryUserDelegationHistory'.
     *
     * @param string      $email      (required)
     * @param int         $startTime  (required)
     * @param int         $endTime    (required)
     * @param null|string $type       Delegate/Undelegate (optional)
     * @param null|string $asset      (optional)
     * @param null|int    $current    current page, default 1, the min value is 1 (optional)
     * @param null|int    $size       page size, default 10, the max value is 100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function queryUserDelegationHistoryRequest($email, $startTime, $endTime, $type = null, $asset = null, $current = null, $size = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['queryUserDelegationHistory'][0];

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

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

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

        $resourcePath = '/sapi/v1/asset/custody/transfer-history';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $email,
            'email', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $startTime,
            'startTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $endTime,
            'endTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $type,
            'type', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $asset,
            'asset', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $current,
            'current', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $size,
            'size', // 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 queryUserUniversalTransferHistory.
     *
     * Query User Universal Transfer History(USER_DATA)
     *
     * @param string      $type       type (required)
     * @param null|int    $startTime  startTime (optional)
     * @param null|int    $endTime    endTime (optional)
     * @param null|int    $current    current page, default 1, the min value is 1 (optional)
     * @param null|int    $size       page size, default 10, the max value is 100 (optional)
     * @param null|string $fromSymbol fromSymbol (optional)
     * @param null|string $toSymbol   toSymbol (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<QueryUserUniversalTransferHistoryResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function queryUserUniversalTransferHistory($type, $startTime = null, $endTime = null, $current = null, $size = null, $fromSymbol = null, $toSymbol = null, $recvWindow = null): ApiResponse
    {
        return $this->queryUserUniversalTransferHistoryWithHttpInfo($type, $startTime, $endTime, $current, $size, $fromSymbol, $toSymbol, $recvWindow);
    }

    /**
     * Operation queryUserUniversalTransferHistoryWithHttpInfo.
     *
     * Query User Universal Transfer History(USER_DATA)
     *
     * @param string      $type       (required)
     * @param null|int    $startTime  (optional)
     * @param null|int    $endTime    (optional)
     * @param null|int    $current    current page, default 1, the min value is 1 (optional)
     * @param null|int    $size       page size, default 10, the max value is 100 (optional)
     * @param null|string $fromSymbol (optional)
     * @param null|string $toSymbol   (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<QueryUserUniversalTransferHistoryResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function queryUserUniversalTransferHistoryWithHttpInfo($type, $startTime = null, $endTime = null, $current = null, $size = null, $fromSymbol = null, $toSymbol = null, $recvWindow = null): ApiResponse
    {
        $request = $this->queryUserUniversalTransferHistoryRequest($type, $startTime, $endTime, $current, $size, $fromSymbol, $toSymbol, $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\QueryUserUniversalTransferHistoryResponse',
                        $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\QueryUserUniversalTransferHistoryResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\QueryUserUniversalTransferHistoryResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'queryUserUniversalTransferHistory'.
     *
     * @param string      $type       (required)
     * @param null|int    $startTime  (optional)
     * @param null|int    $endTime    (optional)
     * @param null|int    $current    current page, default 1, the min value is 1 (optional)
     * @param null|int    $size       page size, default 10, the max value is 100 (optional)
     * @param null|string $fromSymbol (optional)
     * @param null|string $toSymbol   (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function queryUserUniversalTransferHistoryRequest($type, $startTime = null, $endTime = null, $current = null, $size = null, $fromSymbol = null, $toSymbol = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['queryUserUniversalTransferHistory'][0];

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

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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $type,
            'type', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // 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(
            $current,
            'current', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $size,
            'size', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $fromSymbol,
            'fromSymbol', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $toSymbol,
            'toSymbol', // param base name
            'string', // 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 queryUserWalletBalance.
     *
     * Query User Wallet Balance (USER_DATA)
     *
     * @param null|string $quoteAsset &#x60;USDT&#x60;, &#x60;ETH&#x60;, &#x60;USDC&#x60;, &#x60;BNB&#x60;, etc. default &#x60;BTC&#x60; (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<QueryUserWalletBalanceResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function queryUserWalletBalance($quoteAsset = null, $recvWindow = null): ApiResponse
    {
        return $this->queryUserWalletBalanceWithHttpInfo($quoteAsset, $recvWindow);
    }

    /**
     * Operation queryUserWalletBalanceWithHttpInfo.
     *
     * Query User Wallet Balance (USER_DATA)
     *
     * @param null|string $quoteAsset &#x60;USDT&#x60;, &#x60;ETH&#x60;, &#x60;USDC&#x60;, &#x60;BNB&#x60;, etc. default &#x60;BTC&#x60; (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<QueryUserWalletBalanceResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function queryUserWalletBalanceWithHttpInfo($quoteAsset = null, $recvWindow = null): ApiResponse
    {
        $request = $this->queryUserWalletBalanceRequest($quoteAsset, $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\QueryUserWalletBalanceResponse',
                        $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\QueryUserWalletBalanceResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\QueryUserWalletBalanceResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'queryUserWalletBalance'.
     *
     * @param null|string $quoteAsset &#x60;USDT&#x60;, &#x60;ETH&#x60;, &#x60;USDC&#x60;, &#x60;BNB&#x60;, etc. default &#x60;BTC&#x60; (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function queryUserWalletBalanceRequest($quoteAsset = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['queryUserWalletBalance'][0];

        $resourcePath = '/sapi/v1/asset/wallet/balance';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $quoteAsset,
            'quoteAsset', // param base name
            'string', // 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 toggleBnbBurnOnSpotTradeAndMarginInterest.
     *
     * Toggle BNB Burn On Spot Trade And Margin Interest (USER_DATA)
     *
     * @param ToggleBnbBurnOnSpotTradeAndMarginInterestRequest $toggleBnbBurnOnSpotTradeAndMarginInterestRequest toggleBnbBurnOnSpotTradeAndMarginInterestRequest (required)
     *
     * @return ApiResponse<ToggleBnbBurnOnSpotTradeAndMarginInterestResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function toggleBnbBurnOnSpotTradeAndMarginInterest($toggleBnbBurnOnSpotTradeAndMarginInterestRequest): ApiResponse
    {
        return $this->toggleBnbBurnOnSpotTradeAndMarginInterestWithHttpInfo($toggleBnbBurnOnSpotTradeAndMarginInterestRequest);
    }

    /**
     * Operation toggleBnbBurnOnSpotTradeAndMarginInterestWithHttpInfo.
     *
     * Toggle BNB Burn On Spot Trade And Margin Interest (USER_DATA)
     *
     * @param ToggleBnbBurnOnSpotTradeAndMarginInterestRequest $toggleBnbBurnOnSpotTradeAndMarginInterestRequest (required)
     *
     * @return ApiResponse<ToggleBnbBurnOnSpotTradeAndMarginInterestResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function toggleBnbBurnOnSpotTradeAndMarginInterestWithHttpInfo($toggleBnbBurnOnSpotTradeAndMarginInterestRequest): ApiResponse
    {
        $request = $this->toggleBnbBurnOnSpotTradeAndMarginInterestRequest($toggleBnbBurnOnSpotTradeAndMarginInterestRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

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

        $getters = $toggleBnbBurnOnSpotTradeAndMarginInterestRequest::getters();
        $formParams = [];
        foreach ($getters as $property => $getter) {
            $value = $toggleBnbBurnOnSpotTradeAndMarginInterestRequest->{$getter}();
            if (!empty($value)) {
                $formParams[$property] = $toggleBnbBurnOnSpotTradeAndMarginInterestRequest->{$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($toggleBnbBurnOnSpotTradeAndMarginInterestRequest)) {
            if (false !== stripos($headers['Content-Type'], 'application/json')) {
                // if Content-Type contains "application/json", json_encode the body
                $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($toggleBnbBurnOnSpotTradeAndMarginInterestRequest));
            } else {
                $httpBody = $toggleBnbBurnOnSpotTradeAndMarginInterestRequest;
            }
        }

        $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 tradeFee.
     *
     * Trade Fee (USER_DATA)
     *
     * @param null|string $symbol     symbol (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<TradeFeeResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function tradeFee($symbol = null, $recvWindow = null): ApiResponse
    {
        return $this->tradeFeeWithHttpInfo($symbol, $recvWindow);
    }

    /**
     * Operation tradeFeeWithHttpInfo.
     *
     * Trade Fee (USER_DATA)
     *
     * @param null|string $symbol     (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<TradeFeeResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function tradeFeeWithHttpInfo($symbol = null, $recvWindow = null): ApiResponse
    {
        $request = $this->tradeFeeRequest($symbol, $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\TradeFeeResponse',
                        $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\TradeFeeResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Wallet\Model\TradeFeeResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'tradeFee'.
     *
     * @param null|string $symbol     (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function tradeFeeRequest($symbol = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['tradeFee'][0];

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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $symbol,
            'symbol', // param base name
            'string', // 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 userAsset.
     *
     * User Asset (USER_DATA)
     *
     * @param UserAssetRequest $userAssetRequest userAssetRequest (required)
     *
     * @return ApiResponse<UserAssetResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function userAsset($userAssetRequest): ApiResponse
    {
        return $this->userAssetWithHttpInfo($userAssetRequest);
    }

    /**
     * Operation userAssetWithHttpInfo.
     *
     * User Asset (USER_DATA)
     *
     * @param UserAssetRequest $userAssetRequest (required)
     *
     * @return ApiResponse<UserAssetResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function userAssetWithHttpInfo($userAssetRequest): ApiResponse
    {
        $request = $this->userAssetRequest($userAssetRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

        $resourcePath = '/sapi/v3/asset/getUserAsset';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        $getters = $userAssetRequest::getters();
        $formParams = [];
        foreach ($getters as $property => $getter) {
            $value = $userAssetRequest->{$getter}();
            if (!empty($value)) {
                $formParams[$property] = $userAssetRequest->{$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($userAssetRequest)) {
            if (false !== stripos($headers['Content-Type'], 'application/json')) {
                // if Content-Type contains "application/json", json_encode the body
                $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($userAssetRequest));
            } else {
                $httpBody = $userAssetRequest;
            }
        }

        $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 userUniversalTransfer.
     *
     * User Universal Transfer (USER_DATA)
     *
     * @param UserUniversalTransferRequest $userUniversalTransferRequest userUniversalTransferRequest (required)
     *
     * @return ApiResponse<UserUniversalTransferResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function userUniversalTransfer($userUniversalTransferRequest): ApiResponse
    {
        return $this->userUniversalTransferWithHttpInfo($userUniversalTransferRequest);
    }

    /**
     * Operation userUniversalTransferWithHttpInfo.
     *
     * User Universal Transfer (USER_DATA)
     *
     * @param UserUniversalTransferRequest $userUniversalTransferRequest (required)
     *
     * @return ApiResponse<UserUniversalTransferResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function userUniversalTransferWithHttpInfo($userUniversalTransferRequest): ApiResponse
    {
        $request = $this->userUniversalTransferRequest($userUniversalTransferRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

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

        $getters = $userUniversalTransferRequest::getters();
        $formParams = [];
        foreach ($getters as $property => $getter) {
            $value = $userUniversalTransferRequest->{$getter}();
            if (!empty($value)) {
                $formParams[$property] = $userUniversalTransferRequest->{$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($userUniversalTransferRequest)) {
            if (false !== stripos($headers['Content-Type'], 'application/json')) {
                // if Content-Type contains "application/json", json_encode the body
                $httpBody = Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($userUniversalTransferRequest));
            } else {
                $httpBody = $userUniversalTransferRequest;
            }
        }

        $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;
    }
}
