Skip to content

Commit

Permalink
Release v1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alplabin committed May 30, 2024
1 parent f000d18 commit 7fa2f1b
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/spot/giftcard/giftCardBuyCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
]
);

echo json_encode($response);
echo json_encode($response);
2 changes: 1 addition & 1 deletion examples/spot/giftcard/giftCardTokenLimit.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
]
);

echo json_encode($response);
echo json_encode($response);
18 changes: 11 additions & 7 deletions src/Binance/Spot/GiftCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Binance\Util\Strings;
use Binance\Exception\MissingArgumentException;
use Binance\Exception\InvalidArgumentException;

trait GiftCard
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
*
Expand Down
10 changes: 4 additions & 6 deletions src/Binance/Spot/Wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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
*/
Expand Down Expand Up @@ -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
*
Expand All @@ -570,7 +568,7 @@ public function fetchDepositAddressListNetwork(string $coin, array $options = []
]
));
}

/**
* Switch on/off BUSD and stable coins conversion (USER_DATA)
*
Expand Down
19 changes: 16 additions & 3 deletions tests/spot/giftcard/GiftCardBuyCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Binance\Tests\BaseTestCase;
use Aeris\GuzzleHttpMock\Expect;
use Binance\Exception\MissingArgumentException;
use Binance\Exception\InvalidArgumentException;

class GiftCardBuyCodeTest extends BaseTestCase
{
Expand All @@ -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()
Expand Down Expand Up @@ -43,4 +56,4 @@ public function tearDown(): void
{
parent::tearDown();
}
}
}
4 changes: 2 additions & 2 deletions tests/spot/giftcard/GiftCardTokenLimitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function setUp(): void
parent::setUp();
}

public function testGiftCardTokenLimitThrowsExceptionWithoutReferenceNo()
public function testGiftCardTokenLimitThrowsExceptionWithoutBaseToken()
{
$this->expectException(MissingArgumentException::class);
$response = $this->spotClient->giftCardTokenLimit('');
Expand Down Expand Up @@ -40,4 +40,4 @@ public function tearDown(): void
{
parent::tearDown();
}
}
}
4 changes: 3 additions & 1 deletion tests/spot/wallet/DepositCreditApplyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/spot/wallet/FetchDepositAddressListNetworkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/spot/wallet/GetSymbolsDelistScheduleForSpotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down

0 comments on commit 7fa2f1b

Please sign in to comment.