@openweb3-io/dex-aggregator
Version:
dex-aggregator API client and webhook verification library
103 lines (83 loc) • 4.37 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 { PumpMintInput } from '../models/PumpMintInput';
import { PumpMintReply } from '../models/PumpMintReply';
/**
* no description
*/
export class DefiSolanaPumpfunApiRequestFactory extends BaseAPIRequestFactory {
/**
* CONTROLLER.PUMPFUN.MINT.DESCRIPTION
* CONTROLLER.PUMPFUN.MINT.SUMMARY
* @param pumpMintInput Required parameters for minting token
*/
public async pumpfunMint(pumpMintInput: PumpMintInput, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'pumpMintInput' is not null or undefined
if (pumpMintInput === null || pumpMintInput === undefined) {
throw new RequiredError("DefiSolanaPumpfunApi", "pumpfunMint", "pumpMintInput");
}
// Path Params
const localVarPath = '/solana/pumpfun/mint';
// 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(pumpMintInput, "PumpMintInput", ""),
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 DefiSolanaPumpfunApiResponseProcessor {
/**
* 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 pumpfunMint
* @throws ApiException if the response code was not in [200, 299]
*/
public async pumpfunMintWithHttpInfo(response: ResponseContext): Promise<HttpInfo<PumpMintReply >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: PumpMintReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"PumpMintReply", ""
) as PumpMintReply;
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: PumpMintReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"PumpMintReply", ""
) as PumpMintReply;
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);
}
}