<?php

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

/**
 * Binance Derivatives Trading USDS Futures REST API.
 *
 * OpenAPI Specification for the Binance Derivatives Trading USDS Futures 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
 * Please update the test case below to test the endpoint.
 */

namespace Binance\Client\DerivativesTradingUsdsFutures\Test\Api;

use Binance\Client\DerivativesTradingUsdsFutures\Api\AccountApi;
use Binance\Client\DerivativesTradingUsdsFutures\Configuration;
use Binance\Client\DerivativesTradingUsdsFutures\Model\ToggleBnbBurnOnFuturesTradeRequest;
use Binance\Common\Configuration\ClientConfiguration;
use Binance\Common\Configuration\SignatureConfiguration;
use Binance\Common\HttpClient;
use GuzzleHttp\Psr7\Utils;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;

/**
 * AccountApiTest Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 *
 * @internal
 *
 * @coversNothing
 */
class AccountApiTest extends TestCase
{
    public function getApiMock(&$request)
    {
        $clientMock = $this->createMock(HttpClient::class);
        $signatureConfig = new SignatureConfiguration();
        $signatureConfig->setApiKey('apiKey');
        $signatureConfig->setSecretKey('secretKey');
        $clientConfig = new ClientConfiguration();
        $clientConfig->setUrl('http://localhost:8080');
        $clientConfig->setSignatureConfiguration($signatureConfig);
        $responseMock = $this->createMock(ResponseInterface::class);

        $responseMock->expects($this->any())
            ->method('getStatusCode')
            ->willReturn(200)
        ;

        $responseMock->expects($this->any())
            ->method('getBody')
            ->willReturn(Utils::streamFor('{}'))
        ;

        $clientMock->expects($this->once())
            ->method('send')
            ->will($this->returnCallback(function ($actualRequest) use (&$request, $responseMock) {
                $request = $actualRequest;

                return $responseMock;
            }))
        ;

        $apiMock = $this->getMockBuilder(AccountApi::class)
            ->setConstructorArgs([$clientConfig, $clientMock])
            ->onlyMethods(['getTimestamp'])
            ->getMock()
        ;

        $apiMock->method('getTimestamp')->willReturn('1736393892000');

        return $apiMock;
    }

