diff --git a/examples/apidoc/V5/Broker/issue-voucher.js b/examples/apidoc/V5/Broker/issue-voucher.js new file mode 100644 index 0000000..1140f0d --- /dev/null +++ b/examples/apidoc/V5/Broker/issue-voucher.js @@ -0,0 +1,22 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .issueBrokerVoucher({ + accountId: '2846381', + awardId: '123456', + specCode: 'award-001', + amount: '100', + brokerId: 'v-28478', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Broker/query-issued-voucher.js b/examples/apidoc/V5/Broker/query-issued-voucher.js new file mode 100644 index 0000000..df5e1c6 --- /dev/null +++ b/examples/apidoc/V5/Broker/query-issued-voucher.js @@ -0,0 +1,21 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getBrokerVoucherSpec({ + accountId: '5714139', + awardId: '189528', + specCode: 'demo000', + withUsedAmount: false, +}) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Broker/query-voucher-spec.js b/examples/apidoc/V5/Broker/query-voucher-spec.js new file mode 100644 index 0000000..b6e74e2 --- /dev/null +++ b/examples/apidoc/V5/Broker/query-voucher-spec.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getBrokerIssuedVoucher({ + id: '80209', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/package-lock.json b/package-lock.json index 3cc5b80..1559d69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "3.10.18", + "version": "3.10.19", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "3.10.18", + "version": "3.10.19", "license": "MIT", "dependencies": { "axios": "^1.6.6", diff --git a/package.json b/package.json index 7d307a0..64e244b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "3.10.18", + "version": "3.10.19", "description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index f722d31..9a30bf4 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -23,6 +23,8 @@ import { BatchOrderParamsV5, BatchOrdersResponseV5, BorrowHistoryRecordV5, + BrokerIssuedVoucherV5, + BrokerVoucherSpecV5, CancelAllOrdersParamsV5, CancelOrderParamsV5, CategoryCursorListV5, @@ -65,6 +67,7 @@ import { GetAllowedDepositCoinInfoParamsV5, GetAssetInfoParamsV5, GetBorrowHistoryParamsV5, + GetBrokerIssuedVoucherParamsV5, GetBrokerSubAccountDepositsV5, GetClassicTransactionLogsParamsV5, GetClosedPnLParamsV5, @@ -114,6 +117,7 @@ import { InsuranceResponseV5, InternalDepositRecordV5, InternalTransferRecordV5, + IssueVoucherParamsV5, LeverageTokenInfoV5, LeveragedTokenMarketResultV5, LongShortRatioV5, @@ -2167,4 +2171,37 @@ export class RestClientV5 extends BaseRestClient { params, ); } + + /** + * Query Voucher Spec + */ + getBrokerVoucherSpec(params: { + id: string; + }): Promise> { + return this.postPrivate('/v5/broker/award/info', params); + } + + /** + * Issue a voucher to a user + * + * INFO + * Use exchange broker master account to issue + */ + issueBrokerVoucher( + params: IssueVoucherParamsV5, + ): Promise> { + return this.postPrivate('/v5/broker/award/distribute-award', params); + } + + /** + * Query an issued voucher + * + * INFO + * Use exchange broker master account to query + */ + getBrokerIssuedVoucher( + params: GetBrokerIssuedVoucherParamsV5, + ): Promise> { + return this.postPrivate('/v5/broker/award/distribution-record', params); + } } diff --git a/src/types/request/v5-broker.ts b/src/types/request/v5-broker.ts index a815dc7..b604655 100644 --- a/src/types/request/v5-broker.ts +++ b/src/types/request/v5-broker.ts @@ -15,3 +15,18 @@ export interface GetBrokerSubAccountDepositsV5 { limit?: number; cursor?: string; } + +export interface IssueVoucherParamsV5 { + accountId: string; + awardId: string; + specCode: string; + amount: string; + brokerId: string; +} + +export interface GetBrokerIssuedVoucherParamsV5 { + accountId: string; + awardId: string; + specCode: string; + withUsedAmount?: boolean; +} diff --git a/src/types/response/v5-broker.ts b/src/types/response/v5-broker.ts index 6464fae..488ba4c 100644 --- a/src/types/response/v5-broker.ts +++ b/src/types/response/v5-broker.ts @@ -59,3 +59,28 @@ export interface ExchangeBrokerSubAccountDepositRecordV5 { batchReleaseLimit: string; depositType: string; } + +export interface BrokerVoucherSpecV5 { + id: string; + coin: string; + amountUnit: 'AWARD_AMOUNT_UNIT_USD' | 'AWARD_AMOUNT_UNIT_COIN'; + productLine: string; + subProductLine: string; + totalAmount: { + [key: string]: string; + }; + usedAmount: string; +} + +export interface BrokerIssuedVoucherV5 { + accountId: string; + awardId: string; + specCode: string; + amount: string; + isClaimed: boolean; + startAt: string; + endAt: string; + effectiveAt: string; + ineffectiveAt: string; + usedAmount: string; +}