@bluvo/sdk-ts
Version:
Bluvo SDK for TypeScript
423 lines (349 loc) • 23.2 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 { ConnectWallet200Response } from '../models/ConnectWallet200Response';
import { ConnectWalletRequest } from '../models/ConnectWalletRequest';
import { DeleteWallet200Response } from '../models/DeleteWallet200Response';
import { GetWallet200Response } from '../models/GetWallet200Response';
import { ListWallets200Response } from '../models/ListWallets200Response';
/**
* no description
*/
export class WalletsApiRequestFactory extends BaseAPIRequestFactory {
/**
* Connect an external cryptocurrency exchange account to your Bluvo project. This endpoint requires authentication via a valid Bluvo API Key, which must be included in the request headers. The connection is established using the exchange API credentials provided in the request body. It returns a unique workflow run ID that can be used to track the connection process.
* Connect Wallet
* @param exchange The identifier of the exchange to connect (e.g. \'binance\', \'kraken\').
* @param connectWalletRequest
*/
public async connectWallet(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', connectWalletRequest: ConnectWalletRequest, _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("WalletsApi", "connectWallet", "exchange");
}
// verify required parameter 'connectWalletRequest' is not null or undefined
if (connectWalletRequest === null || connectWalletRequest === undefined) {
throw new RequiredError("WalletsApi", "connectWallet", "connectWalletRequest");
}
// Path Params
const localVarPath = '/v0/cex/connect/{exchange}'
.replace('{' + 'exchange' + '}', encodeURIComponent(String(exchange)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(connectWalletRequest, "ConnectWalletRequest", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["bluvoOrgId"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
// Apply auth methods
authMethod = _config.authMethods["bluvoApiKey"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
// Apply auth methods
authMethod = _config.authMethods["bluvoProjectId"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
// Apply auth methods
authMethod = _config.authMethods["bluvoWalletId"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Delete a connected exchange wallet. This endpoint requires authentication via a valid Bluvo API Key, which must be included in the request headers.
* Delete Wallet
* @param walletId
*/
public async deleteWallet(walletId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'walletId' is not null or undefined
if (walletId === null || walletId === undefined) {
throw new RequiredError("WalletsApi", "deleteWallet", "walletId");
}
// Path Params
const localVarPath = '/v0/cex/wallet/{walletId}'
.replace('{' + 'walletId' + '}', encodeURIComponent(String(walletId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["bluvoOrgId"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
// Apply auth methods
authMethod = _config.authMethods["bluvoApiKey"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
// Apply auth methods
authMethod = _config.authMethods["bluvoProjectId"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
// Apply auth methods
authMethod = _config.authMethods["bluvoWalletId"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Retrieve basic information about a connected exchange wallet, including a simple dictionary of balances. This endpoint requires authentication via a valid Bluvo API Key, which must be included in the request headers.
* Get Wallet
* @param walletId
*/
public async getWallet(walletId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'walletId' is not null or undefined
if (walletId === null || walletId === undefined) {
throw new RequiredError("WalletsApi", "getWallet", "walletId");
}
// Path Params
const localVarPath = '/v0/cex/wallet/{walletId}'
.replace('{' + 'walletId' + '}', encodeURIComponent(String(walletId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["bluvoOrgId"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
// Apply auth methods
authMethod = _config.authMethods["bluvoApiKey"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
// Apply auth methods
authMethod = _config.authMethods["bluvoProjectId"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
// Apply auth methods
authMethod = _config.authMethods["bluvoWalletId"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Retrieve a paginated list of connected exchange wallets. This endpoint requires authentication via a valid Bluvo API Key, which must be included in the request headers. Supports pagination, filtering, and field selection.
* List Wallets
* @param page Optional. Page number for pagination (0-indexed). Defaults to 0.
* @param limit Optional. Maximum number of wallets to return per page. Defaults to 10. Maximum value is 1000.
* @param exchange Optional. Filter wallets by exchange.
* @param createdSince Optional. Filter wallets created on or after this date (ISO format).
* @param createdBefore Optional. Filter wallets created before this date (ISO format).
* @param lastSyncSince Optional. Filter wallets synchronized on or after this date (ISO format).
* @param lastSyncBefore Optional. Filter wallets synchronized before this date (ISO format).
* @param invalidApi Optional. Filter wallets by API validity status.
* @param fields Optional. Comma-separated list of fields to include in the response. If not specified, all fields are included.
*/
public async listWallets(page?: number, limit?: number, 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', createdSince?: string, createdBefore?: string, lastSyncSince?: string, lastSyncBefore?: string, invalidApi?: 'true' | 'false', fields?: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// Path Params
const localVarPath = '/v0/cex/wallets';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
if (page !== undefined) {
requestContext.setQueryParam("page", ObjectSerializer.serialize(page, "number", ""));
}
// Query Params
if (limit !== undefined) {
requestContext.setQueryParam("limit", ObjectSerializer.serialize(limit, "number", ""));
}
// Query Params
if (exchange !== undefined) {
requestContext.setQueryParam("exchange", ObjectSerializer.serialize(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'", ""));
}
// Query Params
if (createdSince !== undefined) {
requestContext.setQueryParam("createdSince", ObjectSerializer.serialize(createdSince, "string", ""));
}
// Query Params
if (createdBefore !== undefined) {
requestContext.setQueryParam("createdBefore", ObjectSerializer.serialize(createdBefore, "string", ""));
}
// Query Params
if (lastSyncSince !== undefined) {
requestContext.setQueryParam("lastSyncSince", ObjectSerializer.serialize(lastSyncSince, "string", ""));
}
// Query Params
if (lastSyncBefore !== undefined) {
requestContext.setQueryParam("lastSyncBefore", ObjectSerializer.serialize(lastSyncBefore, "string", ""));
}
// Query Params
if (invalidApi !== undefined) {
requestContext.setQueryParam("invalidApi", ObjectSerializer.serialize(invalidApi, "'true' | 'false'", ""));
}
// Query Params
if (fields !== undefined) {
requestContext.setQueryParam("fields", ObjectSerializer.serialize(fields, "string", ""));
}
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["bluvoOrgId"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
// Apply auth methods
authMethod = _config.authMethods["bluvoApiKey"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
// Apply auth methods
authMethod = _config.authMethods["bluvoProjectId"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _config?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
}
export class WalletsApiResponseProcessor {
/**
* 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 connectWallet
* @throws ApiException if the response code was not in [200, 299]
*/
public async connectWalletWithHttpInfo(response: ResponseContext): Promise<HttpInfo<ConnectWallet200Response >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: ConnectWallet200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ConnectWallet200Response", ""
) as ConnectWallet200Response;
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: ConnectWallet200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ConnectWallet200Response", ""
) as ConnectWallet200Response;
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 deleteWallet
* @throws ApiException if the response code was not in [200, 299]
*/
public async deleteWalletWithHttpInfo(response: ResponseContext): Promise<HttpInfo<DeleteWallet200Response >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: DeleteWallet200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"DeleteWallet200Response", ""
) as DeleteWallet200Response;
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: DeleteWallet200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"DeleteWallet200Response", ""
) as DeleteWallet200Response;
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 getWallet
* @throws ApiException if the response code was not in [200, 299]
*/
public async getWalletWithHttpInfo(response: ResponseContext): Promise<HttpInfo<GetWallet200Response >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: GetWallet200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"GetWallet200Response", ""
) as GetWallet200Response;
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: GetWallet200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"GetWallet200Response", ""
) as GetWallet200Response;
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 listWallets
* @throws ApiException if the response code was not in [200, 299]
*/
public async listWalletsWithHttpInfo(response: ResponseContext): Promise<HttpInfo<ListWallets200Response >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: ListWallets200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ListWallets200Response", ""
) as ListWallets200Response;
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: ListWallets200Response = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ListWallets200Response", ""
) as ListWallets200Response;
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);
}
}