UNPKG

ftx-api-typed

Version:

Node.js/typescript connector for FTX's REST APIs and WebSockets

40 lines (39 loc) 1.65 kB
import { AxiosInstance, AxiosRequestConfig, Method } from 'axios'; import FormData from 'form-data'; import { RestClientOptions, GenericAPIResponse } from './requestUtils'; export default class RequestUtil { private timeOffset; private syncTimePromise; private options; private baseUrl; private globalRequestOptions; private key; private secret; private axiosInstance; constructor(key: string | undefined, secret: string | undefined, baseUrl: string, options: RestClientOptions | undefined, requestOptions: AxiosRequestConfig | undefined, axiosInstance: AxiosInstance); get<T>(endpoint: string, params?: any): GenericAPIResponse<T>; post<T>(endpoint: string, params?: any): GenericAPIResponse<T>; postFormData<T>(endpoint: string, formData?: FormData): GenericAPIResponse<T>; delete<T>(endpoint: string, params?: any): GenericAPIResponse<T>; /** * @private Make a HTTP request to a specific endpoint. Private endpoints are automatically signed. */ _call<T>(method: Method, endpoint: string, params?: string | object, headers?: AxiosRequestConfig["headers"]): GenericAPIResponse<T>; /** * @private generic handler to parse request exceptions */ parseException(e: any): unknown; private getRequestSignature; /** * @private sign request and set recv window */ signRequest(data: any): Promise<any>; /** * @private trigger time sync and store promise */ syncTime(): Promise<boolean>; /** * @deprecated move this somewhere else, because endpoints shouldn't be hardcoded here */ getTimeOffset(): Promise<number>; }