UNPKG

shipstation-client

Version:
293 lines (264 loc) 14.9 kB
/* tslint:disable */ /* eslint-disable */ /** * ShipStation API v2 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 2.0.0 * * * 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, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base'; // @ts-ignore import type { CalculateRatesRequestBody } from '../models'; // @ts-ignore import type { CalculateRatesResponseBody } from '../models'; // @ts-ignore import type { ErrorResponseBody } from '../models'; // @ts-ignore import type { EstimateRatesRequestBody } from '../models'; // @ts-ignore import type { GetRateByIdResponseBody } from '../models'; // @ts-ignore import type { RateEstimate } from '../models'; /** * RatesApi - axios parameter creator * @export */ export const RatesApiAxiosParamCreator = function (configuration?: Configuration) { return { /** * It\'s not uncommon that you want to give your customer the choice between whether they want to ship the fastest, cheapest, or the most trusted route. Most companies don\'t solely ship things using a single shipping option; so we provide functionality to show you all your options! * @summary Get shipping rates * @param {CalculateRatesRequestBody} calculateRatesRequestBody * @param {*} [options] Override http request option. * @throws {RequiredError} */ calculateRates: async (calculateRatesRequestBody: CalculateRatesRequestBody, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'calculateRatesRequestBody' is not null or undefined assertParamExists('calculateRates', 'calculateRatesRequestBody', calculateRatesRequestBody) const localVarPath = `/v2/rates`; // 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 api_keys required await setApiKeyToObject(localVarHeaderParameter, "api-key", configuration) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(calculateRatesRequestBody, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Get Rate Estimates * @summary Estimate rates * @param {EstimateRatesRequestBody} estimateRatesRequestBody * @param {*} [options] Override http request option. * @throws {RequiredError} */ estimateRates: async (estimateRatesRequestBody: EstimateRatesRequestBody, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'estimateRatesRequestBody' is not null or undefined assertParamExists('estimateRates', 'estimateRatesRequestBody', estimateRatesRequestBody) const localVarPath = `/v2/rates/estimate`; // 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 api_keys required await setApiKeyToObject(localVarHeaderParameter, "api-key", configuration) localVarHeaderParameter['Content-Type'] = 'application/json'; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.data = serializeDataIfNeeded(estimateRatesRequestBody, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Retrieve a previously queried rate by its ID * @summary Get rate by id * @param {string} rateId Rate ID * @param {*} [options] Override http request option. * @throws {RequiredError} */ getRateById: async (rateId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { // verify required parameter 'rateId' is not null or undefined assertParamExists('getRateById', 'rateId', rateId) const localVarPath = `/v2/rates/{rate_id}` .replace(`{${"rate_id"}}`, encodeURIComponent(String(rateId))); // 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 api_keys required await setApiKeyToObject(localVarHeaderParameter, "api-key", configuration) setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }, } }; /** * RatesApi - functional programming interface * @export */ export const RatesApiFp = function(configuration?: Configuration) { const localVarAxiosParamCreator = RatesApiAxiosParamCreator(configuration) return { /** * It\'s not uncommon that you want to give your customer the choice between whether they want to ship the fastest, cheapest, or the most trusted route. Most companies don\'t solely ship things using a single shipping option; so we provide functionality to show you all your options! * @summary Get shipping rates * @param {CalculateRatesRequestBody} calculateRatesRequestBody * @param {*} [options] Override http request option. * @throws {RequiredError} */ async calculateRates(calculateRatesRequestBody: CalculateRatesRequestBody, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CalculateRatesResponseBody>> { const localVarAxiosArgs = await localVarAxiosParamCreator.calculateRates(calculateRatesRequestBody, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap['RatesApi.calculateRates']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Get Rate Estimates * @summary Estimate rates * @param {EstimateRatesRequestBody} estimateRatesRequestBody * @param {*} [options] Override http request option. * @throws {RequiredError} */ async estimateRates(estimateRatesRequestBody: EstimateRatesRequestBody, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<RateEstimate>>> { const localVarAxiosArgs = await localVarAxiosParamCreator.estimateRates(estimateRatesRequestBody, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap['RatesApi.estimateRates']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, /** * Retrieve a previously queried rate by its ID * @summary Get rate by id * @param {string} rateId Rate ID * @param {*} [options] Override http request option. * @throws {RequiredError} */ async getRateById(rateId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetRateByIdResponseBody>> { const localVarAxiosArgs = await localVarAxiosParamCreator.getRateById(rateId, options); const localVarOperationServerIndex = configuration?.serverIndex ?? 0; const localVarOperationServerBasePath = operationServerMap['RatesApi.getRateById']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, } }; /** * RatesApi - factory interface * @export */ export const RatesApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { const localVarFp = RatesApiFp(configuration) return { /** * It\'s not uncommon that you want to give your customer the choice between whether they want to ship the fastest, cheapest, or the most trusted route. Most companies don\'t solely ship things using a single shipping option; so we provide functionality to show you all your options! * @summary Get shipping rates * @param {CalculateRatesRequestBody} calculateRatesRequestBody * @param {*} [options] Override http request option. * @throws {RequiredError} */ calculateRates(calculateRatesRequestBody: CalculateRatesRequestBody, options?: RawAxiosRequestConfig): AxiosPromise<CalculateRatesResponseBody> { return localVarFp.calculateRates(calculateRatesRequestBody, options).then((request) => request(axios, basePath)); }, /** * Get Rate Estimates * @summary Estimate rates * @param {EstimateRatesRequestBody} estimateRatesRequestBody * @param {*} [options] Override http request option. * @throws {RequiredError} */ estimateRates(estimateRatesRequestBody: EstimateRatesRequestBody, options?: RawAxiosRequestConfig): AxiosPromise<Array<RateEstimate>> { return localVarFp.estimateRates(estimateRatesRequestBody, options).then((request) => request(axios, basePath)); }, /** * Retrieve a previously queried rate by its ID * @summary Get rate by id * @param {string} rateId Rate ID * @param {*} [options] Override http request option. * @throws {RequiredError} */ getRateById(rateId: string, options?: RawAxiosRequestConfig): AxiosPromise<GetRateByIdResponseBody> { return localVarFp.getRateById(rateId, options).then((request) => request(axios, basePath)); }, }; }; /** * RatesApi - object-oriented interface * @export * @class RatesApi * @extends {BaseAPI} */ export class RatesApi extends BaseAPI { /** * It\'s not uncommon that you want to give your customer the choice between whether they want to ship the fastest, cheapest, or the most trusted route. Most companies don\'t solely ship things using a single shipping option; so we provide functionality to show you all your options! * @summary Get shipping rates * @param {CalculateRatesRequestBody} calculateRatesRequestBody * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof RatesApi */ public calculateRates(calculateRatesRequestBody: CalculateRatesRequestBody, options?: RawAxiosRequestConfig) { return RatesApiFp(this.configuration).calculateRates(calculateRatesRequestBody, options).then((request) => request(this.axios, this.basePath)); } /** * Get Rate Estimates * @summary Estimate rates * @param {EstimateRatesRequestBody} estimateRatesRequestBody * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof RatesApi */ public estimateRates(estimateRatesRequestBody: EstimateRatesRequestBody, options?: RawAxiosRequestConfig) { return RatesApiFp(this.configuration).estimateRates(estimateRatesRequestBody, options).then((request) => request(this.axios, this.basePath)); } /** * Retrieve a previously queried rate by its ID * @summary Get rate by id * @param {string} rateId Rate ID * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof RatesApi */ public getRateById(rateId: string, options?: RawAxiosRequestConfig) { return RatesApiFp(this.configuration).getRateById(rateId, options).then((request) => request(this.axios, this.basePath)); } }