<?php

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

/**
 * Binance Wallet REST API.
 *
 * OpenAPI Specification for the Binance Wallet REST API
 *
 * The version of the OpenAPI document: 1.0.0
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.12.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Please update the test case below to test the endpoint.
 */

namespace Binance\Client\Wallet\Test\Api;

use Binance\Client\Wallet\Api\TravelRuleApi;
use Binance\Client\Wallet\Model\BrokerWithdrawRequest;
use Binance\Client\Wallet\Model\SubmitDepositQuestionnaireRequest;
use Binance\Client\Wallet\Model\SubmitDepositQuestionnaireTravelRuleRequest;
use Binance\Client\Wallet\Model\WithdrawTravelRuleRequest;
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;

/**
 * TravelRuleApiTest Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 *
 * @internal
 *
 * @coversNothing
 */
class TravelRuleApiTest 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(TravelRuleApi::class)
            ->setConstructorArgs([$clientConfig, $clientMock])
            ->onlyMethods(['getTimestamp'])
            ->getMock()
        ;

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

        return $apiMock;
    }

    /**
     * Test case for brokerWithdraw.
     *
     * Broker Withdraw (for brokers of local entities that require travel rule) (USER_DATA).
     */
    public function testBrokerWithdraw()
    {
        $brokerWithdrawRequest = new BrokerWithdrawRequest();
        $brokerWithdrawRequest->setAddress('');
        $brokerWithdrawRequest->setCoin('');
        $brokerWithdrawRequest->setAmount(1.0);
        $brokerWithdrawRequest->setWithdrawOrderId('1');
        $brokerWithdrawRequest->setQuestionnaire('');
        $brokerWithdrawRequest->setOriginatorPii('');
        $brokerWithdrawRequest->setSignature('');

        $response = $this->getApiMock($request)->brokerWithdraw($brokerWithdrawRequest);

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

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/sapi/v1/localentity/broker/withdraw/apply', $request->getUri()->getPath());
        self::assertEquals('a1ee61f2bfa2e72db8f0caba465d54d02b96e1e30615a3b16c8b1e72d0b6e060', $queryMap['signature']);
    }

    /**
     * Test case for depositHistoryTravelRule.
     *
     * Deposit History (for local entities that required travel rule) (supporting network) (USER_DATA).
     */
    public function testDepositHistoryTravelRule()
    {
        $trId = '1';
        $txId = '1';
        $tranId = '1';
        $network = '';
        $coin = '';
        $travelRuleStatus = null;
        $pendingQuestionnaire = null;
        $startTime = 1623319461670;
        $endTime = 1641782889000;
        $offset = 0;
        $limit = 7;
        $response = $this->getApiMock($request)->depositHistoryTravelRule($trId, $txId, $tranId, $network, $coin, $travelRuleStatus, $pendingQuestionnaire, $startTime, $endTime, $offset, $limit);

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

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/sapi/v1/localentity/deposit/history', $request->getUri()->getPath());
        self::assertEquals('c8d3902b485951a73d5ec58900ec1d4678f0a8bae1f9c111c61e080a825a5cf0', $queryMap['signature']);
    }

    /**
     * Test case for fetchAddressVerificationList.
     *
     * Fetch address verification list (USER_DATA).
     */
    public function testFetchAddressVerificationList()
    {
        $response = $this->getApiMock($request)->fetchAddressVerificationList();

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

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/sapi/v1/addressVerify/list', $request->getUri()->getPath());
        self::assertEquals('53668e00dc92eb93de0b253c301e9fc0c20042b13db384a0ad94b38688a5a84c', $queryMap['signature']);
    }

    /**
     * Test case for onboardedVaspList.
     *
     * Onboarded VASP list (for local entities that require travel rule) (supporting network) (USER_DATA).
     */
    public function testOnboardedVaspList()
    {
        $response = $this->getApiMock($request)->onboardedVaspList();

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

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/sapi/v1/localentity/vasp', $request->getUri()->getPath());
        self::assertEquals('53668e00dc92eb93de0b253c301e9fc0c20042b13db384a0ad94b38688a5a84c', $queryMap['signature']);
    }

    /**
     * Test case for submitDepositQuestionnaire.
     *
     * Submit Deposit Questionnaire (For local entities that require travel rule) (supporting network) (USER_DATA).
     */
    public function testSubmitDepositQuestionnaire()
    {
        $submitDepositQuestionnaireRequest = new SubmitDepositQuestionnaireRequest();
        $submitDepositQuestionnaireRequest->setSubAccountId('1');
        $submitDepositQuestionnaireRequest->setDepositId('1');
        $submitDepositQuestionnaireRequest->setQuestionnaire('');
        $submitDepositQuestionnaireRequest->setBeneficiaryPii('');
        $submitDepositQuestionnaireRequest->setSignature('');

        $response = $this->getApiMock($request)->submitDepositQuestionnaire($submitDepositQuestionnaireRequest);

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

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/sapi/v1/localentity/broker/deposit/provide-info', $request->getUri()->getPath());
        self::assertEquals('55b0cc3e73be312e8d1f6544324dc9b0e0766e6c8f6bc4ada1b504713d5abf75', $queryMap['signature']);
    }

    /**
     * Test case for submitDepositQuestionnaireTravelRule.
     *
     * Submit Deposit Questionnaire (For local entities that require travel rule) (supporting network) (USER_DATA).
     */
    public function testSubmitDepositQuestionnaireTravelRule()
    {
        $submitDepositQuestionnaireTravelRuleRequest = new SubmitDepositQuestionnaireTravelRuleRequest();
        $submitDepositQuestionnaireTravelRuleRequest->setTranId(1);
        $submitDepositQuestionnaireTravelRuleRequest->setQuestionnaire('');

        $response = $this->getApiMock($request)->submitDepositQuestionnaireTravelRule($submitDepositQuestionnaireTravelRuleRequest);

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

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/sapi/v1/localentity/deposit/provide-info', $request->getUri()->getPath());
        self::assertEquals('9e2879ef1f6acbc94112cf07e1b20e19c20feb58efaa07eb8f91b2b917dfb74a', $queryMap['signature']);
    }

    /**
     * Test case for withdrawHistoryV1.
     *
     * Withdraw History (for local entities that require travel rule) (supporting network) (USER_DATA).
     */
    public function testWithdrawHistoryV1()
    {
        $trId = '1';
        $txId = '1';
        $withdrawOrderId = '1';
        $network = '';
        $coin = '';
        $travelRuleStatus = null;
        $offset = 0;
        $limit = 7;
        $startTime = 1623319461670;
        $endTime = 1641782889000;
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->withdrawHistoryV1($trId, $txId, $withdrawOrderId, $network, $coin, $travelRuleStatus, $offset, $limit, $startTime, $endTime, $recvWindow);

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

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/sapi/v1/localentity/withdraw/history', $request->getUri()->getPath());
        self::assertEquals('81b84b0e71f20e1d4129775b0cf3d37dc9cf4c0587ae05d69d7ed34e0d4e2ea7', $queryMap['signature']);
    }

    /**
     * Test case for withdrawHistoryV2.
     *
     * Withdraw History V2 (for local entities that require travel rule) (supporting network) (USER_DATA).
     */
    public function testWithdrawHistoryV2()
    {
        $trId = '1';
        $txId = '1';
        $withdrawOrderId = '1';
        $network = '';
        $coin = '';
        $travelRuleStatus = null;
        $offset = 0;
        $limit = 7;
        $startTime = 1623319461670;
        $endTime = 1641782889000;
        $recvWindow = 5000;
        $response = $this->getApiMock($request)->withdrawHistoryV2($trId, $txId, $withdrawOrderId, $network, $coin, $travelRuleStatus, $offset, $limit, $startTime, $endTime, $recvWindow);

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

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/sapi/v2/localentity/withdraw/history', $request->getUri()->getPath());
        self::assertEquals('81b84b0e71f20e1d4129775b0cf3d37dc9cf4c0587ae05d69d7ed34e0d4e2ea7', $queryMap['signature']);
    }

    /**
     * Test case for withdrawTravelRule.
     *
     * Withdraw (for local entities that require travel rule) (USER_DATA).
     */
    public function testWithdrawTravelRule()
    {
        $withdrawTravelRuleRequest = new WithdrawTravelRuleRequest();
        $withdrawTravelRuleRequest->setCoin('');
        $withdrawTravelRuleRequest->setAddress('');
        $withdrawTravelRuleRequest->setAmount(1.0);
        $withdrawTravelRuleRequest->setQuestionnaire('');

        $response = $this->getApiMock($request)->withdrawTravelRule($withdrawTravelRuleRequest);

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

        self::assertEquals(200, $response->getStatusCode());
        self::assertEquals('/sapi/v1/localentity/withdraw/apply', $request->getUri()->getPath());
        self::assertEquals('50d24733794b928836575c346769be26ee1fb5ffbf73f36933cd22c50116f74e', $queryMap['signature']);
    }
}
