Skip to content

Commit

Permalink
v3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alplabin committed Apr 4, 2024
1 parent b62b69f commit 2367915
Show file tree
Hide file tree
Showing 48 changed files with 329 additions and 104 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

## 3.3.0 - 2024-04-04

### Added
- Add Simple Earn endpoints:
- `GET /sapi/v1/simple-earn/flexible/list` to query available Simple Earn flexible product list
- `GET /sapi/v1/simple-earn/locked/list` to query available Simple Earn locked product list
- `POST /sapi/v1/simple-earn/flexible/subscribe` to subscribe to a flexible product
- `POST /sapi/v1/simple-earn/locked/subscribe` to subscribe to a locked product
- `POST /sapi/v1/simple-earn/flexible/redeem` to redeem a flexible product
- `POST /sapi/v1/simple-earn/locked/redeem` to redeem a locked product
- `GET /sapi/v1/simple-earn/flexible/position` to get a flexible product position
- `GET /sapi/v1/simple-earn/locked/position` to get a locked product position
- `GET /sapi/v1/simple-earn/account ` to get a simple account balances
- `GET /sapi/v1/simple-earn/flexible/history/subscriptionRecord` to get flexible subscription records
- `GET /sapi/v1/simple-earn/locked/history/subscriptionRecord ` to get locked subscription records
- `GET /sapi/v1/simple-earn/flexible/history/redemptionRecord ` to retrieve flexible redemption records
- `GET /sapi/v1/simple-earn/locked/history/redemptionRecord ` to retrieve locked redemption records
- `GET /sapi/v1/simple-earn/flexible/history/rewardsRecord ` to get flexible rewards history
- `GET /sapi/v1/simple-earn/locked/history/rewardsRecord ` to get locked rewards history
- `POST /sapi/v1/simple-earn/flexible/setAutoSubscribe` to set an auto-subscription to a flexible product
- `POST /sapi/v1/simple-earn/locked/setAutoSubscribe` to set an auto-subscription to a locked product
- `GET /sapi/v1/simple-earn/flexible/personalLeftQuota` to get flexible personal left quota
- `GET /sapi/v1/simple-earn/locked/personalLeftQuota` to get locked personal left quota
- `GET /sapi/v1/simple-earn/flexible/subscriptionPreview` to get flexible subscription preview
- `GET /sapi/v1/simple-earn/locked/subscriptionPreview` to get locked subscription previews
- `GET /sapi/v1/simple-earn/flexible/history/rateHistory` to get a rate history
- `GET /sapi/v1/simple-earn/flexible/history/collateralRecord` to get collateral records

### Changed
- Update dependencies

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const { mockResponse } = require('../../testUtils/mockData')

const productId = '1'

