From 2fb2b7cc400f7a66e87ffedd5eec91ad3670564e Mon Sep 17 00:00:00 2001 From: Thijmen Maus Date: Tue, 12 Sep 2023 11:25:43 +0200 Subject: [PATCH 1/2] make method generic and add mapping --- src/rest-client-v5.ts | 6 +++--- src/types/response/v5-market.ts | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index 9653caab..14f12c7d 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -231,9 +231,9 @@ export class RestClientV5 extends BaseRestClient { * * Note: Spot does not support pagination, so limit & cursor are invalid. */ - getInstrumentsInfo( - params: GetInstrumentsInfoParamsV5, - ): Promise> { + getInstrumentsInfo( + params: GetInstrumentsInfoParamsV5 & { category: C }, + ): Promise>> { return this.get('/v5/market/instruments-info', params); } diff --git a/src/types/response/v5-market.ts b/src/types/response/v5-market.ts index d65a1f74..217dae88 100644 --- a/src/types/response/v5-market.ts +++ b/src/types/response/v5-market.ts @@ -1,6 +1,8 @@ import { CategoryCursorListV5, + CategoryV5, ContractTypeV5, + CursorListV5, InstrumentStatusV5, OptionTypeV5, OrderSideV5, @@ -110,10 +112,14 @@ export interface SpotInstrumentInfoV5 { }; } -export type InstrumentInfoResponseV5 = - | CategoryCursorListV5 - | CategoryCursorListV5 - | CategoryCursorListV5; +type InstrumentInfoV5Mapping = { + linear: LinearInverseInstrumentInfoV5[], + inverse: LinearInverseInstrumentInfoV5[], + option: OptionInstrumentInfoV5[], + spot: SpotInstrumentInfoV5[] +}; + +export type InstrumentInfoResponseV5 = CategoryCursorListV5; export default interface OrderbookLevelV5 { price: string; From 42ade6d6ddff54bbee82618e501381db68bb91ca Mon Sep 17 00:00:00 2001 From: Thijmen Maus Date: Tue, 12 Sep 2023 11:31:32 +0200 Subject: [PATCH 2/2] remove unused variable --- src/types/response/v5-market.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/types/response/v5-market.ts b/src/types/response/v5-market.ts index 217dae88..9025e121 100644 --- a/src/types/response/v5-market.ts +++ b/src/types/response/v5-market.ts @@ -2,7 +2,6 @@ import { CategoryCursorListV5, CategoryV5, ContractTypeV5, - CursorListV5, InstrumentStatusV5, OptionTypeV5, OrderSideV5,