@openweb3-io/dex-aggregator
Version:
dex-aggregator API client and webhook verification library
196 lines (159 loc) • 8.78 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 { RankingToken } from '../models/RankingToken';
import { TokenSortFilterRequest } from '../models/TokenSortFilterRequest';
/**
* no description
*/
export class RankingApiRequestFactory extends BaseAPIRequestFactory {
/**
* CONTROLLER.RANKING.HOT_TOKENS.DESCRIPTION
* CONTROLLER.RANKING.HOT_TOKENS.SUMMARY
* @param chain GLOBAL.CHAIN.DESCRIPTION
* @param duration CONTROLLER.RANKING.HOT_TOKENS.DURATION.DESCRIPTION
* @param tokenSortFilterRequest
*/
public async getHotTokens(chain: 'sol' | 'base', duration: '1m' | '5m' | '1h' | '4h' | '24h', tokenSortFilterRequest?: TokenSortFilterRequest, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'chain' is not null or undefined
if (chain === null || chain === undefined) {
throw new RequiredError("RankingApi", "getHotTokens", "chain");
}
// verify required parameter 'duration' is not null or undefined
if (duration === null || duration === undefined) {
throw new RequiredError("RankingApi", "getHotTokens", "duration");
}
// Path Params
const localVarPath = '/ranking/{chain}/hotTokens/{duration}'
.replace('{' + 'chain' + '}', encodeURIComponent(String(chain)))
.replace('{' + 'duration' + '}', encodeURIComponent(String(duration)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
const randomId = Math.floor(Math.random() * Math.pow(2, 32))
requestContext.setHeaderParam("x-req-id", randomId.toString())
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(tokenSortFilterRequest, "TokenSortFilterRequest", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["bearer"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* CONTROLLER.RANKING.NEW_TOKENS.DESCRIPTION
* CONTROLLER.RANKING.NEW_TOKENS.SUMMARY
* @param chain GLOBAL.CHAIN.DESCRIPTION
* @param tokenSortFilterRequest
*/
public async getNewTokens(chain: 'sol' | 'base', tokenSortFilterRequest?: TokenSortFilterRequest, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'chain' is not null or undefined
if (chain === null || chain === undefined) {
throw new RequiredError("RankingApi", "getNewTokens", "chain");
}
// Path Params
const localVarPath = '/ranking/{chain}/newTokens'
.replace('{' + 'chain' + '}', encodeURIComponent(String(chain)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
const randomId = Math.floor(Math.random() * Math.pow(2, 32))
requestContext.setHeaderParam("x-req-id", randomId.toString())
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(tokenSortFilterRequest, "TokenSortFilterRequest", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["bearer"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
}
export class RankingApiResponseProcessor {
/**
* 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 getHotTokens
* @throws ApiException if the response code was not in [200, 299]
*/
public async getHotTokensWithHttpInfo(response: ResponseContext): Promise<HttpInfo<Array<RankingToken> >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: Array<RankingToken> = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Array<RankingToken>", ""
) as Array<RankingToken>;
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: Array<RankingToken> = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Array<RankingToken>", ""
) as Array<RankingToken>;
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 getNewTokens
* @throws ApiException if the response code was not in [200, 299]
*/
public async getNewTokensWithHttpInfo(response: ResponseContext): Promise<HttpInfo<Array<RankingToken> >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: Array<RankingToken> = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Array<RankingToken>", ""
) as Array<RankingToken>;
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: Array<RankingToken> = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Array<RankingToken>", ""
) as Array<RankingToken>;
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);
}
}