<?php

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

/**
 * Binance Mining REST API.
 *
 * OpenAPI Specification for the Binance Mining 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\Mining\Api;

use Binance\Client\Mining\Model\AccountListResponse;
use Binance\Client\Mining\Model\AcquiringAlgorithmResponse;
use Binance\Client\Mining\Model\AcquiringCoinnameResponse;
use Binance\Client\Mining\Model\CancelHashrateResaleConfigurationRequest;
use Binance\Client\Mining\Model\CancelHashrateResaleConfigurationResponse;
use Binance\Client\Mining\Model\EarningsListResponse;
use Binance\Client\Mining\Model\ExtraBonusListResponse;
use Binance\Client\Mining\Model\HashrateResaleDetailResponse;
use Binance\Client\Mining\Model\HashrateResaleListResponse;
use Binance\Client\Mining\Model\HashrateResaleRequestRequest;
use Binance\Client\Mining\Model\HashrateResaleRequestResponse;
use Binance\Client\Mining\Model\MiningAccountEarningResponse;
use Binance\Client\Mining\Model\RequestForDetailMinerListResponse;
use Binance\Client\Mining\Model\RequestForMinerListResponse;
use Binance\Client\Mining\Model\StatisticListResponse;
use Binance\Common\ApiException;
use Binance\Common\Auth\SignerFactory;
use Binance\Common\Auth\SignerInterface;
use Binance\Common\CommonUtils;
use Binance\Common\Configuration;
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;

/**
 * MiningApi Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */
