@circle-fin/circle-sdk
Version:
Node.js SDK for Circle API
192 lines (183 loc) • 6.59 kB
text/typescript
/* tslint:disable */
/* eslint-disable */
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import globalAxios, {
AxiosPromise,
AxiosInstance,
AxiosRequestConfig
} from "axios";
import { Configuration } from "../configuration";
// Some imports not used depending on template conditions
// @ts-ignore
import {
DUMMY_BASE_URL,
assertParamExists,
setBearerAuthToObject,
setSearchParams,
serializeDataIfNeeded,
toPathString,
createRequestFunction
} from "../common";
// @ts-ignore
import {
BASE_PATH,
COLLECTION_FORMATS,
RequestArgs,
BaseAPI,
RequiredError
} from "../base";
// @ts-ignore
import { BadRequest } from "../models";
// @ts-ignore
import { GetExchangeRatesResponse } from "../models";
// @ts-ignore
import { NotAuthorized } from "../models";
/**
* CryptoExchangeRatesApi - axios parameter creator
* @export
*/
export const CryptoExchangeRatesApiAxiosParamCreator = function (
configuration?: Configuration
) {
return {
/**
* Fetch the current rates for the specified trading pair. The trading pair is defined by a base currency followed by a quote currency. The response contains buy and sell rates denominated in the quote currency. **Exchange rate is an estimate only and is subject to change by the time you submit the actual request.**
* @summary Get a exchange rate
* @param {'BTC-USD' | 'ETH-USD' | 'FLOW-USD'} tradingPair
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getExchangeRates: async (
tradingPair: "BTC-USD" | "ETH-USD" | "FLOW-USD",
options: AxiosRequestConfig = {}
): Promise<RequestArgs> => {
// verify required parameter 'tradingPair' is not null or undefined
assertParamExists("getExchangeRates", "tradingPair", tradingPair);
const localVarPath = `/v1/exchange/rates/{trading-pair}`.replace(
`{${"trading-pair"}}`,
encodeURIComponent(String(tradingPair))
);
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = {
method: "GET",
...baseOptions,
...options
};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication bearerAuth required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration);
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions =
baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers
};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions
};
}
};
};
/**
* CryptoExchangeRatesApi - functional programming interface
* @export
*/
export const CryptoExchangeRatesApiFp = function (
configuration?: Configuration
) {
const localVarAxiosParamCreator =
CryptoExchangeRatesApiAxiosParamCreator(configuration);
return {
/**
* Fetch the current rates for the specified trading pair. The trading pair is defined by a base currency followed by a quote currency. The response contains buy and sell rates denominated in the quote currency. **Exchange rate is an estimate only and is subject to change by the time you submit the actual request.**
* @summary Get a exchange rate
* @param {'BTC-USD' | 'ETH-USD' | 'FLOW-USD'} tradingPair
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getExchangeRates(
tradingPair: "BTC-USD" | "ETH-USD" | "FLOW-USD",
options?: AxiosRequestConfig
): Promise<
(
axios?: AxiosInstance,
basePath?: string
) => AxiosPromise<GetExchangeRatesResponse>
> {
const localVarAxiosArgs =
await localVarAxiosParamCreator.getExchangeRates(tradingPair, options);
return createRequestFunction(
localVarAxiosArgs,
globalAxios,
BASE_PATH,
configuration
);
}
};
};
/**
* CryptoExchangeRatesApi - factory interface
* @export
*/
export const CryptoExchangeRatesApiFactory = function (
configuration?: Configuration,
basePath?: string,
axios?: AxiosInstance
) {
const localVarFp = CryptoExchangeRatesApiFp(configuration);
return {
/**
* Fetch the current rates for the specified trading pair. The trading pair is defined by a base currency followed by a quote currency. The response contains buy and sell rates denominated in the quote currency. **Exchange rate is an estimate only and is subject to change by the time you submit the actual request.**
* @summary Get a exchange rate
* @param {'BTC-USD' | 'ETH-USD' | 'FLOW-USD'} tradingPair
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getExchangeRates(
tradingPair: "BTC-USD" | "ETH-USD" | "FLOW-USD",
options?: any
): AxiosPromise<GetExchangeRatesResponse> {
return localVarFp
.getExchangeRates(tradingPair, options)
.then((request) => request(axios, basePath));
}
};
};
/**
* CryptoExchangeRatesApi - object-oriented interface
* @export
* @class CryptoExchangeRatesApi
* @extends {BaseAPI}
*/
export class CryptoExchangeRatesApi extends BaseAPI {
/**
* Fetch the current rates for the specified trading pair. The trading pair is defined by a base currency followed by a quote currency. The response contains buy and sell rates denominated in the quote currency. **Exchange rate is an estimate only and is subject to change by the time you submit the actual request.**
* @summary Get a exchange rate
* @param {'BTC-USD' | 'ETH-USD' | 'FLOW-USD'} tradingPair
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof CryptoExchangeRatesApi
*/
public getExchangeRates(
tradingPair: "BTC-USD" | "ETH-USD" | "FLOW-USD",
options?: AxiosRequestConfig
) {
return CryptoExchangeRatesApiFp(this.configuration)
.getExchangeRates(tradingPair, options)
.then((request) => request(this.axios, this.basePath));
}
}