conekta/conekta-node

View on GitHub
api/taxes-api.ts

Summary

Maintainability
A
0 mins
Test Coverage
B
88%
/* 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 { ModelError } from '../model';
// @ts-ignore
import { OrderTaxRequest } from '../model';
// @ts-ignore
import { UpdateOrderTaxRequest } from '../model';
// @ts-ignore
import { UpdateOrderTaxResponse } from '../model';
/**
 * TaxesApi - axios parameter creator
 * @export
 */
export const TaxesApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Create new taxes for an existing orden
         * @summary Create Tax
         * @param {string} id Identifier of the resource
         * @param {OrderTaxRequest} orderTaxRequest requested field for a taxes
         * @param {OrdersCreateTaxesAcceptLanguageEnum} [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}
         */
        ordersCreateTaxes: async (id: string, orderTaxRequest: OrderTaxRequest, acceptLanguage?: OrdersCreateTaxesAcceptLanguageEnum, xChildCompanyId?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('ordersCreateTaxes', 'id', id)
            // verify required parameter 'orderTaxRequest' is not null or undefined
            assertParamExists('ordersCreateTaxes', 'orderTaxRequest', orderTaxRequest)
            const localVarPath = `/orders/{id}/tax_lines`
                .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(orderTaxRequest, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Delete taxes for an existing orden
         * @summary Delete Tax
         * @param {string} id Identifier of the resource
         * @param {string} taxId identifier
         * @param {OrdersDeleteTaxesAcceptLanguageEnum} [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}
         */
        ordersDeleteTaxes: async (id: string, taxId: string, acceptLanguage?: OrdersDeleteTaxesAcceptLanguageEnum, xChildCompanyId?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('ordersDeleteTaxes', 'id', id)
            // verify required parameter 'taxId' is not null or undefined
            assertParamExists('ordersDeleteTaxes', 'taxId', taxId)
            const localVarPath = `/orders/{id}/tax_lines/{tax_id}`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)))
                .replace(`{${"tax_id"}}`, encodeURIComponent(String(taxId)));
            // 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: 'DELETE', ...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);
            }


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

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Update taxes for an existing orden
         * @summary Update Tax
         * @param {string} id Identifier of the resource
         * @param {string} taxId identifier
         * @param {UpdateOrderTaxRequest} updateOrderTaxRequest requested field for taxes
         * @param {OrdersUpdateTaxesAcceptLanguageEnum} [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}
         */
        ordersUpdateTaxes: async (id: string, taxId: string, updateOrderTaxRequest: UpdateOrderTaxRequest, acceptLanguage?: OrdersUpdateTaxesAcceptLanguageEnum, xChildCompanyId?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('ordersUpdateTaxes', 'id', id)
            // verify required parameter 'taxId' is not null or undefined
            assertParamExists('ordersUpdateTaxes', 'taxId', taxId)
            // verify required parameter 'updateOrderTaxRequest' is not null or undefined
            assertParamExists('ordersUpdateTaxes', 'updateOrderTaxRequest', updateOrderTaxRequest)
            const localVarPath = `/orders/{id}/tax_lines/{tax_id}`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)))
                .replace(`{${"tax_id"}}`, encodeURIComponent(String(taxId)));
            // 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(updateOrderTaxRequest, localVarRequestOptions, configuration)

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

/**
 * TaxesApi - functional programming interface
 * @export
 */
