feat(): updated types for batch

This commit is contained in:
JJ-Cro
2025-04-25 13:14:29 +02:00
parent 5fbe3908ce
commit 11e98c7460
3 changed files with 32 additions and 17 deletions

View File

@@ -20,9 +20,12 @@ import {
ApiKeyInfoV5, ApiKeyInfoV5,
AssetInfoV5, AssetInfoV5,
BatchAmendOrderParamsV5, BatchAmendOrderParamsV5,
BatchAmendOrderResultV5,
BatchCancelOrderParamsV5, BatchCancelOrderParamsV5,
BatchCancelOrderResultV5,
BatchCreateOrderResultV5,
BatchOrderParamsV5, BatchOrderParamsV5,
BatchOrdersResponseV5, BatchOrdersRetExtInfoV5,
BorrowCryptoLoanParamsV5, BorrowCryptoLoanParamsV5,
BorrowHistoryRecordV5, BorrowHistoryRecordV5,
BrokerIssuedVoucherV5, BrokerIssuedVoucherV5,
@@ -808,7 +811,14 @@ export class RestClientV5 extends BaseRestClient {
batchSubmitOrders( batchSubmitOrders(
category: 'option' | 'linear', category: 'option' | 'linear',
orders: BatchOrderParamsV5[], orders: BatchOrderParamsV5[],
): Promise<BatchOrdersResponseV5> { ): Promise<
APIResponseV3<
{
list: BatchCreateOrderResultV5[];
},
BatchOrdersRetExtInfoV5
>
> {
return this.postPrivate('/v5/order/create-batch', { return this.postPrivate('/v5/order/create-batch', {
category, category,
request: orders, request: orders,
@@ -826,7 +836,14 @@ export class RestClientV5 extends BaseRestClient {
batchAmendOrders( batchAmendOrders(
category: 'option' | 'linear', category: 'option' | 'linear',
orders: BatchAmendOrderParamsV5[], orders: BatchAmendOrderParamsV5[],
): Promise<BatchOrdersResponseV5> { ): Promise<
APIResponseV3<
{
list: BatchAmendOrderResultV5[];
},
BatchOrdersRetExtInfoV5
>
> {
return this.postPrivate('/v5/order/amend-batch', { return this.postPrivate('/v5/order/amend-batch', {
category, category,
request: orders, request: orders,
@@ -844,7 +861,14 @@ export class RestClientV5 extends BaseRestClient {
batchCancelOrders( batchCancelOrders(
category: 'option' | 'linear', category: 'option' | 'linear',
orders: BatchCancelOrderParamsV5[], orders: BatchCancelOrderParamsV5[],
): Promise<BatchOrdersResponseV5> { ): Promise<
APIResponseV3<
{
list: BatchCancelOrderResultV5[];
},
BatchOrdersRetExtInfoV5
>
> {
return this.postPrivate('/v5/order/cancel-batch', { return this.postPrivate('/v5/order/cancel-batch', {
category, category,
request: orders, request: orders,

View File

@@ -75,7 +75,7 @@ export interface BatchCreateOrderResultV5 {
symbol: string; symbol: string;
orderId: string; orderId: string;
orderLinkId: string; orderLinkId: string;
createAt: string; createAt?: string;
} }
export interface BatchOrdersRetExtInfoV5 { 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 { export interface BatchAmendOrderResultV5 {
category: CategoryV5; category: CategoryV5;
symbol: string; symbol: string;

View File

@@ -49,10 +49,11 @@ export interface APIRateLimit {
resetAtTimestamp: number; resetAtTimestamp: number;
} }
export interface APIResponseV3<T> { export interface APIResponseV3<TResult, TExtInfo = object> {
retCode: number; retCode: number;
retMsg: 'OK' | string; retMsg: 'OK' | string;
result: T; result: TResult;
retExtInfo: TExtInfo;
/** /**
* These are per-UID per-endpoint rate limits, automatically parsed from response headers if available. * These are per-UID per-endpoint rate limits, automatically parsed from response headers if available.
* *