Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rc v3.3.0 #155

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Changelog

## 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

## 3.2.0 - 2024-01-23

### Changed
Expand Down
25 changes: 25 additions & 0 deletions __tests__/spot/simple_earn/getCollateralRecord.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* global describe, it, expect */
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')
const { mockResponse } = require('../../testUtils/mockData')

describe('#getCollateralRecord', () => {
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 return collateral records with params', () => {
const parameters = {
productId: '1'
}
nockMock(`/sapi/v1/simple-earn/flexible/history/collateralRecord?${buildQueryString(parameters)}`)(mockResponse)

return SpotClient.getCollateralRecord(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
28 changes: 28 additions & 0 deletions __tests__/spot/simple_earn/getFlexiblePersonalLeftQuota.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* 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('#getFlexiblePersonalLeftQuota', () => {
describe('throw MissingParameterError', () => {
it('missing productId', () => {
expect(() => {
SpotClient.getFlexiblePersonalLeftQuota('')
}).toThrow(MissingParameterError)
})
})
it('should return flexible personal left quota', () => {
const parameters = {
productId
}
nockMock(`/sapi/v1/simple-earn/flexible/personalLeftQuota?${buildQueryString({ ...parameters })}`)(mockResponse)

return SpotClient.getFlexiblePersonalLeftQuota(productId).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
28 changes: 28 additions & 0 deletions __tests__/spot/simple_earn/getFlexibleProductList.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* global describe, it, expect */
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup')
const { mockResponse } = require('../../testUtils/mockData')

describe('#getFlexibleProductList', () => {
it('should return flexible product list', () => {
nockMock('/sapi/v1/simple-earn/flexible/list')(mockResponse)

return SpotClient.getFlexibleProductList().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})

it('should return flexible product list with params', () => {
const parameters = {
asset: 'USDT',
current: 5,
size: 10
}
nockMock(`/sapi/v1/simple-earn/flexible/list?${buildQueryString(parameters)}`)(mockResponse)

return SpotClient.getFlexibleProductList(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
29 changes: 29 additions & 0 deletions __tests__/spot/simple_earn/getFlexibleProductPosition.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* global describe, it, expect */
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup')
const { mockResponse } = require('../../testUtils/mockData')

describe('#getFlexibleProductPosition', () => {
it('should return flexible product position', () => {
nockMock('/sapi/v1/simple-earn/flexible/position')(mockResponse)

return SpotClient.getFlexibleProductPosition().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})

it('should return flexible product position with params', () => {
const parameters = {
asset: 'USDT',
productId: '1',
current: 5,
size: 10
}
nockMock(`/sapi/v1/simple-earn/flexible/position?${buildQueryString(parameters)}`)(mockResponse)

return SpotClient.getFlexibleProductPosition(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
29 changes: 29 additions & 0 deletions __tests__/spot/simple_earn/getFlexibleRedemptionRecord.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* global describe, it, expect */
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup')
const { mockResponse } = require('../../testUtils/mockData')

describe('#getFlexibleRedemptionRecord', () => {
it('should return flexible redemption records', () => {
nockMock('/sapi/v1/simple-earn/flexible/history/redemptionRecord')(mockResponse)

return SpotClient.getFlexibleRedemptionRecord().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})

it('should return flexible redemption records with params', () => {
const parameters = {
asset: 'USDT',
productId: '1',
current: 5,
size: 10
}
nockMock(`/sapi/v1/simple-earn/flexible/history/redemptionRecord?${buildQueryString(parameters)}`)(mockResponse)

return SpotClient.getFlexibleRedemptionRecord(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
30 changes: 30 additions & 0 deletions __tests__/spot/simple_earn/getFlexibleRewardsRecord.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup')
const { mockResponse } = require('../../testUtils/mockData')

const type = 'REALTIME'

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

it('should return flexible reward records', () => {
const parameters = {
type,
productId: '1',
asset: 'USDT'
}
nockMock(`/sapi/v1/simple-earn/flexible/history/rewardsRecord?${buildQueryString(parameters)}`)(mockResponse)

return SpotClient.getFlexibleRewardsRecord(type, parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
35 changes: 35 additions & 0 deletions __tests__/spot/simple_earn/getFlexibleSubscriptionPreview.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* 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 amount = 10

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

it('missing amount', () => {
expect(() => {
SpotClient.getFlexibleSubscriptionPreview(productId, '')
}).toThrow(MissingParameterError)
})
})
it('should return flexible subscription previews', () => {
const parameters = {
productId,
amount
}
nockMock(`/sapi/v1/simple-earn/flexible/subscriptionPreview?${buildQueryString({ ...parameters })}`)(mockResponse)

return SpotClient.getFlexibleSubscriptionPreview(productId, amount).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
29 changes: 29 additions & 0 deletions __tests__/spot/simple_earn/getFlexibleSubscriptionRecord.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* global describe, it, expect */
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup')
const { mockResponse } = require('../../testUtils/mockData')

describe('#getFlexibleSubscriptionRecord', () => {
it('should return flexible subscription records', () => {
nockMock('/sapi/v1/simple-earn/flexible/history/subscriptionRecord')(mockResponse)

return SpotClient.getFlexibleSubscriptionRecord().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})

it('should return flexible subscription records with params', () => {
const parameters = {
asset: 'USDT',
purchaseId: '1',
current: 5,
size: 10
}
nockMock(`/sapi/v1/simple-earn/flexible/history/subscriptionRecord?${buildQueryString(parameters)}`)(mockResponse)

return SpotClient.getFlexibleSubscriptionRecord(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
27 changes: 27 additions & 0 deletions __tests__/spot/simple_earn/getLockedPersonalLeftQuota.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* global describe, it, expect */
const MissingParameterError = require('../../../src/error/missingParameterError')
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')
const { mockResponse } = require('../../testUtils/mockData')

const projectId = '1'

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

return SpotClient.getLockedPersonalLeftQuota(projectId).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
28 changes: 28 additions & 0 deletions __tests__/spot/simple_earn/getLockedProductList.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* global describe, it, expect */
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup')
const { mockResponse } = require('../../testUtils/mockData')

describe('#getLockedProductList', () => {
it('should return locked product list', () => {
nockMock('/sapi/v1/simple-earn/locked/list')(mockResponse)

return SpotClient.getLockedProductList().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})

it('should return locked product list with params', () => {
const parameters = {
asset: 'USDT',
current: 5,
size: 10
}
nockMock(`/sapi/v1/simple-earn/locked/list?${buildQueryString(parameters)}`)(mockResponse)

return SpotClient.getLockedProductList(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
29 changes: 29 additions & 0 deletions __tests__/spot/simple_earn/getLockedProductPosition.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* global describe, it, expect */
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup')
const { mockResponse } = require('../../testUtils/mockData')

describe('#getLockedProductPosition', () => {
it('should return locked product position', () => {
nockMock('/sapi/v1/simple-earn/locked/position')(mockResponse)

return SpotClient.getLockedProductPosition().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})

it('should return locked product position with params', () => {
const parameters = {
asset: 'USDT',
positionId: '1',
current: 5,
size: 10
}
nockMock(`/sapi/v1/simple-earn/locked/position?${buildQueryString(parameters)}`)(mockResponse)

return SpotClient.getLockedProductPosition(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
29 changes: 29 additions & 0 deletions __tests__/spot/simple_earn/getLockedRedemptionRecord.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* global describe, it, expect */
const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup')
const { mockResponse } = require('../../testUtils/mockData')

describe('#getLockedRedemptionRecord', () => {
it('should return locked redemption records', () => {
nockMock('/sapi/v1/simple-earn/locked/history/redemptionRecord')(mockResponse)

return SpotClient.getLockedRedemptionRecord().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})

it('should return locked redemption records with params', () => {
const parameters = {
asset: 'USDT',
positionId: '1',
current: 5,
size: 10
}
nockMock(`/sapi/v1/simple-earn/locked/history/redemptionRecord?${buildQueryString(parameters)}`)(mockResponse)

return SpotClient.getLockedRedemptionRecord(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
Loading
Loading