cleaning around api response types

This commit is contained in:
tiagosiebler
2022-05-11 23:58:53 +01:00
parent a89cb5148e
commit 326caac96a
6 changed files with 172 additions and 122 deletions

View File

@@ -1,6 +1,5 @@
import { AxiosRequestConfig } from 'axios';
import {
GenericAPIResponse,
getRestBaseUrl,
RestClientOptions,
REST_CLIENT_TYPE_ENUM,
@@ -133,7 +132,7 @@ export class InverseClient extends BaseRestClient {
*
*/
getApiKeyInfo(): GenericAPIResponse {
getApiKeyInfo(): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/account/api-key');
}
@@ -143,21 +142,27 @@ export class InverseClient extends BaseRestClient {
*
*/
getWalletBalance(params?: Partial<CoinParam>): GenericAPIResponse {
getWalletBalance(
params?: Partial<CoinParam>
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/balance', params);
}
getWalletFundRecords(params?: WalletFundRecordsReq): GenericAPIResponse {
getWalletFundRecords(
params?: WalletFundRecordsReq
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/fund/records', params);
}
getWithdrawRecords(params?: WithdrawRecordsReq): GenericAPIResponse {
getWithdrawRecords(
params?: WithdrawRecordsReq
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/wallet/withdraw/list', params);
}
getAssetExchangeRecords(
params?: AssetExchangeRecordsReq
): GenericAPIResponse {
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/exchange-order/list', params);
}
@@ -199,7 +204,7 @@ export class InverseClient extends BaseRestClient {
sl_trigger_by?: 'LastPrice' | 'MarkPrice' | 'IndexPrice';
close_on_trigger?: boolean;
order_link_id?: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/create', orderRequest);
}
@@ -209,7 +214,7 @@ export class InverseClient extends BaseRestClient {
direction?: string;
limit?: number;
cursor?: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/order/list', params);
}
@@ -217,11 +222,13 @@ export class InverseClient extends BaseRestClient {
symbol: string;
order_id?: string;
order_link_id?: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/cancel', params);
}
cancelAllActiveOrders(params: SymbolParam): GenericAPIResponse {
cancelAllActiveOrders(
params: SymbolParam
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/cancelAll', params);
}
@@ -235,7 +242,7 @@ export class InverseClient extends BaseRestClient {
stop_loss?: number;
tp_trigger_by?: string;
sl_trigger_by?: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/order/replace', params);
}
@@ -243,7 +250,7 @@ export class InverseClient extends BaseRestClient {
order_id?: string;
order_link_id?: string;
symbol: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/order', params);
}
@@ -263,7 +270,7 @@ export class InverseClient extends BaseRestClient {
trigger_by?: string;
close_on_trigger?: boolean;
order_link_id?: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/create', params);
}
@@ -274,7 +281,7 @@ export class InverseClient extends BaseRestClient {
direction?: string;
limit?: number;
cursor?: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/stop-order/list', params);
}
@@ -282,11 +289,13 @@ export class InverseClient extends BaseRestClient {
symbol: string;
stop_order_id?: string;
order_link_id?: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/cancel', params);
}
cancelAllConditionalOrders(params: SymbolParam): GenericAPIResponse {
cancelAllConditionalOrders(
params: SymbolParam
): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/cancelAll', params);
}
@@ -297,7 +306,7 @@ export class InverseClient extends BaseRestClient {
p_r_qty?: number;
p_r_price?: string;
p_r_trigger_price?: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/stop-order/replace', params);
}
@@ -305,7 +314,7 @@ export class InverseClient extends BaseRestClient {
symbol: string;
stop_order_id?: string;
order_link_id?: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/stop-order', params);
}
@@ -313,14 +322,16 @@ export class InverseClient extends BaseRestClient {
* Position
*/
getPosition(params?: Partial<SymbolParam>): GenericAPIResponse {
getPosition(
params?: Partial<SymbolParam>
): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/position/list', params);
}
changePositionMargin(params: {
symbol: string;
margin: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('position/change-position-margin', params);
}
@@ -332,7 +343,7 @@ export class InverseClient extends BaseRestClient {
tp_trigger_by?: string;
sl_trigger_by?: string;
new_trailing_active?: number;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/position/trading-stop', params);
}
@@ -340,7 +351,7 @@ export class InverseClient extends BaseRestClient {
symbol: string;
leverage: number;
leverage_only?: boolean;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/position/leverage/save', params);
}
@@ -351,7 +362,7 @@ export class InverseClient extends BaseRestClient {
page?: number;
limit?: number;
order?: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/execution/list', params);
}
@@ -362,14 +373,14 @@ export class InverseClient extends BaseRestClient {
exec_type?: string;
page?: number;
limit?: number;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/trade/closed-pnl/list', params);
}
setSlTpPositionMode(params: {
symbol: string;
tp_sl_mode: 'Full' | 'Partial';
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/tpsl/switch-mode', params);
}
@@ -378,7 +389,7 @@ export class InverseClient extends BaseRestClient {
is_isolated: boolean;
buy_leverage: number;
sell_leverage: number;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('v2/private/position/switch-isolated', params);
}
@@ -386,14 +397,14 @@ export class InverseClient extends BaseRestClient {
* Risk Limit
*/
getRiskLimitList(): GenericAPIResponse {
getRiskLimitList(): Promise<APIResponseWithTime<any>> {
return this.getPrivate('open-api/wallet/risk-limit/list');
}
setRiskLimit(params: {
symbol: string;
risk_id: string;
}): GenericAPIResponse {
}): Promise<APIResponseWithTime<any>> {
return this.postPrivate('open-api/wallet/risk-limit', params);
}
@@ -401,15 +412,15 @@ export class InverseClient extends BaseRestClient {
* Funding
*/
getLastFundingRate(params: SymbolParam): GenericAPIResponse {
getLastFundingRate(params: SymbolParam): Promise<APIResponseWithTime<any>> {
return this.get('v2/public/funding/prev-funding-rate', params);
}
getMyLastFundingFee(params: SymbolParam): GenericAPIResponse {
getMyLastFundingFee(params: SymbolParam): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/funding/prev-funding', params);
}
getPredictedFunding(params: SymbolParam): GenericAPIResponse {
getPredictedFunding(params: SymbolParam): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/funding/predicted-funding', params);
}
@@ -417,7 +428,7 @@ export class InverseClient extends BaseRestClient {
* LCP Info
*/
getLcpInfo(params: SymbolParam): GenericAPIResponse {
getLcpInfo(params: SymbolParam): Promise<APIResponseWithTime<any>> {
return this.getPrivate('v2/private/account/lcp', params);
}
}