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,
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<BatchOrdersResponseV5> {
): 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<BatchOrdersResponseV5> {
): 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<BatchOrdersResponseV5> {
): Promise<
APIResponseV3<
{
list: BatchCancelOrderResultV5[];
},
BatchOrdersRetExtInfoV5
>
> {
return this.postPrivate('/v5/order/cancel-batch', {
category,
request: orders,

View File

@@ -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;

View File

@@ -49,10 +49,11 @@ export interface APIRateLimit {
resetAtTimestamp: number;
}
export interface APIResponseV3<T> {
export interface APIResponseV3<TResult, TExtInfo = object> {
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.
*