<?php

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

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

use Binance\Client\Staking\Model\GetOnChainYieldsLockedPersonalLeftQuotaResponse;
use Binance\Client\Staking\Model\GetOnChainYieldsLockedProductListResponse;
use Binance\Client\Staking\Model\GetOnChainYieldsLockedProductPositionResponse;
use Binance\Client\Staking\Model\GetOnChainYieldsLockedRedemptionRecordResponse;
use Binance\Client\Staking\Model\GetOnChainYieldsLockedRewardsHistoryResponse;
use Binance\Client\Staking\Model\GetOnChainYieldsLockedSubscriptionPreviewResponse;
use Binance\Client\Staking\Model\GetOnChainYieldsLockedSubscriptionRecordResponse;
use Binance\Client\Staking\Model\OnChainYieldsAccountResponse;
use Binance\Client\Staking\Model\RedeemOnChainYieldsLockedProductRequest;
use Binance\Client\Staking\Model\RedeemOnChainYieldsLockedProductResponse;
use Binance\Client\Staking\Model\SetOnChainYieldsLockedAutoSubscribeRequest;
use Binance\Client\Staking\Model\SetOnChainYieldsLockedAutoSubscribeResponse;
use Binance\Client\Staking\Model\SetOnChainYieldsLockedProductRedeemOptionRequest;
use Binance\Client\Staking\Model\SetOnChainYieldsLockedProductRedeemOptionResponse;
use Binance\Client\Staking\Model\SubscribeOnChainYieldsLockedProductRequest;
use Binance\Client\Staking\Model\SubscribeOnChainYieldsLockedProductResponse;
use Binance\Common\ApiException;
use Binance\Common\Auth\SignerFactory;
use Binance\Common\Auth\SignerInterface;
use Binance\Common\CommonUtils;
use Binance\Common\Configuration\ClientConfiguration;
use Binance\Common\Dtos\ApiResponse;
use Binance\Common\HeaderSelector;
use Binance\Common\HttpClient;
use Binance\Common\ObjectSerializer;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Utils;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

/**
 * OnChainYieldsApi Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */
