From 11e98c7460bc47cac9f7384d250c9cb7ec83729a Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Fri, 25 Apr 2025 13:14:29 +0200 Subject: [PATCH] feat(): updated types for batch --- src/rest-client-v5.ts | 32 ++++++++++++++++++++++++++++---- src/types/response/v5-trade.ts | 12 +----------- src/types/shared.ts | 5 +++-- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index 011419c..f6ccab7 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -20,9 +20,12 @@ import { ApiKeyInfoV5, AssetInfoV5, BatchAmendOrderParamsV5, + BatchAmendOrderResultV5, BatchCancelOrderParamsV5, + BatchCancelOrderResultV5, + BatchCreateOrderResultV5, BatchOrderParamsV5, - BatchOrdersResponseV5, + BatchOrdersRetExtInfoV5, BorrowCryptoLoanParamsV5, BorrowHistoryRecordV5, BrokerIssuedVoucherV5, @@ -808,7 +811,14 @@ export class RestClientV5 extends BaseRestClient { batchSubmitOrders( category: 'option' | 'linear', orders: BatchOrderParamsV5[], - ): Promise { + ): Promise< + APIResponseV3< + { + list: BatchCreateOrderResultV5[]; + }, + BatchOrdersRetExtInfoV5 + > + > { return this.postPrivate('/v5/order/create-batch', { category, request: orders, @@ -826,7 +836,14 @@ export class RestClientV5 extends BaseRestClient { batchAmendOrders( category: 'option' | 'linear', orders: BatchAmendOrderParamsV5[], - ): Promise { + ): Promise< + APIResponseV3< + { + list: BatchAmendOrderResultV5[]; + }, + BatchOrdersRetExtInfoV5 + > + > { return this.postPrivate('/v5/order/amend-batch', { category, request: orders, @@ -844,7 +861,14 @@ export class RestClientV5 extends BaseRestClient { batchCancelOrders( category: 'option' | 'linear', orders: BatchCancelOrderParamsV5[], - ): Promise { + ): Promise< + APIResponseV3< + { + list: BatchCancelOrderResultV5[]; + }, + BatchOrdersRetExtInfoV5 + > + > { return this.postPrivate('/v5/order/cancel-batch', { category, request: orders, diff --git a/src/types/response/v5-trade.ts b/src/types/response/v5-trade.ts index db3b446..889b159 100644 --- a/src/types/response/v5-trade.ts +++ b/src/types/response/v5-trade.ts @@ -75,7 +75,7 @@ export interface BatchCreateOrderResultV5 { symbol: string; orderId: string; orderLinkId: string; - createAt: string; + createAt?: string; } export interface BatchOrdersRetExtInfoV5 { @@ -85,16 +85,6 @@ export interface BatchOrdersRetExtInfoV5 { }[]; } -export interface BatchOrdersResponseV5 { - retCode: number; - retMsg: 'OK' | string; - result: { - list: BatchCreateOrderResultV5[]; - }; - retExtInfo: BatchOrdersRetExtInfoV5; - time: number; -} - export interface BatchAmendOrderResultV5 { category: CategoryV5; symbol: string; diff --git a/src/types/shared.ts b/src/types/shared.ts index 4a25db2..2c50c99 100644 --- a/src/types/shared.ts +++ b/src/types/shared.ts @@ -49,10 +49,11 @@ export interface APIRateLimit { resetAtTimestamp: number; } -export interface APIResponseV3 { +export interface APIResponseV3 { retCode: number; retMsg: 'OK' | string; - result: T; + result: TResult; + retExtInfo: TExtInfo; /** * These are per-UID per-endpoint rate limits, automatically parsed from response headers if available. *