From e4a0ad2a53a2f839d94e2187656af9685eebe5d5 Mon Sep 17 00:00:00 2001 From: Daniel Padrino Date: Thu, 15 Feb 2024 21:06:33 -0300 Subject: [PATCH] Simple Earn module --- .../simpleEarn/getCollateralRecord.test.js | 28 + .../getFlexiblePersonalLeftQuota.test.js | 28 + .../simpleEarn/getFlexibleProductList.test.js | 28 + .../getFlexibleProductPosition.test.js | 29 + .../getFlexibleRedemptionRecord.test.js | 29 + .../getFlexibleRewardsRecord.test.js | 30 + .../getFlexibleSubscriptionPreview.test.js | 36 ++ .../getFlexibleSubscriptionRecord.test.js | 29 + .../getLockedPersonalLeftQuota.test.js | 28 + .../simpleEarn/getLockedProductList.test.js | 28 + .../getLockedProductPosition.test.js | 29 + .../getLockedRedemptionRecord.test.js | 29 + .../simpleEarn/getLockedRewardsRecord.test.js | 29 + .../getLockedSubscriptionPreview.test.js | 36 ++ .../getLockedSubscriptionRecord.test.js | 29 + .../spot/simpleEarn/getRateHistory.test.js | 28 + .../spot/simpleEarn/getSimpleAccount.test.js | 26 + .../simpleEarn/redeemFlexibleProduct.test.js | 28 + .../simpleEarn/redeemLockedProduct.test.js | 28 + .../setFlexibleAutoSubscribe.test.js | 36 ++ .../simpleEarn/setLockedAutoSubscribe.test.js | 36 ++ .../subscribeFlexibleProduct.test.js | 36 ++ .../simpleEarn/subscribeLockedProduct.test.js | 36 ++ src/modules/restful/index.js | 1 + src/modules/restful/simpleEarn.js | 545 ++++++++++++++++++ 25 files changed, 1245 insertions(+) create mode 100644 __tests__/spot/simpleEarn/getCollateralRecord.test.js create mode 100644 __tests__/spot/simpleEarn/getFlexiblePersonalLeftQuota.test.js create mode 100644 __tests__/spot/simpleEarn/getFlexibleProductList.test.js create mode 100644 __tests__/spot/simpleEarn/getFlexibleProductPosition.test.js create mode 100644 __tests__/spot/simpleEarn/getFlexibleRedemptionRecord.test.js create mode 100644 __tests__/spot/simpleEarn/getFlexibleRewardsRecord.test.js create mode 100644 __tests__/spot/simpleEarn/getFlexibleSubscriptionPreview.test.js create mode 100644 __tests__/spot/simpleEarn/getFlexibleSubscriptionRecord.test.js create mode 100644 __tests__/spot/simpleEarn/getLockedPersonalLeftQuota.test.js create mode 100644 __tests__/spot/simpleEarn/getLockedProductList.test.js create mode 100644 __tests__/spot/simpleEarn/getLockedProductPosition.test.js create mode 100644 __tests__/spot/simpleEarn/getLockedRedemptionRecord.test.js create mode 100644 __tests__/spot/simpleEarn/getLockedRewardsRecord.test.js create mode 100644 __tests__/spot/simpleEarn/getLockedSubscriptionPreview.test.js create mode 100644 __tests__/spot/simpleEarn/getLockedSubscriptionRecord.test.js create mode 100644 __tests__/spot/simpleEarn/getRateHistory.test.js create mode 100644 __tests__/spot/simpleEarn/getSimpleAccount.test.js create mode 100644 __tests__/spot/simpleEarn/redeemFlexibleProduct.test.js create mode 100644 __tests__/spot/simpleEarn/redeemLockedProduct.test.js create mode 100644 __tests__/spot/simpleEarn/setFlexibleAutoSubscribe.test.js create mode 100644 __tests__/spot/simpleEarn/setLockedAutoSubscribe.test.js create mode 100644 __tests__/spot/simpleEarn/subscribeFlexibleProduct.test.js create mode 100644 __tests__/spot/simpleEarn/subscribeLockedProduct.test.js create mode 100644 src/modules/restful/simpleEarn.js diff --git a/__tests__/spot/simpleEarn/getCollateralRecord.test.js b/__tests__/spot/simpleEarn/getCollateralRecord.test.js new file mode 100644 index 0000000..a8f325e --- /dev/null +++ b/__tests__/spot/simpleEarn/getCollateralRecord.test.js @@ -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('#getCollateralRecord', () => { + describe('throw MissingParameterError', () => { + it('missing productId', () => { + expect(() => { + SpotClient.getCollateralRecord('') + }).toThrow(MissingParameterError) + }) + }) + it('should suscribe locked product', () => { + const parameters = { + productId + } + nockMock(`/sapi/v1/simple-earn/flexible/history/collateralRecord?${buildQueryString(parameters)}`)(mockResponse) + + return SpotClient.getCollateralRecord(productId).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getFlexiblePersonalLeftQuota.test.js b/__tests__/spot/simpleEarn/getFlexiblePersonalLeftQuota.test.js new file mode 100644 index 0000000..7e740f4 --- /dev/null +++ b/__tests__/spot/simpleEarn/getFlexiblePersonalLeftQuota.test.js @@ -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 redeem flexible product', () => { + 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) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getFlexibleProductList.test.js b/__tests__/spot/simpleEarn/getFlexibleProductList.test.js new file mode 100644 index 0000000..c340033 --- /dev/null +++ b/__tests__/spot/simpleEarn/getFlexibleProductList.test.js @@ -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) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getFlexibleProductPosition.test.js b/__tests__/spot/simpleEarn/getFlexibleProductPosition.test.js new file mode 100644 index 0000000..2e78696 --- /dev/null +++ b/__tests__/spot/simpleEarn/getFlexibleProductPosition.test.js @@ -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) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getFlexibleRedemptionRecord.test.js b/__tests__/spot/simpleEarn/getFlexibleRedemptionRecord.test.js new file mode 100644 index 0000000..a064a29 --- /dev/null +++ b/__tests__/spot/simpleEarn/getFlexibleRedemptionRecord.test.js @@ -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) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getFlexibleRewardsRecord.test.js b/__tests__/spot/simpleEarn/getFlexibleRewardsRecord.test.js new file mode 100644 index 0000000..117cb11 --- /dev/null +++ b/__tests__/spot/simpleEarn/getFlexibleRewardsRecord.test.js @@ -0,0 +1,30 @@ +/* global describe, it, expect */ +const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup') +const { mockResponse } = require('../../testUtils/mockData') +const MissingParameterError = require('../../../src/error/missingParameterError') + +const type = 'FLEXIBLE' + +describe('#getFlexibleRewardsRecord', () => { + describe('throw MissingParameterError', () => { + it('missing productId', () => { + expect(() => { + SpotClient.getFlexibleRewardsRecord('') + }).toThrow(MissingParameterError) + }) + }) + + it('should return locked records history with params', () => { + 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) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getFlexibleSubscriptionPreview.test.js b/__tests__/spot/simpleEarn/getFlexibleSubscriptionPreview.test.js new file mode 100644 index 0000000..3def1ae --- /dev/null +++ b/__tests__/spot/simpleEarn/getFlexibleSubscriptionPreview.test.js @@ -0,0 +1,36 @@ +/* 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 suscribe locked product', () => { + 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) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getFlexibleSubscriptionRecord.test.js b/__tests__/spot/simpleEarn/getFlexibleSubscriptionRecord.test.js new file mode 100644 index 0000000..1edbac7 --- /dev/null +++ b/__tests__/spot/simpleEarn/getFlexibleSubscriptionRecord.test.js @@ -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) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getLockedPersonalLeftQuota.test.js b/__tests__/spot/simpleEarn/getLockedPersonalLeftQuota.test.js new file mode 100644 index 0000000..ed17e8a --- /dev/null +++ b/__tests__/spot/simpleEarn/getLockedPersonalLeftQuota.test.js @@ -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('#getLockedPersonalLeftQuota', () => { + describe('throw MissingParameterError', () => { + it('missing productId', () => { + expect(() => { + SpotClient.getLockedPersonalLeftQuota('') + }).toThrow(MissingParameterError) + }) + }) + it('should redeem flexible product', () => { + const parameters = { + productId + } + nockMock(`/sapi/v1/simple-earn/locked/personalLeftQuota?${buildQueryString({ ...parameters })}`)(mockResponse) + + return SpotClient.getLockedPersonalLeftQuota(productId).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getLockedProductList.test.js b/__tests__/spot/simpleEarn/getLockedProductList.test.js new file mode 100644 index 0000000..4251382 --- /dev/null +++ b/__tests__/spot/simpleEarn/getLockedProductList.test.js @@ -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) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getLockedProductPosition.test.js b/__tests__/spot/simpleEarn/getLockedProductPosition.test.js new file mode 100644 index 0000000..fded184 --- /dev/null +++ b/__tests__/spot/simpleEarn/getLockedProductPosition.test.js @@ -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', + productId: '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) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getLockedRedemptionRecord.test.js b/__tests__/spot/simpleEarn/getLockedRedemptionRecord.test.js new file mode 100644 index 0000000..53e6f71 --- /dev/null +++ b/__tests__/spot/simpleEarn/getLockedRedemptionRecord.test.js @@ -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', + productId: '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) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getLockedRewardsRecord.test.js b/__tests__/spot/simpleEarn/getLockedRewardsRecord.test.js new file mode 100644 index 0000000..30dff36 --- /dev/null +++ b/__tests__/spot/simpleEarn/getLockedRewardsRecord.test.js @@ -0,0 +1,29 @@ +/* global describe, it, expect */ +const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup') +const { mockResponse } = require('../../testUtils/mockData') + +describe('#getLockedRewardsRecord', () => { + it('should return locked records history', () => { + nockMock('/sapi/v1/simple-earn/locked/history/rewardsRecord')(mockResponse) + + return SpotClient.getLockedRewardsRecord().then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) + + it('should return locked records history with params', () => { + const parameters = { + asset: 'USDT', + positionId: '1', + current: 5, + size: 10 + } + nockMock(`/sapi/v1/simple-earn/locked/history/rewardsRecord?${buildQueryString(parameters)}`)(mockResponse) + + return SpotClient.getLockedRewardsRecord(parameters).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getLockedSubscriptionPreview.test.js b/__tests__/spot/simpleEarn/getLockedSubscriptionPreview.test.js new file mode 100644 index 0000000..22e5e97 --- /dev/null +++ b/__tests__/spot/simpleEarn/getLockedSubscriptionPreview.test.js @@ -0,0 +1,36 @@ +/* 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('#getLockedSubscriptionPreview', () => { + describe('throw MissingParameterError', () => { + it('missing productId', () => { + expect(() => { + SpotClient.getLockedSubscriptionPreview('', amount) + }).toThrow(MissingParameterError) + }) + + it('missing amount', () => { + expect(() => { + SpotClient.getLockedSubscriptionPreview(productId, '') + }).toThrow(MissingParameterError) + }) + }) + it('should suscribe locked product', () => { + const parameters = { + productId, + amount + } + nockMock(`/sapi/v1/simple-earn/locked/subscriptionPreview?${buildQueryString({ ...parameters })}`)(mockResponse) + + return SpotClient.getLockedSubscriptionPreview(productId, amount).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getLockedSubscriptionRecord.test.js b/__tests__/spot/simpleEarn/getLockedSubscriptionRecord.test.js new file mode 100644 index 0000000..85537d3 --- /dev/null +++ b/__tests__/spot/simpleEarn/getLockedSubscriptionRecord.test.js @@ -0,0 +1,29 @@ +/* global describe, it, expect */ +const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup') +const { mockResponse } = require('../../testUtils/mockData') + +describe('#getLockedSubscriptionRecord', () => { + it('should return locked subscription records', () => { + nockMock('/sapi/v1/simple-earn/locked/history/subscriptionRecord')(mockResponse) + + return SpotClient.getLockedSubscriptionRecord().then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) + + it('should return locked subscription records with params', () => { + const parameters = { + asset: 'USDT', + purchaseId: '1', + current: 5, + size: 10 + } + nockMock(`/sapi/v1/simple-earn/locked/history/subscriptionRecord?${buildQueryString(parameters)}`)(mockResponse) + + return SpotClient.getLockedSubscriptionRecord(parameters).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getRateHistory.test.js b/__tests__/spot/simpleEarn/getRateHistory.test.js new file mode 100644 index 0000000..4cbdabf --- /dev/null +++ b/__tests__/spot/simpleEarn/getRateHistory.test.js @@ -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('#getRateHistory', () => { + describe('throw MissingParameterError', () => { + it('missing productId', () => { + expect(() => { + SpotClient.getRateHistory('') + }).toThrow(MissingParameterError) + }) + }) + it('should suscribe locked product', () => { + const parameters = { + productId + } + nockMock(`/sapi/v1/simple-earn/flexible/history/rateHistory?${buildQueryString(parameters)}`)(mockResponse) + + return SpotClient.getRateHistory(productId).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/getSimpleAccount.test.js b/__tests__/spot/simpleEarn/getSimpleAccount.test.js new file mode 100644 index 0000000..f4f093e --- /dev/null +++ b/__tests__/spot/simpleEarn/getSimpleAccount.test.js @@ -0,0 +1,26 @@ +/* global describe, it, expect */ +const { nockMock, SpotClient, buildQueryString } = require('../../testUtils/testSetup') +const { mockResponse } = require('../../testUtils/mockData') + +describe('#getSimpleAccount', () => { + it('should return simple account details', () => { + nockMock('/sapi/v1/simple-earn/account')(mockResponse) + + return SpotClient.getSimpleAccount().then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) + + it('should return simple account details with params', () => { + const parameters = { + recvWindow: 1000 + } + nockMock(`/sapi/v1/simple-earn/account?${buildQueryString(parameters)}`)(mockResponse) + + return SpotClient.getSimpleAccount(parameters).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/redeemFlexibleProduct.test.js b/__tests__/spot/simpleEarn/redeemFlexibleProduct.test.js new file mode 100644 index 0000000..e2c0a76 --- /dev/null +++ b/__tests__/spot/simpleEarn/redeemFlexibleProduct.test.js @@ -0,0 +1,28 @@ +/* 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' + +describe('#redeemFlexibleProduct', () => { + describe('throw MissingParameterError', () => { + it('missing productId', () => { + expect(() => { + SpotClient.redeemFlexibleProduct('') + }).toThrow(MissingParameterError) + }) + }) + it('should redeem flexible product', () => { + const parameters = { + productId + } + nockPostMock(`/sapi/v1/simple-earn/flexible/redeem?${buildQueryString({ ...parameters })}`)(mockResponse) + + return SpotClient.redeemFlexibleProduct(productId).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/redeemLockedProduct.test.js b/__tests__/spot/simpleEarn/redeemLockedProduct.test.js new file mode 100644 index 0000000..b4db459 --- /dev/null +++ b/__tests__/spot/simpleEarn/redeemLockedProduct.test.js @@ -0,0 +1,28 @@ +/* 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' + +describe('#redeemFlexibleProduct', () => { + describe('throw MissingParameterError', () => { + it('missing productId', () => { + expect(() => { + SpotClient.redeemFlexibleProduct('') + }).toThrow(MissingParameterError) + }) + }) + it('should suscribe flexible product', () => { + const parameters = { + productId + } + nockPostMock(`/sapi/v1/simple-earn/flexible/redeem?${buildQueryString({ ...parameters })}`)(mockResponse) + + return SpotClient.redeemFlexibleProduct(productId).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/setFlexibleAutoSubscribe.test.js b/__tests__/spot/simpleEarn/setFlexibleAutoSubscribe.test.js new file mode 100644 index 0000000..31757ba --- /dev/null +++ b/__tests__/spot/simpleEarn/setFlexibleAutoSubscribe.test.js @@ -0,0 +1,36 @@ +/* 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 autoSubscribe = true + +describe('#setFlexibleAutoSubscribe', () => { + describe('throw MissingParameterError', () => { + it('missing productId', () => { + expect(() => { + SpotClient.setFlexibleAutoSubscribe('', autoSubscribe) + }).toThrow(MissingParameterError) + }) + + it('missing autoSubscribe', () => { + expect(() => { + SpotClient.setFlexibleAutoSubscribe(productId, '') + }).toThrow(MissingParameterError) + }) + }) + it('should suscribe flexible product', () => { + const parameters = { + productId, + autoSubscribe + } + nockPostMock(`/sapi/v1/simple-earn/flexible/setAutoSubscribe?${buildQueryString({ ...parameters })}`)(mockResponse) + + return SpotClient.setFlexibleAutoSubscribe(productId, autoSubscribe).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/setLockedAutoSubscribe.test.js b/__tests__/spot/simpleEarn/setLockedAutoSubscribe.test.js new file mode 100644 index 0000000..decea8d --- /dev/null +++ b/__tests__/spot/simpleEarn/setLockedAutoSubscribe.test.js @@ -0,0 +1,36 @@ +/* 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 autoSubscribe = true + +describe('#setLockedAutoSubscribe', () => { + describe('throw MissingParameterError', () => { + it('missing productId', () => { + expect(() => { + SpotClient.setLockedAutoSubscribe('', autoSubscribe) + }).toThrow(MissingParameterError) + }) + + it('missing autoSubscribe', () => { + expect(() => { + SpotClient.setLockedAutoSubscribe(productId, '') + }).toThrow(MissingParameterError) + }) + }) + it('should suscribe flexible product', () => { + const parameters = { + productId, + autoSubscribe + } + nockPostMock(`/sapi/v1/simple-earn/locked/setAutoSubscribe?${buildQueryString({ ...parameters })}`)(mockResponse) + + return SpotClient.setLockedAutoSubscribe(productId, autoSubscribe).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/subscribeFlexibleProduct.test.js b/__tests__/spot/simpleEarn/subscribeFlexibleProduct.test.js new file mode 100644 index 0000000..fd420fd --- /dev/null +++ b/__tests__/spot/simpleEarn/subscribeFlexibleProduct.test.js @@ -0,0 +1,36 @@ +/* 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 amount = 10 + +describe('#subscribeFlexibleProduct', () => { + describe('throw MissingParameterError', () => { + it('missing productId', () => { + expect(() => { + SpotClient.subscribeFlexibleProduct('', amount) + }).toThrow(MissingParameterError) + }) + + it('missing amount', () => { + expect(() => { + SpotClient.subscribeFlexibleProduct(productId, '') + }).toThrow(MissingParameterError) + }) + }) + it('should suscribe flexible product', () => { + const parameters = { + productId, + amount + } + nockPostMock(`/sapi/v1/simple-earn/flexible/subscribe?${buildQueryString({ ...parameters })}`)(mockResponse) + + return SpotClient.subscribeFlexibleProduct(productId, amount).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/__tests__/spot/simpleEarn/subscribeLockedProduct.test.js b/__tests__/spot/simpleEarn/subscribeLockedProduct.test.js new file mode 100644 index 0000000..a1c2e18 --- /dev/null +++ b/__tests__/spot/simpleEarn/subscribeLockedProduct.test.js @@ -0,0 +1,36 @@ +/* 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 amount = 10 + +describe('#subscribeLockedProduct', () => { + describe('throw MissingParameterError', () => { + it('missing productId', () => { + expect(() => { + SpotClient.subscribeLockedProduct('', amount) + }).toThrow(MissingParameterError) + }) + + it('missing amount', () => { + expect(() => { + SpotClient.subscribeLockedProduct(productId, '') + }).toThrow(MissingParameterError) + }) + }) + it('should suscribe locked product', () => { + const parameters = { + productId, + amount + } + nockPostMock(`/sapi/v1/simple-earn/locked/subscribe?${buildQueryString({ ...parameters })}`)(mockResponse) + + return SpotClient.subscribeLockedProduct(productId, amount).then(response => { + expect(response).toBeDefined() + expect(response.data).toEqual(mockResponse) + }) + }) +}) diff --git a/src/modules/restful/index.js b/src/modules/restful/index.js index aa17535..64de468 100644 --- a/src/modules/restful/index.js +++ b/src/modules/restful/index.js @@ -19,3 +19,4 @@ module.exports.Rebate = require('./rebate') module.exports.NFT = require('./nft') module.exports.GiftCard = require('./giftCard') module.exports.PortfolioMargin = require('./portfolioMargin') +module.exports.SimpleEarn = require('./simpleEarn') diff --git a/src/modules/restful/simpleEarn.js b/src/modules/restful/simpleEarn.js new file mode 100644 index 0000000..3e057f7 --- /dev/null +++ b/src/modules/restful/simpleEarn.js @@ -0,0 +1,545 @@ +'use strict' + +const { validateRequiredParameters } = require('../../helpers/validation') + +/** + * API Simple Earn endpoints + * @module SimpleEarn + * @param {*} superclass + */ +const SimpleEarn = superclass => class extends superclass { + /** + * Get Simple Earn Flexible Product List (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/flexible/list
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-simple-earn-flexible-product-list-user_data} + * + * @param {object} [options] + * @param {string} [options.asset] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getFlexibleProductList (options = {}) { + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/flexible/list', + options + ) + } + + /** + * Get Simple Earn Locked Product List (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/locked/list
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-simple-earn-locked-product-list-user_data} + * + * @param {object} [options] + * @param {string} [options.asset] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getLockedProductList (options = {}) { + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/locked/list', + options + ) + } + + /** + * Subscribe Flexible Product (TRADE)
+ * + * POST /sapi/v1/simple-earn/flexible/subscribe
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-simple-earn-locked-product-list-user_data} + * + * @param {string} productId + * @param {number} amount + * @param {object} options + * @param {boolean} [options.autoSubscribe] + * @param {string} [options.sourceAccount] + * @param {number} [options.recvWindow] + * + */ + subscribeFlexibleProduct (productId, amount, options = {}) { + validateRequiredParameters({ productId, amount }) + return this.signRequest( + 'POST', + '/sapi/v1/simple-earn/flexible/subscribe', + Object.assign(options, { productId, amount }) + ) + } + + /** + * Subscribe Locked Product (TRADE)
+ * + * POST /sapi/v1/simple-earn/locked/subscribe
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#subscribe-locked-product-trade} + * + * @param {string} productId + * @param {number} amount + * @param {object} options + * @param {boolean} [options.autoSubscribe] + * @param {string} [options.sourceAccount] + * @param {number} [options.recvWindow] + * + */ + subscribeLockedProduct (productId, amount, options = {}) { + validateRequiredParameters({ productId, amount }) + return this.signRequest( + 'POST', + '/sapi/v1/simple-earn/locked/subscribe', + Object.assign(options, { productId, amount }) + ) + } + + /** + * Redeem Flexible Product (TRADE)
+ * + * POST /sapi/v1/simple-earn/flexible/redeem
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#redeem-flexible-product-trade} + * + * @param {string} productId + * @param {object} options + * @param {boolean} [options.redeemAll] // true or false, default to false + * @param {number} [options.amount] // if redeemAll is false, amount is mandatory + * @param {string} [options.destAccount] + * @param {number} [options.recvWindow] + * + */ + redeemFlexibleProduct (productId, options = {}) { + validateRequiredParameters({ productId }) + return this.signRequest( + 'POST', + '/sapi/v1/simple-earn/flexible/redeem', + Object.assign(options, { productId }) + ) + } + + /** + * Redeem Locked Product (TRADE)
+ * + * POST /sapi/v1/simple-earn/locked/redeem
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#redeem-locked-product-trade} + * + * @param {string} productId + * @param {object} options + * @param {number} [options.recvWindow] + * + */ + redeemLockedProduct (productId, options = {}) { + validateRequiredParameters({ productId }) + return this.signRequest( + 'POST', + '/sapi/v1/simple-earn/locked/redeem', + Object.assign(options, { productId }) + ) + } + + /** + * Get Flexible Product Position (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/flexible/position
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-flexible-product-position-user_data} + * + * + * @param {object} options + * @param {string} [options.asset] + * @param {string} [options.productId] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getFlexibleProductPosition (options = {}) { + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/flexible/position', + options + ) + } + + /** + * Get Locked Product Position (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/locked/position
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-locked-product-position-user_data} + * + * + * @param {object} options + * @param {string} [options.asset] + * @param {string} [options.productId] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getLockedProductPosition (options = {}) { + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/locked/position', + options + ) + } + + /** + * Get Simple Account (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/account
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-simple-account-user_data} + * + * @param {object} options + * @param {number} [options.recvWindow] + * + */ + getSimpleAccount (options = {}) { + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/account', + options + ) + } + + /** + * Get Flexible Subscription Record (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/flexible/history/subscriptionRecord
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-flexible-subscription-record-user_data} + * + * @param {object} options + * @param {string} [options.productId] + * @param {string} [options.purchaseId] + * @param {string} [options.asset] + * @param {number} [options.startTime] + * @param {number} [options.endTime] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getFlexibleSubscriptionRecord (options = {}) { + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/flexible/history/subscriptionRecord', + options + ) + } + + /** + * Get Locked Subscription Record (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/locked/history/subscriptionRecord
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-locked-subscription-record-user_data} + * + * @param {object} options + * @param {string} [options.purchaseId] + * @param {string} [options.asset] + * @param {number} [options.startTime] + * @param {number} [options.endTime] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getLockedSubscriptionRecord (options = {}) { + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/locked/history/subscriptionRecord', + options + ) + } + + /** + * Get Flexible Redemption Record (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/flexible/history/redemptionRecord
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-flexible-redemption-record-user_data} + * + * @param {object} options + * @param {string} [options.productId] + * @param {string} [options.redeemId] + * @param {string} [options.asset] + * @param {number} [options.startTime] + * @param {number} [options.endTime] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getFlexibleRedemptionRecord (options = {}) { + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/flexible/history/redemptionRecord', + options + ) + } + + /** + * Get Locked Redemption Record (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/locked/history/redemptionRecord
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-locked-redemption-record-user_data} + * + * @param {object} options + * @param {string} [options.redeemId] + * @param {string} [options.asset] + * @param {number} [options.startTime] + * @param {number} [options.endTime] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getLockedRedemptionRecord (options = {}) { + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/locked/history/redemptionRecord', + options + ) + } + + /** + * Get Flexible Rewards History (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/flexible/history/rewardsRecord
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-flexible-rewards-history-user_data} + * + * @param {object} options + * @param {string} type + * @param {string} [options.productId] + * @param {string} [options.asset] + * @param {number} [options.startTime] + * @param {number} [options.endTime] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getFlexibleRewardsRecord (type, options = {}) { + validateRequiredParameters({ type }) + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/flexible/history/rewardsRecord', + Object.assign(options, { type }) + ) + } + + /** + * Get Locked Rewards History (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/locked/history/rewardsRecord
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-locked-rewards-history-user_data} + * + * @param {object} options + * @param {string} [options.positionId] + * @param {string} [options.asset] + * @param {number} [options.startTime] + * @param {number} [options.endTime] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getLockedRewardsRecord (options = {}) { + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/locked/history/rewardsRecord', + options + ) + } + + /** + * Set Flexible Auto Subscribe (USER_DATA)
+ * + * POST /sapi/v1/simple-earn/flexible/setAutoSubscribe
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#set-flexible-auto-subscribe-user_data} + * + * @param {string} productId + * @param {boolean} autoSubscribe + * @param {object} [options] + * @param {number} [options.recvWindow] + * + */ + setFlexibleAutoSubscribe (productId, autoSubscribe, options = {}) { + validateRequiredParameters({ productId, autoSubscribe }) + return this.signRequest( + 'POST', + '/sapi/v1/simple-earn/flexible/setAutoSubscribe', + Object.assign(options, { productId, autoSubscribe }) + ) + } + + /** + * Set Locked Auto Subscribe (USER_DATA)
+ * + * POST /sapi/v1/simple-earn/locked/setAutoSubscribe
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#set-locked-auto-subscribe-user_data} + * + * @param {string} productId + * @param {boolean} autoSubscribe + * @param {object} [options] + * @param {number} [options.recvWindow] + * + */ + setLockedAutoSubscribe (productId, autoSubscribe, options = {}) { + validateRequiredParameters({ productId, autoSubscribe }) + return this.signRequest( + 'POST', + '/sapi/v1/simple-earn/locked/setAutoSubscribe', + Object.assign(options, { productId, autoSubscribe }) + ) + } + + /** + * Get Flexible Personal Left Quota (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/flexible/personalLeftQuota
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-flexible-personal-left-quota-user_data} + * + * @param {string} productId + * @param {number} [options.recvWindow] + * + */ + getFlexiblePersonalLeftQuota (productId, options = {}) { + validateRequiredParameters({ productId }) + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/flexible/personalLeftQuota', + Object.assign(options, { productId }) + ) + } + + /** + * Get Locked Personal Left Quota (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/locked/personalLeftQuota
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-locked-personal-left-quota-user_data} + * + * @param {string} productId + * @param {number} [options.recvWindow] + * + */ + getLockedPersonalLeftQuota (productId, options = {}) { + validateRequiredParameters({ productId }) + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/locked/personalLeftQuota', + Object.assign(options, { productId }) + ) + } + + /** + * Get Flexible Subscription Preview (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/flexible/subscriptionPreview
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-flexible-subscription-preview-user_data} + * + * @param {string} productId + * @param {number} amount + * @param {object} [options] + * @param {number} [options.recvWindow] + * + */ + getFlexibleSubscriptionPreview (productId, amount, options = {}) { + validateRequiredParameters({ productId, amount }) + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/flexible/subscriptionPreview', + Object.assign(options, { productId, amount }) + ) + } + + /** + * Get Locked Subscription Preview (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/locked/subscriptionPreview
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-locked-subscription-preview-user_data} + * + * @param {string} productId + * @param {number} amount + * @param {object} [options] + * @param {number} [options.recvWindow] + * + */ + getLockedSubscriptionPreview (productId, amount, options = {}) { + validateRequiredParameters({ productId, amount }) + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/locked/subscriptionPreview', + Object.assign(options, { productId, amount }) + ) + } + + /** + * Get Rate History (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/flexible/history/rateHistory
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-rate-history-user_data} + * + * @param {string} productId + * @param {number} [options.startTime] + * @param {number} [options.endTime] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getRateHistory (productId, options = {}) { + validateRequiredParameters({ productId }) + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/flexible/history/rateHistory', + Object.assign(options, { productId }) + ) + } + + /** + * Get Collateral Record (USER_DATA)
+ * + * GET /sapi/v1/simple-earn/flexible/history/collateralRecord
+ * + * {@link https://binance-docs.github.io/apidocs/spot/en/#get-collateral-record-user_data} + * + * @param {string} productId + * @param {number} [options.startTime] + * @param {number} [options.endTime] + * @param {number} [options.current] + * @param {number} [options.size] + * @param {number} [options.recvWindow] + * + */ + getCollateralRecord (productId, options = {}) { + validateRequiredParameters({ productId }) + return this.signRequest( + 'GET', + '/sapi/v1/simple-earn/flexible/history/collateralRecord', + Object.assign(options, { productId }) + ) + } +} +module.exports = SimpleEarn