@openweb3-io/dex-aggregator
Version:
dex-aggregator API client and webhook verification library
502 lines (417 loc) • 22.6 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 { CancelAllOrdersInput } from '../models/CancelAllOrdersInput';
import { CancelOrderInput } from '../models/CancelOrderInput';
import { CloseMarketInput } from '../models/CloseMarketInput';
import { CreateMarketInput } from '../models/CreateMarketInput';
import { OrderReply } from '../models/OrderReply';
import { PlaceOrderInput } from '../models/PlaceOrderInput';
/**
* no description
*/
export class OrderApiRequestFactory extends BaseAPIRequestFactory {
/**
* CONTROLLER.ORDER.CANCEL.DESCRIPTION
* CONTROLLER.ORDER.CANCEL.SUMMARY
* @param cancelOrderInput CONTROLLER.ORDER.CANCEL.BODY
*/
public async cancel(cancelOrderInput: CancelOrderInput, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'cancelOrderInput' is not null or undefined
if (cancelOrderInput === null || cancelOrderInput === undefined) {
throw new RequiredError("OrderApi", "cancel", "cancelOrderInput");
}
// Path Params
const localVarPath = '/orders/cancelOrder';
// 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(cancelOrderInput, "CancelOrderInput", ""),
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.ORDER.CANCEL_ALL.DESCRIPTION
* CONTROLLER.ORDER.CANCEL_ALL.SUMMARY
* @param cancelAllOrdersInput CONTROLLER.ORDER.CANCEL_ALL.BODY
*/
public async cancelAll(cancelAllOrdersInput: CancelAllOrdersInput, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'cancelAllOrdersInput' is not null or undefined
if (cancelAllOrdersInput === null || cancelAllOrdersInput === undefined) {
throw new RequiredError("OrderApi", "cancelAll", "cancelAllOrdersInput");
}
// Path Params
const localVarPath = '/orders/cancelAllOrders';
// 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(cancelAllOrdersInput, "CancelAllOrdersInput", ""),
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.ORDER.CLOSE_MARKET.DESCRIPTION
* CONTROLLER.ORDER.CLOSE_MARKET.SUMMARY
* @param closeMarketInput CONTROLLER.ORDER.CLOSE_MARKET.BODY
*/
public async closeMarket(closeMarketInput: CloseMarketInput, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'closeMarketInput' is not null or undefined
if (closeMarketInput === null || closeMarketInput === undefined) {
throw new RequiredError("OrderApi", "closeMarket", "closeMarketInput");
}
// Path Params
const localVarPath = '/orders/closeMarket';
// 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(closeMarketInput, "CloseMarketInput", ""),
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.ORDER.CREATE_MARKET.DESCRIPTION
* CONTROLLER.ORDER.CREATE_MARKET.SUMMARY
* @param createMarketInput CONTROLLER.ORDER.CREATE_MARKET.BODY
*/
public async createMarket(createMarketInput: CreateMarketInput, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'createMarketInput' is not null or undefined
if (createMarketInput === null || createMarketInput === undefined) {
throw new RequiredError("OrderApi", "createMarket", "createMarketInput");
}
// Path Params
const localVarPath = '/orders/createMarket';
// 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(createMarketInput, "CreateMarketInput", ""),
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.ORDER.PLACE.DESCRIPTION
* CONTROLLER.ORDER.PLACE.SUMMARY
* @param placeOrderInput CONTROLLER.ORDER.PLACE.BODY
*/
public async place(placeOrderInput: PlaceOrderInput, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'placeOrderInput' is not null or undefined
if (placeOrderInput === null || placeOrderInput === undefined) {
throw new RequiredError("OrderApi", "place", "placeOrderInput");
}
// Path Params
const localVarPath = '/orders/placeOrder';
// 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(placeOrderInput, "PlaceOrderInput", ""),
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.ORDER.TAKE.DESCRIPTION
* CONTROLLER.ORDER.TAKE.SUMMARY
* @param placeOrderInput CONTROLLER.ORDER.TAKE.BODY
*/
public async take(placeOrderInput: PlaceOrderInput, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'placeOrderInput' is not null or undefined
if (placeOrderInput === null || placeOrderInput === undefined) {
throw new RequiredError("OrderApi", "take", "placeOrderInput");
}
// Path Params
const localVarPath = '/orders/takeOrder';
// 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(placeOrderInput, "PlaceOrderInput", ""),
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 OrderApiResponseProcessor {
/**
* 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 cancel
* @throws ApiException if the response code was not in [200, 299]
*/
public async cancelWithHttpInfo(response: ResponseContext): Promise<HttpInfo<OrderReply >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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 cancelAll
* @throws ApiException if the response code was not in [200, 299]
*/
public async cancelAllWithHttpInfo(response: ResponseContext): Promise<HttpInfo<OrderReply >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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 closeMarket
* @throws ApiException if the response code was not in [200, 299]
*/
public async closeMarketWithHttpInfo(response: ResponseContext): Promise<HttpInfo<OrderReply >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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 createMarket
* @throws ApiException if the response code was not in [200, 299]
*/
public async createMarketWithHttpInfo(response: ResponseContext): Promise<HttpInfo<OrderReply >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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 place
* @throws ApiException if the response code was not in [200, 299]
*/
public async placeWithHttpInfo(response: ResponseContext): Promise<HttpInfo<OrderReply >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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 take
* @throws ApiException if the response code was not in [200, 299]
*/
public async takeWithHttpInfo(response: ResponseContext): Promise<HttpInfo<OrderReply >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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: OrderReply = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"OrderReply", ""
) as OrderReply;
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);
}
}