diff --git a/src/linear-client.ts b/src/linear-client.ts new file mode 100644 index 0000000..26dccc7 --- /dev/null +++ b/src/linear-client.ts @@ -0,0 +1,47 @@ +import { AxiosRequestConfig } from 'axios'; +import { GenericAPIResponse, getBaseRESTInverseUrl, RestClientInverseOptions } from './util/requestUtils'; +import RequestWrapper from './util/requestWrapper'; +import { SharedEndpoints } from './shared-endpoints'; + +export class LinearClient extends SharedEndpoints { + protected requestWrapper: RequestWrapper; + + /** + * @public Creates an instance of the inverse REST API client. + * + * @param {string} key - your API key + * @param {string} secret - your API secret + * @param {boolean} [livenet=false] + * @param {RestClientInverseOptions} [restInverseOptions={}] options to configure REST API connectivity + * @param {AxiosRequestConfig} [requestOptions={}] HTTP networking options for axios + */ + + constructor( + key?: string | undefined, + secret?: string | undefined, + livenet?: boolean, + restInverseOptions:RestClientInverseOptions = {}, // TODO: Rename this type to be more general. + requestOptions: AxiosRequestConfig = {} + ) { + super() + this.requestWrapper = new RequestWrapper( + key, + secret, + getBaseRESTInverseUrl(livenet), + restInverseOptions, + requestOptions + ); + return this; + } + + /** + * @public Get the last funding rate. + */ + + getLastFundingRate(params: { + symbol: string; + }): GenericAPIResponse { + return this.requestWrapper.get('public/linear/funding/prev-funding-rate', params); + } + +}