From 6cabbe5edb89f894461bb7aec4b25586270e7303 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Fri, 13 Dec 2024 12:12:16 +0100 Subject: [PATCH] feat(): added all broker response types --- src/rest-client-v2.ts | 67 ++++++++++---- src/types/response/index.ts | 1 + src/types/response/v2/broker.ts | 159 ++++++++++++++++++++++++++++++++ 3 files changed, 208 insertions(+), 19 deletions(-) create mode 100644 src/types/response/v2/broker.ts diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index ebbbe10..05f70c3 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -16,6 +16,9 @@ import { ConvertTradeResponseV2, CopyTradingProductTypeV2, CreateSubAccountApiKeyRequestV2, + CreateSubaccountApiKeyResponseV2, + CreateSubaccountDepositAddressV2, + CreateSubaccountResponseV2, CreateVirtualSubAccountAndApiKeyV2, CreateVirtualSubAccountApiKeyV2, CreateVirtualSubAccountV2, @@ -158,6 +161,8 @@ import { ModifyFuturesTraderOrderTPSLRequestV2, ModifyLoanPledgeRateRequestV2, ModifySubAccountApiKeyRequestV2, + ModifySubaccountApiKeyResponseV2, + ModifySubaccountResponseV2, ModifySubRequestV2, ModifyVirtualSubAccountApiKeyV2, ModifyVirtualSubApiKeyRequestV2, @@ -214,6 +219,13 @@ import { SpotWithdrawalRecordV2, SpotWithdrawalRequestV2, SubAccountApiKeyListV2, + SubaccountApiKeyV2, + SubaccountDepositV2, + SubaccountEmailV2, + SubaccountFutureAssetsV2, + SubaccountsListV2, + SubaccountSpotAssetsV2, + SubaccountWithdrawalV2, SubDepositRecordsRequestV2, SubmitSpotBatchOrdersResponseV2, SubWithdrawalRecordsRequestV2, @@ -1451,33 +1463,45 @@ export class RestClientV2 extends BaseRestClient { modifySubaccountEmail(params: { subUid: string; subaccountEmail: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/broker/account/modify-subaccount-email', params, ); } - getBrokerInfo(): Promise> { + getBrokerInfo(): Promise< + APIResponse<{ + subAccountSize: string; + maxSubAccountSize: string; + uTime: string; + }> + > { return this.getPrivate('/api/v2/broker/account/info'); } createSubaccount(params: { subaccountName: string; label: string; - }): Promise> { + }): Promise> { return this.postPrivate('/api/v2/broker/account/create-subaccount', params); } - getSubaccounts(params?: GetSubAccountsRequestV2): Promise> { + getSubaccounts( + params?: GetSubAccountsRequestV2, + ): Promise> { return this.getPrivate('/api/v2/broker/account/subaccount-list', params); } - modifySubaccount(params: ModifySubRequestV2): Promise> { + modifySubaccount( + params: ModifySubRequestV2, + ): Promise> { return this.postPrivate('/api/v2/broker/account/modify-subaccount', params); } - getSubaccountEmail(params: { subUid: string }): Promise> { + getSubaccountEmail(params: { + subUid: string; + }): Promise> { return this.getPrivate('/api/v2/broker/account/subaccount-email', params); } @@ -1485,7 +1509,7 @@ export class RestClientV2 extends BaseRestClient { subUid: string; coin?: string; assetType?: 'hold_only' | 'all'; - }): Promise> { + }): Promise> { return this.getPrivate( '/api/v2/broker/account/subaccount-spot-assets', params, @@ -1495,7 +1519,7 @@ export class RestClientV2 extends BaseRestClient { getSubaccountFuturesAssets(params: { subUid: string; productType: FuturesProductTypeV2; - }): Promise> { + }): Promise> { return this.getPrivate( '/api/v2/broker/account/subaccount-future-assets', params, @@ -1506,16 +1530,19 @@ export class RestClientV2 extends BaseRestClient { subUid: string; coin: string; chain?: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/broker/account/subaccount-address', params, ); } - subaccountWithdrawal( - params: SubWithdrawalRequestV2, - ): Promise> { + subaccountWithdrawal(params: SubWithdrawalRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate( '/api/v2/broker/account/subaccount-withdrawal', params, @@ -1526,7 +1553,7 @@ export class RestClientV2 extends BaseRestClient { subUid: string; coin: string; toAccountType: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/broker/account/set-subaccount-autotransfer', params, @@ -1535,32 +1562,34 @@ export class RestClientV2 extends BaseRestClient { subaccountDepositRecords( params: SubDepositRecordsRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/broker/subaccount-deposit', params); } subaccountWithdrawalRecords( params: SubWithdrawalRecordsRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/broker/subaccount-withdrawal', params); } /** * - * * Broker | Subaccount + * Broker | Api Key * */ createSubaccountApiKey( params: CreateSubAccountApiKeyRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate( '/api/v2/broker/manage/create-subaccount-apikey', params, ); } - getSubaccountApiKey(params: { subUid: string }): Promise> { + getSubaccountApiKey(params: { + subUid: string; + }): Promise> { return this.getPrivate( '/api/v2/broker/manage/subaccount-apikey-list', params, @@ -1569,7 +1598,7 @@ export class RestClientV2 extends BaseRestClient { modifySubaccountApiKey( params: ModifySubAccountApiKeyRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate( '/api/v2/broker/manage/modify-subaccount-apikey', params, diff --git a/src/types/response/index.ts b/src/types/response/index.ts index f9c806c..235f9c8 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -1,6 +1,7 @@ export * from './v1/futures'; export * from './v1/shared'; export * from './v1/spot'; +export * from './v2/broker'; export * from './v2/common'; export * from './v2/futures'; export * from './v2/spot'; diff --git a/src/types/response/v2/broker.ts b/src/types/response/v2/broker.ts new file mode 100644 index 0000000..dffc862 --- /dev/null +++ b/src/types/response/v2/broker.ts @@ -0,0 +1,159 @@ +/** + * + * * Broker | Subaccount + * + */ + +export interface CreateSubaccountResponseV2 { + subUid: string; + subaccountName: string; + status: string; + permList: string[]; + label: string; + cTime: string; +} + +export interface SubaccountsListV2 { + hasNextPage: boolean; + idLessThan: number; + subList: { + subUid: string; + subaccountName: string; + status: string; + permList: string[]; + label: string; + language: string; + cTime: string; + uTime: string; + }[]; +} + +export interface ModifySubaccountResponseV2 { + subUid: string; + subaccountName: string; + status: string; + permList: string[]; + label: string; + language: string; + cTime: string; + uTime: string; +} + +export interface SubaccountEmailV2 { + subUid: string; + subaccountName: string; + subaccountEmail: string; + cTime: string; + uTime: string; +} + +export interface SubaccountSpotAssetsV2 { + assetsList: { + coin: string; + available: string; + frozen: string; + locked: string; + uTime: string; + }[]; +} + +export interface SubaccountFutureAssetsV2 { + assetsList: { + marginCoin: string; + available: string; + frozen: string; + locked: string; + crossedMaxAvailable: string; + isolatedMaxAvailable: string; + maxTransferOut: string; + accountEquity: string; + usdtEquity: string; + btcEquity: string; + uTime: string; + }[]; +} + +export interface CreateSubaccountDepositAddressV2 { + subUid: string; + coin: string; + address: string; + chain: string; + tag: string; + url: string; + cTime: string; +} + +export interface SubaccountDepositV2 { + orderId: string; + txId: string; + coin: string; + type: string; + dest: string; + amount: string; + status: string; + fromAddress: string; + toAddress: string; + fee: string; + chain: string; + confirm: string; + tag: string; + cTime: string; + uTime: string; +} + +export interface SubaccountWithdrawalV2 { + resultList: { + orderId: string; + txId: string; + coin: string; + type: string; + dest: string; + amount: string; + status: string; + fromAddress: string; + toAddress: string; + fee: string; + chain: string; + confirm: string; + tag: string; + userId: string; + cTime: string; + uTime: string; + }[]; + endId: string; +} + +/** + * + * Broker | Api Key + * + */ + +export interface CreateSubaccountApiKeyResponseV2 { + subUid: string; + apiKey: string; + secretKey: string; + label: string; + ipList: string[]; + permType: string; + permList: string[]; +} + +export interface SubaccountApiKeyV2 { + subUid: string; + label: string; + apiKey: string; + secretKey: string; + permType: string; + permList: string[]; + ipList: string[]; +} + +export interface ModifySubaccountApiKeyResponseV2 { + subUid: string; + apiKey: string; + label: string; + ipList: string[]; + permType: string; + permList: string[]; +}