    /**
     * Test case for accountInformationV2.
     *
     * Account Information V2(USER_DATA).
     */
    public function testAccountInformationV2()
    {
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->accountInformationV2($recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v2/account', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for accountInformationV3.
     *
     * Account Information V3(USER_DATA).
     */
    public function testAccountInformationV3()
    {
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->accountInformationV3($recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v3/account', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for futuresAccountBalanceV2.
     *
     * Futures Account Balance V2 (USER_DATA).
     */
    public function testFuturesAccountBalanceV2()
    {
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->futuresAccountBalanceV2($recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v2/balance', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for futuresAccountBalanceV3.
     *
     * Futures Account Balance V3 (USER_DATA).
     */
    public function testFuturesAccountBalanceV3()
    {
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->futuresAccountBalanceV3($recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v3/balance', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for futuresAccountConfiguration.
     *
     * Futures Account Configuration(USER_DATA).
     */
    public function testFuturesAccountConfiguration()
    {
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->futuresAccountConfiguration($recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/accountConfig', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for futuresTradingQuantitativeRulesIndicators.
     *
     * Futures Trading Quantitative Rules Indicators (USER_DATA).
     */
    public function testFuturesTradingQuantitativeRulesIndicators()
    {
        $symbol = '';
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->futuresTradingQuantitativeRulesIndicators($symbol, $recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/apiTradingStatus', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for getBnbBurnStatus.
     *
     * Get BNB Burn Status (USER_DATA).
     */
    public function testGetBnbBurnStatus()
    {
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->getBnbBurnStatus($recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/feeBurn', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for getCurrentMultiAssetsMode.
     *
     * Get Current Multi-Assets Mode (USER_DATA).
     */
    public function testGetCurrentMultiAssetsMode()
    {
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->getCurrentMultiAssetsMode($recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/multiAssetsMargin', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for getCurrentPositionMode.
     *
     * Get Current Position Mode(USER_DATA).
     */
    public function testGetCurrentPositionMode()
    {
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->getCurrentPositionMode($recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/positionSide/dual', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for getDownloadIdForFuturesOrderHistory.
     *
     * Get Download Id For Futures Order History (USER_DATA).
     */
    public function testGetDownloadIdForFuturesOrderHistory()
    {
        $startTime = 1623319461670;
        $endTime = 1641782889000;
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->getDownloadIdForFuturesOrderHistory($startTime, $endTime, $recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/order/asyn', $request->getUri()->getPath());
        self::assertEquals('812caedbe8f349196a4532c2050ff706ed2569fed185039c7b60a78cd84bc718', $queryMap['signature']);
    }

    /**
     * Test case for getDownloadIdForFuturesTradeHistory.
     *
     * Get Download Id For Futures Trade History (USER_DATA).
     */
    public function testGetDownloadIdForFuturesTradeHistory()
    {
        $startTime = 1623319461670;
        $endTime = 1641782889000;
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->getDownloadIdForFuturesTradeHistory($startTime, $endTime, $recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/trade/asyn', $request->getUri()->getPath());
        self::assertEquals('812caedbe8f349196a4532c2050ff706ed2569fed185039c7b60a78cd84bc718', $queryMap['signature']);
    }

    /**
     * Test case for getDownloadIdForFuturesTransactionHistory.
     *
     * Get Download Id For Futures Transaction History(USER_DATA).
     */
    public function testGetDownloadIdForFuturesTransactionHistory()
    {
        $startTime = 1623319461670;
        $endTime = 1641782889000;
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->getDownloadIdForFuturesTransactionHistory($startTime, $endTime, $recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/income/asyn', $request->getUri()->getPath());
        self::assertEquals('812caedbe8f349196a4532c2050ff706ed2569fed185039c7b60a78cd84bc718', $queryMap['signature']);
    }

    /**
     * Test case for getFuturesOrderHistoryDownloadLinkById.
     *
     * Get Futures Order History Download Link by Id (USER_DATA).
     */
    public function testGetFuturesOrderHistoryDownloadLinkById()
    {
        $downloadId = '1';
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->getFuturesOrderHistoryDownloadLinkById($downloadId, $recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/order/asyn/id', $request->getUri()->getPath());
        self::assertEquals('4947fe463a17e3ec0b50fc22b21afc2aafddf3da892fa0c8dfd1b9c50af87349', $queryMap['signature']);
    }

    /**
     * Test case for getFuturesTradeDownloadLinkById.
     *
     * Get Futures Trade Download Link by Id(USER_DATA).
     */
    public function testGetFuturesTradeDownloadLinkById()
    {
        $downloadId = '1';
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->getFuturesTradeDownloadLinkById($downloadId, $recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/trade/asyn/id', $request->getUri()->getPath());
        self::assertEquals('4947fe463a17e3ec0b50fc22b21afc2aafddf3da892fa0c8dfd1b9c50af87349', $queryMap['signature']);
    }

    /**
     * Test case for getFuturesTransactionHistoryDownloadLinkById.
     *
     * Get Futures Transaction History Download Link by Id (USER_DATA).
     */
    public function testGetFuturesTransactionHistoryDownloadLinkById()
    {
        $downloadId = '1';
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->getFuturesTransactionHistoryDownloadLinkById($downloadId, $recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/income/asyn/id', $request->getUri()->getPath());
        self::assertEquals('4947fe463a17e3ec0b50fc22b21afc2aafddf3da892fa0c8dfd1b9c50af87349', $queryMap['signature']);
    }

    /**
     * Test case for getIncomeHistory.
     *
     * Get Income History (USER_DATA).
     */
    public function testGetIncomeHistory()
    {
        $symbol = '';
        $incomeType = '';
        $startTime = 1623319461670;
        $endTime = 1641782889000;
        $page = null;
        $limit = 100;
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->getIncomeHistory($symbol, $incomeType, $startTime, $endTime, $page, $limit, $recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/income', $request->getUri()->getPath());
        self::assertEquals('23689f3330f331d9db9c46c9dc87d2217486442f1746adfdda02c10e3dbde13e', $queryMap['signature']);
    }

    /**
     * Test case for notionalAndLeverageBrackets.
     *
     * Notional and Leverage Brackets (USER_DATA).
     */
    public function testNotionalAndLeverageBrackets()
    {
        $symbol = '';
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->notionalAndLeverageBrackets($symbol, $recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/leverageBracket', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for queryUserRateLimit.
     *
     * Query User Rate Limit (USER_DATA).
     */
    public function testQueryUserRateLimit()
    {
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->queryUserRateLimit($recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/rateLimit/order', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for symbolConfiguration.
     *
     * Symbol Configuration(USER_DATA).
     */
    public function testSymbolConfiguration()
    {
        $symbol = '';
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->symbolConfiguration($symbol, $recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/symbolConfig', $request->getUri()->getPath());
        self::assertEquals('2cdd1e484bce80021437bee6b762e6a276b1954c3a0c011a16f6f2f6a47aba75', $queryMap['signature']);
    }

    /**
     * Test case for toggleBnbBurnOnFuturesTrade.
     *
     * Toggle BNB Burn On Futures Trade (TRADE).
     */
    public function testToggleBnbBurnOnFuturesTrade()
    {
        $toggleBnbBurnOnFuturesTradeRequest = new ToggleBnbBurnOnFuturesTradeRequest();
        $toggleBnbBurnOnFuturesTradeRequest->setFeeBurn('');

        $response = $this->getApiMock($request)->toggleBnbBurnOnFuturesTrade($toggleBnbBurnOnFuturesTradeRequest);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/feeBurn', $request->getUri()->getPath());
        self::assertEquals('5747e73ac9c0fa786582e0c2b52dbd801c39ad2e8daf94fcb325d73b857ac282', $queryMap['signature']);
    }

    /**
     * Test case for userCommissionRate.
     *
     * User Commission Rate (USER_DATA).
     */
    public function testUserCommissionRate()
    {
        $symbol = '';
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->userCommissionRate($symbol, $recvWindow);

        parse_str($request->getUri(), $queryMap);

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/fapi/v1/commissionRate', $request->getUri()->getPath());
        self::assertEquals('db1a455af0a2e82b4ec79595d994eb2e7f6b8a93c91a67a2aa59e2b2eae4bc68', $queryMap['signature']);
    }
}
