Skip to content

Commit

Permalink
Merge pull request #378 from JJ-Cro/Update031024
Browse files Browse the repository at this point in the history
feat(): added new endpoints
  • Loading branch information
tiagosiebler authored Oct 3, 2024
2 parents 4091270 + 7567af4 commit 10046f8
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 3 deletions.
22 changes: 22 additions & 0 deletions examples/apidoc/V5/Broker/issue-voucher.js
Original file line number Diff line number Diff line change
@@ -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);
});
21 changes: 21 additions & 0 deletions examples/apidoc/V5/Broker/query-issued-voucher.js
Original file line number Diff line number Diff line change
@@ -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);
});
18 changes: 18 additions & 0 deletions examples/apidoc/V5/Broker/query-voucher-spec.js
Original file line number Diff line number Diff line change
@@ -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);
});
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
37 changes: 37 additions & 0 deletions src/rest-client-v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
BatchOrderParamsV5,
BatchOrdersResponseV5,
BorrowHistoryRecordV5,
BrokerIssuedVoucherV5,
BrokerVoucherSpecV5,
CancelAllOrdersParamsV5,
CancelOrderParamsV5,
CategoryCursorListV5,
Expand Down Expand Up @@ -65,6 +67,7 @@ import {
GetAllowedDepositCoinInfoParamsV5,
GetAssetInfoParamsV5,
GetBorrowHistoryParamsV5,
GetBrokerIssuedVoucherParamsV5,
GetBrokerSubAccountDepositsV5,
GetClassicTransactionLogsParamsV5,
GetClosedPnLParamsV5,
Expand Down Expand Up @@ -114,6 +117,7 @@ import {
InsuranceResponseV5,
InternalDepositRecordV5,
InternalTransferRecordV5,
IssueVoucherParamsV5,
LeverageTokenInfoV5,
LeveragedTokenMarketResultV5,
LongShortRatioV5,
Expand Down Expand Up @@ -2167,4 +2171,37 @@ export class RestClientV5 extends BaseRestClient {
params,
);
}

/**
* Query Voucher Spec
*/
getBrokerVoucherSpec(params: {
id: string;
}): Promise<APIResponseV3WithTime<BrokerVoucherSpecV5>> {
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<APIResponseV3<undefined>> {
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<APIResponseV3<BrokerIssuedVoucherV5>> {
return this.postPrivate('/v5/broker/award/distribution-record', params);
}
}
15 changes: 15 additions & 0 deletions src/types/request/v5-broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
25 changes: 25 additions & 0 deletions src/types/response/v5-broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 10046f8

Please sign in to comment.