diff --git a/examples/spot/giftcard/giftCardBuyCode.php b/examples/spot/giftcard/giftCardBuyCode.php index 7bd601e..b14737a 100644 --- a/examples/spot/giftcard/giftCardBuyCode.php +++ b/examples/spot/giftcard/giftCardBuyCode.php @@ -19,4 +19,4 @@ ] ); -echo json_encode($response); \ No newline at end of file +echo json_encode($response); diff --git a/examples/spot/giftcard/giftCardTokenLimit.php b/examples/spot/giftcard/giftCardTokenLimit.php index dd7ef4c..0561b9d 100644 --- a/examples/spot/giftcard/giftCardTokenLimit.php +++ b/examples/spot/giftcard/giftCardTokenLimit.php @@ -17,4 +17,4 @@ ] ); -echo json_encode($response); \ No newline at end of file +echo json_encode($response); diff --git a/examples/spot/wallet/symbolsDelistScheduleForSpot.php b/examples/spot/wallet/getSymbolsDelistScheduleForSpot.php similarity index 100% rename from examples/spot/wallet/symbolsDelistScheduleForSpot.php rename to examples/spot/wallet/getSymbolsDelistScheduleForSpot.php diff --git a/src/Binance/Spot/GiftCard.php b/src/Binance/Spot/GiftCard.php index a270eb2..c44b22d 100644 --- a/src/Binance/Spot/GiftCard.php +++ b/src/Binance/Spot/GiftCard.php @@ -4,6 +4,7 @@ use Binance\Util\Strings; use Binance\Exception\MissingArgumentException; +use Binance\Exception\InvalidArgumentException; trait GiftCard { @@ -51,30 +52,33 @@ public function giftCardCreateCode(string $token, $amount, array $options = []) * You may create a gift card using USDT as baseToken, that is redeemable to another designated token (faceToken). * For example, you can create a fixed-value BTC gift card and pay with 100 USDT plus 1 USDT fee. * This gift card can keep the value fixed at 100 USDT before redemption, and will be redeemable to BTC equivalent to 100 USDT upon redemption. - * + * Once successfully created, the amount of baseToken (e.g. USDT) in the fixed-value gift card along with the fee would be deducted from your funding wallet. + * To get started with, please make sure: * - You have a Binance account * - You have passed KYB * - You have a sufficient balance(Gift Card amount and fee amount) in your Binance funding wallet * - You need Enable Withdrawals for the API Key which requests this endpoint. * - * Daily creation volume: 2 BTC / 24H Daily creation times: 200 Codes / 24H - * * Weight(IP): 1 + * - Daily creation volume: 2 BTC / 24H / account + * - Daily creation quantity: 200 Gift Cards / 24H / account * * @param string $baseToken * @param string $faceToken - * @param mixed $baseTokenAmount + * @param float $baseTokenAmount * @param array $options */ - public function giftCardBuyCode(string $baseToken, string $faceToken, $baseTokenAmount, array $options = []) + public function giftCardBuyCode(string $baseToken, string $faceToken, float $baseTokenAmount, array $options = []) { if (Strings::isEmpty($baseToken)) { throw new MissingArgumentException('baseToken'); } - if (Strings::isEmpty($faceToken)) { throw new MissingArgumentException('faceToken'); } + if ($baseTokenAmount <= 0) { + throw new InvalidArgumentException('baseTokenAmount', $baseTokenAmount, 'greater than 0'); + } return $this->signRequest('POST', '/sapi/v1/giftcard/buyCode', array_merge( $options, @@ -165,7 +169,7 @@ public function giftCardRsaPublicKey(array $options = []) * * GET /sapi/v1/giftcard/buyCode/token-limit * - * This API is to help you verify which tokens are available for you to create Stablecoin-Denominated gift cards as mentioned in section 2 and its’ limitation. + * This API is to help you verify which tokens are available for you to create Stablecoin-Denominated gift cards as mentioned in section 2 and its’ limitation * * Weight(IP): 1 * diff --git a/src/Binance/Spot/Wallet.php b/src/Binance/Spot/Wallet.php index ebfcf70..d97c986 100644 --- a/src/Binance/Spot/Wallet.php +++ b/src/Binance/Spot/Wallet.php @@ -476,10 +476,9 @@ public function fundingWallet(array $options = []) * * @param array $options */ - public function getSymbolsDelistScheduleForSpot(array $options = []) { - return $this->signRequest('GET', '/sapi/v1/spot/delist-schedule', $options); + return $this->publicRequest('GET', '/sapi/v1/spot/delist-schedule', $options); } /** @@ -503,7 +502,7 @@ public function apiKeyPermission(array $options = []) * * - Apply deposit credit for expired address (One click arrival) * - * Weight(UID): 1 + * Weight(IP): 1 * * @param array $options */ @@ -539,14 +538,13 @@ public function queryAutoConvertingStableCoin(array $options = []) * * @param array $options */ - public function queryUserWalletBalance(array $options = []) { return $this->signRequest('GET', '/sapi/v1/asset/wallet/balance', $options); } /** - * Fetch deposit address list with network(USER_DATA) + * Fetch deposit address list with network (USER_DATA) * * GET /sapi/v1/capital/deposit/address/list * @@ -570,7 +568,7 @@ public function fetchDepositAddressListNetwork(string $coin, array $options = [] ] )); } - + /** * Switch on/off BUSD and stable coins conversion (USER_DATA) * diff --git a/tests/spot/giftcard/GiftCardBuyCodeTest.php b/tests/spot/giftcard/GiftCardBuyCodeTest.php index f78fde9..a1614b6 100644 --- a/tests/spot/giftcard/GiftCardBuyCodeTest.php +++ b/tests/spot/giftcard/GiftCardBuyCodeTest.php @@ -3,6 +3,7 @@ use Binance\Tests\BaseTestCase; use Aeris\GuzzleHttpMock\Expect; use Binance\Exception\MissingArgumentException; +use Binance\Exception\InvalidArgumentException; class GiftCardBuyCodeTest extends BaseTestCase { @@ -11,10 +12,22 @@ public function setUp(): void parent::setUp(); } - public function testGiftCardBuyCodeThrowsExceptionWithoutReferenceNo() + public function testGiftCardBuyCodeThrowsExceptionWithoutBaseToken() { $this->expectException(MissingArgumentException::class); - $response = $this->spotClient->giftCardBuyCode('','',1.01); + $response = $this->spotClient->giftCardBuyCode('', 'BNB', 1.002); + } + + public function testGiftCardBuyCodeThrowsExceptionWithoutFaceToken() + { + $this->expectException(MissingArgumentException::class); + $response = $this->spotClient->giftCardBuyCode('BUSD', '', 1.002); + } + + public function testGiftCardBuyCodeThrowsExceptionWithoutBaseTokenAmount() + { + $this->expectException(InvalidArgumentException::class); + $response = $this->spotClient->giftCardBuyCode('BUSD', 'BNB', 0.0); } public function testGiftCardBuyCode() @@ -43,4 +56,4 @@ public function tearDown(): void { parent::tearDown(); } -} \ No newline at end of file +} diff --git a/tests/spot/giftcard/GiftCardTokenLimitTest.php b/tests/spot/giftcard/GiftCardTokenLimitTest.php index 1ec21e6..34346e4 100644 --- a/tests/spot/giftcard/GiftCardTokenLimitTest.php +++ b/tests/spot/giftcard/GiftCardTokenLimitTest.php @@ -11,7 +11,7 @@ public function setUp(): void parent::setUp(); } - public function testGiftCardTokenLimitThrowsExceptionWithoutReferenceNo() + public function testGiftCardTokenLimitThrowsExceptionWithoutBaseToken() { $this->expectException(MissingArgumentException::class); $response = $this->spotClient->giftCardTokenLimit(''); @@ -40,4 +40,4 @@ public function tearDown(): void { parent::tearDown(); } -} \ No newline at end of file +} diff --git a/tests/spot/wallet/DepositCreditApplyTest.php b/tests/spot/wallet/DepositCreditApplyTest.php index 6e85e5a..f2c1a71 100644 --- a/tests/spot/wallet/DepositCreditApplyTest.php +++ b/tests/spot/wallet/DepositCreditApplyTest.php @@ -18,11 +18,13 @@ public function testDepositCreditApply() ->withMethod('POST') ->withQueryParams(new Expect\ArrayEquals([ 'subUserId' => '500', + 'recvWindow' => '5000' ]), ['timestamp', 'signature']) ->andRespondWithJson($this->data, $statusCode = 200); $response = $this->spotClient->depositCreditApply([ - 'subUserId' => '500' + 'subUserId' => '500', + 'recvWindow' => 5000 ]); $this->assertEquals($response, $this->data); diff --git a/tests/spot/wallet/FetchDepositAddressListNetworkTest.php b/tests/spot/wallet/FetchDepositAddressListNetworkTest.php index 36c76aa..5b341d8 100644 --- a/tests/spot/wallet/FetchDepositAddressListNetworkTest.php +++ b/tests/spot/wallet/FetchDepositAddressListNetworkTest.php @@ -11,13 +11,13 @@ public function setUp(): void parent::setUp(); } - public function testFetchDepositAddressThrowsExceptionWithoutCoin() + public function testFetchDepositAddressListNetworkThrowsExceptionWithoutCoin() { $this->expectException(MissingArgumentException::class); $response = $this->spotClient->fetchDepositAddressListNetwork(''); } - public function testDepositAddress() + public function testFetchDepositAddressListNetwork() { $this->httpMock ->shouldReceiveRequest() diff --git a/tests/spot/wallet/GetSymbolsDelistScheduleForSpotTest.php b/tests/spot/wallet/GetSymbolsDelistScheduleForSpotTest.php index ed4db4e..4867666 100644 --- a/tests/spot/wallet/GetSymbolsDelistScheduleForSpotTest.php +++ b/tests/spot/wallet/GetSymbolsDelistScheduleForSpotTest.php @@ -18,7 +18,7 @@ public function testGetSymbolsDelistScheduleForSpot() ->withMethod('GET') ->withQueryParams(new Expect\ArrayEquals([ 'recvWindow' => '5000' - ]), ['timestamp', 'signature']) + ])) ->andRespondWithJson($this->data, $statusCode = 200); $response = $this->spotClient->getSymbolsDelistScheduleForSpot([