make method generic and add mapping
This commit is contained in:
@@ -231,9 +231,9 @@ export class RestClientV5 extends BaseRestClient {
|
|||||||
*
|
*
|
||||||
* Note: Spot does not support pagination, so limit & cursor are invalid.
|
* Note: Spot does not support pagination, so limit & cursor are invalid.
|
||||||
*/
|
*/
|
||||||
getInstrumentsInfo(
|
getInstrumentsInfo<C extends CategoryV5>(
|
||||||
params: GetInstrumentsInfoParamsV5,
|
params: GetInstrumentsInfoParamsV5 & { category: C },
|
||||||
): Promise<APIResponseV3WithTime<InstrumentInfoResponseV5>> {
|
): Promise<APIResponseV3WithTime<InstrumentInfoResponseV5<C>>> {
|
||||||
return this.get('/v5/market/instruments-info', params);
|
return this.get('/v5/market/instruments-info', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
CategoryCursorListV5,
|
CategoryCursorListV5,
|
||||||
|
CategoryV5,
|
||||||
ContractTypeV5,
|
ContractTypeV5,
|
||||||
|
CursorListV5,
|
||||||
InstrumentStatusV5,
|
InstrumentStatusV5,
|
||||||
OptionTypeV5,
|
OptionTypeV5,
|
||||||
OrderSideV5,
|
OrderSideV5,
|
||||||
@@ -110,10 +112,14 @@ export interface SpotInstrumentInfoV5 {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export type InstrumentInfoResponseV5 =
|
type InstrumentInfoV5Mapping = {
|
||||||
| CategoryCursorListV5<LinearInverseInstrumentInfoV5[], 'linear' | 'inverse'>
|
linear: LinearInverseInstrumentInfoV5[],
|
||||||
| CategoryCursorListV5<OptionInstrumentInfoV5[], 'option'>
|
inverse: LinearInverseInstrumentInfoV5[],
|
||||||
| CategoryCursorListV5<SpotInstrumentInfoV5[], 'spot'>;
|
option: OptionInstrumentInfoV5[],
|
||||||
|
spot: SpotInstrumentInfoV5[]
|
||||||
|
};
|
||||||
|
|
||||||
|
export type InstrumentInfoResponseV5<C extends CategoryV5> = CategoryCursorListV5<InstrumentInfoV5Mapping[C], C>;
|
||||||
|
|
||||||
export default interface OrderbookLevelV5 {
|
export default interface OrderbookLevelV5 {
|
||||||
price: string;
|
price: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user