@bluvo/sdk-ts
Version:
Bluvo SDK for TypeScript
228 lines (179 loc) • 12 kB
text/typescript
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi';
import {Configuration} from '../configuration';
import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http';
import {ObjectSerializer} from '../models/ObjectSerializer';
import {ApiException} from './exception';
import {canConsumeForm, isCodeInRange} from '../util';
import {SecurityAuthentication} from '../auth/auth';
import { Asset200Response } from '../models/Asset200Response';
import { ListAssets200Response } from '../models/ListAssets200Response';
import { ListPairs200Response } from '../models/ListPairs200Response';
/**
* no description
*/
export class BasicApiRequestFactory extends BaseAPIRequestFactory {
/**
* Retrieve detailed information for a specific asset. The asset parameter in the URL path should be the asset\'s symbol (e.g. BTC, ETH). Because some assets have duplications, this endpoint returns a list of matching asset objects. Optionally, the \'img\' query parameter can be used to control whether an image URL is included and which variant is provided.
* Asset
* @param asset The asset symbol to query (e.g. BTC, ETH).
* @param img Specifies whether to include an image URL in each asset object. Allowed values are: \'true\' (include the default image), \'false\' (exclude image), \'32\' (32px variant), or \'64\' (64px variant).
*/
public async asset(asset: string, img?: 'false' | '32' | '64' | '128', _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'asset' is not null or undefined
if (asset === null || asset === undefined) {
throw new RequiredError("BasicApi", "asset", "asset");
}
// Path Params
const localVarPath = '/v0/info/asset/{asset}'
.replace('{' + 'asset' + '}', encodeURIComponent(String(asset)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
if (img !== undefined) {
requestContext.setQueryParam("img", ObjectSerializer.serialize(img, "'false' | '32' | '64' | '128'", ""));
}
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Retrieve a paginated list of available assets. Optionally, use the \'img\' query parameter to include a specific image variant with each asset. The \'page\' and \'limit\' parameters control pagination.
* List Assets
* @param img Optional. Specifies the image variant for each asset. Allowed values: \'false\' (exclude images), \'true\' (include default image), \'64\' (64px variant), or \'32\' (32px variant).
* @param page Optional. Page number for pagination (0-indexed). Defaults to 0.
* @param limit Optional. Maximum number of assets to return per page. Defaults to 100.
*/
public async listAssets(img?: 'false' | '32' | '64' | '128', page?: number, limit?: number, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// Path Params
const localVarPath = '/v0/info/assets';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
if (img !== undefined) {
requestContext.setQueryParam("img", ObjectSerializer.serialize(img, "'false' | '32' | '64' | '128'", ""));
}
// Query Params
if (page !== undefined) {
requestContext.setQueryParam("page", ObjectSerializer.serialize(page, "number", ""));
}
// Query Params
if (limit !== undefined) {
requestContext.setQueryParam("limit", ObjectSerializer.serialize(limit, "number", ""));
}
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Retrieve a list of available trading pairs for a specified exchange. The exchange parameter in the URL path must be one of the supported exchanges.
* List Pairs
* @param exchange The identifier of the exchange to query (e.g. \'binance\', \'kraken\').
*/
public async listPairs(exchange: 'ace' | 'ascendex' | 'bequant' | 'bigone' | 'binance' | 'coinbase' | 'binanceus' | 'bingx' | 'bit2c' | 'bitbank' | 'bitbns' | 'bitcoincom' | 'bitfinex' | 'bitflyer' | 'bitget' | 'bithumb' | 'bitmart' | 'bitmex' | 'bitopro' | 'bitpanda' | 'bitrue' | 'bitso' | 'bitstamp' | 'bitteam' | 'bitvavo' | 'bl3p' | 'blockchaincom' | 'blofin' | 'btcalpha' | 'btcbox' | 'btcmarkets' | 'btcturk' | 'cex' | 'coincheck' | 'coinex' | 'coinlist' | 'coinmate' | 'coinmetro' | 'coinone' | 'coinsph' | 'coinspot' | 'cryptocom' | 'delta' | 'deribit' | 'digifinex' | 'exmo' | 'fmfwio' | 'gate' | 'gateio' | 'gemini' | 'hashkey' | 'hitbtc' | 'hollaex' | 'htx' | 'huobi' | 'huobijp' | 'hyperliquid' | 'independentreserve' | 'indodax' | 'kraken' | 'krakenfutures' | 'kucoin' | 'kucoinfutures' | 'latoken' | 'lbank' | 'luno' | 'mercado' | 'mexc' | 'ndax' | 'novadax' | 'oceanex' | 'okcoin' | 'okx' | 'onetrading' | 'oxfun' | 'p2b' | 'paradex' | 'paymium' | 'phemex' | 'poloniex' | 'poloniexfutures' | 'probit' | 'timex' | 'tradeogre' | 'upbit' | 'vertex' | 'wavesexchange' | 'whitebit' | 'woo' | 'woofipro' | 'xt' | 'yobit' | 'zaif' | 'zonda', _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'exchange' is not null or undefined
if (exchange === null || exchange === undefined) {
throw new RequiredError("BasicApi", "listPairs", "exchange");
}
// Path Params
const localVarPath = '/v0/info/{exchange}/pairs'
.replace('{' + 'exchange' + '}', encodeURIComponent(String(exchange)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
}
export class BasicApiResponseProcessor {
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to asset
* @throws ApiException if the response code was not in [200, 299]
*/
public async assetWithHttpInfo(response: ResponseContext): Promise<HttpInfo<Asset200Response >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: Asset200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Asset200Response", ""
) as Asset200Response;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: Asset200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Asset200Response", ""
) as Asset200Response;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to listAssets
* @throws ApiException if the response code was not in [200, 299]
*/
public async listAssetsWithHttpInfo(response: ResponseContext): Promise<HttpInfo<ListAssets200Response >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: ListAssets200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ListAssets200Response", ""
) as ListAssets200Response;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: ListAssets200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ListAssets200Response", ""
) as ListAssets200Response;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to listPairs
* @throws ApiException if the response code was not in [200, 299]
*/
public async listPairsWithHttpInfo(response: ResponseContext): Promise<HttpInfo<ListPairs200Response >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: ListPairs200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ListPairs200Response", ""
) as ListPairs200Response;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: ListPairs200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ListPairs200Response", ""
) as ListPairs200Response;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}