class OnChainYieldsApi
{
    /** @var string[] */
    public const contentTypes = [
        'getOnChainYieldsLockedPersonalLeftQuota' => ['application/x-www-form-urlencoded'],
        'getOnChainYieldsLockedProductList' => ['application/x-www-form-urlencoded'],
        'getOnChainYieldsLockedProductPosition' => ['application/x-www-form-urlencoded'],
        'getOnChainYieldsLockedRedemptionRecord' => ['application/x-www-form-urlencoded'],
        'getOnChainYieldsLockedRewardsHistory' => ['application/x-www-form-urlencoded'],
        'getOnChainYieldsLockedSubscriptionPreview' => ['application/x-www-form-urlencoded'],
        'getOnChainYieldsLockedSubscriptionRecord' => ['application/x-www-form-urlencoded'],
        'onChainYieldsAccount' => ['application/x-www-form-urlencoded'],
        'redeemOnChainYieldsLockedProduct' => ['application/x-www-form-urlencoded'],
        'setOnChainYieldsLockedAutoSubscribe' => ['application/x-www-form-urlencoded'],
        'setOnChainYieldsLockedProductRedeemOption' => ['application/x-www-form-urlencoded'],
        'subscribeOnChainYieldsLockedProduct' => ['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('staking');
    }

    /**
     * Operation getOnChainYieldsLockedPersonalLeftQuota.
     *
     * Get On-chain Yields Locked Personal Left Quota (USER_DATA)
     *
     * @param string   $projectId  projectId (required)
     * @param null|int $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedPersonalLeftQuotaResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedPersonalLeftQuota($projectId, $recvWindow = null): ApiResponse
    {
        return $this->getOnChainYieldsLockedPersonalLeftQuotaWithHttpInfo($projectId, $recvWindow);
    }

    /**
     * Operation getOnChainYieldsLockedPersonalLeftQuotaWithHttpInfo.
     *
     * Get On-chain Yields Locked Personal Left Quota (USER_DATA)
     *
     * @param string   $projectId  (required)
     * @param null|int $recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedPersonalLeftQuotaResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedPersonalLeftQuotaWithHttpInfo($projectId, $recvWindow = null): ApiResponse
    {
        $request = $this->getOnChainYieldsLockedPersonalLeftQuotaRequest($projectId, $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\Staking\Model\GetOnChainYieldsLockedPersonalLeftQuotaResponse',
                        $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\Staking\Model\GetOnChainYieldsLockedPersonalLeftQuotaResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Staking\Model\GetOnChainYieldsLockedPersonalLeftQuotaResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

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

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

        $resourcePath = '/sapi/v1/onchain-yields/locked/personalLeftQuota';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $projectId,
            'projectId', // 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 getOnChainYieldsLockedProductList.
     *
     * Get On-chain Yields Locked Product List (USER_DATA)
     *
     * @param null|string $asset      asset (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedProductListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedProductList($asset = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        return $this->getOnChainYieldsLockedProductListWithHttpInfo($asset, $current, $size, $recvWindow);
    }

    /**
     * Operation getOnChainYieldsLockedProductListWithHttpInfo.
     *
     * Get On-chain Yields Locked Product List (USER_DATA)
     *
     * @param null|string $asset      (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedProductListResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedProductListWithHttpInfo($asset = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        $request = $this->getOnChainYieldsLockedProductListRequest($asset, $current, $size, $recvWindow);

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

            $statusCode = $response->getStatusCode();

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

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'getOnChainYieldsLockedProductList'.
     *
     * @param null|string $asset      (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedProductListRequest($asset = null, $current = null, $size = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['getOnChainYieldsLockedProductList'][0];

        $resourcePath = '/sapi/v1/onchain-yields/locked/list';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

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

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

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

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

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

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

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

    /**
     * Operation getOnChainYieldsLockedProductPosition.
     *
     * Get On-chain Yields Locked Product Position (USER_DATA)
     *
     * @param null|string $asset      asset (optional)
     * @param null|string $positionId positionId (optional)
     * @param null|string $projectId  projectId (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedProductPositionResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedProductPosition($asset = null, $positionId = null, $projectId = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        return $this->getOnChainYieldsLockedProductPositionWithHttpInfo($asset, $positionId, $projectId, $current, $size, $recvWindow);
    }

    /**
     * Operation getOnChainYieldsLockedProductPositionWithHttpInfo.
     *
     * Get On-chain Yields Locked Product Position (USER_DATA)
     *
     * @param null|string $asset      (optional)
     * @param null|string $positionId (optional)
     * @param null|string $projectId  (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedProductPositionResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedProductPositionWithHttpInfo($asset = null, $positionId = null, $projectId = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        $request = $this->getOnChainYieldsLockedProductPositionRequest($asset, $positionId, $projectId, $current, $size, $recvWindow);

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

            $statusCode = $response->getStatusCode();

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

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'getOnChainYieldsLockedProductPosition'.
     *
     * @param null|string $asset      (optional)
     * @param null|string $positionId (optional)
     * @param null|string $projectId  (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedProductPositionRequest($asset = null, $positionId = null, $projectId = null, $current = null, $size = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['getOnChainYieldsLockedProductPosition'][0];

        $resourcePath = '/sapi/v1/onchain-yields/locked/position';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $asset,
            'asset', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $positionId,
            'positionId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $projectId,
            'projectId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $current,
            'current', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $size,
            'size', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $recvWindow,
            'recvWindow', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);

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

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

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

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

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

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

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

    /**
     * Operation getOnChainYieldsLockedRedemptionRecord.
     *
     * Get On-chain Yields Locked Redemption Record (USER_DATA)
     *
     * @param null|string $positionId positionId (optional)
     * @param null|string $redeemId   redeemId (optional)
     * @param null|string $asset      asset (optional)
     * @param null|int    $startTime  startTime (optional)
     * @param null|int    $endTime    endTime (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedRedemptionRecordResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedRedemptionRecord($positionId = null, $redeemId = null, $asset = null, $startTime = null, $endTime = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        return $this->getOnChainYieldsLockedRedemptionRecordWithHttpInfo($positionId, $redeemId, $asset, $startTime, $endTime, $current, $size, $recvWindow);
    }

    /**
     * Operation getOnChainYieldsLockedRedemptionRecordWithHttpInfo.
     *
     * Get On-chain Yields Locked Redemption Record (USER_DATA)
     *
     * @param null|string $positionId (optional)
     * @param null|string $redeemId   (optional)
     * @param null|string $asset      (optional)
     * @param null|int    $startTime  (optional)
     * @param null|int    $endTime    (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedRedemptionRecordResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedRedemptionRecordWithHttpInfo($positionId = null, $redeemId = null, $asset = null, $startTime = null, $endTime = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        $request = $this->getOnChainYieldsLockedRedemptionRecordRequest($positionId, $redeemId, $asset, $startTime, $endTime, $current, $size, $recvWindow);

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

            $statusCode = $response->getStatusCode();

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

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'getOnChainYieldsLockedRedemptionRecord'.
     *
     * @param null|string $positionId (optional)
     * @param null|string $redeemId   (optional)
     * @param null|string $asset      (optional)
     * @param null|int    $startTime  (optional)
     * @param null|int    $endTime    (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedRedemptionRecordRequest($positionId = null, $redeemId = null, $asset = null, $startTime = null, $endTime = null, $current = null, $size = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['getOnChainYieldsLockedRedemptionRecord'][0];

        $resourcePath = '/sapi/v1/onchain-yields/locked/history/redemptionRecord';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $positionId,
            'positionId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $redeemId,
            'redeemId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $asset,
            'asset', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $startTime,
            'startTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $endTime,
            'endTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $current,
            'current', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $size,
            'size', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $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 getOnChainYieldsLockedRewardsHistory.
     *
     * Get On-chain Yields Locked Rewards History (USER_DATA)
     *
     * @param null|string $positionId positionId (optional)
     * @param null|string $asset      asset (optional)
     * @param null|int    $startTime  startTime (optional)
     * @param null|int    $endTime    endTime (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedRewardsHistoryResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedRewardsHistory($positionId = null, $asset = null, $startTime = null, $endTime = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        return $this->getOnChainYieldsLockedRewardsHistoryWithHttpInfo($positionId, $asset, $startTime, $endTime, $current, $size, $recvWindow);
    }

    /**
     * Operation getOnChainYieldsLockedRewardsHistoryWithHttpInfo.
     *
     * Get On-chain Yields Locked Rewards History (USER_DATA)
     *
     * @param null|string $positionId (optional)
     * @param null|string $asset      (optional)
     * @param null|int    $startTime  (optional)
     * @param null|int    $endTime    (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedRewardsHistoryResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedRewardsHistoryWithHttpInfo($positionId = null, $asset = null, $startTime = null, $endTime = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        $request = $this->getOnChainYieldsLockedRewardsHistoryRequest($positionId, $asset, $startTime, $endTime, $current, $size, $recvWindow);

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

            $statusCode = $response->getStatusCode();

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

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'getOnChainYieldsLockedRewardsHistory'.
     *
     * @param null|string $positionId (optional)
     * @param null|string $asset      (optional)
     * @param null|int    $startTime  (optional)
     * @param null|int    $endTime    (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedRewardsHistoryRequest($positionId = null, $asset = null, $startTime = null, $endTime = null, $current = null, $size = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['getOnChainYieldsLockedRewardsHistory'][0];

        $resourcePath = '/sapi/v1/onchain-yields/locked/history/rewardsRecord';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $positionId,
            'positionId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $asset,
            'asset', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $startTime,
            'startTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $endTime,
            'endTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $current,
            'current', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $size,
            'size', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $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 getOnChainYieldsLockedSubscriptionPreview.
     *
     * Get On-chain Yields Locked Subscription Preview (USER_DATA)
     *
     * @param string    $projectId     projectId (required)
     * @param float     $amount        amount (required)
     * @param null|bool $autoSubscribe true or false, default true. (optional)
     * @param null|int  $recvWindow    recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedSubscriptionPreviewResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedSubscriptionPreview($projectId, $amount, $autoSubscribe = null, $recvWindow = null): ApiResponse
    {
        return $this->getOnChainYieldsLockedSubscriptionPreviewWithHttpInfo($projectId, $amount, $autoSubscribe, $recvWindow);
    }

    /**
     * Operation getOnChainYieldsLockedSubscriptionPreviewWithHttpInfo.
     *
     * Get On-chain Yields Locked Subscription Preview (USER_DATA)
     *
     * @param string    $projectId     (required)
     * @param float     $amount        (required)
     * @param null|bool $autoSubscribe true or false, default true. (optional)
     * @param null|int  $recvWindow    (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedSubscriptionPreviewResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedSubscriptionPreviewWithHttpInfo($projectId, $amount, $autoSubscribe = null, $recvWindow = null): ApiResponse
    {
        $request = $this->getOnChainYieldsLockedSubscriptionPreviewRequest($projectId, $amount, $autoSubscribe, $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\Staking\Model\GetOnChainYieldsLockedSubscriptionPreviewResponse',
                        $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\Staking\Model\GetOnChainYieldsLockedSubscriptionPreviewResponse',
                $request,
                $response,
            );
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = ObjectSerializer::deserialize(
                        $e->getResponseBody(),
                        '\Binance\Client\Staking\Model\GetOnChainYieldsLockedSubscriptionPreviewResponse',
                        $e->getResponseHeaders()
                    );
                    $e->setResponseObject($data);

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'getOnChainYieldsLockedSubscriptionPreview'.
     *
     * @param string    $projectId     (required)
     * @param float     $amount        (required)
     * @param null|bool $autoSubscribe true or false, default true. (optional)
     * @param null|int  $recvWindow    (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedSubscriptionPreviewRequest($projectId, $amount, $autoSubscribe = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['getOnChainYieldsLockedSubscriptionPreview'][0];

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

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

        $resourcePath = '/sapi/v1/onchain-yields/locked/subscriptionPreview';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $projectId,
            'projectId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $amount,
            'amount', // param base name
            'number', // openApiType
            'form', // style
            true, // explode
            true // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $autoSubscribe,
            'autoSubscribe', // param base name
            'boolean', // 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 getOnChainYieldsLockedSubscriptionRecord.
     *
     * Get On-chain Yields Locked Subscription Record (USER_DATA)
     *
     * @param null|string $purchaseId purchaseId (optional)
     * @param null|string $clientId   clientId (optional)
     * @param null|string $asset      asset (optional)
     * @param null|int    $startTime  startTime (optional)
     * @param null|int    $endTime    endTime (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedSubscriptionRecordResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedSubscriptionRecord($purchaseId = null, $clientId = null, $asset = null, $startTime = null, $endTime = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        return $this->getOnChainYieldsLockedSubscriptionRecordWithHttpInfo($purchaseId, $clientId, $asset, $startTime, $endTime, $current, $size, $recvWindow);
    }

    /**
     * Operation getOnChainYieldsLockedSubscriptionRecordWithHttpInfo.
     *
     * Get On-chain Yields Locked Subscription Record (USER_DATA)
     *
     * @param null|string $purchaseId (optional)
     * @param null|string $clientId   (optional)
     * @param null|string $asset      (optional)
     * @param null|int    $startTime  (optional)
     * @param null|int    $endTime    (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return ApiResponse<GetOnChainYieldsLockedSubscriptionRecordResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedSubscriptionRecordWithHttpInfo($purchaseId = null, $clientId = null, $asset = null, $startTime = null, $endTime = null, $current = null, $size = null, $recvWindow = null): ApiResponse
    {
        $request = $this->getOnChainYieldsLockedSubscriptionRecordRequest($purchaseId, $clientId, $asset, $startTime, $endTime, $current, $size, $recvWindow);

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

            $statusCode = $response->getStatusCode();

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

                    throw $e;
            }

            throw $e;
        }
    }

    /**
     * Create request for operation 'getOnChainYieldsLockedSubscriptionRecord'.
     *
     * @param null|string $purchaseId (optional)
     * @param null|string $clientId   (optional)
     * @param null|string $asset      (optional)
     * @param null|int    $startTime  (optional)
     * @param null|int    $endTime    (optional)
     * @param null|int    $current    Currently querying page. Start from 1. Default:1 (optional)
     * @param null|int    $size       Default:10, Max:100 (optional)
     * @param null|int    $recvWindow (optional)
     *
     * @return Request
     *
     * @throws \InvalidArgumentException
     */
    public function getOnChainYieldsLockedSubscriptionRecordRequest($purchaseId = null, $clientId = null, $asset = null, $startTime = null, $endTime = null, $current = null, $size = null, $recvWindow = null)
    {
        $contentType = self::contentTypes['getOnChainYieldsLockedSubscriptionRecord'][0];

        $resourcePath = '/sapi/v1/onchain-yields/locked/history/subscriptionRecord';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $purchaseId,
            'purchaseId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $clientId,
            'clientId', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $asset,
            'asset', // param base name
            'string', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $startTime,
            'startTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $endTime,
            'endTime', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $current,
            'current', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $size,
            'size', // param base name
            'integer', // openApiType
            'form', // style
            true, // explode
            false // required
        ) ?? []);
        // query params
        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
            $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 onChainYieldsAccount.
     *
     * On-chain Yields Account (USER_DATA)
     *
     * @param null|int $recvWindow recvWindow (optional)
     *
     * @return ApiResponse<OnChainYieldsAccountResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function onChainYieldsAccount($recvWindow = null): ApiResponse
    {
        return $this->onChainYieldsAccountWithHttpInfo($recvWindow);
    }

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

