debank-open-api
Version:
JavaScript library for DeBank OpenAPI
191 lines (182 loc) • 7.69 kB
text/typescript
/* tslint:disable */
/* eslint-disable */
/**
* DeBank OpenAPI
* Build for DeFi Developers.
*
* OpenAPI spec version: 1.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import globalAxios, { AxiosPromise, AxiosInstance } from 'axios';
import { Configuration } from '../configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
import { Chain } from '../models';
/**
* ChainApi - axios parameter creator
* @export
*/
export const ChainApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
* Get supported chain list
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getChainList: async (options: any = {}): Promise<RequestArgs> => {
const localVarPath = `/v1/chain/list`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.query) {
query.set(key, options.query[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
* Get chain info by id
* @param {string} id ChainID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getChainR: async (id: string, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new RequiredError('id','Required parameter id was null or undefined when calling getChainR.');
}
const localVarPath = `/v1/chain`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (id !== undefined) {
localVarQueryParameter['id'] = id;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.query) {
query.set(key, options.query[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
}
};
/**
* ChainApi - functional programming interface
* @export
*/
export const ChainApiFp = function(configuration?: Configuration) {
return {
/**
* Get supported chain list
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getChainList(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Chain>>> {
const localVarAxiosArgs = await ChainApiAxiosParamCreator(configuration).getChainList(options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
/**
* Get chain info by id
* @param {string} id ChainID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getChainR(id: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Chain>> {
const localVarAxiosArgs = await ChainApiAxiosParamCreator(configuration).getChainR(id, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
}
};
/**
* ChainApi - factory interface
* @export
*/
export const ChainApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
return {
/**
* Get supported chain list
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getChainList(options?: any): AxiosPromise<Array<Chain>> {
return ChainApiFp(configuration).getChainList(options).then((request) => request(axios, basePath));
},
/**
* Get chain info by id
* @param {string} id ChainID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getChainR(id: string, options?: any): AxiosPromise<Chain> {
return ChainApiFp(configuration).getChainR(id, options).then((request) => request(axios, basePath));
},
};
};
/**
* ChainApi - object-oriented interface
* @export
* @class ChainApi
* @extends {BaseAPI}
*/
export class ChainApi extends BaseAPI {
/**
* Get supported chain list
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChainApi
*/
public getChainList(options?: any) {
return ChainApiFp(this.configuration).getChainList(options).then((request) => request(this.axios, this.basePath));
}
/**
* Get chain info by id
* @param {string} id ChainID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChainApi
*/
public getChainR(id: string, options?: any) {
return ChainApiFp(this.configuration).getChainR(id, options).then((request) => request(this.axios, this.basePath));
}
}