- Returned type improvements.
- Start migrating to base rest client. - Remove deprecated methods. - Run linter. - Deprecate shared endpoints for readibility. All methods are replicated within each client (there's not much duplication). - Expand test coverage for public inverse endpoints.
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import { AxiosRequestConfig } from 'axios';
|
||||
import { KlineInterval } from './types/shared';
|
||||
import { NewSpotOrder, OrderSide, OrderTypeSpot, SpotOrderQueryById } from './types/spot';
|
||||
import {
|
||||
NewSpotOrder,
|
||||
OrderSide,
|
||||
OrderTypeSpot,
|
||||
SpotOrderQueryById,
|
||||
} from './types/spot';
|
||||
import BaseRestClient from './util/BaseRestClient';
|
||||
import { GenericAPIResponse, getRestBaseUrl, RestClientOptions } from './util/requestUtils';
|
||||
import { getRestBaseUrl, RestClientOptions } from './util/requestUtils';
|
||||
import RequestWrapper from './util/requestWrapper';
|
||||
|
||||
export class SpotClient extends BaseRestClient {
|
||||
@@ -24,19 +29,22 @@ export class SpotClient extends BaseRestClient {
|
||||
restClientOptions: RestClientOptions = {},
|
||||
requestOptions: AxiosRequestConfig = {}
|
||||
) {
|
||||
super(key, secret, getRestBaseUrl(useLivenet, restClientOptions), restClientOptions, requestOptions);
|
||||
super(
|
||||
key,
|
||||
secret,
|
||||
getRestBaseUrl(useLivenet, restClientOptions),
|
||||
restClientOptions,
|
||||
requestOptions
|
||||
);
|
||||
|
||||
// this.requestWrapper = new RequestWrapper(
|
||||
// key,
|
||||
// secret,
|
||||
// getRestBaseUrl(useLivenet, restClientOptions),
|
||||
// restClientOptions,
|
||||
// requestOptions
|
||||
// );
|
||||
return this;
|
||||
}
|
||||
|
||||
async getServerTime(urlKeyOverride?: string): Promise<number> {
|
||||
fetchServerTime(): Promise<number> {
|
||||
return this.getServerTime();
|
||||
}
|
||||
|
||||
async getServerTime(): Promise<number> {
|
||||
const result = await this.get('/spot/v1/time');
|
||||
return result.serverTime;
|
||||
}
|
||||
@@ -45,7 +53,7 @@ export class SpotClient extends BaseRestClient {
|
||||
*
|
||||
* Market Data Endpoints
|
||||
*
|
||||
**/
|
||||
**/
|
||||
|
||||
getSymbols() {
|
||||
return this.get('/spot/v1/symbols');
|
||||
@@ -53,7 +61,8 @@ export class SpotClient extends BaseRestClient {
|
||||
|
||||
getOrderBook(symbol: string, limit?: number) {
|
||||
return this.get('/spot/quote/v1/depth', {
|
||||
symbol, limit
|
||||
symbol,
|
||||
limit,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,7 +81,13 @@ export class SpotClient extends BaseRestClient {
|
||||
});
|
||||
}
|
||||
|
||||
getCandles(symbol: string, interval: KlineInterval, limit?: number, startTime?: number, endTime?: number) {
|
||||
getCandles(
|
||||
symbol: string,
|
||||
interval: KlineInterval,
|
||||
limit?: number,
|
||||
startTime?: number,
|
||||
endTime?: number
|
||||
) {
|
||||
return this.get('/spot/quote/v1/kline', {
|
||||
symbol,
|
||||
interval,
|
||||
@@ -113,9 +128,11 @@ export class SpotClient extends BaseRestClient {
|
||||
cancelOrderBatch(params: {
|
||||
symbol: string;
|
||||
side?: OrderSide;
|
||||
orderTypes: OrderTypeSpot[]
|
||||
orderTypes: OrderTypeSpot[];
|
||||
}) {
|
||||
const orderTypes = params.orderTypes ? params.orderTypes.join(',') : undefined;
|
||||
const orderTypes = params.orderTypes
|
||||
? params.orderTypes.join(',')
|
||||
: undefined;
|
||||
return this.deletePrivate('/spot/order/batch-cancel', {
|
||||
...params,
|
||||
orderTypes,
|
||||
|
||||
Reference in New Issue
Block a user