                    throw $e;
            }

            throw $e;
        }
    }

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

        $resourcePath = '/sapi/v1/onchain-yields/account';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

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

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

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

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

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

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

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

    /**
     * Operation redeemOnChainYieldsLockedProduct.
     *
     * Redeem On-chain Yields Locked Product (TRADE)
     *
     * @param RedeemOnChainYieldsLockedProductRequest $redeemOnChainYieldsLockedProductRequest redeemOnChainYieldsLockedProductRequest (required)
     *
     * @return ApiResponse<RedeemOnChainYieldsLockedProductResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function redeemOnChainYieldsLockedProduct($redeemOnChainYieldsLockedProductRequest): ApiResponse
    {
        return $this->redeemOnChainYieldsLockedProductWithHttpInfo($redeemOnChainYieldsLockedProductRequest);
    }

    /**
     * Operation redeemOnChainYieldsLockedProductWithHttpInfo.
     *
     * Redeem On-chain Yields Locked Product (TRADE)
     *
     * @param RedeemOnChainYieldsLockedProductRequest $redeemOnChainYieldsLockedProductRequest (required)
     *
     * @return ApiResponse<RedeemOnChainYieldsLockedProductResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function redeemOnChainYieldsLockedProductWithHttpInfo($redeemOnChainYieldsLockedProductRequest): ApiResponse
    {
        $request = $this->redeemOnChainYieldsLockedProductRequest($redeemOnChainYieldsLockedProductRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

        $resourcePath = '/sapi/v1/onchain-yields/locked/redeem';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        $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 setOnChainYieldsLockedAutoSubscribe.
     *
     * Set On-chain Yields Locked Auto Subscribe(USER_DATA)
     *
     * @param SetOnChainYieldsLockedAutoSubscribeRequest $setOnChainYieldsLockedAutoSubscribeRequest setOnChainYieldsLockedAutoSubscribeRequest (required)
     *
     * @return ApiResponse<SetOnChainYieldsLockedAutoSubscribeResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function setOnChainYieldsLockedAutoSubscribe($setOnChainYieldsLockedAutoSubscribeRequest): ApiResponse
    {
        return $this->setOnChainYieldsLockedAutoSubscribeWithHttpInfo($setOnChainYieldsLockedAutoSubscribeRequest);
    }

    /**
     * Operation setOnChainYieldsLockedAutoSubscribeWithHttpInfo.
     *
     * Set On-chain Yields Locked Auto Subscribe(USER_DATA)
     *
     * @param SetOnChainYieldsLockedAutoSubscribeRequest $setOnChainYieldsLockedAutoSubscribeRequest (required)
     *
     * @return ApiResponse<SetOnChainYieldsLockedAutoSubscribeResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function setOnChainYieldsLockedAutoSubscribeWithHttpInfo($setOnChainYieldsLockedAutoSubscribeRequest): ApiResponse
    {
        $request = $this->setOnChainYieldsLockedAutoSubscribeRequest($setOnChainYieldsLockedAutoSubscribeRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

        $resourcePath = '/sapi/v1/onchain-yields/locked/setAutoSubscribe';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        $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 setOnChainYieldsLockedProductRedeemOption.
     *
     * Set On-chain Yields Locked Product Redeem Option(USER_DATA)
     *
     * @param SetOnChainYieldsLockedProductRedeemOptionRequest $setOnChainYieldsLockedProductRedeemOptionRequest setOnChainYieldsLockedProductRedeemOptionRequest (required)
     *
     * @return ApiResponse<SetOnChainYieldsLockedProductRedeemOptionResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function setOnChainYieldsLockedProductRedeemOption($setOnChainYieldsLockedProductRedeemOptionRequest): ApiResponse
    {
        return $this->setOnChainYieldsLockedProductRedeemOptionWithHttpInfo($setOnChainYieldsLockedProductRedeemOptionRequest);
    }

    /**
     * Operation setOnChainYieldsLockedProductRedeemOptionWithHttpInfo.
     *
     * Set On-chain Yields Locked Product Redeem Option(USER_DATA)
     *
     * @param SetOnChainYieldsLockedProductRedeemOptionRequest $setOnChainYieldsLockedProductRedeemOptionRequest (required)
     *
     * @return ApiResponse<SetOnChainYieldsLockedProductRedeemOptionResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function setOnChainYieldsLockedProductRedeemOptionWithHttpInfo($setOnChainYieldsLockedProductRedeemOptionRequest): ApiResponse
    {
        $request = $this->setOnChainYieldsLockedProductRedeemOptionRequest($setOnChainYieldsLockedProductRedeemOptionRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

        $resourcePath = '/sapi/v1/onchain-yields/locked/setRedeemOption';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

        $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 subscribeOnChainYieldsLockedProduct.
     *
     * Subscribe On-chain Yields Locked Product(TRADE)
     *
     * @param SubscribeOnChainYieldsLockedProductRequest $subscribeOnChainYieldsLockedProductRequest subscribeOnChainYieldsLockedProductRequest (required)
     *
     * @return ApiResponse<SubscribeOnChainYieldsLockedProductResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function subscribeOnChainYieldsLockedProduct($subscribeOnChainYieldsLockedProductRequest): ApiResponse
    {
        return $this->subscribeOnChainYieldsLockedProductWithHttpInfo($subscribeOnChainYieldsLockedProductRequest);
    }

    /**
     * Operation subscribeOnChainYieldsLockedProductWithHttpInfo.
     *
     * Subscribe On-chain Yields Locked Product(TRADE)
     *
     * @param SubscribeOnChainYieldsLockedProductRequest $subscribeOnChainYieldsLockedProductRequest (required)
     *
     * @return ApiResponse<SubscribeOnChainYieldsLockedProductResponse>
     *
     * @throws ApiException              on non-2xx response or if the response body is not in the expected format
     * @throws \InvalidArgumentException
     */
    public function subscribeOnChainYieldsLockedProductWithHttpInfo($subscribeOnChainYieldsLockedProductRequest): ApiResponse
    {
        $request = $this->subscribeOnChainYieldsLockedProductRequest($subscribeOnChainYieldsLockedProductRequest);

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

                    throw $e;
            }

            throw $e;
        }
    }

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

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

        $resourcePath = '/sapi/v1/onchain-yields/locked/subscribe';
        $formParams = [];
        $queryParams = [];
        $headerParams = [];
        $httpBody = '';
        $multipart = false;

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

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

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

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

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

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

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

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

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

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

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

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

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