-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from phroca/rc-v3.4.2
Add method giftCardBuyCode in order to create a dual-token gift card
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* global describe, it, expect */ | ||
const MissingParameterError = require('../../../src/error/missingParameterError') | ||
const { nockPostMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup') | ||
|
||
const { | ||
mockResponse, | ||
amount | ||
} = require('../../testUtils/mockData') | ||
|
||
const baseToken = 'USDT' | ||
const faceToken = 'BNB' | ||
|
||
describe('#giftCardBuyCode', () => { | ||
it.each([ | ||
[undefined, undefined, undefined], ['', '', ''], [null, null, null], | ||
[undefined, faceToken, undefined], ['', faceToken, ''], [null, faceToken, null], | ||
[baseToken, undefined, undefined], [baseToken, '', ''], [baseToken, null, null], | ||
[undefined, undefined, amount], ['', '', amount], [baseToken, faceToken, null] | ||
])('should throw MissingParameterError given missing params', (baseToken, faceToken, amount) => { | ||
expect(() => { | ||
SpotClient.giftCardBuyCode(baseToken, faceToken, amount) | ||
}).toThrow(MissingParameterError) | ||
}) | ||
|
||
it('should return binance code info', () => { | ||
nockPostMock(`/sapi/v1/giftcard/buyCode?${buildQueryString({ baseToken, faceToken, baseTokenAmount: amount })}`)(mockResponse) | ||
|
||
return SpotClient.giftCardBuyCode(baseToken, faceToken, amount).then(response => { | ||
expect(response).toBeDefined() | ||
expect(response.data).toEqual(mockResponse) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict' | ||
|
||
const Spot = require('../../../src/spot') | ||
|
||
const apiKey = '' | ||
const apiSecret = '' | ||
const client = new Spot(apiKey, apiSecret) | ||
|
||
client.giftCardBuyCode('BUSD', 'BNB', 10).then(response => client.logger.log(response.data)) | ||
.catch(error => client.logger.error(error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters