conekta/conekta-node

View on GitHub
api/charges-api.ts

Summary

Maintainability
A
0 mins
Test Coverage
B
87%
/* tslint:disable */
/* eslint-disable */
/**
 * Conekta API
 * Conekta sdk
 *
 * The version of the OpenAPI document: 2.1.0
 * Contact: engineering@conekta.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import { ChargeOrderResponse } from '../model';
// @ts-ignore
import { ChargeRequest } from '../model';
// @ts-ignore
import { ChargeResponse } from '../model';
// @ts-ignore
import { ChargeUpdateRequest } from '../model';
// @ts-ignore
import { GetChargesResponse } from '../model';
// @ts-ignore
import { ModelError } from '../model';
/**
 * ChargesApi - axios parameter creator
 * @export
 */
export const ChargesApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * 
         * @summary Get A List of Charges
         * @param {GetChargesAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
         * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
         * @param {number} [limit] The numbers of items to return, the maximum value is 250
         * @param {string} [search] General order search, e.g. by mail, reference etc.
         * @param {string} [next] next page
         * @param {string} [previous] previous page
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getCharges: async (acceptLanguage?: GetChargesAcceptLanguageEnum, xChildCompanyId?: string, limit?: number, search?: string, next?: string, previous?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/charges`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication bearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (limit !== undefined) {
                localVarQueryParameter['limit'] = limit;
            }

            if (search !== undefined) {
                localVarQueryParameter['search'] = search;
            }

            if (next !== undefined) {
                localVarQueryParameter['next'] = next;
            }

            if (previous !== undefined) {
                localVarQueryParameter['previous'] = previous;
            }

            if (acceptLanguage != null) {
                localVarHeaderParameter['Accept-Language'] = String(acceptLanguage);
            }

            if (xChildCompanyId != null) {
                localVarHeaderParameter['X-Child-Company-Id'] = String(xChildCompanyId);
            }


    
            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Create charge for an existing orden
         * @summary Create charge
         * @param {string} id Identifier of the resource
         * @param {ChargeRequest} chargeRequest requested field for a charge
         * @param {OrdersCreateChargeAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
         * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        ordersCreateCharge: async (id: string, chargeRequest: ChargeRequest, acceptLanguage?: OrdersCreateChargeAcceptLanguageEnum, xChildCompanyId?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('ordersCreateCharge', 'id', id)
            // verify required parameter 'chargeRequest' is not null or undefined
            assertParamExists('ordersCreateCharge', 'chargeRequest', chargeRequest)
            const localVarPath = `/orders/{id}/charges`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication bearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (acceptLanguage != null) {
                localVarHeaderParameter['Accept-Language'] = String(acceptLanguage);
            }

            if (xChildCompanyId != null) {
                localVarHeaderParameter['X-Child-Company-Id'] = String(xChildCompanyId);
            }


    
            localVarHeaderParameter['Content-Type'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            localVarRequestOptions.data = serializeDataIfNeeded(chargeRequest, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * 
         * @summary Update a charge
         * @param {string} id Identifier of the resource
         * @param {ChargeUpdateRequest} chargeUpdateRequest requested field for update a charge
         * @param {UpdateChargeAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
         * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        updateCharge: async (id: string, chargeUpdateRequest: ChargeUpdateRequest, acceptLanguage?: UpdateChargeAcceptLanguageEnum, xChildCompanyId?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('updateCharge', 'id', id)
            // verify required parameter 'chargeUpdateRequest' is not null or undefined
            assertParamExists('updateCharge', 'chargeUpdateRequest', chargeUpdateRequest)
            const localVarPath = `/charges/{id}`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication bearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (acceptLanguage != null) {
                localVarHeaderParameter['Accept-Language'] = String(acceptLanguage);
            }

            if (xChildCompanyId != null) {
                localVarHeaderParameter['X-Child-Company-Id'] = String(xChildCompanyId);
            }


    
            localVarHeaderParameter['Content-Type'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            localVarRequestOptions.data = serializeDataIfNeeded(chargeUpdateRequest, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    }
};

/**
 * ChargesApi - functional programming interface
 * @export
 */
export const ChargesApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = ChargesApiAxiosParamCreator(configuration)
    return {
        /**
         * 
         * @summary Get A List of Charges
         * @param {GetChargesAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
         * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
         * @param {number} [limit] The numbers of items to return, the maximum value is 250
         * @param {string} [search] General order search, e.g. by mail, reference etc.
         * @param {string} [next] next page
         * @param {string} [previous] previous page
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getCharges(acceptLanguage?: GetChargesAcceptLanguageEnum, xChildCompanyId?: string, limit?: number, search?: string, next?: string, previous?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetChargesResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getCharges(acceptLanguage, xChildCompanyId, limit, search, next, previous, options);
            const index = configuration?.serverIndex ?? 0;
            const operationBasePath = operationServerMap['ChargesApi.getCharges']?.[index]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
        },
        /**
         * Create charge for an existing orden
         * @summary Create charge
         * @param {string} id Identifier of the resource
         * @param {ChargeRequest} chargeRequest requested field for a charge
         * @param {OrdersCreateChargeAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
         * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async ordersCreateCharge(id: string, chargeRequest: ChargeRequest, acceptLanguage?: OrdersCreateChargeAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ChargeOrderResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.ordersCreateCharge(id, chargeRequest, acceptLanguage, xChildCompanyId, options);
            const index = configuration?.serverIndex ?? 0;
            const operationBasePath = operationServerMap['ChargesApi.ordersCreateCharge']?.[index]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
        },
        /**
         * 
         * @summary Update a charge
         * @param {string} id Identifier of the resource
         * @param {ChargeUpdateRequest} chargeUpdateRequest requested field for update a charge
         * @param {UpdateChargeAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
         * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async updateCharge(id: string, chargeUpdateRequest: ChargeUpdateRequest, acceptLanguage?: UpdateChargeAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ChargeResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.updateCharge(id, chargeUpdateRequest, acceptLanguage, xChildCompanyId, options);
            const index = configuration?.serverIndex ?? 0;
            const operationBasePath = operationServerMap['ChargesApi.updateCharge']?.[index]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
        },
    }
};

/**
 * ChargesApi - factory interface
 * @export
 */
export const ChargesApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = ChargesApiFp(configuration)
    return {
        /**
         * 
         * @summary Get A List of Charges
         * @param {GetChargesAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
         * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
         * @param {number} [limit] The numbers of items to return, the maximum value is 250
         * @param {string} [search] General order search, e.g. by mail, reference etc.
         * @param {string} [next] next page
         * @param {string} [previous] previous page
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getCharges(acceptLanguage?: GetChargesAcceptLanguageEnum, xChildCompanyId?: string, limit?: number, search?: string, next?: string, previous?: string, options?: any): AxiosPromise<GetChargesResponse> {
            return localVarFp.getCharges(acceptLanguage, xChildCompanyId, limit, search, next, previous, options).then((request) => request(axios, basePath));
        },
        /**
         * Create charge for an existing orden
         * @summary Create charge
         * @param {string} id Identifier of the resource
         * @param {ChargeRequest} chargeRequest requested field for a charge
         * @param {OrdersCreateChargeAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
         * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        ordersCreateCharge(id: string, chargeRequest: ChargeRequest, acceptLanguage?: OrdersCreateChargeAcceptLanguageEnum, xChildCompanyId?: string, options?: any): AxiosPromise<ChargeOrderResponse> {
            return localVarFp.ordersCreateCharge(id, chargeRequest, acceptLanguage, xChildCompanyId, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Update a charge
         * @param {string} id Identifier of the resource
         * @param {ChargeUpdateRequest} chargeUpdateRequest requested field for update a charge
         * @param {UpdateChargeAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
         * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        updateCharge(id: string, chargeUpdateRequest: ChargeUpdateRequest, acceptLanguage?: UpdateChargeAcceptLanguageEnum, xChildCompanyId?: string, options?: any): AxiosPromise<ChargeResponse> {
            return localVarFp.updateCharge(id, chargeUpdateRequest, acceptLanguage, xChildCompanyId, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * ChargesApi - interface
 * @export
 * @interface ChargesApi
 */
export interface ChargesApiInterface {
    /**
     * 
     * @summary Get A List of Charges
     * @param {GetChargesAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
     * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
     * @param {number} [limit] The numbers of items to return, the maximum value is 250
     * @param {string} [search] General order search, e.g. by mail, reference etc.
     * @param {string} [next] next page
     * @param {string} [previous] previous page
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ChargesApiInterface
     */
    getCharges(acceptLanguage?: GetChargesAcceptLanguageEnum, xChildCompanyId?: string, limit?: number, search?: string, next?: string, previous?: string, options?: RawAxiosRequestConfig): AxiosPromise<GetChargesResponse>;

    /**
     * Create charge for an existing orden
     * @summary Create charge
     * @param {string} id Identifier of the resource
     * @param {ChargeRequest} chargeRequest requested field for a charge
     * @param {OrdersCreateChargeAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
     * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ChargesApiInterface
     */
    ordersCreateCharge(id: string, chargeRequest: ChargeRequest, acceptLanguage?: OrdersCreateChargeAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig): AxiosPromise<ChargeOrderResponse>;

    /**
     * 
     * @summary Update a charge
     * @param {string} id Identifier of the resource
     * @param {ChargeUpdateRequest} chargeUpdateRequest requested field for update a charge
     * @param {UpdateChargeAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
     * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ChargesApiInterface
     */
    updateCharge(id: string, chargeUpdateRequest: ChargeUpdateRequest, acceptLanguage?: UpdateChargeAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig): AxiosPromise<ChargeResponse>;

}

/**
 * ChargesApi - object-oriented interface
 * @export
 * @class ChargesApi
 * @extends {BaseAPI}
 */
export class ChargesApi extends BaseAPI implements ChargesApiInterface {
    /**
     * 
     * @summary Get A List of Charges
     * @param {GetChargesAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
     * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
     * @param {number} [limit] The numbers of items to return, the maximum value is 250
     * @param {string} [search] General order search, e.g. by mail, reference etc.
     * @param {string} [next] next page
     * @param {string} [previous] previous page
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ChargesApi
     */
    public getCharges(acceptLanguage?: GetChargesAcceptLanguageEnum, xChildCompanyId?: string, limit?: number, search?: string, next?: string, previous?: string, options?: RawAxiosRequestConfig) {
        return ChargesApiFp(this.configuration).getCharges(acceptLanguage, xChildCompanyId, limit, search, next, previous, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Create charge for an existing orden
     * @summary Create charge
     * @param {string} id Identifier of the resource
     * @param {ChargeRequest} chargeRequest requested field for a charge
     * @param {OrdersCreateChargeAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
     * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ChargesApi
     */
    public ordersCreateCharge(id: string, chargeRequest: ChargeRequest, acceptLanguage?: OrdersCreateChargeAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig) {
        return ChargesApiFp(this.configuration).ordersCreateCharge(id, chargeRequest, acceptLanguage, xChildCompanyId, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Update a charge
     * @param {string} id Identifier of the resource
     * @param {ChargeUpdateRequest} chargeUpdateRequest requested field for update a charge
     * @param {UpdateChargeAcceptLanguageEnum} [acceptLanguage] Use for knowing which language to use
     * @param {string} [xChildCompanyId] In the case of a holding company, the company id of the child company to which will process the request.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ChargesApi
     */
    public updateCharge(id: string, chargeUpdateRequest: ChargeUpdateRequest, acceptLanguage?: UpdateChargeAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig) {
        return ChargesApiFp(this.configuration).updateCharge(id, chargeUpdateRequest, acceptLanguage, xChildCompanyId, options).then((request) => request(this.axios, this.basePath));
    }
}

/**
 * @export
 */
export const GetChargesAcceptLanguageEnum = {
    es: 'es',
    en: 'en'
} as const;
export type GetChargesAcceptLanguageEnum = typeof GetChargesAcceptLanguageEnum[keyof typeof GetChargesAcceptLanguageEnum];
/**
 * @export
 */
export const OrdersCreateChargeAcceptLanguageEnum = {
    es: 'es',
    en: 'en'
} as const;
export type OrdersCreateChargeAcceptLanguageEnum = typeof OrdersCreateChargeAcceptLanguageEnum[keyof typeof OrdersCreateChargeAcceptLanguageEnum];
/**
 * @export
 */
export const UpdateChargeAcceptLanguageEnum = {
    es: 'es',
    en: 'en'
} as const;
export type UpdateChargeAcceptLanguageEnum = typeof UpdateChargeAcceptLanguageEnum[keyof typeof UpdateChargeAcceptLanguageEnum];