describe('#getCollateralRecord', () => {
describe('throw MissingParameterError', () => {
it('missing productId', () => {
expect(() => {
SpotClient.getCollateralRecord('')
}).toThrow(MissingParameterError)
it('should return collateral records', () => {
nockMock('/sapi/v1/simple-earn/flexible/history/collateralRecord')(mockResponse)

return SpotClient.getCollateralRecord().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
it('should suscribe locked product', () => {
it('should return collateral records with params', () => {
const parameters = {
productId
productId: '1'
}
nockMock(`/sapi/v1/simple-earn/flexible/history/collateralRecord?${buildQueryString(parameters)}`)(mockResponse)

return SpotClient.getCollateralRecord(productId).then(response => {
return SpotClient.getCollateralRecord(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('#getFlexiblePersonalLeftQuota', () => {
}).toThrow(MissingParameterError)
})
})
it('should redeem flexible product', () => {
it('should return flexible personal left quota', () => {
const parameters = {
productId
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup')
const { mockResponse } = require('../../testUtils/mockData')
const MissingParameterError = require('../../../src/error/missingParameterError')

const type = 'FLEXIBLE'
const type = 'REALTIME'

describe('#getFlexibleRewardsRecord', () => {
describe('throw MissingParameterError', () => {
Expand All @@ -14,7 +14,7 @@ describe('#getFlexibleRewardsRecord', () => {
})
})

it('should return locked records history with params', () => {
it('should return flexible reward records', () => {
const parameters = {
type,
productId: '1',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const { mockResponse } = require('../../testUtils/mockData')

const productId = '1'
Expand All @@ -21,7 +20,7 @@ describe('#getFlexibleSubscriptionPreview', () => {
}).toThrow(MissingParameterError)
})
})
it('should suscribe locked product', () => {
it('should return flexible subscription previews', () => {
const parameters = {
productId,
amount
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const { mockResponse } = require('../../testUtils/mockData')

const productId = '1'
const projectId = '1'

describe('#getLockedPersonalLeftQuota', () => {
describe('throw MissingParameterError', () => {
it('missing productId', () => {
it('missing projectId', () => {
expect(() => {
SpotClient.getLockedPersonalLeftQuota('')
}).toThrow(MissingParameterError)
})
})
it('should redeem flexible product', () => {
it('should return locked personal left quota', () => {
const parameters = {
productId
projectId
}
nockMock(`/sapi/v1/simple-earn/locked/personalLeftQuota?${buildQueryString({ ...parameters })}`)(mockResponse)

return SpotClient.getLockedPersonalLeftQuota(productId).then(response => {
return SpotClient.getLockedPersonalLeftQuota(projectId).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('#getLockedProductPosition', () => {
it('should return locked product position with params', () => {
const parameters = {
asset: 'USDT',
productId: '1',
positionId: '1',
current: 5,
size: 10
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('#getLockedRedemptionRecord', () => {
it('should return locked redemption records with params', () => {
const parameters = {
asset: 'USDT',
productId: '1',
positionId: '1',
current: 5,
size: 10
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const { mockResponse } = require('../../testUtils/mockData')

const productId = '1'
const projectId = '1'
const amount = 10

describe('#getLockedSubscriptionPreview', () => {
describe('throw MissingParameterError', () => {
it('missing productId', () => {
it('missing projectId', () => {
expect(() => {
SpotClient.getLockedSubscriptionPreview('', amount)
}).toThrow(MissingParameterError)
})

it('missing amount', () => {
expect(() => {
SpotClient.getLockedSubscriptionPreview(productId, '')
SpotClient.getLockedSubscriptionPreview(projectId, '')
}).toThrow(MissingParameterError)
})
})
it('should suscribe locked product', () => {
it('should return locked subscription preview', () => {
const parameters = {
productId,
projectId,
amount
}
nockMock(`/sapi/v1/simple-earn/locked/subscriptionPreview?${buildQueryString({ ...parameters })}`)(mockResponse)

return SpotClient.getLockedSubscriptionPreview(productId, amount).then(response => {
return SpotClient.getLockedSubscriptionPreview(projectId, amount).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const { mockResponse } = require('../../testUtils/mockData')

const productId = '1'
Expand All @@ -14,7 +13,7 @@ describe('#getRateHistory', () => {
}).toThrow(MissingParameterError)
})
})
it('should suscribe locked product', () => {
it('should return rate history', () => {
const parameters = {
productId
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockPostMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const { mockResponse } = require('../../testUtils/mockData')

const productId = '1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockPostMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const { mockResponse } = require('../../testUtils/mockData')

const productId = '1'
const positionId = '1'

describe('#redeemFlexibleProduct', () => {
describe('#redeemLockedProduct', () => {
describe('throw MissingParameterError', () => {
it('missing productId', () => {
it('missing positionId', () => {
expect(() => {
SpotClient.redeemFlexibleProduct('')
SpotClient.redeemLockedProduct('')
}).toThrow(MissingParameterError)
})
})
it('should suscribe flexible product', () => {
it('should redeem locked product', () => {
const parameters = {
productId
positionId
}
nockPostMock(`/sapi/v1/simple-earn/flexible/redeem?${buildQueryString({ ...parameters })}`)(mockResponse)
nockPostMock(`/sapi/v1/simple-earn/locked/redeem?${buildQueryString({ ...parameters })}`)(mockResponse)

return SpotClient.redeemFlexibleProduct(productId).then(response => {
return SpotClient.redeemLockedProduct(positionId).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockPostMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const { mockResponse } = require('../../testUtils/mockData')

const productId = '1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockPostMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const { mockResponse } = require('../../testUtils/mockData')

const productId = '1'
const positionId = '1'
const autoSubscribe = true

describe('#setLockedAutoSubscribe', () => {
describe('throw MissingParameterError', () => {
it('missing productId', () => {
it('missing positionId', () => {
expect(() => {
SpotClient.setLockedAutoSubscribe('', autoSubscribe)
}).toThrow(MissingParameterError)
})

it('missing autoSubscribe', () => {
expect(() => {
SpotClient.setLockedAutoSubscribe(productId, '')
SpotClient.setLockedAutoSubscribe(positionId, '')
}).toThrow(MissingParameterError)
})
})
it('should suscribe flexible product', () => {
it('should suscribe locked product', () => {
const parameters = {
productId,
positionId,
autoSubscribe
}
nockPostMock(`/sapi/v1/simple-earn/locked/setAutoSubscribe?${buildQueryString({ ...parameters })}`)(mockResponse)

return SpotClient.setLockedAutoSubscribe(productId, autoSubscribe).then(response => {
return SpotClient.setLockedAutoSubscribe(positionId, autoSubscribe).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockPostMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const { mockResponse } = require('../../testUtils/mockData')

const productId = '1'
Expand All @@ -21,7 +20,7 @@ describe('#subscribeFlexibleProduct', () => {
}).toThrow(MissingParameterError)
})
})
it('should suscribe flexible product', () => {
it('should subscribe flexible product', () => {
const parameters = {
productId,
amount
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockPostMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const { mockResponse } = require('../../testUtils/mockData')

const productId = '1'
const projectId = '1'
const amount = 10

describe('#subscribeLockedProduct', () => {
describe('throw MissingParameterError', () => {
it('missing productId', () => {
it('missing projectId', () => {
expect(() => {
SpotClient.subscribeLockedProduct('', amount)
}).toThrow(MissingParameterError)
})

it('missing amount', () => {
expect(() => {
SpotClient.subscribeLockedProduct(productId, '')
SpotClient.subscribeLockedProduct(projectId, '')
}).toThrow(MissingParameterError)
})
})
it('should suscribe locked product', () => {
it('should subscribe locked product', () => {
const parameters = {
productId,
projectId,
amount
}
nockPostMock(`/sapi/v1/simple-earn/locked/subscribe?${buildQueryString({ ...parameters })}`)(mockResponse)

return SpotClient.subscribeLockedProduct(productId, amount).then(response => {
return SpotClient.subscribeLockedProduct(projectId, amount).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
Expand Down
9 changes: 9 additions & 0 deletions examples/spot/simple_earn/getCollateralRecord.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Spot = require('../../../src/spot')

const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret)

client.getCollateralRecord()
.then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
9 changes: 9 additions & 0 deletions examples/spot/simple_earn/getFlexiblePersonalLeftQuota.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Spot = require('../../../src/spot')

const apiKey = ''
const apiSecret = ''
const client = new Spot(apiKey, apiSecret)

client.getFlexiblePersonalLeftQuota('BTC001')
.then(response => client.logger.log(response.data))
.catch(error => client.logger.error(error))
Loading

0 comments on commit 2367915

Please sign in to comment.