class MiningApi
{
    /** @var string[] */
    public const contentTypes = [
        'accountList' => ['application/x-www-form-urlencoded'],
        'acquiringAlgorithm' => ['application/x-www-form-urlencoded'],
        'acquiringCoinname' => ['application/x-www-form-urlencoded'],
        'cancelHashrateResaleConfiguration' => ['application/x-www-form-urlencoded'],
        'earningsList' => ['application/x-www-form-urlencoded'],
        'extraBonusList' => ['application/x-www-form-urlencoded'],
        'hashrateResaleDetail' => ['application/x-www-form-urlencoded'],
        'hashrateResaleList' => ['application/x-www-form-urlencoded'],
        'hashrateResaleRequest' => ['application/x-www-form-urlencoded'],
        'miningAccountEarning' => ['application/x-www-form-urlencoded'],
        'requestForDetailMinerList' => ['application/x-www-form-urlencoded'],
        'requestForMinerList' => ['application/x-www-form-urlencoded'],
        'statisticList' => ['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('mining');
    }

    /**
     * Operation accountList.
     *
     * Account List(USER_DATA)
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param string   $userName   Mining account test (required)
     * @param null|int $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<AccountListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function accountList($algo, $userName, $recvWindow = null): ApiResponse
    {
        return $this->accountListWithHttpInfo($algo, $userName, $recvWindow);
    }

    /**
     * Operation accountListWithHttpInfo.
     *
     * Account List(USER_DATA)
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param string   $userName   Mining account test (required)
     * @param null|int $recvWindow (optional)
     *
     * @return ApiResponse<AccountListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function accountListWithHttpInfo($algo, $userName, $recvWindow = null): ApiResponse
    {
        $request = $this->accountListRequest($algo, $userName, $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\Mining\Model\AccountListResponse',
                        $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\Mining\Model\AccountListResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Mining\Model\AccountListResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'accountList'.
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param string   $userName   Mining account test (required)
     * @param null|int $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function accountListRequest($algo, $userName, $recvWindow = null)
    {
        $contentType = self::contentTypes['accountList'][0];

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

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

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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $algo,
            'algo', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $userName,
            'userName', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // 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 acquiringAlgorithm.
     *
     * Acquiring Algorithm(MARKET_DATA)
     *
     * @return ApiResponse<AcquiringAlgorithmResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function acquiringAlgorithm(): ApiResponse
    {
        return $this->acquiringAlgorithmWithHttpInfo();
    }

    /**
     * Operation acquiringAlgorithmWithHttpInfo.
     *
     * Acquiring Algorithm(MARKET_DATA)
     *
     * @return ApiResponse<AcquiringAlgorithmResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function acquiringAlgorithmWithHttpInfo(): ApiResponse
    {
        $request = $this->acquiringAlgorithmRequest();

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

                    throw $e;
            }

            throw $e;
        }
    }

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

        $resourcePath = '/sapi/v1/mining/pub/algoList';
        $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 acquiringCoinname.
     *
     * Acquiring CoinName(MARKET_DATA)
     *
     * @return ApiResponse<AcquiringCoinnameResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function acquiringCoinname(): ApiResponse
    {
        return $this->acquiringCoinnameWithHttpInfo();
    }

    /**
     * Operation acquiringCoinnameWithHttpInfo.
     *
     * Acquiring CoinName(MARKET_DATA)
     *
     * @return ApiResponse<AcquiringCoinnameResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function acquiringCoinnameWithHttpInfo(): ApiResponse
    {
        $request = $this->acquiringCoinnameRequest();

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

                    throw $e;
            }

            throw $e;
        }
    }

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

        $resourcePath = '/sapi/v1/mining/pub/coinList';
        $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 cancelHashrateResaleConfiguration.
     *
     * Cancel hashrate resale configuration(USER_DATA)
     *
     * @param CancelHashrateResaleConfigurationRequest $cancelHashrateResaleConfigurationRequest cancelHashrateResaleConfigurationRequest (required)
     *
     * @return ApiResponse<CancelHashrateResaleConfigurationResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function cancelHashrateResaleConfiguration($cancelHashrateResaleConfigurationRequest): ApiResponse
    {
        return $this->cancelHashrateResaleConfigurationWithHttpInfo($cancelHashrateResaleConfigurationRequest);
    }

    /**
     * Operation cancelHashrateResaleConfigurationWithHttpInfo.
     *
     * Cancel hashrate resale configuration(USER_DATA)
     *
     * @param CancelHashrateResaleConfigurationRequest $cancelHashrateResaleConfigurationRequest (required)
     *
     * @return ApiResponse<CancelHashrateResaleConfigurationResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function cancelHashrateResaleConfigurationWithHttpInfo($cancelHashrateResaleConfigurationRequest): ApiResponse
    {
        $request = $this->cancelHashrateResaleConfigurationRequest($cancelHashrateResaleConfigurationRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

        $resourcePath = '/sapi/v1/mining/hash-transfer/config/cancel';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        $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 earningsList.
     *
     * Earnings List(USER_DATA)
     *
     * @param string      $algo       Algorithm(sha256) sha256 (required)
     * @param string      $userName   Mining account test (required)
     * @param null|string $coin       Coin Name (optional)
     * @param null|int    $startDate  Millisecond timestamp (optional)
     * @param null|int    $endDate    Millisecond timestamp (optional)
     * @param null|int    $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int    $pageSize   Min 10,Max 200 (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<EarningsListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function earningsList($algo, $userName, $coin = null, $startDate = null, $endDate = null, $pageIndex = null, $pageSize = null, $recvWindow = null): ApiResponse
    {
        return $this->earningsListWithHttpInfo($algo, $userName, $coin, $startDate, $endDate, $pageIndex, $pageSize, $recvWindow);
    }

    /**
     * Operation earningsListWithHttpInfo.
     *
     * Earnings List(USER_DATA)
     *
     * @param string      $algo       Algorithm(sha256) sha256 (required)
     * @param string      $userName   Mining account test (required)
     * @param null|string $coin       Coin Name (optional)
     * @param null|int    $startDate  Millisecond timestamp (optional)
     * @param null|int    $endDate    Millisecond timestamp (optional)
     * @param null|int    $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int    $pageSize   Min 10,Max 200 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<EarningsListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function earningsListWithHttpInfo($algo, $userName, $coin = null, $startDate = null, $endDate = null, $pageIndex = null, $pageSize = null, $recvWindow = null): ApiResponse
    {
        $request = $this->earningsListRequest($algo, $userName, $coin, $startDate, $endDate, $pageIndex, $pageSize, $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\Mining\Model\EarningsListResponse',
                        $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\Mining\Model\EarningsListResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Mining\Model\EarningsListResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'earningsList'.
     *
     * @param string      $algo       Algorithm(sha256) sha256 (required)
     * @param string      $userName   Mining account test (required)
     * @param null|string $coin       Coin Name (optional)
     * @param null|int    $startDate  Millisecond timestamp (optional)
     * @param null|int    $endDate    Millisecond timestamp (optional)
     * @param null|int    $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int    $pageSize   Min 10,Max 200 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function earningsListRequest($algo, $userName, $coin = null, $startDate = null, $endDate = null, $pageIndex = null, $pageSize = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['earningsList'][0];

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

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

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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $algo,
            'algo', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $userName,
            'userName', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $coin,
            'coin', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $startDate,
            'startDate', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $endDate,
            'endDate', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pageIndex,
            'pageIndex', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pageSize,
            'pageSize', // 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 extraBonusList.
     *
     * Extra Bonus List(USER_DATA)
     *
     * @param string      $algo       Algorithm(sha256) sha256 (required)
     * @param string      $userName   Mining account test (required)
     * @param null|string $coin       Coin Name (optional)
     * @param null|int    $startDate  Millisecond timestamp (optional)
     * @param null|int    $endDate    Millisecond timestamp (optional)
     * @param null|int    $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int    $pageSize   Min 10,Max 200 (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<ExtraBonusListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function extraBonusList($algo, $userName, $coin = null, $startDate = null, $endDate = null, $pageIndex = null, $pageSize = null, $recvWindow = null): ApiResponse
    {
        return $this->extraBonusListWithHttpInfo($algo, $userName, $coin, $startDate, $endDate, $pageIndex, $pageSize, $recvWindow);
    }

    /**
     * Operation extraBonusListWithHttpInfo.
     *
     * Extra Bonus List(USER_DATA)
     *
     * @param string      $algo       Algorithm(sha256) sha256 (required)
     * @param string      $userName   Mining account test (required)
     * @param null|string $coin       Coin Name (optional)
     * @param null|int    $startDate  Millisecond timestamp (optional)
     * @param null|int    $endDate    Millisecond timestamp (optional)
     * @param null|int    $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int    $pageSize   Min 10,Max 200 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<ExtraBonusListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function extraBonusListWithHttpInfo($algo, $userName, $coin = null, $startDate = null, $endDate = null, $pageIndex = null, $pageSize = null, $recvWindow = null): ApiResponse
    {
        $request = $this->extraBonusListRequest($algo, $userName, $coin, $startDate, $endDate, $pageIndex, $pageSize, $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\Mining\Model\ExtraBonusListResponse',
                        $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\Mining\Model\ExtraBonusListResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Mining\Model\ExtraBonusListResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'extraBonusList'.
     *
     * @param string      $algo       Algorithm(sha256) sha256 (required)
     * @param string      $userName   Mining account test (required)
     * @param null|string $coin       Coin Name (optional)
     * @param null|int    $startDate  Millisecond timestamp (optional)
     * @param null|int    $endDate    Millisecond timestamp (optional)
     * @param null|int    $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int    $pageSize   Min 10,Max 200 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function extraBonusListRequest($algo, $userName, $coin = null, $startDate = null, $endDate = null, $pageIndex = null, $pageSize = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['extraBonusList'][0];

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

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

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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $algo,
            'algo', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $userName,
            'userName', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $coin,
            'coin', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $startDate,
            'startDate', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $endDate,
            'endDate', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pageIndex,
            'pageIndex', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pageSize,
            'pageSize', // 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 hashrateResaleDetail.
     *
     * Hashrate Resale Detail(USER_DATA)
     *
     * @param int      $configId   Mining ID 168 (required)
     * @param string   $userName   Mining account test (required)
     * @param null|int $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int $pageSize   Min 10,Max 200 (optional)
     * @param null|int $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<HashrateResaleDetailResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function hashrateResaleDetail($configId, $userName, $pageIndex = null, $pageSize = null, $recvWindow = null): ApiResponse
    {
        return $this->hashrateResaleDetailWithHttpInfo($configId, $userName, $pageIndex, $pageSize, $recvWindow);
    }

    /**
     * Operation hashrateResaleDetailWithHttpInfo.
     *
     * Hashrate Resale Detail(USER_DATA)
     *
     * @param int      $configId   Mining ID 168 (required)
     * @param string   $userName   Mining account test (required)
     * @param null|int $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int $pageSize   Min 10,Max 200 (optional)
     * @param null|int $recvWindow (optional)
     *
     * @return ApiResponse<HashrateResaleDetailResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function hashrateResaleDetailWithHttpInfo($configId, $userName, $pageIndex = null, $pageSize = null, $recvWindow = null): ApiResponse
    {
        $request = $this->hashrateResaleDetailRequest($configId, $userName, $pageIndex, $pageSize, $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\Mining\Model\HashrateResaleDetailResponse',
                        $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\Mining\Model\HashrateResaleDetailResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Mining\Model\HashrateResaleDetailResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'hashrateResaleDetail'.
     *
     * @param int      $configId   Mining ID 168 (required)
     * @param string   $userName   Mining account test (required)
     * @param null|int $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int $pageSize   Min 10,Max 200 (optional)
     * @param null|int $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function hashrateResaleDetailRequest($configId, $userName, $pageIndex = null, $pageSize = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['hashrateResaleDetail'][0];

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

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

        $resourcePath = '/sapi/v1/mining/hash-transfer/profit/details';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $configId,
            'configId', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $userName,
            'userName', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pageIndex,
            'pageIndex', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pageSize,
            'pageSize', // 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 hashrateResaleList.
     *
     * Hashrate Resale List
     *
     * @param null|int $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int $pageSize   Min 10,Max 200 (optional)
     * @param null|int $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<HashrateResaleListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function hashrateResaleList($pageIndex = null, $pageSize = null, $recvWindow = null): ApiResponse
    {
        return $this->hashrateResaleListWithHttpInfo($pageIndex, $pageSize, $recvWindow);
    }

    /**
     * Operation hashrateResaleListWithHttpInfo.
     *
     * Hashrate Resale List
     *
     * @param null|int $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int $pageSize   Min 10,Max 200 (optional)
     * @param null|int $recvWindow (optional)
     *
     * @return ApiResponse<HashrateResaleListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function hashrateResaleListWithHttpInfo($pageIndex = null, $pageSize = null, $recvWindow = null): ApiResponse
    {
        $request = $this->hashrateResaleListRequest($pageIndex, $pageSize, $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\Mining\Model\HashrateResaleListResponse',
                        $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\Mining\Model\HashrateResaleListResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Mining\Model\HashrateResaleListResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'hashrateResaleList'.
     *
     * @param null|int $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int $pageSize   Min 10,Max 200 (optional)
     * @param null|int $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function hashrateResaleListRequest($pageIndex = null, $pageSize = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['hashrateResaleList'][0];

        $resourcePath = '/sapi/v1/mining/hash-transfer/config/details/list';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pageIndex,
            'pageIndex', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pageSize,
            'pageSize', // 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 hashrateResaleRequest.
     *
     * Hashrate Resale Request(USER_DATA)
     *
     * @param HashrateResaleRequestRequest $hashrateResaleRequestRequest hashrateResaleRequestRequest (required)
     *
     * @return ApiResponse<HashrateResaleRequestResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function hashrateResaleRequest($hashrateResaleRequestRequest): ApiResponse
    {
        return $this->hashrateResaleRequestWithHttpInfo($hashrateResaleRequestRequest);
    }

    /**
     * Operation hashrateResaleRequestWithHttpInfo.
     *
     * Hashrate Resale Request(USER_DATA)
     *
     * @param HashrateResaleRequestRequest $hashrateResaleRequestRequest (required)
     *
     * @return ApiResponse<HashrateResaleRequestResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function hashrateResaleRequestWithHttpInfo($hashrateResaleRequestRequest): ApiResponse
    {
        $request = $this->hashrateResaleRequestRequest($hashrateResaleRequestRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

        $resourcePath = '/sapi/v1/mining/hash-transfer/config';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        $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 miningAccountEarning.
     *
     * Mining Account Earning(USER_DATA)
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param null|int $startDate  Millisecond timestamp (optional)
     * @param null|int $endDate    Millisecond timestamp (optional)
     * @param null|int $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int $pageSize   Min 10,Max 200 (optional)
     * @param null|int $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<MiningAccountEarningResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function miningAccountEarning($algo, $startDate = null, $endDate = null, $pageIndex = null, $pageSize = null, $recvWindow = null): ApiResponse
    {
        return $this->miningAccountEarningWithHttpInfo($algo, $startDate, $endDate, $pageIndex, $pageSize, $recvWindow);
    }

    /**
     * Operation miningAccountEarningWithHttpInfo.
     *
     * Mining Account Earning(USER_DATA)
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param null|int $startDate  Millisecond timestamp (optional)
     * @param null|int $endDate    Millisecond timestamp (optional)
     * @param null|int $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int $pageSize   Min 10,Max 200 (optional)
     * @param null|int $recvWindow (optional)
     *
     * @return ApiResponse<MiningAccountEarningResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function miningAccountEarningWithHttpInfo($algo, $startDate = null, $endDate = null, $pageIndex = null, $pageSize = null, $recvWindow = null): ApiResponse
    {
        $request = $this->miningAccountEarningRequest($algo, $startDate, $endDate, $pageIndex, $pageSize, $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\Mining\Model\MiningAccountEarningResponse',
                        $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\Mining\Model\MiningAccountEarningResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Mining\Model\MiningAccountEarningResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'miningAccountEarning'.
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param null|int $startDate  Millisecond timestamp (optional)
     * @param null|int $endDate    Millisecond timestamp (optional)
     * @param null|int $pageIndex  Page number, empty default first page, starting from 1 (optional)
     * @param null|int $pageSize   Min 10,Max 200 (optional)
     * @param null|int $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function miningAccountEarningRequest($algo, $startDate = null, $endDate = null, $pageIndex = null, $pageSize = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['miningAccountEarning'][0];

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

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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $algo,
            'algo', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $startDate,
            'startDate', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $endDate,
            'endDate', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pageIndex,
            'pageIndex', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pageSize,
            'pageSize', // 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 requestForDetailMinerList.
     *
     * Request for Detail Miner List(USER_DATA)
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param string   $userName   Mining account test (required)
     * @param string   $workerName Miner’s name(required) bhdc1.16A10404B (required)
     * @param null|int $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<RequestForDetailMinerListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function requestForDetailMinerList($algo, $userName, $workerName, $recvWindow = null): ApiResponse
    {
        return $this->requestForDetailMinerListWithHttpInfo($algo, $userName, $workerName, $recvWindow);
    }

    /**
     * Operation requestForDetailMinerListWithHttpInfo.
     *
     * Request for Detail Miner List(USER_DATA)
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param string   $userName   Mining account test (required)
     * @param string   $workerName Miner’s name(required) bhdc1.16A10404B (required)
     * @param null|int $recvWindow (optional)
     *
     * @return ApiResponse<RequestForDetailMinerListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function requestForDetailMinerListWithHttpInfo($algo, $userName, $workerName, $recvWindow = null): ApiResponse
    {
        $request = $this->requestForDetailMinerListRequest($algo, $userName, $workerName, $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\Mining\Model\RequestForDetailMinerListResponse',
                        $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\Mining\Model\RequestForDetailMinerListResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Mining\Model\RequestForDetailMinerListResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'requestForDetailMinerList'.
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param string   $userName   Mining account test (required)
     * @param string   $workerName Miner’s name(required) bhdc1.16A10404B (required)
     * @param null|int $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function requestForDetailMinerListRequest($algo, $userName, $workerName, $recvWindow = null)
    {
        $contentType = self::contentTypes['requestForDetailMinerList'][0];

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

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

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

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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $algo,
            'algo', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $userName,
            'userName', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $workerName,
            'workerName', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // 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 requestForMinerList.
     *
     * Request for Miner List(USER_DATA)
     *
     * @param string   $algo         Algorithm(sha256) sha256 (required)
     * @param string   $userName     Mining account test (required)
     * @param null|int $pageIndex    Page number, empty default first page, starting from 1 (optional)
     * @param null|int $sort         sort sequence(default&#x3D;0)0 positive sequence，1 negative sequence (optional)
     * @param null|int $sortColumn   Sort by( default 1): &lt;br&gt;&lt;/br&gt;1: miner name, &lt;br&gt;&lt;/br&gt;2: real-time computing power, &lt;br&gt;&lt;/br&gt;3: daily average computing power, &lt;br&gt;&lt;/br&gt;4: real-time rejection rate, &lt;br&gt;&lt;/br&gt;5: last submission time (optional)
     * @param null|int $workerStatus miners status(default&#x3D;0),0 all，1 valid，2 invalid，3 failure (optional)
     * @param null|int $recvWindow   recvWindow (optional)
     *
     * @return ApiResponse<RequestForMinerListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function requestForMinerList($algo, $userName, $pageIndex = null, $sort = null, $sortColumn = null, $workerStatus = null, $recvWindow = null): ApiResponse
    {
        return $this->requestForMinerListWithHttpInfo($algo, $userName, $pageIndex, $sort, $sortColumn, $workerStatus, $recvWindow);
    }

    /**
     * Operation requestForMinerListWithHttpInfo.
     *
     * Request for Miner List(USER_DATA)
     *
     * @param string   $algo         Algorithm(sha256) sha256 (required)
     * @param string   $userName     Mining account test (required)
     * @param null|int $pageIndex    Page number, empty default first page, starting from 1 (optional)
     * @param null|int $sort         sort sequence(default&#x3D;0)0 positive sequence，1 negative sequence (optional)
     * @param null|int $sortColumn   Sort by( default 1): &lt;br&gt;&lt;/br&gt;1: miner name, &lt;br&gt;&lt;/br&gt;2: real-time computing power, &lt;br&gt;&lt;/br&gt;3: daily average computing power, &lt;br&gt;&lt;/br&gt;4: real-time rejection rate, &lt;br&gt;&lt;/br&gt;5: last submission time (optional)
     * @param null|int $workerStatus miners status(default&#x3D;0),0 all，1 valid，2 invalid，3 failure (optional)
     * @param null|int $recvWindow   (optional)
     *
     * @return ApiResponse<RequestForMinerListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function requestForMinerListWithHttpInfo($algo, $userName, $pageIndex = null, $sort = null, $sortColumn = null, $workerStatus = null, $recvWindow = null): ApiResponse
    {
        $request = $this->requestForMinerListRequest($algo, $userName, $pageIndex, $sort, $sortColumn, $workerStatus, $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\Mining\Model\RequestForMinerListResponse',
                        $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\Mining\Model\RequestForMinerListResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Mining\Model\RequestForMinerListResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'requestForMinerList'.
     *
     * @param string   $algo         Algorithm(sha256) sha256 (required)
     * @param string   $userName     Mining account test (required)
     * @param null|int $pageIndex    Page number, empty default first page, starting from 1 (optional)
     * @param null|int $sort         sort sequence(default&#x3D;0)0 positive sequence，1 negative sequence (optional)
     * @param null|int $sortColumn   Sort by( default 1): &lt;br&gt;&lt;/br&gt;1: miner name, &lt;br&gt;&lt;/br&gt;2: real-time computing power, &lt;br&gt;&lt;/br&gt;3: daily average computing power, &lt;br&gt;&lt;/br&gt;4: real-time rejection rate, &lt;br&gt;&lt;/br&gt;5: last submission time (optional)
     * @param null|int $workerStatus miners status(default&#x3D;0),0 all，1 valid，2 invalid，3 failure (optional)
     * @param null|int $recvWindow   (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function requestForMinerListRequest($algo, $userName, $pageIndex = null, $sort = null, $sortColumn = null, $workerStatus = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['requestForMinerList'][0];

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

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

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

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $algo,
            'algo', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $userName,
            'userName', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $pageIndex,
            'pageIndex', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $sort,
            'sort', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $sortColumn,
            'sortColumn', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $workerStatus,
            'workerStatus', // 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 statisticList.
     *
     * Statistic List(USER_DATA)
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param string   $userName   Mining account test (required)
     * @param null|int $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<StatisticListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function statisticList($algo, $userName, $recvWindow = null): ApiResponse
    {
        return $this->statisticListWithHttpInfo($algo, $userName, $recvWindow);
    }

    /**
     * Operation statisticListWithHttpInfo.
     *
     * Statistic List(USER_DATA)
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param string   $userName   Mining account test (required)
     * @param null|int $recvWindow (optional)
     *
     * @return ApiResponse<StatisticListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function statisticListWithHttpInfo($algo, $userName, $recvWindow = null): ApiResponse
    {
        $request = $this->statisticListRequest($algo, $userName, $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\Mining\Model\StatisticListResponse',
                        $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\Mining\Model\StatisticListResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Mining\Model\StatisticListResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'statisticList'.
     *
     * @param string   $algo       Algorithm(sha256) sha256 (required)
     * @param string   $userName   Mining account test (required)
     * @param null|int $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function statisticListRequest($algo, $userName, $recvWindow = null)
    {
        $contentType = self::contentTypes['statisticList'][0];

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

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

        $resourcePath = '/sapi/v1/mining/statistics/user/status';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $algo,
            'algo', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $userName,
            'userName', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // 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
        );
    }

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