export const TaxesApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = TaxesApiAxiosParamCreator(configuration)
    return {
        /**
         * Create new taxes for an existing orden
         * @summary Create Tax
         * @param {string} id Identifier of the resource
         * @param {OrderTaxRequest} orderTaxRequest requested field for a taxes
         * @param {OrdersCreateTaxesAcceptLanguageEnum} [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 ordersCreateTaxes(id: string, orderTaxRequest: OrderTaxRequest, acceptLanguage?: OrdersCreateTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UpdateOrderTaxResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.ordersCreateTaxes(id, orderTaxRequest, acceptLanguage, xChildCompanyId, options);
            const index = configuration?.serverIndex ?? 0;
            const operationBasePath = operationServerMap['TaxesApi.ordersCreateTaxes']?.[index]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
        },
        /**
         * Delete taxes for an existing orden
         * @summary Delete Tax
         * @param {string} id Identifier of the resource
         * @param {string} taxId identifier
         * @param {OrdersDeleteTaxesAcceptLanguageEnum} [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 ordersDeleteTaxes(id: string, taxId: string, acceptLanguage?: OrdersDeleteTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UpdateOrderTaxResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.ordersDeleteTaxes(id, taxId, acceptLanguage, xChildCompanyId, options);
            const index = configuration?.serverIndex ?? 0;
            const operationBasePath = operationServerMap['TaxesApi.ordersDeleteTaxes']?.[index]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
        },
        /**
         * Update taxes for an existing orden
         * @summary Update Tax
         * @param {string} id Identifier of the resource
         * @param {string} taxId identifier
         * @param {UpdateOrderTaxRequest} updateOrderTaxRequest requested field for taxes
         * @param {OrdersUpdateTaxesAcceptLanguageEnum} [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 ordersUpdateTaxes(id: string, taxId: string, updateOrderTaxRequest: UpdateOrderTaxRequest, acceptLanguage?: OrdersUpdateTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UpdateOrderTaxResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.ordersUpdateTaxes(id, taxId, updateOrderTaxRequest, acceptLanguage, xChildCompanyId, options);
            const index = configuration?.serverIndex ?? 0;
            const operationBasePath = operationServerMap['TaxesApi.ordersUpdateTaxes']?.[index]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
        },
    }
};

/**
 * TaxesApi - factory interface
 * @export
 */
export const TaxesApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = TaxesApiFp(configuration)
    return {
        /**
         * Create new taxes for an existing orden
         * @summary Create Tax
         * @param {string} id Identifier of the resource
         * @param {OrderTaxRequest} orderTaxRequest requested field for a taxes
         * @param {OrdersCreateTaxesAcceptLanguageEnum} [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}
         */
        ordersCreateTaxes(id: string, orderTaxRequest: OrderTaxRequest, acceptLanguage?: OrdersCreateTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: any): AxiosPromise<UpdateOrderTaxResponse> {
            return localVarFp.ordersCreateTaxes(id, orderTaxRequest, acceptLanguage, xChildCompanyId, options).then((request) => request(axios, basePath));
        },
        /**
         * Delete taxes for an existing orden
         * @summary Delete Tax
         * @param {string} id Identifier of the resource
         * @param {string} taxId identifier
         * @param {OrdersDeleteTaxesAcceptLanguageEnum} [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}
         */
        ordersDeleteTaxes(id: string, taxId: string, acceptLanguage?: OrdersDeleteTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: any): AxiosPromise<UpdateOrderTaxResponse> {
            return localVarFp.ordersDeleteTaxes(id, taxId, acceptLanguage, xChildCompanyId, options).then((request) => request(axios, basePath));
        },
        /**
         * Update taxes for an existing orden
         * @summary Update Tax
         * @param {string} id Identifier of the resource
         * @param {string} taxId identifier
         * @param {UpdateOrderTaxRequest} updateOrderTaxRequest requested field for taxes
         * @param {OrdersUpdateTaxesAcceptLanguageEnum} [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}
         */
        ordersUpdateTaxes(id: string, taxId: string, updateOrderTaxRequest: UpdateOrderTaxRequest, acceptLanguage?: OrdersUpdateTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: any): AxiosPromise<UpdateOrderTaxResponse> {
            return localVarFp.ordersUpdateTaxes(id, taxId, updateOrderTaxRequest, acceptLanguage, xChildCompanyId, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * TaxesApi - interface
 * @export
 * @interface TaxesApi
 */
export interface TaxesApiInterface {
    /**
     * Create new taxes for an existing orden
     * @summary Create Tax
     * @param {string} id Identifier of the resource
     * @param {OrderTaxRequest} orderTaxRequest requested field for a taxes
     * @param {OrdersCreateTaxesAcceptLanguageEnum} [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 TaxesApiInterface
     */
    ordersCreateTaxes(id: string, orderTaxRequest: OrderTaxRequest, acceptLanguage?: OrdersCreateTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig): AxiosPromise<UpdateOrderTaxResponse>;

    /**
     * Delete taxes for an existing orden
     * @summary Delete Tax
     * @param {string} id Identifier of the resource
     * @param {string} taxId identifier
     * @param {OrdersDeleteTaxesAcceptLanguageEnum} [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 TaxesApiInterface
     */
    ordersDeleteTaxes(id: string, taxId: string, acceptLanguage?: OrdersDeleteTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig): AxiosPromise<UpdateOrderTaxResponse>;

    /**
     * Update taxes for an existing orden
     * @summary Update Tax
     * @param {string} id Identifier of the resource
     * @param {string} taxId identifier
     * @param {UpdateOrderTaxRequest} updateOrderTaxRequest requested field for taxes
     * @param {OrdersUpdateTaxesAcceptLanguageEnum} [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 TaxesApiInterface
     */
    ordersUpdateTaxes(id: string, taxId: string, updateOrderTaxRequest: UpdateOrderTaxRequest, acceptLanguage?: OrdersUpdateTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig): AxiosPromise<UpdateOrderTaxResponse>;

}

/**
 * TaxesApi - object-oriented interface
 * @export
 * @class TaxesApi
 * @extends {BaseAPI}
 */
export class TaxesApi extends BaseAPI implements TaxesApiInterface {
    /**
     * Create new taxes for an existing orden
     * @summary Create Tax
     * @param {string} id Identifier of the resource
     * @param {OrderTaxRequest} orderTaxRequest requested field for a taxes
     * @param {OrdersCreateTaxesAcceptLanguageEnum} [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 TaxesApi
     */
    public ordersCreateTaxes(id: string, orderTaxRequest: OrderTaxRequest, acceptLanguage?: OrdersCreateTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig) {
        return TaxesApiFp(this.configuration).ordersCreateTaxes(id, orderTaxRequest, acceptLanguage, xChildCompanyId, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Delete taxes for an existing orden
     * @summary Delete Tax
     * @param {string} id Identifier of the resource
     * @param {string} taxId identifier
     * @param {OrdersDeleteTaxesAcceptLanguageEnum} [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 TaxesApi
     */
    public ordersDeleteTaxes(id: string, taxId: string, acceptLanguage?: OrdersDeleteTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig) {
        return TaxesApiFp(this.configuration).ordersDeleteTaxes(id, taxId, acceptLanguage, xChildCompanyId, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Update taxes for an existing orden
     * @summary Update Tax
     * @param {string} id Identifier of the resource
     * @param {string} taxId identifier
     * @param {UpdateOrderTaxRequest} updateOrderTaxRequest requested field for taxes
     * @param {OrdersUpdateTaxesAcceptLanguageEnum} [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 TaxesApi
     */
    public ordersUpdateTaxes(id: string, taxId: string, updateOrderTaxRequest: UpdateOrderTaxRequest, acceptLanguage?: OrdersUpdateTaxesAcceptLanguageEnum, xChildCompanyId?: string, options?: RawAxiosRequestConfig) {
        return TaxesApiFp(this.configuration).ordersUpdateTaxes(id, taxId, updateOrderTaxRequest, acceptLanguage, xChildCompanyId, options).then((request) => request(this.axios, this.basePath));
    }
}

/**
 * @export
 */
export const OrdersCreateTaxesAcceptLanguageEnum = {
    es: 'es',
    en: 'en'
} as const;
export type OrdersCreateTaxesAcceptLanguageEnum = typeof OrdersCreateTaxesAcceptLanguageEnum[keyof typeof OrdersCreateTaxesAcceptLanguageEnum];
/**
 * @export
 */
export const OrdersDeleteTaxesAcceptLanguageEnum = {
    es: 'es',
    en: 'en'
} as const;
export type OrdersDeleteTaxesAcceptLanguageEnum = typeof OrdersDeleteTaxesAcceptLanguageEnum[keyof typeof OrdersDeleteTaxesAcceptLanguageEnum];
/**
 * @export
 */
export const OrdersUpdateTaxesAcceptLanguageEnum = {
    es: 'es',
    en: 'en'
} as const;
export type OrdersUpdateTaxesAcceptLanguageEnum = typeof OrdersUpdateTaxesAcceptLanguageEnum[keyof typeof OrdersUpdateTaxesAcceptLanguageEnum];