diff --git a/__tests__/CardsApi.unit.ts b/__tests__/CardsApi.unit.ts index 4873075..1d48d5a 100755 --- a/__tests__/CardsApi.unit.ts +++ b/__tests__/CardsApi.unit.ts @@ -462,12 +462,10 @@ describe("CardsApi", () => { })); const cardsApi = await new CardsApi(CONFIG_FOR_UNIT).list( - 1, - "fake", - "id", - { - id: "asc", - } + 1, // limit + "fake", // before + "id", // after + ["total_count"] // include ); expect(cardsApi).toBeDefined(); expect(cardsApi.data?.length).toEqual(1); diff --git a/__tests__/MiscellaneousModels.unit.ts b/__tests__/MiscellaneousModels.unit.ts index d2f9c12..0421e95 100755 --- a/__tests__/MiscellaneousModels.unit.ts +++ b/__tests__/MiscellaneousModels.unit.ts @@ -9,8 +9,6 @@ import { SortBy1, SortBy2, SortBy3, - SortBy4, - SortBy5, SortByDateCreatedEnum, SortBySendDateEnum, SortBy1DateCreatedEnum, @@ -19,10 +17,6 @@ import { SortBy2SendDateEnum, SortBy3DateCreatedEnum, SortBy3SendDateEnum, - SortBy4DateCreatedEnum, - SortBy4SendDateEnum, - SortBy5DateCreatedEnum, - SortBy5SendDateEnum, Thumbnail, CountryExtended, TrackingEventCertified, @@ -576,50 +570,6 @@ describe("Sort Criteria", () => { expect((rec as any)[prop]).toEqual(val); }); }); - - describe("SortBy4", () => { - it("can be created", () => { - const rec = new SortBy4(); - expect(rec).toBeDefined(); - }); - - it.each([ - ["date_created", SortBy4DateCreatedEnum.Asc], - ["date_created", SortBy4DateCreatedEnum.Desc], - ["send_date", SortBy4SendDateEnum.Asc], - ["send_date", SortBy4SendDateEnum.Desc], - ])("can be created with a provided %s value", (prop, val) => { - const input = {}; - (input as any)[prop] = val; - - const rec = new SortBy4(input); - - expect(rec).toBeDefined(); - expect((rec as any)[prop]).toEqual(val); - }); - }); - - describe("SortBy5", () => { - it("can be created", () => { - const rec = new SortBy5(); - expect(rec).toBeDefined(); - }); - - it.each([ - ["date_created", SortBy5DateCreatedEnum.Asc], - ["date_created", SortBy5DateCreatedEnum.Desc], - ["send_date", SortBy5SendDateEnum.Asc], - ["send_date", SortBy5SendDateEnum.Desc], - ])("can be created with a provided %s value", (prop, val) => { - const input = {}; - (input as any)[prop] = val; - - const rec = new SortBy5(input); - - expect(rec).toBeDefined(); - expect((rec as any)[prop]).toEqual(val); - }); - }); }); describe("Location", () => { diff --git a/api/addresses-api.ts b/api/addresses-api.ts index 033e71d..6e9d0d4 100644 --- a/api/addresses-api.ts +++ b/api/addresses-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,364 +12,537 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { Address } from '../models'; +import { Address } from "../models"; // @ts-ignore -import { AddressDeletion } from '../models'; +import { AddressDeletion } from "../models"; // @ts-ignore -import { AddressEditable } from '../models'; +import { AddressEditable } from "../models"; // @ts-ignore -import { AddressList } from '../models'; +import { AddressList } from "../models"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; /** * AddressesApi - axios parameter creator * @export */ -export const AddressesApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Creates a new address given information - * @summary create - * @param {AddressEditable} addressEditable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - addressCreate: async (addressEditable: AddressEditable, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'addressEditable' is not null or undefined - assertParamExists('addressCreate', 'addressEditable', addressEditable) - const localVarPath = `/addresses`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(addressEditable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Deletes the details of an existing address. - * @summary delete - * @param {string} adrId id of the address - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - addressDelete: async (adrId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'adrId' is not null or undefined - assertParamExists('addressDelete', 'adrId', adrId) - const localVarPath = `/addresses/{adr_id}` - .replace(`{${"adr_id"}}`, encodeURIComponent(String(adrId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the details of an existing address. - * @summary get - * @param {string} adrId id of the address - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - addressRetrieve: async (adrId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'adrId' is not null or undefined - assertParamExists('addressRetrieve', 'adrId', adrId) - const localVarPath = `/addresses/{adr_id}` - .replace(`{${"adr_id"}}`, encodeURIComponent(String(adrId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a list of your addresses. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - addressesList: async (limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/addresses`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (before !== undefined) { - localVarQueryParameter['before'] = before; - } - - if (after !== undefined) { - localVarQueryParameter['after'] = after; - } - - if (include) { - localVarQueryParameter['include'] = valueToString(include); - } - - if (dateCreated !== undefined) { - localVarQueryParameter['date_created'] = valueToString(dateCreated); - } - - if (metadata !== undefined) { - localVarQueryParameter['metadata'] = valueToString(metadata); - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } +export const AddressesApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Creates a new address given information + * @summary create + * @param {AddressEditable} addressEditable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + addressCreate: async ( + addressEditable: AddressEditable, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'addressEditable' is not null or undefined + assertParamExists("addressCreate", "addressEditable", addressEditable); + const localVarPath = `/addresses`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + addressEditable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Deletes the details of an existing address. + * @summary delete + * @param {string} adrId id of the address + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + addressDelete: async ( + adrId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'adrId' is not null or undefined + assertParamExists("addressDelete", "adrId", adrId); + const localVarPath = `/addresses/{adr_id}`.replace( + `{${"adr_id"}}`, + encodeURIComponent(String(adrId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the details of an existing address. + * @summary get + * @param {string} adrId id of the address + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + addressRetrieve: async ( + adrId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'adrId' is not null or undefined + assertParamExists("addressRetrieve", "adrId", adrId); + const localVarPath = `/addresses/{adr_id}`.replace( + `{${"adr_id"}}`, + encodeURIComponent(String(adrId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of your addresses. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + addressesList: async ( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + options: AxiosRequestConfig = {} + ): Promise => { + const localVarPath = `/addresses`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (before !== undefined) { + localVarQueryParameter["before"] = before; + } + + if (after !== undefined) { + localVarQueryParameter["after"] = after; + } + + if (include) { + localVarQueryParameter["include"] = valueToString(include); + } + + if (dateCreated !== undefined) { + localVarQueryParameter["date_created"] = valueToString(dateCreated); + } + + if (metadata !== undefined) { + localVarQueryParameter["metadata"] = valueToString(metadata); + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * AddressesApi - functional programming interface * @export */ -export const AddressesApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = AddressesApiAxiosParamCreator(configuration) - return { - /** - * Creates a new address given information - * @summary create - * @param {AddressEditable} addressEditable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async addressCreate(addressEditable: AddressEditable, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise

> { - const localVarAxiosArgs = await localVarAxiosParamCreator.addressCreate(addressEditable, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Deletes the details of an existing address. - * @summary delete - * @param {string} adrId id of the address - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async addressDelete(adrId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.addressDelete(adrId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Retrieves the details of an existing address. - * @summary get - * @param {string} adrId id of the address - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async addressRetrieve(adrId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise
> { - const localVarAxiosArgs = await localVarAxiosParamCreator.addressRetrieve(adrId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Returns a list of your addresses. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async addressesList(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.addressesList(limit, before, after, include, dateCreated, metadata, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * AddressesApi - object-oriented interface - * @export - * @class AddressesApi - * @extends {BaseAPI} - */ -export class AddressesApi extends BaseAPI { +export const AddressesApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = + AddressesApiAxiosParamCreator(configuration); + return { /** * Creates a new address given information * @summary create - * @param {AddressEditable} addressEditable + * @param {AddressEditable} addressEditable * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof AddressesApi */ - public create(addressEditable: AddressEditable, options?: AxiosRequestConfig) { - return AddressesApiFp(this.configuration).addressCreate(addressEditable, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Address(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async addressCreate( + addressEditable: AddressEditable, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise
+ > { + const localVarAxiosArgs = await localVarAxiosParamCreator.addressCreate( + addressEditable, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Deletes the details of an existing address. * @summary delete * @param {string} adrId id of the address * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof AddressesApi */ - public delete(adrId: string, options?: AxiosRequestConfig) { - return AddressesApiFp(this.configuration).addressDelete(adrId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new AddressDeletion(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async addressDelete( + adrId: string, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.addressDelete( + adrId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Retrieves the details of an existing address. * @summary get * @param {string} adrId id of the address * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof AddressesApi */ - public get(adrId: string, options?: AxiosRequestConfig) { - return AddressesApiFp(this.configuration).addressRetrieve(adrId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Address(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async addressRetrieve( + adrId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise
+ > { + const localVarAxiosArgs = await localVarAxiosParamCreator.addressRetrieve( + adrId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Returns a list of your addresses. * @summary list * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof AddressesApi */ - public list(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, options?: AxiosRequestConfig) { - return AddressesApiFp(this.configuration).addressesList(limit, before, after, include, dateCreated, metadata, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new AddressList(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async addressesList( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.addressesList( + limit, + before, + after, + include, + dateCreated, + metadata, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * AddressesApi - object-oriented interface + * @export + * @class AddressesApi + * @extends {BaseAPI} + */ +export class AddressesApi extends BaseAPI { + /** + * Creates a new address given information + * @summary create + * @param {AddressEditable} addressEditable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AddressesApi + */ + public create( + addressEditable: AddressEditable, + options?: AxiosRequestConfig + ) { + return AddressesApiFp(this.configuration) + .addressCreate(addressEditable, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Address(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Deletes the details of an existing address. + * @summary delete + * @param {string} adrId id of the address + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AddressesApi + */ + public delete(adrId: string, options?: AxiosRequestConfig) { + return AddressesApiFp(this.configuration) + .addressDelete(adrId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new AddressDeletion(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Retrieves the details of an existing address. + * @summary get + * @param {string} adrId id of the address + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AddressesApi + */ + public get(adrId: string, options?: AxiosRequestConfig) { + return AddressesApiFp(this.configuration) + .addressRetrieve(adrId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Address(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Returns a list of your addresses. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AddressesApi + */ + public list( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + options?: AxiosRequestConfig + ) { + return AddressesApiFp(this.configuration) + .addressesList( + limit, + before, + after, + include, + dateCreated, + metadata, + options + ) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new AddressList(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -377,4 +550,3 @@ export class AddressesApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/bank-accounts-api.ts b/api/bank-accounts-api.ts index aaa1301..71c04ae 100644 --- a/api/bank-accounts-api.ts +++ b/api/bank-accounts-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,443 +12,665 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { BankAccount } from '../models'; +import { BankAccount } from "../models"; // @ts-ignore -import { BankAccountDeletion } from '../models'; +import { BankAccountDeletion } from "../models"; // @ts-ignore -import { BankAccountList } from '../models'; +import { BankAccountList } from "../models"; // @ts-ignore -import { BankAccountVerify } from '../models'; +import { BankAccountVerify } from "../models"; // @ts-ignore -import { BankAccountWritable } from '../models'; +import { BankAccountWritable } from "../models"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; /** * BankAccountsApi - axios parameter creator * @export */ -export const BankAccountsApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Creates a new bank account with the provided properties. Bank accounts created in live mode will need to be verified via micro deposits before being able to send live checks. The deposits will appear in the bank account in 2-3 business days and have the description \"VERIFICATION\". - * @summary create - * @param {BankAccountWritable} bankAccountWritable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - bankAccountCreate: async (bankAccountWritable: BankAccountWritable, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'bankAccountWritable' is not null or undefined - assertParamExists('bankAccountCreate', 'bankAccountWritable', bankAccountWritable) - const localVarPath = `/bank_accounts`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(bankAccountWritable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Permanently deletes a bank account. It cannot be undone. - * @summary delete - * @param {string} bankId id of the bank account - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - bankAccountDelete: async (bankId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'bankId' is not null or undefined - assertParamExists('bankAccountDelete', 'bankId', bankId) - const localVarPath = `/bank_accounts/{bank_id}` - .replace(`{${"bank_id"}}`, encodeURIComponent(String(bankId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the details of an existing bank account. You need only supply the unique bank account identifier that was returned upon bank account creation. - * @summary get - * @param {string} bankId id of the bank account - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - bankAccountRetrieve: async (bankId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'bankId' is not null or undefined - assertParamExists('bankAccountRetrieve', 'bankId', bankId) - const localVarPath = `/bank_accounts/{bank_id}` - .replace(`{${"bank_id"}}`, encodeURIComponent(String(bankId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Verify a bank account in order to create a check. - * @summary verify - * @param {string} bankId id of the bank account to be verified - * @param {BankAccountVerify} bankAccountVerify - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - bankAccountVerify: async (bankId: string, bankAccountVerify: BankAccountVerify, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'bankId' is not null or undefined - assertParamExists('bankAccountVerify', 'bankId', bankId) - // verify required parameter 'bankAccountVerify' is not null or undefined - assertParamExists('bankAccountVerify', 'bankAccountVerify', bankAccountVerify) - const localVarPath = `/bank_accounts/{bank_id}/verify` - .replace(`{${"bank_id"}}`, encodeURIComponent(String(bankId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(bankAccountVerify, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a list of your bank accounts. The bank accounts are returned sorted by creation date, with the most recently created bank accounts appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - bankAccountsList: async (limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/bank_accounts`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (before !== undefined) { - localVarQueryParameter['before'] = before; - } - - if (after !== undefined) { - localVarQueryParameter['after'] = after; - } - - if (include) { - localVarQueryParameter['include'] = valueToString(include); - } - - if (dateCreated !== undefined) { - localVarQueryParameter['date_created'] = valueToString(dateCreated); - } - - if (metadata !== undefined) { - localVarQueryParameter['metadata'] = valueToString(metadata); - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } +export const BankAccountsApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Creates a new bank account with the provided properties. Bank accounts created in live mode will need to be verified via micro deposits before being able to send live checks. The deposits will appear in the bank account in 2-3 business days and have the description \"VERIFICATION\". + * @summary create + * @param {BankAccountWritable} bankAccountWritable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + bankAccountCreate: async ( + bankAccountWritable: BankAccountWritable, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'bankAccountWritable' is not null or undefined + assertParamExists( + "bankAccountCreate", + "bankAccountWritable", + bankAccountWritable + ); + const localVarPath = `/bank_accounts`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + bankAccountWritable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Permanently deletes a bank account. It cannot be undone. + * @summary delete + * @param {string} bankId id of the bank account + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + bankAccountDelete: async ( + bankId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'bankId' is not null or undefined + assertParamExists("bankAccountDelete", "bankId", bankId); + const localVarPath = `/bank_accounts/{bank_id}`.replace( + `{${"bank_id"}}`, + encodeURIComponent(String(bankId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the details of an existing bank account. You need only supply the unique bank account identifier that was returned upon bank account creation. + * @summary get + * @param {string} bankId id of the bank account + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + bankAccountRetrieve: async ( + bankId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'bankId' is not null or undefined + assertParamExists("bankAccountRetrieve", "bankId", bankId); + const localVarPath = `/bank_accounts/{bank_id}`.replace( + `{${"bank_id"}}`, + encodeURIComponent(String(bankId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Verify a bank account in order to create a check. + * @summary verify + * @param {string} bankId id of the bank account to be verified + * @param {BankAccountVerify} bankAccountVerify + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + bankAccountVerify: async ( + bankId: string, + bankAccountVerify: BankAccountVerify, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'bankId' is not null or undefined + assertParamExists("bankAccountVerify", "bankId", bankId); + // verify required parameter 'bankAccountVerify' is not null or undefined + assertParamExists( + "bankAccountVerify", + "bankAccountVerify", + bankAccountVerify + ); + const localVarPath = `/bank_accounts/{bank_id}/verify`.replace( + `{${"bank_id"}}`, + encodeURIComponent(String(bankId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + bankAccountVerify, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of your bank accounts. The bank accounts are returned sorted by creation date, with the most recently created bank accounts appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + bankAccountsList: async ( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + options: AxiosRequestConfig = {} + ): Promise => { + const localVarPath = `/bank_accounts`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (before !== undefined) { + localVarQueryParameter["before"] = before; + } + + if (after !== undefined) { + localVarQueryParameter["after"] = after; + } + + if (include) { + localVarQueryParameter["include"] = valueToString(include); + } + + if (dateCreated !== undefined) { + localVarQueryParameter["date_created"] = valueToString(dateCreated); + } + + if (metadata !== undefined) { + localVarQueryParameter["metadata"] = valueToString(metadata); + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * BankAccountsApi - functional programming interface * @export */ -export const BankAccountsApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = BankAccountsApiAxiosParamCreator(configuration) - return { - /** - * Creates a new bank account with the provided properties. Bank accounts created in live mode will need to be verified via micro deposits before being able to send live checks. The deposits will appear in the bank account in 2-3 business days and have the description \"VERIFICATION\". - * @summary create - * @param {BankAccountWritable} bankAccountWritable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async bankAccountCreate(bankAccountWritable: BankAccountWritable, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.bankAccountCreate(bankAccountWritable, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Permanently deletes a bank account. It cannot be undone. - * @summary delete - * @param {string} bankId id of the bank account - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async bankAccountDelete(bankId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.bankAccountDelete(bankId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Retrieves the details of an existing bank account. You need only supply the unique bank account identifier that was returned upon bank account creation. - * @summary get - * @param {string} bankId id of the bank account - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async bankAccountRetrieve(bankId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.bankAccountRetrieve(bankId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Verify a bank account in order to create a check. - * @summary verify - * @param {string} bankId id of the bank account to be verified - * @param {BankAccountVerify} bankAccountVerify - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async bankAccountVerify(bankId: string, bankAccountVerify: BankAccountVerify, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.bankAccountVerify(bankId, bankAccountVerify, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Returns a list of your bank accounts. The bank accounts are returned sorted by creation date, with the most recently created bank accounts appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async bankAccountsList(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.bankAccountsList(limit, before, after, include, dateCreated, metadata, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * BankAccountsApi - object-oriented interface - * @export - * @class BankAccountsApi - * @extends {BaseAPI} - */ -export class BankAccountsApi extends BaseAPI { +export const BankAccountsApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = + BankAccountsApiAxiosParamCreator(configuration); + return { /** * Creates a new bank account with the provided properties. Bank accounts created in live mode will need to be verified via micro deposits before being able to send live checks. The deposits will appear in the bank account in 2-3 business days and have the description \"VERIFICATION\". * @summary create - * @param {BankAccountWritable} bankAccountWritable + * @param {BankAccountWritable} bankAccountWritable * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof BankAccountsApi */ - public create(bankAccountWritable: BankAccountWritable, options?: AxiosRequestConfig) { - return BankAccountsApiFp(this.configuration).bankAccountCreate(bankAccountWritable, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new BankAccount(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async bankAccountCreate( + bankAccountWritable: BankAccountWritable, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.bankAccountCreate( + bankAccountWritable, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Permanently deletes a bank account. It cannot be undone. * @summary delete * @param {string} bankId id of the bank account * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof BankAccountsApi */ - public delete(bankId: string, options?: AxiosRequestConfig) { - return BankAccountsApiFp(this.configuration).bankAccountDelete(bankId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new BankAccountDeletion(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async bankAccountDelete( + bankId: string, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.bankAccountDelete(bankId, options); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Retrieves the details of an existing bank account. You need only supply the unique bank account identifier that was returned upon bank account creation. * @summary get * @param {string} bankId id of the bank account * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof BankAccountsApi */ - public get(bankId: string, options?: AxiosRequestConfig) { - return BankAccountsApiFp(this.configuration).bankAccountRetrieve(bankId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new BankAccount(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async bankAccountRetrieve( + bankId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.bankAccountRetrieve(bankId, options); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Verify a bank account in order to create a check. * @summary verify * @param {string} bankId id of the bank account to be verified - * @param {BankAccountVerify} bankAccountVerify + * @param {BankAccountVerify} bankAccountVerify * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof BankAccountsApi */ - public verify(bankId: string, bankAccountVerify: BankAccountVerify, options?: AxiosRequestConfig) { - return BankAccountsApiFp(this.configuration).bankAccountVerify(bankId, bankAccountVerify, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new BankAccount(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async bankAccountVerify( + bankId: string, + bankAccountVerify: BankAccountVerify, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.bankAccountVerify( + bankId, + bankAccountVerify, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Returns a list of your bank accounts. The bank accounts are returned sorted by creation date, with the most recently created bank accounts appearing first. * @summary list * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof BankAccountsApi */ - public list(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, options?: AxiosRequestConfig) { - return BankAccountsApiFp(this.configuration).bankAccountsList(limit, before, after, include, dateCreated, metadata, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new BankAccountList(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async bankAccountsList( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.bankAccountsList( + limit, + before, + after, + include, + dateCreated, + metadata, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * BankAccountsApi - object-oriented interface + * @export + * @class BankAccountsApi + * @extends {BaseAPI} + */ +export class BankAccountsApi extends BaseAPI { + /** + * Creates a new bank account with the provided properties. Bank accounts created in live mode will need to be verified via micro deposits before being able to send live checks. The deposits will appear in the bank account in 2-3 business days and have the description \"VERIFICATION\". + * @summary create + * @param {BankAccountWritable} bankAccountWritable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof BankAccountsApi + */ + public create( + bankAccountWritable: BankAccountWritable, + options?: AxiosRequestConfig + ) { + return BankAccountsApiFp(this.configuration) + .bankAccountCreate(bankAccountWritable, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new BankAccount(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Permanently deletes a bank account. It cannot be undone. + * @summary delete + * @param {string} bankId id of the bank account + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof BankAccountsApi + */ + public delete(bankId: string, options?: AxiosRequestConfig) { + return BankAccountsApiFp(this.configuration) + .bankAccountDelete(bankId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new BankAccountDeletion(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Retrieves the details of an existing bank account. You need only supply the unique bank account identifier that was returned upon bank account creation. + * @summary get + * @param {string} bankId id of the bank account + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof BankAccountsApi + */ + public get(bankId: string, options?: AxiosRequestConfig) { + return BankAccountsApiFp(this.configuration) + .bankAccountRetrieve(bankId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new BankAccount(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Verify a bank account in order to create a check. + * @summary verify + * @param {string} bankId id of the bank account to be verified + * @param {BankAccountVerify} bankAccountVerify + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof BankAccountsApi + */ + public verify( + bankId: string, + bankAccountVerify: BankAccountVerify, + options?: AxiosRequestConfig + ) { + return BankAccountsApiFp(this.configuration) + .bankAccountVerify(bankId, bankAccountVerify, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new BankAccount(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Returns a list of your bank accounts. The bank accounts are returned sorted by creation date, with the most recently created bank accounts appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof BankAccountsApi + */ + public list( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + options?: AxiosRequestConfig + ) { + return BankAccountsApiFp(this.configuration) + .bankAccountsList( + limit, + before, + after, + include, + dateCreated, + metadata, + options + ) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new BankAccountList(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -456,4 +678,3 @@ export class BankAccountsApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/billing-groups-api.ts b/api/billing-groups-api.ts index 86c285c..33620d4 100644 --- a/api/billing-groups-api.ts +++ b/api/billing-groups-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,370 +12,563 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { BillingGroup } from '../models'; +import { BillingGroup } from "../models"; // @ts-ignore -import { BillingGroupEditable } from '../models'; +import { BillingGroupEditable } from "../models"; // @ts-ignore -import { BillingGroupList } from '../models'; +import { BillingGroupList } from "../models"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; /** * BillingGroupsApi - axios parameter creator * @export */ -export const BillingGroupsApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Creates a new billing_group with the provided properties. - * @summary create - * @param {BillingGroupEditable} billingGroupEditable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - billingGroupCreate: async (billingGroupEditable: BillingGroupEditable, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'billingGroupEditable' is not null or undefined - assertParamExists('billingGroupCreate', 'billingGroupEditable', billingGroupEditable) - const localVarPath = `/billing_groups`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(billingGroupEditable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the details of an existing billing_group. You need only supply the unique billing_group identifier that was returned upon billing_group creation. - * @summary get - * @param {string} bgId id of the billing_group - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - billingGroupRetrieve: async (bgId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'bgId' is not null or undefined - assertParamExists('billingGroupRetrieve', 'bgId', bgId) - const localVarPath = `/billing_groups/{bg_id}` - .replace(`{${"bg_id"}}`, encodeURIComponent(String(bgId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Updates all editable attributes of the billing_group with the given id. - * @summary update - * @param {string} bgId id of the billing_group - * @param {BillingGroupEditable} billingGroupEditable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - billingGroupUpdate: async (bgId: string, billingGroupEditable: BillingGroupEditable, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'bgId' is not null or undefined - assertParamExists('billingGroupUpdate', 'bgId', bgId) - // verify required parameter 'billingGroupEditable' is not null or undefined - assertParamExists('billingGroupUpdate', 'billingGroupEditable', billingGroupEditable) - const localVarPath = `/billing_groups/{bg_id}` - .replace(`{${"bg_id"}}`, encodeURIComponent(String(bgId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(billingGroupEditable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a list of your billing_groups. The billing_groups are returned sorted by creation date, with the most recently created billing_groups appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {number} [offset] An integer that designates the offset at which to begin returning results. Defaults to 0. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [dateModified] Filter by date modified. - * @param {object} [sortByDateModified] Sorts items by ascending or descending dates. Use either `date_created` or `date_modfied`, not both. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - billingGroupsList: async (limit?: number, offset?: number, include?: Array, dateCreated?: { [key: string]: string; }, dateModified?: { [key: string]: string; }, sortByDateModified?: object, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/billing_groups`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (offset !== undefined) { - localVarQueryParameter['offset'] = offset; - } - - if (include) { - localVarQueryParameter['include'] = valueToString(include); - } - - if (dateCreated !== undefined) { - localVarQueryParameter['date_created'] = valueToString(dateCreated); - } - - if (dateModified !== undefined) { - localVarQueryParameter['date_modified'] = valueToString(dateModified); - } - - if (sortByDateModified !== undefined) { - localVarQueryParameter['sort_by_date_modified'] = valueToString(sortByDateModified); - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } +export const BillingGroupsApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Creates a new billing_group with the provided properties. + * @summary create + * @param {BillingGroupEditable} billingGroupEditable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + billingGroupCreate: async ( + billingGroupEditable: BillingGroupEditable, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'billingGroupEditable' is not null or undefined + assertParamExists( + "billingGroupCreate", + "billingGroupEditable", + billingGroupEditable + ); + const localVarPath = `/billing_groups`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + billingGroupEditable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the details of an existing billing_group. You need only supply the unique billing_group identifier that was returned upon billing_group creation. + * @summary get + * @param {string} bgId id of the billing_group + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + billingGroupRetrieve: async ( + bgId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'bgId' is not null or undefined + assertParamExists("billingGroupRetrieve", "bgId", bgId); + const localVarPath = `/billing_groups/{bg_id}`.replace( + `{${"bg_id"}}`, + encodeURIComponent(String(bgId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Updates all editable attributes of the billing_group with the given id. + * @summary update + * @param {string} bgId id of the billing_group + * @param {BillingGroupEditable} billingGroupEditable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + billingGroupUpdate: async ( + bgId: string, + billingGroupEditable: BillingGroupEditable, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'bgId' is not null or undefined + assertParamExists("billingGroupUpdate", "bgId", bgId); + // verify required parameter 'billingGroupEditable' is not null or undefined + assertParamExists( + "billingGroupUpdate", + "billingGroupEditable", + billingGroupEditable + ); + const localVarPath = `/billing_groups/{bg_id}`.replace( + `{${"bg_id"}}`, + encodeURIComponent(String(bgId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + billingGroupEditable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of your billing_groups. The billing_groups are returned sorted by creation date, with the most recently created billing_groups appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {number} [offset] An integer that designates the offset at which to begin returning results. Defaults to 0. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [dateModified] Filter by date modified. + * @param {object} [sortByDateModified] Sorts items by ascending or descending dates. Use either `date_created` or `date_modfied`, not both. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + billingGroupsList: async ( + limit?: number, + offset?: number, + include?: Array, + dateCreated?: { [key: string]: string }, + dateModified?: { [key: string]: string }, + sortByDateModified?: object, + options: AxiosRequestConfig = {} + ): Promise => { + const localVarPath = `/billing_groups`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (offset !== undefined) { + localVarQueryParameter["offset"] = offset; + } + + if (include) { + localVarQueryParameter["include"] = valueToString(include); + } + + if (dateCreated !== undefined) { + localVarQueryParameter["date_created"] = valueToString(dateCreated); + } + + if (dateModified !== undefined) { + localVarQueryParameter["date_modified"] = valueToString(dateModified); + } + + if (sortByDateModified !== undefined) { + localVarQueryParameter["sort_by"] = valueToString(sortByDateModified); + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * BillingGroupsApi - functional programming interface * @export */ -export const BillingGroupsApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = BillingGroupsApiAxiosParamCreator(configuration) - return { - /** - * Creates a new billing_group with the provided properties. - * @summary create - * @param {BillingGroupEditable} billingGroupEditable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async billingGroupCreate(billingGroupEditable: BillingGroupEditable, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.billingGroupCreate(billingGroupEditable, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Retrieves the details of an existing billing_group. You need only supply the unique billing_group identifier that was returned upon billing_group creation. - * @summary get - * @param {string} bgId id of the billing_group - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async billingGroupRetrieve(bgId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.billingGroupRetrieve(bgId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Updates all editable attributes of the billing_group with the given id. - * @summary update - * @param {string} bgId id of the billing_group - * @param {BillingGroupEditable} billingGroupEditable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async billingGroupUpdate(bgId: string, billingGroupEditable: BillingGroupEditable, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.billingGroupUpdate(bgId, billingGroupEditable, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Returns a list of your billing_groups. The billing_groups are returned sorted by creation date, with the most recently created billing_groups appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {number} [offset] An integer that designates the offset at which to begin returning results. Defaults to 0. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [dateModified] Filter by date modified. - * @param {object} [sortByDateModified] Sorts items by ascending or descending dates. Use either `date_created` or `date_modfied`, not both. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async billingGroupsList(limit?: number, offset?: number, include?: Array, dateCreated?: { [key: string]: string; }, dateModified?: { [key: string]: string; }, sortByDateModified?: object, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.billingGroupsList(limit, offset, include, dateCreated, dateModified, sortByDateModified, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * BillingGroupsApi - object-oriented interface - * @export - * @class BillingGroupsApi - * @extends {BaseAPI} - */ -export class BillingGroupsApi extends BaseAPI { +export const BillingGroupsApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = + BillingGroupsApiAxiosParamCreator(configuration); + return { /** * Creates a new billing_group with the provided properties. * @summary create - * @param {BillingGroupEditable} billingGroupEditable + * @param {BillingGroupEditable} billingGroupEditable * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof BillingGroupsApi */ - public create(billingGroupEditable: BillingGroupEditable, options?: AxiosRequestConfig) { - return BillingGroupsApiFp(this.configuration).billingGroupCreate(billingGroupEditable, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new BillingGroup(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async billingGroupCreate( + billingGroupEditable: BillingGroupEditable, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.billingGroupCreate( + billingGroupEditable, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Retrieves the details of an existing billing_group. You need only supply the unique billing_group identifier that was returned upon billing_group creation. * @summary get * @param {string} bgId id of the billing_group * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof BillingGroupsApi */ - public get(bgId: string, options?: AxiosRequestConfig) { - return BillingGroupsApiFp(this.configuration).billingGroupRetrieve(bgId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new BillingGroup(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async billingGroupRetrieve( + bgId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.billingGroupRetrieve(bgId, options); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Updates all editable attributes of the billing_group with the given id. * @summary update * @param {string} bgId id of the billing_group - * @param {BillingGroupEditable} billingGroupEditable + * @param {BillingGroupEditable} billingGroupEditable * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof BillingGroupsApi */ - public update(bgId: string, billingGroupEditable: BillingGroupEditable, options?: AxiosRequestConfig) { - return BillingGroupsApiFp(this.configuration).billingGroupUpdate(bgId, billingGroupEditable, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new BillingGroup(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async billingGroupUpdate( + bgId: string, + billingGroupEditable: BillingGroupEditable, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.billingGroupUpdate( + bgId, + billingGroupEditable, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Returns a list of your billing_groups. The billing_groups are returned sorted by creation date, with the most recently created billing_groups appearing first. * @summary list * @param {number} [limit] How many results to return. * @param {number} [offset] An integer that designates the offset at which to begin returning results. Defaults to 0. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. * @param {{ [key: string]: string; }} [dateModified] Filter by date modified. - * @param {object} [sortByDateModified] Sorts items by ascending or descending dates. Use either `date_created` or `date_modfied`, not both. + * @param {object} [sortByDateModified] Sorts items by ascending or descending dates. Use either `date_created` or `date_modfied`, not both. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof BillingGroupsApi */ - public list(limit?: number, offset?: number, include?: Array, dateCreated?: { [key: string]: string; }, dateModified?: { [key: string]: string; }, sortByDateModified?: object, options?: AxiosRequestConfig) { - return BillingGroupsApiFp(this.configuration).billingGroupsList(limit, offset, include, dateCreated, dateModified, sortByDateModified, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new BillingGroupList(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async billingGroupsList( + limit?: number, + offset?: number, + include?: Array, + dateCreated?: { [key: string]: string }, + dateModified?: { [key: string]: string }, + sortByDateModified?: object, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.billingGroupsList( + limit, + offset, + include, + dateCreated, + dateModified, + sortByDateModified, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * BillingGroupsApi - object-oriented interface + * @export + * @class BillingGroupsApi + * @extends {BaseAPI} + */ +export class BillingGroupsApi extends BaseAPI { + /** + * Creates a new billing_group with the provided properties. + * @summary create + * @param {BillingGroupEditable} billingGroupEditable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof BillingGroupsApi + */ + public create( + billingGroupEditable: BillingGroupEditable, + options?: AxiosRequestConfig + ) { + return BillingGroupsApiFp(this.configuration) + .billingGroupCreate(billingGroupEditable, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new BillingGroup(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Retrieves the details of an existing billing_group. You need only supply the unique billing_group identifier that was returned upon billing_group creation. + * @summary get + * @param {string} bgId id of the billing_group + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof BillingGroupsApi + */ + public get(bgId: string, options?: AxiosRequestConfig) { + return BillingGroupsApiFp(this.configuration) + .billingGroupRetrieve(bgId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new BillingGroup(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Updates all editable attributes of the billing_group with the given id. + * @summary update + * @param {string} bgId id of the billing_group + * @param {BillingGroupEditable} billingGroupEditable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof BillingGroupsApi + */ + public update( + bgId: string, + billingGroupEditable: BillingGroupEditable, + options?: AxiosRequestConfig + ) { + return BillingGroupsApiFp(this.configuration) + .billingGroupUpdate(bgId, billingGroupEditable, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new BillingGroup(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Returns a list of your billing_groups. The billing_groups are returned sorted by creation date, with the most recently created billing_groups appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {number} [offset] An integer that designates the offset at which to begin returning results. Defaults to 0. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [dateModified] Filter by date modified. + * @param {object} [sortByDateModified] Sorts items by ascending or descending dates. Use either `date_created` or `date_modfied`, not both. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof BillingGroupsApi + */ + public list( + limit?: number, + offset?: number, + include?: Array, + dateCreated?: { [key: string]: string }, + dateModified?: { [key: string]: string }, + sortByDateModified?: object, + options?: AxiosRequestConfig + ) { + return BillingGroupsApiFp(this.configuration) + .billingGroupsList( + limit, + offset, + include, + dateCreated, + dateModified, + sortByDateModified, + options + ) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new BillingGroupList(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -383,4 +576,3 @@ export class BillingGroupsApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/campaigns-api.ts b/api/campaigns-api.ts index 5843060..671d4b9 100644 --- a/api/campaigns-api.ts +++ b/api/campaigns-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,436 +12,638 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { Campaign } from '../models'; +import { Campaign } from "../models"; // @ts-ignore -import { CampaignUpdatable } from '../models'; +import { CampaignUpdatable } from "../models"; // @ts-ignore -import { CampaignWritable } from '../models'; +import { CampaignWritable } from "../models"; // @ts-ignore -import { CampaignsList } from '../models'; +import { CampaignsList } from "../models"; // @ts-ignore -import { InlineResponse200 } from '../models'; +import { InlineResponse200 } from "../models"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; /** * CampaignsApi - axios parameter creator * @export */ -export const CampaignsApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Creates a new campaign with the provided properties. See how to launch your first campaign [here](https://help.lob.com/best-practices/launching-your-first-campaign). - * @summary create - * @param {CampaignWritable} campaignWritable - * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - campaignCreate: async (campaignWritable: CampaignWritable, xLangOutput?: 'native' | 'match', options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'campaignWritable' is not null or undefined - assertParamExists('campaignCreate', 'campaignWritable', campaignWritable) - const localVarPath = `/campaigns`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (xLangOutput !== undefined && xLangOutput !== null) { - localVarHeaderParameter['x-lang-output'] = String(xLangOutput); - } - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(campaignWritable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Delete an existing campaign. You need only supply the unique identifier that was returned upon campaign creation. Deleting a campaign also deletes any associated mail pieces that have been created but not sent. A campaign\'s `send_date` matches its associated mail pieces\' `send_date`s. - * @summary delete - * @param {string} cmpId id of the campaign - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - campaignDelete: async (cmpId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'cmpId' is not null or undefined - assertParamExists('campaignDelete', 'cmpId', cmpId) - const localVarPath = `/campaigns/{cmp_id}` - .replace(`{${"cmp_id"}}`, encodeURIComponent(String(cmpId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the details of an existing campaign. You need only supply the unique campaign identifier that was returned upon campaign creation. - * @summary get - * @param {string} cmpId id of the campaign - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - campaignRetrieve: async (cmpId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'cmpId' is not null or undefined - assertParamExists('campaignRetrieve', 'cmpId', cmpId) - const localVarPath = `/campaigns/{cmp_id}` - .replace(`{${"cmp_id"}}`, encodeURIComponent(String(cmpId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Update the details of an existing campaign. You need only supply the unique identifier that was returned upon campaign creation. - * @summary update - * @param {string} cmpId id of the campaign - * @param {CampaignUpdatable} campaignUpdatable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - campaignUpdate: async (cmpId: string, campaignUpdatable: CampaignUpdatable, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'cmpId' is not null or undefined - assertParamExists('campaignUpdate', 'cmpId', cmpId) - // verify required parameter 'campaignUpdatable' is not null or undefined - assertParamExists('campaignUpdate', 'campaignUpdatable', campaignUpdatable) - const localVarPath = `/campaigns/{cmp_id}` - .replace(`{${"cmp_id"}}`, encodeURIComponent(String(cmpId))); - // 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: 'PATCH', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - // authentication basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(campaignUpdatable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a list of your campaigns. The campaigns are returned sorted by creation date, with the most recently created campaigns appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - campaignsList: async (limit?: number, include?: Array, before?: string, after?: string, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/campaigns`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (include) { - localVarQueryParameter['include'] = valueToString(include); - } - - if (before !== undefined) { - localVarQueryParameter['before'] = before; - } - - if (after !== undefined) { - localVarQueryParameter['after'] = after; - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } +export const CampaignsApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Creates a new campaign with the provided properties. See how to launch your first campaign [here](https://help.lob.com/best-practices/launching-your-first-campaign). + * @summary create + * @param {CampaignWritable} campaignWritable + * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + campaignCreate: async ( + campaignWritable: CampaignWritable, + xLangOutput?: "native" | "match", + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'campaignWritable' is not null or undefined + assertParamExists("campaignCreate", "campaignWritable", campaignWritable); + const localVarPath = `/campaigns`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (xLangOutput !== undefined && xLangOutput !== null) { + localVarHeaderParameter["x-lang-output"] = String(xLangOutput); + } + + localVarHeaderParameter["Content-Type"] = "application/json"; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + localVarRequestOptions.data = serializeDataIfNeeded( + campaignWritable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Delete an existing campaign. You need only supply the unique identifier that was returned upon campaign creation. Deleting a campaign also deletes any associated mail pieces that have been created but not sent. A campaign\'s `send_date` matches its associated mail pieces\' `send_date`s. + * @summary delete + * @param {string} cmpId id of the campaign + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + campaignDelete: async ( + cmpId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'cmpId' is not null or undefined + assertParamExists("campaignDelete", "cmpId", cmpId); + const localVarPath = `/campaigns/{cmp_id}`.replace( + `{${"cmp_id"}}`, + encodeURIComponent(String(cmpId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the details of an existing campaign. You need only supply the unique campaign identifier that was returned upon campaign creation. + * @summary get + * @param {string} cmpId id of the campaign + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + campaignRetrieve: async ( + cmpId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'cmpId' is not null or undefined + assertParamExists("campaignRetrieve", "cmpId", cmpId); + const localVarPath = `/campaigns/{cmp_id}`.replace( + `{${"cmp_id"}}`, + encodeURIComponent(String(cmpId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Update the details of an existing campaign. You need only supply the unique identifier that was returned upon campaign creation. + * @summary update + * @param {string} cmpId id of the campaign + * @param {CampaignUpdatable} campaignUpdatable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + campaignUpdate: async ( + cmpId: string, + campaignUpdatable: CampaignUpdatable, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'cmpId' is not null or undefined + assertParamExists("campaignUpdate", "cmpId", cmpId); + // verify required parameter 'campaignUpdatable' is not null or undefined + assertParamExists( + "campaignUpdate", + "campaignUpdatable", + campaignUpdatable + ); + const localVarPath = `/campaigns/{cmp_id}`.replace( + `{${"cmp_id"}}`, + encodeURIComponent(String(cmpId)) + ); + // 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: "PATCH", + ...baseOptions, + ...options, + }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + campaignUpdatable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of your campaigns. The campaigns are returned sorted by creation date, with the most recently created campaigns appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + campaignsList: async ( + limit?: number, + include?: Array, + before?: string, + after?: string, + options: AxiosRequestConfig = {} + ): Promise => { + const localVarPath = `/campaigns`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (include) { + localVarQueryParameter["include"] = valueToString(include); + } + + if (before !== undefined) { + localVarQueryParameter["before"] = before; + } + + if (after !== undefined) { + localVarQueryParameter["after"] = after; + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * CampaignsApi - functional programming interface * @export */ -export const CampaignsApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = CampaignsApiAxiosParamCreator(configuration) - return { - /** - * Creates a new campaign with the provided properties. See how to launch your first campaign [here](https://help.lob.com/best-practices/launching-your-first-campaign). - * @summary create - * @param {CampaignWritable} campaignWritable - * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async campaignCreate(campaignWritable: CampaignWritable, xLangOutput?: 'native' | 'match', options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.campaignCreate(campaignWritable, xLangOutput, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Delete an existing campaign. You need only supply the unique identifier that was returned upon campaign creation. Deleting a campaign also deletes any associated mail pieces that have been created but not sent. A campaign\'s `send_date` matches its associated mail pieces\' `send_date`s. - * @summary delete - * @param {string} cmpId id of the campaign - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async campaignDelete(cmpId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.campaignDelete(cmpId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Retrieves the details of an existing campaign. You need only supply the unique campaign identifier that was returned upon campaign creation. - * @summary get - * @param {string} cmpId id of the campaign - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async campaignRetrieve(cmpId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.campaignRetrieve(cmpId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Update the details of an existing campaign. You need only supply the unique identifier that was returned upon campaign creation. - * @summary update - * @param {string} cmpId id of the campaign - * @param {CampaignUpdatable} campaignUpdatable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async campaignUpdate(cmpId: string, campaignUpdatable: CampaignUpdatable, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.campaignUpdate(cmpId, campaignUpdatable, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Returns a list of your campaigns. The campaigns are returned sorted by creation date, with the most recently created campaigns appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async campaignsList(limit?: number, include?: Array, before?: string, after?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.campaignsList(limit, include, before, after, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * CampaignsApi - object-oriented interface - * @export - * @class CampaignsApi - * @extends {BaseAPI} - */ -export class CampaignsApi extends BaseAPI { +export const CampaignsApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = + CampaignsApiAxiosParamCreator(configuration); + return { /** * Creates a new campaign with the provided properties. See how to launch your first campaign [here](https://help.lob.com/best-practices/launching-your-first-campaign). * @summary create - * @param {CampaignWritable} campaignWritable - * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. + * @param {CampaignWritable} campaignWritable + * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CampaignsApi */ - public create(campaignWritable: CampaignWritable, xLangOutput?: 'native' | 'match', options?: AxiosRequestConfig) { - return CampaignsApiFp(this.configuration).campaignCreate(campaignWritable, xLangOutput, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Campaign(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async campaignCreate( + campaignWritable: CampaignWritable, + xLangOutput?: "native" | "match", + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.campaignCreate( + campaignWritable, + xLangOutput, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Delete an existing campaign. You need only supply the unique identifier that was returned upon campaign creation. Deleting a campaign also deletes any associated mail pieces that have been created but not sent. A campaign\'s `send_date` matches its associated mail pieces\' `send_date`s. * @summary delete * @param {string} cmpId id of the campaign * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CampaignsApi */ - public delete(cmpId: string, options?: AxiosRequestConfig) { - return CampaignsApiFp(this.configuration).campaignDelete(cmpId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new InlineResponse200(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async campaignDelete( + cmpId: string, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.campaignDelete( + cmpId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Retrieves the details of an existing campaign. You need only supply the unique campaign identifier that was returned upon campaign creation. * @summary get * @param {string} cmpId id of the campaign * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CampaignsApi */ - public get(cmpId: string, options?: AxiosRequestConfig) { - return CampaignsApiFp(this.configuration).campaignRetrieve(cmpId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Campaign(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async campaignRetrieve( + cmpId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.campaignRetrieve(cmpId, options); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Update the details of an existing campaign. You need only supply the unique identifier that was returned upon campaign creation. * @summary update * @param {string} cmpId id of the campaign - * @param {CampaignUpdatable} campaignUpdatable + * @param {CampaignUpdatable} campaignUpdatable * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CampaignsApi */ - public update(cmpId: string, campaignUpdatable: CampaignUpdatable, options?: AxiosRequestConfig) { - return CampaignsApiFp(this.configuration).campaignUpdate(cmpId, campaignUpdatable, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Campaign(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async campaignUpdate( + cmpId: string, + campaignUpdatable: CampaignUpdatable, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.campaignUpdate( + cmpId, + campaignUpdatable, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Returns a list of your campaigns. The campaigns are returned sorted by creation date, with the most recently created campaigns appearing first. * @summary list * @param {number} [limit] How many results to return. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CampaignsApi */ - public list(limit?: number, include?: Array, before?: string, after?: string, options?: AxiosRequestConfig) { - return CampaignsApiFp(this.configuration).campaignsList(limit, include, before, after, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new CampaignsList(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async campaignsList( + limit?: number, + include?: Array, + before?: string, + after?: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.campaignsList( + limit, + include, + before, + after, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * CampaignsApi - object-oriented interface + * @export + * @class CampaignsApi + * @extends {BaseAPI} + */ +export class CampaignsApi extends BaseAPI { + /** + * Creates a new campaign with the provided properties. See how to launch your first campaign [here](https://help.lob.com/best-practices/launching-your-first-campaign). + * @summary create + * @param {CampaignWritable} campaignWritable + * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CampaignsApi + */ + public create( + campaignWritable: CampaignWritable, + xLangOutput?: "native" | "match", + options?: AxiosRequestConfig + ) { + return CampaignsApiFp(this.configuration) + .campaignCreate(campaignWritable, xLangOutput, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Campaign(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Delete an existing campaign. You need only supply the unique identifier that was returned upon campaign creation. Deleting a campaign also deletes any associated mail pieces that have been created but not sent. A campaign\'s `send_date` matches its associated mail pieces\' `send_date`s. + * @summary delete + * @param {string} cmpId id of the campaign + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CampaignsApi + */ + public delete(cmpId: string, options?: AxiosRequestConfig) { + return CampaignsApiFp(this.configuration) + .campaignDelete(cmpId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new InlineResponse200(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Retrieves the details of an existing campaign. You need only supply the unique campaign identifier that was returned upon campaign creation. + * @summary get + * @param {string} cmpId id of the campaign + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CampaignsApi + */ + public get(cmpId: string, options?: AxiosRequestConfig) { + return CampaignsApiFp(this.configuration) + .campaignRetrieve(cmpId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Campaign(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Update the details of an existing campaign. You need only supply the unique identifier that was returned upon campaign creation. + * @summary update + * @param {string} cmpId id of the campaign + * @param {CampaignUpdatable} campaignUpdatable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CampaignsApi + */ + public update( + cmpId: string, + campaignUpdatable: CampaignUpdatable, + options?: AxiosRequestConfig + ) { + return CampaignsApiFp(this.configuration) + .campaignUpdate(cmpId, campaignUpdatable, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Campaign(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Returns a list of your campaigns. The campaigns are returned sorted by creation date, with the most recently created campaigns appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CampaignsApi + */ + public list( + limit?: number, + include?: Array, + before?: string, + after?: string, + options?: AxiosRequestConfig + ) { + return CampaignsApiFp(this.configuration) + .campaignsList(limit, include, before, after, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new CampaignsList(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -449,4 +651,3 @@ export class CampaignsApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/card-orders-api.ts b/api/card-orders-api.ts index 4db384e..2bf76c4 100644 --- a/api/card-orders-api.ts +++ b/api/card-orders-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,187 +12,217 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { CardOrder } from '../models'; +import { CardOrder } from "../models"; // @ts-ignore -import { CardOrderEditable } from '../models'; +import { CardOrderEditable } from "../models"; // @ts-ignore -import { CardOrderList } from '../models'; +import { CardOrderList } from "../models"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; /** * CardOrdersApi - axios parameter creator * @export */ -export const CardOrdersApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Creates a new card order given information - * @summary create - * @param {string} cardId The ID of the card to which the card orders belong. - * @param {CardOrderEditable} cardOrderEditable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - cardOrderCreate: async (cardId: string, cardOrderEditable: CardOrderEditable, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'cardId' is not null or undefined - assertParamExists('cardOrderCreate', 'cardId', cardId) - // verify required parameter 'cardOrderEditable' is not null or undefined - assertParamExists('cardOrderCreate', 'cardOrderEditable', cardOrderEditable) - const localVarPath = `/cards/{card_id}/orders` - .replace(`{${"card_id"}}`, encodeURIComponent(String(cardId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(cardOrderEditable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the card orders associated with the given card id. - * @summary get - * @param {string} cardId The ID of the card to which the card orders belong. - * @param {number} [limit] How many results to return. - * @param {number} [offset] An integer that designates the offset at which to begin returning results. Defaults to 0. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - cardOrdersRetrieve: async (cardId: string, limit?: number, offset?: number, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'cardId' is not null or undefined - assertParamExists('cardOrdersRetrieve', 'cardId', cardId) - const localVarPath = `/cards/{card_id}/orders` - .replace(`{${"card_id"}}`, encodeURIComponent(String(cardId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (offset !== undefined) { - localVarQueryParameter['offset'] = offset; - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; +export const CardOrdersApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Creates a new card order given information + * @summary create + * @param {string} cardId The ID of the card to which the card orders belong. + * @param {CardOrderEditable} cardOrderEditable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + cardOrderCreate: async ( + cardId: string, + cardOrderEditable: CardOrderEditable, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'cardId' is not null or undefined + assertParamExists("cardOrderCreate", "cardId", cardId); + // verify required parameter 'cardOrderEditable' is not null or undefined + assertParamExists( + "cardOrderCreate", + "cardOrderEditable", + cardOrderEditable + ); + const localVarPath = `/cards/{card_id}/orders`.replace( + `{${"card_id"}}`, + encodeURIComponent(String(cardId)) + ); + // 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; + } -/** - * CardOrdersApi - functional programming interface - * @export - */ -export const CardOrdersApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = CardOrdersApiAxiosParamCreator(configuration) - return { - /** - * Creates a new card order given information - * @summary create - * @param {string} cardId The ID of the card to which the card orders belong. - * @param {CardOrderEditable} cardOrderEditable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async cardOrderCreate(cardId: string, cardOrderEditable: CardOrderEditable, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.cardOrderCreate(cardId, cardOrderEditable, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Retrieves the card orders associated with the given card id. - * @summary get - * @param {string} cardId The ID of the card to which the card orders belong. - * @param {number} [limit] How many results to return. - * @param {number} [offset] An integer that designates the offset at which to begin returning results. Defaults to 0. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async cardOrdersRetrieve(cardId: string, limit?: number, offset?: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.cardOrdersRetrieve(cardId, limit, offset, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } + const localVarRequestOptions = { + method: "POST", + ...baseOptions, + ...options, + }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + cardOrderEditable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the card orders associated with the given card id. + * @summary get + * @param {string} cardId The ID of the card to which the card orders belong. + * @param {number} [limit] How many results to return. + * @param {number} [offset] An integer that designates the offset at which to begin returning results. Defaults to 0. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + cardOrdersRetrieve: async ( + cardId: string, + limit?: number, + offset?: number, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'cardId' is not null or undefined + assertParamExists("cardOrdersRetrieve", "cardId", cardId); + const localVarPath = `/cards/{card_id}/orders`.replace( + `{${"card_id"}}`, + encodeURIComponent(String(cardId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (offset !== undefined) { + localVarQueryParameter["offset"] = offset; + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** - * CardOrdersApi - object-oriented interface + * CardOrdersApi - functional programming interface * @export - * @class CardOrdersApi - * @extends {BaseAPI} */ -export class CardOrdersApi extends BaseAPI { +export const CardOrdersApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = + CardOrdersApiAxiosParamCreator(configuration); + return { /** * Creates a new card order given information * @summary create * @param {string} cardId The ID of the card to which the card orders belong. - * @param {CardOrderEditable} cardOrderEditable + * @param {CardOrderEditable} cardOrderEditable * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CardOrdersApi */ - public create(cardId: string, cardOrderEditable: CardOrderEditable, options?: AxiosRequestConfig) { - return CardOrdersApiFp(this.configuration).cardOrderCreate(cardId, cardOrderEditable, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new CardOrder(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async cardOrderCreate( + cardId: string, + cardOrderEditable: CardOrderEditable, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.cardOrderCreate( + cardId, + cardOrderEditable, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Retrieves the card orders associated with the given card id. * @summary get @@ -201,19 +231,96 @@ export class CardOrdersApi extends BaseAPI { * @param {number} [offset] An integer that designates the offset at which to begin returning results. Defaults to 0. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CardOrdersApi */ - public get(cardId: string, limit?: number, offset?: number, options?: AxiosRequestConfig) { - return CardOrdersApiFp(this.configuration).cardOrdersRetrieve(cardId, limit, offset, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new CardOrderList(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async cardOrdersRetrieve( + cardId: string, + limit?: number, + offset?: number, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.cardOrdersRetrieve( + cardId, + limit, + offset, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * CardOrdersApi - object-oriented interface + * @export + * @class CardOrdersApi + * @extends {BaseAPI} + */ +export class CardOrdersApi extends BaseAPI { + /** + * Creates a new card order given information + * @summary create + * @param {string} cardId The ID of the card to which the card orders belong. + * @param {CardOrderEditable} cardOrderEditable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CardOrdersApi + */ + public create( + cardId: string, + cardOrderEditable: CardOrderEditable, + options?: AxiosRequestConfig + ) { + return CardOrdersApiFp(this.configuration) + .cardOrderCreate(cardId, cardOrderEditable, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new CardOrder(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Retrieves the card orders associated with the given card id. + * @summary get + * @param {string} cardId The ID of the card to which the card orders belong. + * @param {number} [limit] How many results to return. + * @param {number} [offset] An integer that designates the offset at which to begin returning results. Defaults to 0. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CardOrdersApi + */ + public get( + cardId: string, + limit?: number, + offset?: number, + options?: AxiosRequestConfig + ) { + return CardOrdersApiFp(this.configuration) + .cardOrdersRetrieve(cardId, limit, offset, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new CardOrderList(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -221,4 +328,3 @@ export class CardOrdersApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/cards-api.ts b/api/cards-api.ts index b110b25..ae48c37 100644 --- a/api/cards-api.ts +++ b/api/cards-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,429 +12,618 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { Card } from '../models'; +import { Card } from "../models"; // @ts-ignore -import { CardDeletion } from '../models'; +import { CardDeletion } from "../models"; // @ts-ignore -import { CardEditable } from '../models'; +import { CardEditable } from "../models"; // @ts-ignore -import { CardList } from '../models'; +import { CardList } from "../models"; // @ts-ignore -import { CardUpdatable } from '../models'; +import { CardUpdatable } from "../models"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; /** * CardsApi - axios parameter creator * @export */ -export const CardsApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Creates a new card given information - * @summary create - * @param {CardEditable} cardEditable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - cardCreate: async (cardEditable: CardEditable, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'cardEditable' is not null or undefined - assertParamExists('cardCreate', 'cardEditable', cardEditable) - const localVarPath = `/cards`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(cardEditable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Delete an existing card. You need only supply the unique identifier that was returned upon card creation. - * @summary delete - * @param {string} cardId id of the card - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - cardDelete: async (cardId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'cardId' is not null or undefined - assertParamExists('cardDelete', 'cardId', cardId) - const localVarPath = `/cards/{card_id}` - .replace(`{${"card_id"}}`, encodeURIComponent(String(cardId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the details of an existing card. You need only supply the unique customer identifier that was returned upon card creation. - * @summary get - * @param {string} cardId id of the card - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - cardRetrieve: async (cardId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'cardId' is not null or undefined - assertParamExists('cardRetrieve', 'cardId', cardId) - const localVarPath = `/cards/{card_id}` - .replace(`{${"card_id"}}`, encodeURIComponent(String(cardId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Update the details of an existing card. You need only supply the unique identifier that was returned upon card creation. - * @summary update - * @param {string} cardId id of the card - * @param {CardUpdatable} cardUpdatable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - cardUpdate: async (cardId: string, cardUpdatable: CardUpdatable, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'cardId' is not null or undefined - assertParamExists('cardUpdate', 'cardId', cardId) - // verify required parameter 'cardUpdatable' is not null or undefined - assertParamExists('cardUpdate', 'cardUpdatable', cardUpdatable) - const localVarPath = `/cards/{card_id}` - .replace(`{${"card_id"}}`, encodeURIComponent(String(cardId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(cardUpdatable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a list of your cards. The cards are returned sorted by creation date, with the most recently created addresses appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - cardsList: async (limit?: number, before?: string, after?: string, include?: Array, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/cards`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (before !== undefined) { - localVarQueryParameter['before'] = before; - } - - if (after !== undefined) { - localVarQueryParameter['after'] = after; - } - - if (include) { - localVarQueryParameter['include'] = valueToString(include); - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } +export const CardsApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Creates a new card given information + * @summary create + * @param {CardEditable} cardEditable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + cardCreate: async ( + cardEditable: CardEditable, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'cardEditable' is not null or undefined + assertParamExists("cardCreate", "cardEditable", cardEditable); + const localVarPath = `/cards`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + cardEditable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Delete an existing card. You need only supply the unique identifier that was returned upon card creation. + * @summary delete + * @param {string} cardId id of the card + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + cardDelete: async ( + cardId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'cardId' is not null or undefined + assertParamExists("cardDelete", "cardId", cardId); + const localVarPath = `/cards/{card_id}`.replace( + `{${"card_id"}}`, + encodeURIComponent(String(cardId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the details of an existing card. You need only supply the unique customer identifier that was returned upon card creation. + * @summary get + * @param {string} cardId id of the card + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + cardRetrieve: async ( + cardId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'cardId' is not null or undefined + assertParamExists("cardRetrieve", "cardId", cardId); + const localVarPath = `/cards/{card_id}`.replace( + `{${"card_id"}}`, + encodeURIComponent(String(cardId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Update the details of an existing card. You need only supply the unique identifier that was returned upon card creation. + * @summary update + * @param {string} cardId id of the card + * @param {CardUpdatable} cardUpdatable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + cardUpdate: async ( + cardId: string, + cardUpdatable: CardUpdatable, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'cardId' is not null or undefined + assertParamExists("cardUpdate", "cardId", cardId); + // verify required parameter 'cardUpdatable' is not null or undefined + assertParamExists("cardUpdate", "cardUpdatable", cardUpdatable); + const localVarPath = `/cards/{card_id}`.replace( + `{${"card_id"}}`, + encodeURIComponent(String(cardId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + cardUpdatable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of your cards. The cards are returned sorted by creation date, with the most recently created addresses appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + cardsList: async ( + limit?: number, + before?: string, + after?: string, + include?: Array, + options: AxiosRequestConfig = {} + ): Promise => { + const localVarPath = `/cards`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (before !== undefined) { + localVarQueryParameter["before"] = before; + } + + if (after !== undefined) { + localVarQueryParameter["after"] = after; + } + + if (include) { + localVarQueryParameter["include"] = valueToString(include); + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * CardsApi - functional programming interface * @export */ -export const CardsApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = CardsApiAxiosParamCreator(configuration) - return { - /** - * Creates a new card given information - * @summary create - * @param {CardEditable} cardEditable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async cardCreate(cardEditable: CardEditable, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.cardCreate(cardEditable, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Delete an existing card. You need only supply the unique identifier that was returned upon card creation. - * @summary delete - * @param {string} cardId id of the card - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async cardDelete(cardId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.cardDelete(cardId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Retrieves the details of an existing card. You need only supply the unique customer identifier that was returned upon card creation. - * @summary get - * @param {string} cardId id of the card - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async cardRetrieve(cardId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.cardRetrieve(cardId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Update the details of an existing card. You need only supply the unique identifier that was returned upon card creation. - * @summary update - * @param {string} cardId id of the card - * @param {CardUpdatable} cardUpdatable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async cardUpdate(cardId: string, cardUpdatable: CardUpdatable, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.cardUpdate(cardId, cardUpdatable, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Returns a list of your cards. The cards are returned sorted by creation date, with the most recently created addresses appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async cardsList(limit?: number, before?: string, after?: string, include?: Array, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.cardsList(limit, before, after, include, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * CardsApi - object-oriented interface - * @export - * @class CardsApi - * @extends {BaseAPI} - */ -export class CardsApi extends BaseAPI { +export const CardsApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = CardsApiAxiosParamCreator(configuration); + return { /** * Creates a new card given information * @summary create - * @param {CardEditable} cardEditable + * @param {CardEditable} cardEditable * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CardsApi */ - public create(cardEditable: CardEditable, options?: AxiosRequestConfig) { - return CardsApiFp(this.configuration).cardCreate(cardEditable, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Card(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async cardCreate( + cardEditable: CardEditable, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.cardCreate( + cardEditable, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Delete an existing card. You need only supply the unique identifier that was returned upon card creation. * @summary delete * @param {string} cardId id of the card * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CardsApi */ - public delete(cardId: string, options?: AxiosRequestConfig) { - return CardsApiFp(this.configuration).cardDelete(cardId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new CardDeletion(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async cardDelete( + cardId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.cardDelete( + cardId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Retrieves the details of an existing card. You need only supply the unique customer identifier that was returned upon card creation. * @summary get * @param {string} cardId id of the card * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CardsApi */ - public get(cardId: string, options?: AxiosRequestConfig) { - return CardsApiFp(this.configuration).cardRetrieve(cardId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Card(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async cardRetrieve( + cardId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.cardRetrieve( + cardId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Update the details of an existing card. You need only supply the unique identifier that was returned upon card creation. * @summary update * @param {string} cardId id of the card - * @param {CardUpdatable} cardUpdatable + * @param {CardUpdatable} cardUpdatable * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CardsApi */ - public update(cardId: string, cardUpdatable: CardUpdatable, options?: AxiosRequestConfig) { - return CardsApiFp(this.configuration).cardUpdate(cardId, cardUpdatable, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Card(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async cardUpdate( + cardId: string, + cardUpdatable: CardUpdatable, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.cardUpdate( + cardId, + cardUpdatable, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Returns a list of your cards. The cards are returned sorted by creation date, with the most recently created addresses appearing first. * @summary list * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof CardsApi */ - public list(limit?: number, before?: string, after?: string, include?: Array, options?: AxiosRequestConfig) { - return CardsApiFp(this.configuration).cardsList(limit, before, after, include, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new CardList(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async cardsList( + limit?: number, + before?: string, + after?: string, + include?: Array, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.cardsList( + limit, + before, + after, + include, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * CardsApi - object-oriented interface + * @export + * @class CardsApi + * @extends {BaseAPI} + */ +export class CardsApi extends BaseAPI { + /** + * Creates a new card given information + * @summary create + * @param {CardEditable} cardEditable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CardsApi + */ + public create(cardEditable: CardEditable, options?: AxiosRequestConfig) { + return CardsApiFp(this.configuration) + .cardCreate(cardEditable, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Card(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Delete an existing card. You need only supply the unique identifier that was returned upon card creation. + * @summary delete + * @param {string} cardId id of the card + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CardsApi + */ + public delete(cardId: string, options?: AxiosRequestConfig) { + return CardsApiFp(this.configuration) + .cardDelete(cardId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new CardDeletion(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Retrieves the details of an existing card. You need only supply the unique customer identifier that was returned upon card creation. + * @summary get + * @param {string} cardId id of the card + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CardsApi + */ + public get(cardId: string, options?: AxiosRequestConfig) { + return CardsApiFp(this.configuration) + .cardRetrieve(cardId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Card(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Update the details of an existing card. You need only supply the unique identifier that was returned upon card creation. + * @summary update + * @param {string} cardId id of the card + * @param {CardUpdatable} cardUpdatable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CardsApi + */ + public update( + cardId: string, + cardUpdatable: CardUpdatable, + options?: AxiosRequestConfig + ) { + return CardsApiFp(this.configuration) + .cardUpdate(cardId, cardUpdatable, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Card(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Returns a list of your cards. The cards are returned sorted by creation date, with the most recently created addresses appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof CardsApi + */ + public list( + limit?: number, + before?: string, + after?: string, + include?: Array, + options?: AxiosRequestConfig + ) { + return CardsApiFp(this.configuration) + .cardsList(limit, before, after, include, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new CardList(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -442,4 +631,3 @@ export class CardsApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/checks-api.ts b/api/checks-api.ts index 13ac88d..b961a4f 100644 --- a/api/checks-api.ts +++ b/api/checks-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,401 +12,594 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { Check } from '../models'; +import { Check } from "../models"; // @ts-ignore -import { CheckDeletion } from '../models'; +import { CheckDeletion } from "../models"; // @ts-ignore -import { CheckEditable } from '../models'; +import { CheckEditable } from "../models"; // @ts-ignore -import { CheckList } from '../models'; +import { CheckList } from "../models"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; // @ts-ignore -import { MailType } from '../models'; +import { MailType } from "../models"; /** * ChecksApi - axios parameter creator * @export */ -export const ChecksApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Completely removes a check from production. This can only be done if the check has a `send_date` and the `send_date` has not yet passed. If the check is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. - * @summary cancel - * @param {string} chkId id of the check - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - checkCancel: async (chkId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'chkId' is not null or undefined - assertParamExists('checkCancel', 'chkId', chkId) - const localVarPath = `/checks/{chk_id}` - .replace(`{${"chk_id"}}`, encodeURIComponent(String(chkId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Creates a new check with the provided properties. - * @summary create - * @param {CheckEditable} checkEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - checkCreate: async (checkEditable: CheckEditable, idempotencyKey?: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'checkEditable' is not null or undefined - assertParamExists('checkCreate', 'checkEditable', checkEditable) - const localVarPath = `/checks`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (idempotencyKey !== undefined && idempotencyKey !== null) { - localVarHeaderParameter['Idempotency-Key'] = String(idempotencyKey); - } - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(checkEditable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the details of an existing check. You need only supply the unique check identifier that was returned upon check creation. - * @summary get - * @param {string} chkId id of the check - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - checkRetrieve: async (chkId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'chkId' is not null or undefined - assertParamExists('checkRetrieve', 'chkId', chkId) - const localVarPath = `/checks/{chk_id}` - .replace(`{${"chk_id"}}`, encodeURIComponent(String(chkId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a list of your checks. The checks are returned sorted by creation date, with the most recently created checks appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` - * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - checksList: async (limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/checks`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (before !== undefined) { - localVarQueryParameter['before'] = before; - } - - if (after !== undefined) { - localVarQueryParameter['after'] = after; - } - - if (include) { - localVarQueryParameter['include'] = valueToString(include); - } - - if (dateCreated !== undefined) { - localVarQueryParameter['date_created'] = valueToString(dateCreated); - } - - if (metadata !== undefined) { - localVarQueryParameter['metadata'] = valueToString(metadata); - } - - if (scheduled !== undefined) { - localVarQueryParameter['scheduled'] = scheduled; - } - - if (sendDate !== undefined) { - localVarQueryParameter['send_date'] = valueToString(sendDate); - } - - if (mailType !== undefined) { - localVarQueryParameter['mail_type'] = valueToString(mailType); - } - - if (sortBy !== undefined) { - localVarQueryParameter['sort_by'] = valueToString(sortBy); - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } +export const ChecksApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Completely removes a check from production. This can only be done if the check has a `send_date` and the `send_date` has not yet passed. If the check is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. + * @summary cancel + * @param {string} chkId id of the check + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + checkCancel: async ( + chkId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'chkId' is not null or undefined + assertParamExists("checkCancel", "chkId", chkId); + const localVarPath = `/checks/{chk_id}`.replace( + `{${"chk_id"}}`, + encodeURIComponent(String(chkId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Creates a new check with the provided properties. + * @summary create + * @param {CheckEditable} checkEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + checkCreate: async ( + checkEditable: CheckEditable, + idempotencyKey?: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'checkEditable' is not null or undefined + assertParamExists("checkCreate", "checkEditable", checkEditable); + const localVarPath = `/checks`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (idempotencyKey !== undefined && idempotencyKey !== null) { + localVarHeaderParameter["Idempotency-Key"] = String(idempotencyKey); + } + + localVarHeaderParameter["Content-Type"] = "application/json"; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + localVarRequestOptions.data = serializeDataIfNeeded( + checkEditable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the details of an existing check. You need only supply the unique check identifier that was returned upon check creation. + * @summary get + * @param {string} chkId id of the check + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + checkRetrieve: async ( + chkId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'chkId' is not null or undefined + assertParamExists("checkRetrieve", "chkId", chkId); + const localVarPath = `/checks/{chk_id}`.replace( + `{${"chk_id"}}`, + encodeURIComponent(String(chkId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of your checks. The checks are returned sorted by creation date, with the most recently created checks appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + checksList: async ( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options: AxiosRequestConfig = {} + ): Promise => { + const localVarPath = `/checks`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (before !== undefined) { + localVarQueryParameter["before"] = before; + } + + if (after !== undefined) { + localVarQueryParameter["after"] = after; + } + + if (include) { + localVarQueryParameter["include"] = valueToString(include); + } + + if (dateCreated !== undefined) { + localVarQueryParameter["date_created"] = valueToString(dateCreated); + } + + if (metadata !== undefined) { + localVarQueryParameter["metadata"] = valueToString(metadata); + } + + if (scheduled !== undefined) { + localVarQueryParameter["scheduled"] = scheduled; + } + + if (sendDate !== undefined) { + localVarQueryParameter["send_date"] = valueToString(sendDate); + } + + if (mailType !== undefined) { + localVarQueryParameter["mail_type"] = valueToString(mailType); + } + + if (sortBy !== undefined) { + localVarQueryParameter["sort_by"] = valueToString(sortBy); + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * ChecksApi - functional programming interface * @export */ -export const ChecksApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = ChecksApiAxiosParamCreator(configuration) - return { - /** - * Completely removes a check from production. This can only be done if the check has a `send_date` and the `send_date` has not yet passed. If the check is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. - * @summary cancel - * @param {string} chkId id of the check - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async checkCancel(chkId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.checkCancel(chkId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Creates a new check with the provided properties. - * @summary create - * @param {CheckEditable} checkEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async checkCreate(checkEditable: CheckEditable, idempotencyKey?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.checkCreate(checkEditable, idempotencyKey, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Retrieves the details of an existing check. You need only supply the unique check identifier that was returned upon check creation. - * @summary get - * @param {string} chkId id of the check - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async checkRetrieve(chkId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.checkRetrieve(chkId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Returns a list of your checks. The checks are returned sorted by creation date, with the most recently created checks appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` - * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async checksList(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.checksList(limit, before, after, include, dateCreated, metadata, scheduled, sendDate, mailType, sortBy, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * ChecksApi - object-oriented interface - * @export - * @class ChecksApi - * @extends {BaseAPI} - */ -export class ChecksApi extends BaseAPI { +export const ChecksApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = ChecksApiAxiosParamCreator(configuration); + return { /** * Completely removes a check from production. This can only be done if the check has a `send_date` and the `send_date` has not yet passed. If the check is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. * @summary cancel * @param {string} chkId id of the check * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ChecksApi */ - public cancel(chkId: string, options?: AxiosRequestConfig) { - return ChecksApiFp(this.configuration).checkCancel(chkId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new CheckDeletion(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async checkCancel( + chkId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.checkCancel( + chkId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Creates a new check with the provided properties. * @summary create - * @param {CheckEditable} checkEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {CheckEditable} checkEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ChecksApi */ - public create(checkEditable: CheckEditable, idempotencyKey?: string, options?: AxiosRequestConfig) { - return ChecksApiFp(this.configuration).checkCreate(checkEditable, idempotencyKey, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Check(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async checkCreate( + checkEditable: CheckEditable, + idempotencyKey?: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.checkCreate( + checkEditable, + idempotencyKey, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Retrieves the details of an existing check. You need only supply the unique check identifier that was returned upon check creation. * @summary get * @param {string} chkId id of the check * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ChecksApi */ - public get(chkId: string, options?: AxiosRequestConfig) { - return ChecksApiFp(this.configuration).checkRetrieve(chkId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Check(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async checkRetrieve( + chkId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.checkRetrieve( + chkId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Returns a list of your checks. The checks are returned sorted by creation date, with the most recently created checks appearing first. * @summary list * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof ChecksApi */ - public list(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options?: AxiosRequestConfig) { - return ChecksApiFp(this.configuration).checksList(limit, before, after, include, dateCreated, metadata, scheduled, sendDate, mailType, sortBy, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new CheckList(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async checksList( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.checksList( + limit, + before, + after, + include, + dateCreated, + metadata, + scheduled, + sendDate, + mailType, + sortBy, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * ChecksApi - object-oriented interface + * @export + * @class ChecksApi + * @extends {BaseAPI} + */ +export class ChecksApi extends BaseAPI { + /** + * Completely removes a check from production. This can only be done if the check has a `send_date` and the `send_date` has not yet passed. If the check is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. + * @summary cancel + * @param {string} chkId id of the check + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ChecksApi + */ + public cancel(chkId: string, options?: AxiosRequestConfig) { + return ChecksApiFp(this.configuration) + .checkCancel(chkId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new CheckDeletion(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Creates a new check with the provided properties. + * @summary create + * @param {CheckEditable} checkEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ChecksApi + */ + public create( + checkEditable: CheckEditable, + idempotencyKey?: string, + options?: AxiosRequestConfig + ) { + return ChecksApiFp(this.configuration) + .checkCreate(checkEditable, idempotencyKey, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Check(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Retrieves the details of an existing check. You need only supply the unique check identifier that was returned upon check creation. + * @summary get + * @param {string} chkId id of the check + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ChecksApi + */ + public get(chkId: string, options?: AxiosRequestConfig) { + return ChecksApiFp(this.configuration) + .checkRetrieve(chkId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Check(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Returns a list of your checks. The checks are returned sorted by creation date, with the most recently created checks appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ChecksApi + */ + public list( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options?: AxiosRequestConfig + ) { + return ChecksApiFp(this.configuration) + .checksList( + limit, + before, + after, + include, + dateCreated, + metadata, + scheduled, + sendDate, + mailType, + sortBy, + options + ) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new CheckList(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -414,4 +607,3 @@ export class ChecksApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/intl-autocompletions-api.ts b/api/intl-autocompletions-api.ts index 3c85db3..0d0d289 100644 --- a/api/intl-autocompletions-api.ts +++ b/api/intl-autocompletions-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,95 +12,159 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { IntlAutocompletions } from '../models'; +import { IntlAutocompletions } from "../models"; // @ts-ignore -import { IntlAutocompletionsWritable } from '../models'; +import { IntlAutocompletionsWritable } from "../models"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; /** * IntlAutocompletionsApi - axios parameter creator * @export */ -export const IntlAutocompletionsApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Given an address prefix consisting of a partial primary line and country, as well as optional input of city, state, and zip code, this functionality returns up to 10 full International address suggestions. Not all of them will turn out to be valid addresses; they\'ll need to be [verified](#operation/intl_verification). - * @summary autocomplete - * @param {IntlAutocompletionsWritable} intlAutocompletionsWritable - * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - intlAutocompletion: async (intlAutocompletionsWritable: IntlAutocompletionsWritable, xLangOutput?: 'native' | 'match', options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'intlAutocompletionsWritable' is not null or undefined - assertParamExists('intlAutocompletion', 'intlAutocompletionsWritable', intlAutocompletionsWritable) - const localVarPath = `/intl_autocompletions`; - // 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; +export const IntlAutocompletionsApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Given an address prefix consisting of a partial primary line and country, as well as optional input of city, state, and zip code, this functionality returns up to 10 full International address suggestions. Not all of them will turn out to be valid addresses; they\'ll need to be [verified](#operation/intl_verification). + * @summary autocomplete + * @param {IntlAutocompletionsWritable} intlAutocompletionsWritable + * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + intlAutocompletion: async ( + intlAutocompletionsWritable: IntlAutocompletionsWritable, + xLangOutput?: "native" | "match", + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'intlAutocompletionsWritable' is not null or undefined + assertParamExists( + "intlAutocompletion", + "intlAutocompletionsWritable", + intlAutocompletionsWritable + ); + const localVarPath = `/intl_autocompletions`; + // 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; + } - // authentication basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) + const localVarRequestOptions = { + method: "POST", + ...baseOptions, + ...options, + }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - if (xLangOutput !== undefined && xLangOutput !== null) { - localVarHeaderParameter['x-lang-output'] = String(xLangOutput); - } + // authentication basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + if (xLangOutput !== undefined && xLangOutput !== null) { + localVarHeaderParameter["x-lang-output"] = String(xLangOutput); + } - - localVarHeaderParameter['Content-Type'] = 'application/json'; + localVarHeaderParameter["Content-Type"] = "application/json"; - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(intlAutocompletionsWritable, localVarRequestOptions, configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + localVarRequestOptions.data = serializeDataIfNeeded( + intlAutocompletionsWritable, + localVarRequestOptions, + configuration + ); - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * IntlAutocompletionsApi - functional programming interface * @export */ -export const IntlAutocompletionsApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = IntlAutocompletionsApiAxiosParamCreator(configuration) - return { - /** - * Given an address prefix consisting of a partial primary line and country, as well as optional input of city, state, and zip code, this functionality returns up to 10 full International address suggestions. Not all of them will turn out to be valid addresses; they\'ll need to be [verified](#operation/intl_verification). - * @summary autocomplete - * @param {IntlAutocompletionsWritable} intlAutocompletionsWritable - * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async intlAutocompletion(intlAutocompletionsWritable: IntlAutocompletionsWritable, xLangOutput?: 'native' | 'match', options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.intlAutocompletion(intlAutocompletionsWritable, xLangOutput, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } +export const IntlAutocompletionsApiFp = function ( + configuration?: Configuration +) { + const localVarAxiosParamCreator = + IntlAutocompletionsApiAxiosParamCreator(configuration); + return { + /** + * Given an address prefix consisting of a partial primary line and country, as well as optional input of city, state, and zip code, this functionality returns up to 10 full International address suggestions. Not all of them will turn out to be valid addresses; they\'ll need to be [verified](#operation/intl_verification). + * @summary autocomplete + * @param {IntlAutocompletionsWritable} intlAutocompletionsWritable + * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async intlAutocompletion( + intlAutocompletionsWritable: IntlAutocompletionsWritable, + xLangOutput?: "native" | "match", + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.intlAutocompletion( + intlAutocompletionsWritable, + xLangOutput, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; }; /** @@ -110,26 +174,33 @@ export const IntlAutocompletionsApiFp = function(configuration?: Configuration) * @extends {BaseAPI} */ export class IntlAutocompletionsApi extends BaseAPI { - /** - * Given an address prefix consisting of a partial primary line and country, as well as optional input of city, state, and zip code, this functionality returns up to 10 full International address suggestions. Not all of them will turn out to be valid addresses; they\'ll need to be [verified](#operation/intl_verification). - * @summary autocomplete - * @param {IntlAutocompletionsWritable} intlAutocompletionsWritable - * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof IntlAutocompletionsApi - */ - public autocomplete(intlAutocompletionsWritable: IntlAutocompletionsWritable, xLangOutput?: 'native' | 'match', options?: AxiosRequestConfig) { - return IntlAutocompletionsApiFp(this.configuration).intlAutocompletion(intlAutocompletionsWritable, xLangOutput, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new IntlAutocompletions(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + /** + * Given an address prefix consisting of a partial primary line and country, as well as optional input of city, state, and zip code, this functionality returns up to 10 full International address suggestions. Not all of them will turn out to be valid addresses; they\'ll need to be [verified](#operation/intl_verification). + * @summary autocomplete + * @param {IntlAutocompletionsWritable} intlAutocompletionsWritable + * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof IntlAutocompletionsApi + */ + public autocomplete( + intlAutocompletionsWritable: IntlAutocompletionsWritable, + xLangOutput?: "native" | "match", + options?: AxiosRequestConfig + ) { + return IntlAutocompletionsApiFp(this.configuration) + .intlAutocompletion(intlAutocompletionsWritable, xLangOutput, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new IntlAutocompletions(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -137,4 +208,3 @@ export class IntlAutocompletionsApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/intl-verifications-api.ts b/api/intl-verifications-api.ts index 34b98d6..4394b15 100644 --- a/api/intl-verifications-api.ts +++ b/api/intl-verifications-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,199 +12,309 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { IntlVerification } from '../models'; +import { IntlVerification } from "../models"; // @ts-ignore -import { IntlVerificationWritable } from '../models'; +import { IntlVerificationWritable } from "../models"; // @ts-ignore -import { IntlVerifications } from '../models'; +import { IntlVerifications } from "../models"; // @ts-ignore -import { IntlVerificationsPayload } from '../models'; +import { IntlVerificationsPayload } from "../models"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; /** * IntlVerificationsApi - axios parameter creator * @export */ -export const IntlVerificationsApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Verify a list of international (except US or US territories) address with a live API key. - * @summary verifyBulk - * @param {IntlVerificationsPayload} intlVerificationsPayload - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - bulkIntlVerifications: async (intlVerificationsPayload: IntlVerificationsPayload, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'intlVerificationsPayload' is not null or undefined - assertParamExists('bulkIntlVerifications', 'intlVerificationsPayload', intlVerificationsPayload) - const localVarPath = `/bulk/intl_verifications`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(intlVerificationsPayload, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Verify an international (except US or US territories) address with a live API key. - * @summary verifySingle - * @param {IntlVerificationWritable} intlVerificationWritable - * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - intlVerification: async (intlVerificationWritable: IntlVerificationWritable, xLangOutput?: 'native' | 'match', options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'intlVerificationWritable' is not null or undefined - assertParamExists('intlVerification', 'intlVerificationWritable', intlVerificationWritable) - const localVarPath = `/intl_verifications`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (xLangOutput !== undefined && xLangOutput !== null) { - localVarHeaderParameter['x-lang-output'] = String(xLangOutput); - } - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(intlVerificationWritable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; +export const IntlVerificationsApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Verify a list of international (except US or US territories) address with a live API key. + * @summary verifyBulk + * @param {IntlVerificationsPayload} intlVerificationsPayload + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + bulkIntlVerifications: async ( + intlVerificationsPayload: IntlVerificationsPayload, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'intlVerificationsPayload' is not null or undefined + assertParamExists( + "bulkIntlVerifications", + "intlVerificationsPayload", + intlVerificationsPayload + ); + const localVarPath = `/bulk/intl_verifications`; + // 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; + } -/** - * IntlVerificationsApi - functional programming interface - * @export - */ -export const IntlVerificationsApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = IntlVerificationsApiAxiosParamCreator(configuration) - return { - /** - * Verify a list of international (except US or US territories) address with a live API key. - * @summary verifyBulk - * @param {IntlVerificationsPayload} intlVerificationsPayload - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async bulkIntlVerifications(intlVerificationsPayload: IntlVerificationsPayload, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.bulkIntlVerifications(intlVerificationsPayload, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Verify an international (except US or US territories) address with a live API key. - * @summary verifySingle - * @param {IntlVerificationWritable} intlVerificationWritable - * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async intlVerification(intlVerificationWritable: IntlVerificationWritable, xLangOutput?: 'native' | 'match', options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.intlVerification(intlVerificationWritable, xLangOutput, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } + const localVarRequestOptions = { + method: "POST", + ...baseOptions, + ...options, + }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + intlVerificationsPayload, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Verify an international (except US or US territories) address with a live API key. + * @summary verifySingle + * @param {IntlVerificationWritable} intlVerificationWritable + * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + intlVerification: async ( + intlVerificationWritable: IntlVerificationWritable, + xLangOutput?: "native" | "match", + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'intlVerificationWritable' is not null or undefined + assertParamExists( + "intlVerification", + "intlVerificationWritable", + intlVerificationWritable + ); + const localVarPath = `/intl_verifications`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (xLangOutput !== undefined && xLangOutput !== null) { + localVarHeaderParameter["x-lang-output"] = String(xLangOutput); + } + + localVarHeaderParameter["Content-Type"] = "application/json"; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + localVarRequestOptions.data = serializeDataIfNeeded( + intlVerificationWritable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** - * IntlVerificationsApi - object-oriented interface + * IntlVerificationsApi - functional programming interface * @export - * @class IntlVerificationsApi - * @extends {BaseAPI} */ -export class IntlVerificationsApi extends BaseAPI { +export const IntlVerificationsApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = + IntlVerificationsApiAxiosParamCreator(configuration); + return { /** * Verify a list of international (except US or US territories) address with a live API key. * @summary verifyBulk - * @param {IntlVerificationsPayload} intlVerificationsPayload + * @param {IntlVerificationsPayload} intlVerificationsPayload * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof IntlVerificationsApi */ - public verifyBulk(intlVerificationsPayload: IntlVerificationsPayload, options?: AxiosRequestConfig) { - return IntlVerificationsApiFp(this.configuration).bulkIntlVerifications(intlVerificationsPayload, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new IntlVerifications(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async bulkIntlVerifications( + intlVerificationsPayload: IntlVerificationsPayload, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.bulkIntlVerifications( + intlVerificationsPayload, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Verify an international (except US or US territories) address with a live API key. * @summary verifySingle - * @param {IntlVerificationWritable} intlVerificationWritable - * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. + * @param {IntlVerificationWritable} intlVerificationWritable + * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof IntlVerificationsApi */ - public verifySingle(intlVerificationWritable: IntlVerificationWritable, xLangOutput?: 'native' | 'match', options?: AxiosRequestConfig) { - return IntlVerificationsApiFp(this.configuration).intlVerification(intlVerificationWritable, xLangOutput, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new IntlVerification(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async intlVerification( + intlVerificationWritable: IntlVerificationWritable, + xLangOutput?: "native" | "match", + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.intlVerification( + intlVerificationWritable, + xLangOutput, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * IntlVerificationsApi - object-oriented interface + * @export + * @class IntlVerificationsApi + * @extends {BaseAPI} + */ +export class IntlVerificationsApi extends BaseAPI { + /** + * Verify a list of international (except US or US territories) address with a live API key. + * @summary verifyBulk + * @param {IntlVerificationsPayload} intlVerificationsPayload + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof IntlVerificationsApi + */ + public verifyBulk( + intlVerificationsPayload: IntlVerificationsPayload, + options?: AxiosRequestConfig + ) { + return IntlVerificationsApiFp(this.configuration) + .bulkIntlVerifications(intlVerificationsPayload, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new IntlVerifications(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Verify an international (except US or US territories) address with a live API key. + * @summary verifySingle + * @param {IntlVerificationWritable} intlVerificationWritable + * @param {'native' | 'match'} [xLangOutput] * `native` - Translate response to the native language of the country in the request * `match` - match the response to the language in the request Default response is in English. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof IntlVerificationsApi + */ + public verifySingle( + intlVerificationWritable: IntlVerificationWritable, + xLangOutput?: "native" | "match", + options?: AxiosRequestConfig + ) { + return IntlVerificationsApiFp(this.configuration) + .intlVerification(intlVerificationWritable, xLangOutput, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new IntlVerification(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -212,4 +322,3 @@ export class IntlVerificationsApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/letters-api.ts b/api/letters-api.ts index d36eb47..beaad5a 100644 --- a/api/letters-api.ts +++ b/api/letters-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,408 +12,606 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { Letter } from '../models'; +import { Letter } from "../models"; // @ts-ignore -import { LetterDeletion } from '../models'; +import { LetterDeletion } from "../models"; // @ts-ignore -import { LetterEditable } from '../models'; +import { LetterEditable } from "../models"; // @ts-ignore -import { LetterList } from '../models'; +import { LetterList } from "../models"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; // @ts-ignore -import { MailType } from '../models'; +import { MailType } from "../models"; /** * LettersApi - axios parameter creator * @export */ -export const LettersApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Completely removes a letter from production. This can only be done if the letter has a `send_date` and the `send_date` has not yet passed. If the letter is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. - * @summary cancel - * @param {string} ltrId id of the letter - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - letterCancel: async (ltrId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'ltrId' is not null or undefined - assertParamExists('letterCancel', 'ltrId', ltrId) - const localVarPath = `/letters/{ltr_id}` - .replace(`{${"ltr_id"}}`, encodeURIComponent(String(ltrId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Creates a new letter given information - * @summary create - * @param {LetterEditable} letterEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - letterCreate: async (letterEditable: LetterEditable, idempotencyKey?: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'letterEditable' is not null or undefined - assertParamExists('letterCreate', 'letterEditable', letterEditable) - const localVarPath = `/letters`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (idempotencyKey !== undefined && idempotencyKey !== null) { - localVarHeaderParameter['Idempotency-Key'] = String(idempotencyKey); - } - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(letterEditable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the details of an existing letter. You need only supply the unique letter identifier that was returned upon letter creation. - * @summary get - * @param {string} ltrId id of the letter - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - letterRetrieve: async (ltrId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'ltrId' is not null or undefined - assertParamExists('letterRetrieve', 'ltrId', ltrId) - const localVarPath = `/letters/{ltr_id}` - .replace(`{${"ltr_id"}}`, encodeURIComponent(String(ltrId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a list of your letters. The letters are returned sorted by creation date, with the most recently created letters appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {boolean} [color] Set to `true` to return only color letters. Set to `false` to return only black & white letters. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` - * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - lettersList: async (limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, color?: boolean, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/letters`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (before !== undefined) { - localVarQueryParameter['before'] = before; - } - - if (after !== undefined) { - localVarQueryParameter['after'] = after; - } - - if (include) { - localVarQueryParameter['include'] = valueToString(include); - } - - if (dateCreated !== undefined) { - localVarQueryParameter['date_created'] = valueToString(dateCreated); - } - - if (metadata !== undefined) { - localVarQueryParameter['metadata'] = valueToString(metadata); - } - - if (color !== undefined) { - localVarQueryParameter['color'] = color; - } - - if (scheduled !== undefined) { - localVarQueryParameter['scheduled'] = scheduled; - } - - if (sendDate !== undefined) { - localVarQueryParameter['send_date'] = valueToString(sendDate); - } - - if (mailType !== undefined) { - localVarQueryParameter['mail_type'] = valueToString(mailType); - } - - if (sortBy !== undefined) { - localVarQueryParameter['sort_by'] = valueToString(sortBy); - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } +export const LettersApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Completely removes a letter from production. This can only be done if the letter has a `send_date` and the `send_date` has not yet passed. If the letter is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. + * @summary cancel + * @param {string} ltrId id of the letter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + letterCancel: async ( + ltrId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'ltrId' is not null or undefined + assertParamExists("letterCancel", "ltrId", ltrId); + const localVarPath = `/letters/{ltr_id}`.replace( + `{${"ltr_id"}}`, + encodeURIComponent(String(ltrId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Creates a new letter given information + * @summary create + * @param {LetterEditable} letterEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + letterCreate: async ( + letterEditable: LetterEditable, + idempotencyKey?: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'letterEditable' is not null or undefined + assertParamExists("letterCreate", "letterEditable", letterEditable); + const localVarPath = `/letters`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (idempotencyKey !== undefined && idempotencyKey !== null) { + localVarHeaderParameter["Idempotency-Key"] = String(idempotencyKey); + } + + localVarHeaderParameter["Content-Type"] = "application/json"; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + localVarRequestOptions.data = serializeDataIfNeeded( + letterEditable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the details of an existing letter. You need only supply the unique letter identifier that was returned upon letter creation. + * @summary get + * @param {string} ltrId id of the letter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + letterRetrieve: async ( + ltrId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'ltrId' is not null or undefined + assertParamExists("letterRetrieve", "ltrId", ltrId); + const localVarPath = `/letters/{ltr_id}`.replace( + `{${"ltr_id"}}`, + encodeURIComponent(String(ltrId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of your letters. The letters are returned sorted by creation date, with the most recently created letters appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {boolean} [color] Set to `true` to return only color letters. Set to `false` to return only black & white letters. + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + lettersList: async ( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + color?: boolean, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options: AxiosRequestConfig = {} + ): Promise => { + const localVarPath = `/letters`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (before !== undefined) { + localVarQueryParameter["before"] = before; + } + + if (after !== undefined) { + localVarQueryParameter["after"] = after; + } + + if (include) { + localVarQueryParameter["include"] = valueToString(include); + } + + if (dateCreated !== undefined) { + localVarQueryParameter["date_created"] = valueToString(dateCreated); + } + + if (metadata !== undefined) { + localVarQueryParameter["metadata"] = valueToString(metadata); + } + + if (color !== undefined) { + localVarQueryParameter["color"] = color; + } + + if (scheduled !== undefined) { + localVarQueryParameter["scheduled"] = scheduled; + } + + if (sendDate !== undefined) { + localVarQueryParameter["send_date"] = valueToString(sendDate); + } + + if (mailType !== undefined) { + localVarQueryParameter["mail_type"] = valueToString(mailType); + } + + if (sortBy !== undefined) { + localVarQueryParameter["sort_by"] = valueToString(sortBy); + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * LettersApi - functional programming interface * @export */ -export const LettersApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = LettersApiAxiosParamCreator(configuration) - return { - /** - * Completely removes a letter from production. This can only be done if the letter has a `send_date` and the `send_date` has not yet passed. If the letter is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. - * @summary cancel - * @param {string} ltrId id of the letter - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async letterCancel(ltrId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.letterCancel(ltrId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Creates a new letter given information - * @summary create - * @param {LetterEditable} letterEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async letterCreate(letterEditable: LetterEditable, idempotencyKey?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.letterCreate(letterEditable, idempotencyKey, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Retrieves the details of an existing letter. You need only supply the unique letter identifier that was returned upon letter creation. - * @summary get - * @param {string} ltrId id of the letter - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async letterRetrieve(ltrId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.letterRetrieve(ltrId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Returns a list of your letters. The letters are returned sorted by creation date, with the most recently created letters appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {boolean} [color] Set to `true` to return only color letters. Set to `false` to return only black & white letters. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` - * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async lettersList(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, color?: boolean, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.lettersList(limit, before, after, include, dateCreated, metadata, color, scheduled, sendDate, mailType, sortBy, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * LettersApi - object-oriented interface - * @export - * @class LettersApi - * @extends {BaseAPI} - */ -export class LettersApi extends BaseAPI { +export const LettersApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = LettersApiAxiosParamCreator(configuration); + return { /** * Completely removes a letter from production. This can only be done if the letter has a `send_date` and the `send_date` has not yet passed. If the letter is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. * @summary cancel * @param {string} ltrId id of the letter * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof LettersApi */ - public cancel(ltrId: string, options?: AxiosRequestConfig) { - return LettersApiFp(this.configuration).letterCancel(ltrId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new LetterDeletion(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async letterCancel( + ltrId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.letterCancel( + ltrId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Creates a new letter given information * @summary create - * @param {LetterEditable} letterEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {LetterEditable} letterEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof LettersApi */ - public create(letterEditable: LetterEditable, idempotencyKey?: string, options?: AxiosRequestConfig) { - return LettersApiFp(this.configuration).letterCreate(letterEditable, idempotencyKey, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Letter(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async letterCreate( + letterEditable: LetterEditable, + idempotencyKey?: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.letterCreate( + letterEditable, + idempotencyKey, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Retrieves the details of an existing letter. You need only supply the unique letter identifier that was returned upon letter creation. * @summary get * @param {string} ltrId id of the letter * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof LettersApi */ - public get(ltrId: string, options?: AxiosRequestConfig) { - return LettersApiFp(this.configuration).letterRetrieve(ltrId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Letter(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async letterRetrieve( + ltrId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.letterRetrieve( + ltrId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Returns a list of your letters. The letters are returned sorted by creation date, with the most recently created letters appearing first. * @summary list * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. * @param {boolean} [color] Set to `true` to return only color letters. Set to `false` to return only black & white letters. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof LettersApi */ - public list(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, color?: boolean, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options?: AxiosRequestConfig) { - return LettersApiFp(this.configuration).lettersList(limit, before, after, include, dateCreated, metadata, color, scheduled, sendDate, mailType, sortBy, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new LetterList(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async lettersList( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + color?: boolean, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.lettersList( + limit, + before, + after, + include, + dateCreated, + metadata, + color, + scheduled, + sendDate, + mailType, + sortBy, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * LettersApi - object-oriented interface + * @export + * @class LettersApi + * @extends {BaseAPI} + */ +export class LettersApi extends BaseAPI { + /** + * Completely removes a letter from production. This can only be done if the letter has a `send_date` and the `send_date` has not yet passed. If the letter is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. + * @summary cancel + * @param {string} ltrId id of the letter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LettersApi + */ + public cancel(ltrId: string, options?: AxiosRequestConfig) { + return LettersApiFp(this.configuration) + .letterCancel(ltrId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new LetterDeletion(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Creates a new letter given information + * @summary create + * @param {LetterEditable} letterEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LettersApi + */ + public create( + letterEditable: LetterEditable, + idempotencyKey?: string, + options?: AxiosRequestConfig + ) { + return LettersApiFp(this.configuration) + .letterCreate(letterEditable, idempotencyKey, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Letter(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Retrieves the details of an existing letter. You need only supply the unique letter identifier that was returned upon letter creation. + * @summary get + * @param {string} ltrId id of the letter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LettersApi + */ + public get(ltrId: string, options?: AxiosRequestConfig) { + return LettersApiFp(this.configuration) + .letterRetrieve(ltrId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Letter(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Returns a list of your letters. The letters are returned sorted by creation date, with the most recently created letters appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {boolean} [color] Set to `true` to return only color letters. Set to `false` to return only black & white letters. + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof LettersApi + */ + public list( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + color?: boolean, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options?: AxiosRequestConfig + ) { + return LettersApiFp(this.configuration) + .lettersList( + limit, + before, + after, + include, + dateCreated, + metadata, + color, + scheduled, + sendDate, + mailType, + sortBy, + options + ) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new LetterList(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -421,4 +619,3 @@ export class LettersApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/postcards-api.ts b/api/postcards-api.ts index ea5d877..0163bb3 100644 --- a/api/postcards-api.ts +++ b/api/postcards-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,410 +12,610 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; // @ts-ignore -import { MailType } from '../models'; +import { MailType } from "../models"; // @ts-ignore -import { Postcard } from '../models'; +import { Postcard } from "../models"; // @ts-ignore -import { PostcardDeletion } from '../models'; +import { PostcardDeletion } from "../models"; // @ts-ignore -import { PostcardEditable } from '../models'; +import { PostcardEditable } from "../models"; // @ts-ignore -import { PostcardList } from '../models'; +import { PostcardList } from "../models"; // @ts-ignore -import { PostcardSize } from '../models'; +import { PostcardSize } from "../models"; /** * PostcardsApi - axios parameter creator * @export */ -export const PostcardsApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Creates a new postcard given information - * @summary create - * @param {PostcardEditable} postcardEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - postcardCreate: async (postcardEditable: PostcardEditable, idempotencyKey?: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'postcardEditable' is not null or undefined - assertParamExists('postcardCreate', 'postcardEditable', postcardEditable) - const localVarPath = `/postcards`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (idempotencyKey !== undefined && idempotencyKey !== null) { - localVarHeaderParameter['Idempotency-Key'] = String(idempotencyKey); - } - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(postcardEditable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Completely removes a postcard from production. This can only be done if the postcard has a `send_date` and the `send_date` has not yet passed. If the postcard is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. - * @summary cancel - * @param {string} pscId id of the postcard - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - postcardDelete: async (pscId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'pscId' is not null or undefined - assertParamExists('postcardDelete', 'pscId', pscId) - const localVarPath = `/postcards/{psc_id}` - .replace(`{${"psc_id"}}`, encodeURIComponent(String(pscId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the details of an existing postcard. You need only supply the unique customer identifier that was returned upon postcard creation. - * @summary get - * @param {string} pscId id of the postcard - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - postcardRetrieve: async (pscId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'pscId' is not null or undefined - assertParamExists('postcardRetrieve', 'pscId', pscId) - const localVarPath = `/postcards/{psc_id}` - .replace(`{${"psc_id"}}`, encodeURIComponent(String(pscId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a list of your postcards. The addresses are returned sorted by creation date, with the most recently created addresses appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {Array} [size] Specifies the size of the postcard. Only `4x6` postcards can be sent to international destinations. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` - * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - postcardsList: async (limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, size?: Array, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/postcards`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (before !== undefined) { - localVarQueryParameter['before'] = before; - } - - if (after !== undefined) { - localVarQueryParameter['after'] = after; - } - - if (include) { - localVarQueryParameter['include'] = valueToString(include); - } - - if (dateCreated !== undefined) { - localVarQueryParameter['date_created'] = valueToString(dateCreated); - } - - if (metadata !== undefined) { - localVarQueryParameter['metadata'] = valueToString(metadata); - } - - if (size) { - localVarQueryParameter['size'] = valueToString(size); - } - - if (scheduled !== undefined) { - localVarQueryParameter['scheduled'] = scheduled; - } - - if (sendDate !== undefined) { - localVarQueryParameter['send_date'] = valueToString(sendDate); - } - - if (mailType !== undefined) { - localVarQueryParameter['mail_type'] = valueToString(mailType); - } - - if (sortBy !== undefined) { - localVarQueryParameter['sort_by'] = valueToString(sortBy); - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } +export const PostcardsApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Creates a new postcard given information + * @summary create + * @param {PostcardEditable} postcardEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + postcardCreate: async ( + postcardEditable: PostcardEditable, + idempotencyKey?: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'postcardEditable' is not null or undefined + assertParamExists("postcardCreate", "postcardEditable", postcardEditable); + const localVarPath = `/postcards`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (idempotencyKey !== undefined && idempotencyKey !== null) { + localVarHeaderParameter["Idempotency-Key"] = String(idempotencyKey); + } + + localVarHeaderParameter["Content-Type"] = "application/json"; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + localVarRequestOptions.data = serializeDataIfNeeded( + postcardEditable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Completely removes a postcard from production. This can only be done if the postcard has a `send_date` and the `send_date` has not yet passed. If the postcard is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. + * @summary cancel + * @param {string} pscId id of the postcard + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + postcardDelete: async ( + pscId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'pscId' is not null or undefined + assertParamExists("postcardDelete", "pscId", pscId); + const localVarPath = `/postcards/{psc_id}`.replace( + `{${"psc_id"}}`, + encodeURIComponent(String(pscId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the details of an existing postcard. You need only supply the unique customer identifier that was returned upon postcard creation. + * @summary get + * @param {string} pscId id of the postcard + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + postcardRetrieve: async ( + pscId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'pscId' is not null or undefined + assertParamExists("postcardRetrieve", "pscId", pscId); + const localVarPath = `/postcards/{psc_id}`.replace( + `{${"psc_id"}}`, + encodeURIComponent(String(pscId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of your postcards. The addresses are returned sorted by creation date, with the most recently created addresses appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {Array} [size] Specifies the size of the postcard. Only `4x6` postcards can be sent to international destinations. + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + postcardsList: async ( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + size?: Array, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options: AxiosRequestConfig = {} + ): Promise => { + const localVarPath = `/postcards`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (before !== undefined) { + localVarQueryParameter["before"] = before; + } + + if (after !== undefined) { + localVarQueryParameter["after"] = after; + } + + if (include) { + localVarQueryParameter["include"] = valueToString(include); + } + + if (dateCreated !== undefined) { + localVarQueryParameter["date_created"] = valueToString(dateCreated); + } + + if (metadata !== undefined) { + localVarQueryParameter["metadata"] = valueToString(metadata); + } + + if (size) { + localVarQueryParameter["size"] = valueToString(size); + } + + if (scheduled !== undefined) { + localVarQueryParameter["scheduled"] = scheduled; + } + + if (sendDate !== undefined) { + localVarQueryParameter["send_date"] = valueToString(sendDate); + } + + if (mailType !== undefined) { + localVarQueryParameter["mail_type"] = valueToString(mailType); + } + + if (sortBy !== undefined) { + localVarQueryParameter["sort_by"] = valueToString(sortBy); + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * PostcardsApi - functional programming interface * @export */ -export const PostcardsApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = PostcardsApiAxiosParamCreator(configuration) - return { - /** - * Creates a new postcard given information - * @summary create - * @param {PostcardEditable} postcardEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async postcardCreate(postcardEditable: PostcardEditable, idempotencyKey?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.postcardCreate(postcardEditable, idempotencyKey, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Completely removes a postcard from production. This can only be done if the postcard has a `send_date` and the `send_date` has not yet passed. If the postcard is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. - * @summary cancel - * @param {string} pscId id of the postcard - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async postcardDelete(pscId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.postcardDelete(pscId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Retrieves the details of an existing postcard. You need only supply the unique customer identifier that was returned upon postcard creation. - * @summary get - * @param {string} pscId id of the postcard - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async postcardRetrieve(pscId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.postcardRetrieve(pscId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Returns a list of your postcards. The addresses are returned sorted by creation date, with the most recently created addresses appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {Array} [size] Specifies the size of the postcard. Only `4x6` postcards can be sent to international destinations. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` - * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async postcardsList(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, size?: Array, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.postcardsList(limit, before, after, include, dateCreated, metadata, size, scheduled, sendDate, mailType, sortBy, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * PostcardsApi - object-oriented interface - * @export - * @class PostcardsApi - * @extends {BaseAPI} - */ -export class PostcardsApi extends BaseAPI { +export const PostcardsApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = + PostcardsApiAxiosParamCreator(configuration); + return { /** * Creates a new postcard given information * @summary create - * @param {PostcardEditable} postcardEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {PostcardEditable} postcardEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof PostcardsApi */ - public create(postcardEditable: PostcardEditable, idempotencyKey?: string, options?: AxiosRequestConfig) { - return PostcardsApiFp(this.configuration).postcardCreate(postcardEditable, idempotencyKey, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Postcard(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async postcardCreate( + postcardEditable: PostcardEditable, + idempotencyKey?: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.postcardCreate( + postcardEditable, + idempotencyKey, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Completely removes a postcard from production. This can only be done if the postcard has a `send_date` and the `send_date` has not yet passed. If the postcard is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. * @summary cancel * @param {string} pscId id of the postcard * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof PostcardsApi */ - public cancel(pscId: string, options?: AxiosRequestConfig) { - return PostcardsApiFp(this.configuration).postcardDelete(pscId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new PostcardDeletion(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async postcardDelete( + pscId: string, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.postcardDelete( + pscId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Retrieves the details of an existing postcard. You need only supply the unique customer identifier that was returned upon postcard creation. * @summary get * @param {string} pscId id of the postcard * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof PostcardsApi */ - public get(pscId: string, options?: AxiosRequestConfig) { - return PostcardsApiFp(this.configuration).postcardRetrieve(pscId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new Postcard(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async postcardRetrieve( + pscId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.postcardRetrieve(pscId, options); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Returns a list of your postcards. The addresses are returned sorted by creation date, with the most recently created addresses appearing first. * @summary list * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. * @param {Array} [size] Specifies the size of the postcard. Only `4x6` postcards can be sent to international destinations. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof PostcardsApi */ - public list(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, size?: Array, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options?: AxiosRequestConfig) { - return PostcardsApiFp(this.configuration).postcardsList(limit, before, after, include, dateCreated, metadata, size, scheduled, sendDate, mailType, sortBy, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new PostcardList(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async postcardsList( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + size?: Array, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.postcardsList( + limit, + before, + after, + include, + dateCreated, + metadata, + size, + scheduled, + sendDate, + mailType, + sortBy, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * PostcardsApi - object-oriented interface + * @export + * @class PostcardsApi + * @extends {BaseAPI} + */ +export class PostcardsApi extends BaseAPI { + /** + * Creates a new postcard given information + * @summary create + * @param {PostcardEditable} postcardEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PostcardsApi + */ + public create( + postcardEditable: PostcardEditable, + idempotencyKey?: string, + options?: AxiosRequestConfig + ) { + return PostcardsApiFp(this.configuration) + .postcardCreate(postcardEditable, idempotencyKey, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Postcard(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Completely removes a postcard from production. This can only be done if the postcard has a `send_date` and the `send_date` has not yet passed. If the postcard is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions) to gain access. + * @summary cancel + * @param {string} pscId id of the postcard + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PostcardsApi + */ + public cancel(pscId: string, options?: AxiosRequestConfig) { + return PostcardsApiFp(this.configuration) + .postcardDelete(pscId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new PostcardDeletion(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Retrieves the details of an existing postcard. You need only supply the unique customer identifier that was returned upon postcard creation. + * @summary get + * @param {string} pscId id of the postcard + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PostcardsApi + */ + public get(pscId: string, options?: AxiosRequestConfig) { + return PostcardsApiFp(this.configuration) + .postcardRetrieve(pscId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new Postcard(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Returns a list of your postcards. The addresses are returned sorted by creation date, with the most recently created addresses appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {Array} [size] Specifies the size of the postcard. Only `4x6` postcards can be sent to international destinations. + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PostcardsApi + */ + public list( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + size?: Array, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options?: AxiosRequestConfig + ) { + return PostcardsApiFp(this.configuration) + .postcardsList( + limit, + before, + after, + include, + dateCreated, + metadata, + size, + scheduled, + sendDate, + mailType, + sortBy, + options + ) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new PostcardList(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -423,4 +623,3 @@ export class PostcardsApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/reverse-geocode-lookups-api.ts b/api/reverse-geocode-lookups-api.ts index 034f363..812cc96 100644 --- a/api/reverse-geocode-lookups-api.ts +++ b/api/reverse-geocode-lookups-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,95 +12,152 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; // @ts-ignore -import { Location } from '../models'; +import { Location } from "../models"; // @ts-ignore -import { ReverseGeocode } from '../models'; +import { ReverseGeocode } from "../models"; /** * ReverseGeocodeLookupsApi - axios parameter creator * @export */ -export const ReverseGeocodeLookupsApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Reverse geocode a valid US location with a live API key. - * @summary lookup - * @param {Location} location - * @param {number} [size] Determines the number of locations returned. Possible values are between 1 and 50 and any number higher will be rounded down to 50. Default size is a list of 5 reverse geocoded locations. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - reverseGeocodeLookup: async (location: Location, size?: number, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'location' is not null or undefined - assertParamExists('reverseGeocodeLookup', 'location', location) - const localVarPath = `/us_reverse_geocode_lookups`; - // 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; +export const ReverseGeocodeLookupsApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Reverse geocode a valid US location with a live API key. + * @summary lookup + * @param {Location} location + * @param {number} [size] Determines the number of locations returned. Possible values are between 1 and 50 and any number higher will be rounded down to 50. Default size is a list of 5 reverse geocoded locations. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + reverseGeocodeLookup: async ( + location: Location, + size?: number, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'location' is not null or undefined + assertParamExists("reverseGeocodeLookup", "location", location); + const localVarPath = `/us_reverse_geocode_lookups`; + // 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; + } - // authentication basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) + const localVarRequestOptions = { + method: "POST", + ...baseOptions, + ...options, + }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - if (size !== undefined) { - localVarQueryParameter['size'] = size; - } + // authentication basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + if (size !== undefined) { + localVarQueryParameter["size"] = size; + } - - localVarHeaderParameter['Content-Type'] = 'application/json'; + localVarHeaderParameter["Content-Type"] = "application/json"; - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(location, localVarRequestOptions, configuration) + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + localVarRequestOptions.data = serializeDataIfNeeded( + location, + localVarRequestOptions, + configuration + ); - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * ReverseGeocodeLookupsApi - functional programming interface * @export */ -export const ReverseGeocodeLookupsApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = ReverseGeocodeLookupsApiAxiosParamCreator(configuration) - return { - /** - * Reverse geocode a valid US location with a live API key. - * @summary lookup - * @param {Location} location - * @param {number} [size] Determines the number of locations returned. Possible values are between 1 and 50 and any number higher will be rounded down to 50. Default size is a list of 5 reverse geocoded locations. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async reverseGeocodeLookup(location: Location, size?: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.reverseGeocodeLookup(location, size, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } +export const ReverseGeocodeLookupsApiFp = function ( + configuration?: Configuration +) { + const localVarAxiosParamCreator = + ReverseGeocodeLookupsApiAxiosParamCreator(configuration); + return { + /** + * Reverse geocode a valid US location with a live API key. + * @summary lookup + * @param {Location} location + * @param {number} [size] Determines the number of locations returned. Possible values are between 1 and 50 and any number higher will be rounded down to 50. Default size is a list of 5 reverse geocoded locations. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async reverseGeocodeLookup( + location: Location, + size?: number, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.reverseGeocodeLookup( + location, + size, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; }; /** @@ -110,26 +167,33 @@ export const ReverseGeocodeLookupsApiFp = function(configuration?: Configuration * @extends {BaseAPI} */ export class ReverseGeocodeLookupsApi extends BaseAPI { - /** - * Reverse geocode a valid US location with a live API key. - * @summary lookup - * @param {Location} location - * @param {number} [size] Determines the number of locations returned. Possible values are between 1 and 50 and any number higher will be rounded down to 50. Default size is a list of 5 reverse geocoded locations. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof ReverseGeocodeLookupsApi - */ - public lookup(location: Location, size?: number, options?: AxiosRequestConfig) { - return ReverseGeocodeLookupsApiFp(this.configuration).reverseGeocodeLookup(location, size, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new ReverseGeocode(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + /** + * Reverse geocode a valid US location with a live API key. + * @summary lookup + * @param {Location} location + * @param {number} [size] Determines the number of locations returned. Possible values are between 1 and 50 and any number higher will be rounded down to 50. Default size is a list of 5 reverse geocoded locations. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ReverseGeocodeLookupsApi + */ + public lookup( + location: Location, + size?: number, + options?: AxiosRequestConfig + ) { + return ReverseGeocodeLookupsApiFp(this.configuration) + .reverseGeocodeLookup(location, size, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new ReverseGeocode(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -137,4 +201,3 @@ export class ReverseGeocodeLookupsApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/self-mailers-api.ts b/api/self-mailers-api.ts index 2ee0837..0156315 100644 --- a/api/self-mailers-api.ts +++ b/api/self-mailers-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,410 +12,613 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; // @ts-ignore -import { MailType } from '../models'; +import { MailType } from "../models"; // @ts-ignore -import { SelfMailer } from '../models'; +import { SelfMailer } from "../models"; // @ts-ignore -import { SelfMailerDeletion } from '../models'; +import { SelfMailerDeletion } from "../models"; // @ts-ignore -import { SelfMailerEditable } from '../models'; +import { SelfMailerEditable } from "../models"; // @ts-ignore -import { SelfMailerList } from '../models'; +import { SelfMailerList } from "../models"; // @ts-ignore -import { SelfMailerSize } from '../models'; +import { SelfMailerSize } from "../models"; /** * SelfMailersApi - axios parameter creator * @export */ -export const SelfMailersApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Creates a new self_mailer given information - * @summary create - * @param {SelfMailerEditable} selfMailerEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - selfMailerCreate: async (selfMailerEditable: SelfMailerEditable, idempotencyKey?: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'selfMailerEditable' is not null or undefined - assertParamExists('selfMailerCreate', 'selfMailerEditable', selfMailerEditable) - const localVarPath = `/self_mailers`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (idempotencyKey !== undefined && idempotencyKey !== null) { - localVarHeaderParameter['Idempotency-Key'] = String(idempotencyKey); - } - - - - localVarHeaderParameter['Content-Type'] = 'application/json'; - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(selfMailerEditable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Completely removes a self mailer from production. This can only be done if the self mailer\'s `send_date` has not yet passed. - * @summary delete - * @param {string} sfmId id of the self_mailer - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - selfMailerDelete: async (sfmId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'sfmId' is not null or undefined - assertParamExists('selfMailerDelete', 'sfmId', sfmId) - const localVarPath = `/self_mailers/{sfm_id}` - .replace(`{${"sfm_id"}}`, encodeURIComponent(String(sfmId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the details of an existing self_mailer. You need only supply the unique self_mailer identifier that was returned upon self_mailer creation. - * @summary get - * @param {string} sfmId id of the self_mailer - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - selfMailerRetrieve: async (sfmId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'sfmId' is not null or undefined - assertParamExists('selfMailerRetrieve', 'sfmId', sfmId) - const localVarPath = `/self_mailers/{sfm_id}` - .replace(`{${"sfm_id"}}`, encodeURIComponent(String(sfmId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a list of your self_mailers. The self_mailers are returned sorted by creation date, with the most recently created self_mailers appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {Array} [size] The self mailer sizes to be returned. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` - * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - selfMailersList: async (limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, size?: Array, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/self_mailers`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (before !== undefined) { - localVarQueryParameter['before'] = before; - } - - if (after !== undefined) { - localVarQueryParameter['after'] = after; - } - - if (include) { - localVarQueryParameter['include'] = valueToString(include); - } - - if (dateCreated !== undefined) { - localVarQueryParameter['date_created'] = valueToString(dateCreated); - } - - if (metadata !== undefined) { - localVarQueryParameter['metadata'] = valueToString(metadata); - } - - if (size) { - localVarQueryParameter['size'] = valueToString(size); - } - - if (scheduled !== undefined) { - localVarQueryParameter['scheduled'] = scheduled; - } - - if (sendDate !== undefined) { - localVarQueryParameter['send_date'] = valueToString(sendDate); - } - - if (mailType !== undefined) { - localVarQueryParameter['mail_type'] = valueToString(mailType); - } - - if (sortBy !== undefined) { - localVarQueryParameter['sort_by'] = valueToString(sortBy); - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } +export const SelfMailersApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Creates a new self_mailer given information + * @summary create + * @param {SelfMailerEditable} selfMailerEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + selfMailerCreate: async ( + selfMailerEditable: SelfMailerEditable, + idempotencyKey?: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'selfMailerEditable' is not null or undefined + assertParamExists( + "selfMailerCreate", + "selfMailerEditable", + selfMailerEditable + ); + const localVarPath = `/self_mailers`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (idempotencyKey !== undefined && idempotencyKey !== null) { + localVarHeaderParameter["Idempotency-Key"] = String(idempotencyKey); + } + + localVarHeaderParameter["Content-Type"] = "application/json"; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + localVarRequestOptions.data = serializeDataIfNeeded( + selfMailerEditable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Completely removes a self mailer from production. This can only be done if the self mailer\'s `send_date` has not yet passed. + * @summary delete + * @param {string} sfmId id of the self_mailer + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + selfMailerDelete: async ( + sfmId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'sfmId' is not null or undefined + assertParamExists("selfMailerDelete", "sfmId", sfmId); + const localVarPath = `/self_mailers/{sfm_id}`.replace( + `{${"sfm_id"}}`, + encodeURIComponent(String(sfmId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the details of an existing self_mailer. You need only supply the unique self_mailer identifier that was returned upon self_mailer creation. + * @summary get + * @param {string} sfmId id of the self_mailer + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + selfMailerRetrieve: async ( + sfmId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'sfmId' is not null or undefined + assertParamExists("selfMailerRetrieve", "sfmId", sfmId); + const localVarPath = `/self_mailers/{sfm_id}`.replace( + `{${"sfm_id"}}`, + encodeURIComponent(String(sfmId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of your self_mailers. The self_mailers are returned sorted by creation date, with the most recently created self_mailers appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {Array} [size] The self mailer sizes to be returned. + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + selfMailersList: async ( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + size?: Array, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options: AxiosRequestConfig = {} + ): Promise => { + const localVarPath = `/self_mailers`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (before !== undefined) { + localVarQueryParameter["before"] = before; + } + + if (after !== undefined) { + localVarQueryParameter["after"] = after; + } + + if (include) { + localVarQueryParameter["include"] = valueToString(include); + } + + if (dateCreated !== undefined) { + localVarQueryParameter["date_created"] = valueToString(dateCreated); + } + + if (metadata !== undefined) { + localVarQueryParameter["metadata"] = valueToString(metadata); + } + + if (size) { + localVarQueryParameter["size"] = valueToString(size); + } + + if (scheduled !== undefined) { + localVarQueryParameter["scheduled"] = scheduled; + } + + if (sendDate !== undefined) { + localVarQueryParameter["send_date"] = valueToString(sendDate); + } + + if (mailType !== undefined) { + localVarQueryParameter["mail_type"] = valueToString(mailType); + } + + if (sortBy !== undefined) { + localVarQueryParameter["sort_by"] = valueToString(sortBy); + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * SelfMailersApi - functional programming interface * @export */ -export const SelfMailersApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = SelfMailersApiAxiosParamCreator(configuration) - return { - /** - * Creates a new self_mailer given information - * @summary create - * @param {SelfMailerEditable} selfMailerEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async selfMailerCreate(selfMailerEditable: SelfMailerEditable, idempotencyKey?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.selfMailerCreate(selfMailerEditable, idempotencyKey, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Completely removes a self mailer from production. This can only be done if the self mailer\'s `send_date` has not yet passed. - * @summary delete - * @param {string} sfmId id of the self_mailer - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async selfMailerDelete(sfmId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.selfMailerDelete(sfmId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Retrieves the details of an existing self_mailer. You need only supply the unique self_mailer identifier that was returned upon self_mailer creation. - * @summary get - * @param {string} sfmId id of the self_mailer - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async selfMailerRetrieve(sfmId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.selfMailerRetrieve(sfmId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Returns a list of your self_mailers. The self_mailers are returned sorted by creation date, with the most recently created self_mailers appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {Array} [size] The self mailer sizes to be returned. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` - * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async selfMailersList(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, size?: Array, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.selfMailersList(limit, before, after, include, dateCreated, metadata, size, scheduled, sendDate, mailType, sortBy, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * SelfMailersApi - object-oriented interface - * @export - * @class SelfMailersApi - * @extends {BaseAPI} - */ -export class SelfMailersApi extends BaseAPI { +export const SelfMailersApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = + SelfMailersApiAxiosParamCreator(configuration); + return { /** * Creates a new self_mailer given information * @summary create - * @param {SelfMailerEditable} selfMailerEditable - * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {SelfMailerEditable} selfMailerEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof SelfMailersApi */ - public create(selfMailerEditable: SelfMailerEditable, idempotencyKey?: string, options?: AxiosRequestConfig) { - return SelfMailersApiFp(this.configuration).selfMailerCreate(selfMailerEditable, idempotencyKey, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new SelfMailer(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async selfMailerCreate( + selfMailerEditable: SelfMailerEditable, + idempotencyKey?: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.selfMailerCreate( + selfMailerEditable, + idempotencyKey, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Completely removes a self mailer from production. This can only be done if the self mailer\'s `send_date` has not yet passed. * @summary delete * @param {string} sfmId id of the self_mailer * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof SelfMailersApi */ - public delete(sfmId: string, options?: AxiosRequestConfig) { - return SelfMailersApiFp(this.configuration).selfMailerDelete(sfmId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new SelfMailerDeletion(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async selfMailerDelete( + sfmId: string, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.selfMailerDelete(sfmId, options); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Retrieves the details of an existing self_mailer. You need only supply the unique self_mailer identifier that was returned upon self_mailer creation. * @summary get * @param {string} sfmId id of the self_mailer * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof SelfMailersApi */ - public get(sfmId: string, options?: AxiosRequestConfig) { - return SelfMailersApiFp(this.configuration).selfMailerRetrieve(sfmId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new SelfMailer(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async selfMailerRetrieve( + sfmId: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.selfMailerRetrieve(sfmId, options); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Returns a list of your self_mailers. The self_mailers are returned sorted by creation date, with the most recently created self_mailers appearing first. * @summary list * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. * @param {Array} [size] The self mailer sizes to be returned. - * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. - * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. - * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof SelfMailersApi */ - public list(limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, size?: Array, scheduled?: boolean, sendDate?: { [key: string]: string; }, mailType?: MailType, sortBy?: object, options?: AxiosRequestConfig) { - return SelfMailersApiFp(this.configuration).selfMailersList(limit, before, after, include, dateCreated, metadata, size, scheduled, sendDate, mailType, sortBy, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new SelfMailerList(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async selfMailersList( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + size?: Array, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = await localVarAxiosParamCreator.selfMailersList( + limit, + before, + after, + include, + dateCreated, + metadata, + size, + scheduled, + sendDate, + mailType, + sortBy, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * SelfMailersApi - object-oriented interface + * @export + * @class SelfMailersApi + * @extends {BaseAPI} + */ +export class SelfMailersApi extends BaseAPI { + /** + * Creates a new self_mailer given information + * @summary create + * @param {SelfMailerEditable} selfMailerEditable + * @param {string} [idempotencyKey] A string of no longer than 256 characters that uniquely identifies this resource. For more help integrating idempotency keys, refer to our [implementation guide](https://www.lob.com/guides#idempotent_request). + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SelfMailersApi + */ + public create( + selfMailerEditable: SelfMailerEditable, + idempotencyKey?: string, + options?: AxiosRequestConfig + ) { + return SelfMailersApiFp(this.configuration) + .selfMailerCreate(selfMailerEditable, idempotencyKey, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new SelfMailer(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Completely removes a self mailer from production. This can only be done if the self mailer\'s `send_date` has not yet passed. + * @summary delete + * @param {string} sfmId id of the self_mailer + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SelfMailersApi + */ + public delete(sfmId: string, options?: AxiosRequestConfig) { + return SelfMailersApiFp(this.configuration) + .selfMailerDelete(sfmId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new SelfMailerDeletion(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Retrieves the details of an existing self_mailer. You need only supply the unique self_mailer identifier that was returned upon self_mailer creation. + * @summary get + * @param {string} sfmId id of the self_mailer + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SelfMailersApi + */ + public get(sfmId: string, options?: AxiosRequestConfig) { + return SelfMailersApiFp(this.configuration) + .selfMailerRetrieve(sfmId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new SelfMailer(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Returns a list of your self_mailers. The self_mailers are returned sorted by creation date, with the most recently created self_mailers appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {Array} [size] The self mailer sizes to be returned. + * @param {boolean} [scheduled] * `true` - only return orders (past or future) where `send_date` is greater than `date_created` * `false` - only return orders where `send_date` is equal to `date_created` + * @param {{ [key: string]: string; }} [sendDate] Filter by date sent. + * @param {MailType} [mailType] A string designating the mail postage type: * `usps_first_class` - (default) * `usps_standard` - a [cheaper option](https://lob.com/pricing/print-mail#compare) which is less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6` postcards or for any postcards sent outside of the United States. + * @param {object} [sortBy] Sorts items by ascending or descending dates. Use either `date_created` or `send_date`, not both. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SelfMailersApi + */ + public list( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + size?: Array, + scheduled?: boolean, + sendDate?: { [key: string]: string }, + mailType?: MailType, + sortBy?: object, + options?: AxiosRequestConfig + ) { + return SelfMailersApiFp(this.configuration) + .selfMailersList( + limit, + before, + after, + include, + dateCreated, + metadata, + size, + scheduled, + sendDate, + mailType, + sortBy, + options + ) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new SelfMailerList(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -423,4 +626,3 @@ export class SelfMailersApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/template-versions-api.ts b/api/template-versions-api.ts index 09ae757..9dacd74 100644 --- a/api/template-versions-api.ts +++ b/api/template-versions-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,378 +12,417 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; // @ts-ignore -import { TemplateVersion } from '../models'; +import { TemplateVersion } from "../models"; // @ts-ignore -import { TemplateVersionDeletion } from '../models'; +import { TemplateVersionDeletion } from "../models"; // @ts-ignore -import { TemplateVersionList } from '../models'; +import { TemplateVersionList } from "../models"; // @ts-ignore -import { TemplateVersionUpdatable } from '../models'; +import { TemplateVersionUpdatable } from "../models"; // @ts-ignore -import { TemplateVersionWritable } from '../models'; +import { TemplateVersionWritable } from "../models"; /** * TemplateVersionsApi - axios parameter creator * @export */ -export const TemplateVersionsApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Creates a new template version attached to the specified template. - * @summary create - * @param {string} tmplId The ID of the template the new version will be attached to - * @param {TemplateVersionWritable} templateVersionWritable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createTemplateVersion: async (tmplId: string, templateVersionWritable: TemplateVersionWritable, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'tmplId' is not null or undefined - assertParamExists('createTemplateVersion', 'tmplId', tmplId) - // verify required parameter 'templateVersionWritable' is not null or undefined - assertParamExists('createTemplateVersion', 'templateVersionWritable', templateVersionWritable) - const localVarPath = `/templates/{tmpl_id}/versions` - .replace(`{${"tmpl_id"}}`, encodeURIComponent(String(tmplId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(templateVersionWritable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Permanently deletes a template version. A template\'s `published_version` can not be deleted. - * @summary delete - * @param {string} tmplId The ID of the template to which the version belongs. - * @param {string} vrsnId id of the template_version - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - templateVersionDelete: async (tmplId: string, vrsnId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'tmplId' is not null or undefined - assertParamExists('templateVersionDelete', 'tmplId', tmplId) - // verify required parameter 'vrsnId' is not null or undefined - assertParamExists('templateVersionDelete', 'vrsnId', vrsnId) - const localVarPath = `/templates/{tmpl_id}/versions/{vrsn_id}` - .replace(`{${"tmpl_id"}}`, encodeURIComponent(String(tmplId))) - .replace(`{${"vrsn_id"}}`, encodeURIComponent(String(vrsnId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the template version with the given template and version ids. - * @summary get - * @param {string} tmplId The ID of the template to which the version belongs. - * @param {string} vrsnId id of the template_version - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - templateVersionRetrieve: async (tmplId: string, vrsnId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'tmplId' is not null or undefined - assertParamExists('templateVersionRetrieve', 'tmplId', tmplId) - // verify required parameter 'vrsnId' is not null or undefined - assertParamExists('templateVersionRetrieve', 'vrsnId', vrsnId) - const localVarPath = `/templates/{tmpl_id}/versions/{vrsn_id}` - .replace(`{${"tmpl_id"}}`, encodeURIComponent(String(tmplId))) - .replace(`{${"vrsn_id"}}`, encodeURIComponent(String(vrsnId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Updates the template version with the given template and version ids. - * @summary update - * @param {string} tmplId The ID of the template to which the version belongs. - * @param {string} vrsnId id of the template_version - * @param {TemplateVersionUpdatable} templateVersionUpdatable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - templateVersionUpdate: async (tmplId: string, vrsnId: string, templateVersionUpdatable: TemplateVersionUpdatable, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'tmplId' is not null or undefined - assertParamExists('templateVersionUpdate', 'tmplId', tmplId) - // verify required parameter 'vrsnId' is not null or undefined - assertParamExists('templateVersionUpdate', 'vrsnId', vrsnId) - // verify required parameter 'templateVersionUpdatable' is not null or undefined - assertParamExists('templateVersionUpdate', 'templateVersionUpdatable', templateVersionUpdatable) - const localVarPath = `/templates/{tmpl_id}/versions/{vrsn_id}` - .replace(`{${"tmpl_id"}}`, encodeURIComponent(String(tmplId))) - .replace(`{${"vrsn_id"}}`, encodeURIComponent(String(vrsnId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(templateVersionUpdatable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a list of template versions for the given template ID. The template versions are sorted by creation date, with the most recently created appearing first. - * @summary list - * @param {string} tmplId The ID of the template associated with the retrieved versions - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - templateVersionsList: async (tmplId: string, limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'tmplId' is not null or undefined - assertParamExists('templateVersionsList', 'tmplId', tmplId) - const localVarPath = `/templates/{tmpl_id}/versions` - .replace(`{${"tmpl_id"}}`, encodeURIComponent(String(tmplId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (before !== undefined) { - localVarQueryParameter['before'] = before; - } - - if (after !== undefined) { - localVarQueryParameter['after'] = after; - } - - if (include) { - localVarQueryParameter['include'] = valueToString(include); - } - - if (dateCreated !== undefined) { - localVarQueryParameter['date_created'] = valueToString(dateCreated); - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } +export const TemplateVersionsApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Creates a new template version attached to the specified template. + * @summary create + * @param {string} tmplId The ID of the template the new version will be attached to + * @param {TemplateVersionWritable} templateVersionWritable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createTemplateVersion: async ( + tmplId: string, + templateVersionWritable: TemplateVersionWritable, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'tmplId' is not null or undefined + assertParamExists("createTemplateVersion", "tmplId", tmplId); + // verify required parameter 'templateVersionWritable' is not null or undefined + assertParamExists( + "createTemplateVersion", + "templateVersionWritable", + templateVersionWritable + ); + const localVarPath = `/templates/{tmpl_id}/versions`.replace( + `{${"tmpl_id"}}`, + encodeURIComponent(String(tmplId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + templateVersionWritable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Permanently deletes a template version. A template\'s `published_version` can not be deleted. + * @summary delete + * @param {string} tmplId The ID of the template to which the version belongs. + * @param {string} vrsnId id of the template_version + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + templateVersionDelete: async ( + tmplId: string, + vrsnId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'tmplId' is not null or undefined + assertParamExists("templateVersionDelete", "tmplId", tmplId); + // verify required parameter 'vrsnId' is not null or undefined + assertParamExists("templateVersionDelete", "vrsnId", vrsnId); + const localVarPath = `/templates/{tmpl_id}/versions/{vrsn_id}` + .replace(`{${"tmpl_id"}}`, encodeURIComponent(String(tmplId))) + .replace(`{${"vrsn_id"}}`, encodeURIComponent(String(vrsnId))); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the template version with the given template and version ids. + * @summary get + * @param {string} tmplId The ID of the template to which the version belongs. + * @param {string} vrsnId id of the template_version + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + templateVersionRetrieve: async ( + tmplId: string, + vrsnId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'tmplId' is not null or undefined + assertParamExists("templateVersionRetrieve", "tmplId", tmplId); + // verify required parameter 'vrsnId' is not null or undefined + assertParamExists("templateVersionRetrieve", "vrsnId", vrsnId); + const localVarPath = `/templates/{tmpl_id}/versions/{vrsn_id}` + .replace(`{${"tmpl_id"}}`, encodeURIComponent(String(tmplId))) + .replace(`{${"vrsn_id"}}`, encodeURIComponent(String(vrsnId))); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Updates the template version with the given template and version ids. + * @summary update + * @param {string} tmplId The ID of the template to which the version belongs. + * @param {string} vrsnId id of the template_version + * @param {TemplateVersionUpdatable} templateVersionUpdatable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + templateVersionUpdate: async ( + tmplId: string, + vrsnId: string, + templateVersionUpdatable: TemplateVersionUpdatable, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'tmplId' is not null or undefined + assertParamExists("templateVersionUpdate", "tmplId", tmplId); + // verify required parameter 'vrsnId' is not null or undefined + assertParamExists("templateVersionUpdate", "vrsnId", vrsnId); + // verify required parameter 'templateVersionUpdatable' is not null or undefined + assertParamExists( + "templateVersionUpdate", + "templateVersionUpdatable", + templateVersionUpdatable + ); + const localVarPath = `/templates/{tmpl_id}/versions/{vrsn_id}` + .replace(`{${"tmpl_id"}}`, encodeURIComponent(String(tmplId))) + .replace(`{${"vrsn_id"}}`, encodeURIComponent(String(vrsnId))); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + templateVersionUpdatable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of template versions for the given template ID. The template versions are sorted by creation date, with the most recently created appearing first. + * @summary list + * @param {string} tmplId The ID of the template associated with the retrieved versions + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + templateVersionsList: async ( + tmplId: string, + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'tmplId' is not null or undefined + assertParamExists("templateVersionsList", "tmplId", tmplId); + const localVarPath = `/templates/{tmpl_id}/versions`.replace( + `{${"tmpl_id"}}`, + encodeURIComponent(String(tmplId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (before !== undefined) { + localVarQueryParameter["before"] = before; + } + + if (after !== undefined) { + localVarQueryParameter["after"] = after; + } + + if (include) { + localVarQueryParameter["include"] = valueToString(include); + } + + if (dateCreated !== undefined) { + localVarQueryParameter["date_created"] = valueToString(dateCreated); + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * TemplateVersionsApi - functional programming interface * @export */ -export const TemplateVersionsApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = TemplateVersionsApiAxiosParamCreator(configuration) - return { - /** - * Creates a new template version attached to the specified template. - * @summary create - * @param {string} tmplId The ID of the template the new version will be attached to - * @param {TemplateVersionWritable} templateVersionWritable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async createTemplateVersion(tmplId: string, templateVersionWritable: TemplateVersionWritable, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.createTemplateVersion(tmplId, templateVersionWritable, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Permanently deletes a template version. A template\'s `published_version` can not be deleted. - * @summary delete - * @param {string} tmplId The ID of the template to which the version belongs. - * @param {string} vrsnId id of the template_version - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async templateVersionDelete(tmplId: string, vrsnId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.templateVersionDelete(tmplId, vrsnId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Retrieves the template version with the given template and version ids. - * @summary get - * @param {string} tmplId The ID of the template to which the version belongs. - * @param {string} vrsnId id of the template_version - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async templateVersionRetrieve(tmplId: string, vrsnId: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.templateVersionRetrieve(tmplId, vrsnId, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Updates the template version with the given template and version ids. - * @summary update - * @param {string} tmplId The ID of the template to which the version belongs. - * @param {string} vrsnId id of the template_version - * @param {TemplateVersionUpdatable} templateVersionUpdatable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async templateVersionUpdate(tmplId: string, vrsnId: string, templateVersionUpdatable: TemplateVersionUpdatable, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.templateVersionUpdate(tmplId, vrsnId, templateVersionUpdatable, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - /** - * Returns a list of template versions for the given template ID. The template versions are sorted by creation date, with the most recently created appearing first. - * @summary list - * @param {string} tmplId The ID of the template associated with the retrieved versions - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async templateVersionsList(tmplId: string, limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.templateVersionsList(tmplId, limit, before, after, include, dateCreated, options); - return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); - }, - } -}; - -/** - * TemplateVersionsApi - object-oriented interface - * @export - * @class TemplateVersionsApi - * @extends {BaseAPI} - */ -export class TemplateVersionsApi extends BaseAPI { +export const TemplateVersionsApiFp = function (configuration?: Configuration) { + const localVarAxiosParamCreator = + TemplateVersionsApiAxiosParamCreator(configuration); + return { /** * Creates a new template version attached to the specified template. * @summary create * @param {string} tmplId The ID of the template the new version will be attached to - * @param {TemplateVersionWritable} templateVersionWritable + * @param {TemplateVersionWritable} templateVersionWritable * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof TemplateVersionsApi */ - public create(tmplId: string, templateVersionWritable: TemplateVersionWritable, options?: AxiosRequestConfig) { - return TemplateVersionsApiFp(this.configuration).createTemplateVersion(tmplId, templateVersionWritable, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new TemplateVersion(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async createTemplateVersion( + tmplId: string, + templateVersionWritable: TemplateVersionWritable, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.createTemplateVersion( + tmplId, + templateVersionWritable, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Permanently deletes a template version. A template\'s `published_version` can not be deleted. * @summary delete @@ -391,20 +430,30 @@ export class TemplateVersionsApi extends BaseAPI { * @param {string} vrsnId id of the template_version * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof TemplateVersionsApi */ - public delete(tmplId: string, vrsnId: string, options?: AxiosRequestConfig) { - return TemplateVersionsApiFp(this.configuration).templateVersionDelete(tmplId, vrsnId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new TemplateVersionDeletion(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async templateVersionDelete( + tmplId: string, + vrsnId: string, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.templateVersionDelete( + tmplId, + vrsnId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Retrieves the template version with the given template and version ids. * @summary get @@ -412,66 +461,266 @@ export class TemplateVersionsApi extends BaseAPI { * @param {string} vrsnId id of the template_version * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof TemplateVersionsApi */ - public get(tmplId: string, vrsnId: string, options?: AxiosRequestConfig) { - return TemplateVersionsApiFp(this.configuration).templateVersionRetrieve(tmplId, vrsnId, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new TemplateVersion(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async templateVersionRetrieve( + tmplId: string, + vrsnId: string, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.templateVersionRetrieve( + tmplId, + vrsnId, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Updates the template version with the given template and version ids. * @summary update * @param {string} tmplId The ID of the template to which the version belongs. * @param {string} vrsnId id of the template_version - * @param {TemplateVersionUpdatable} templateVersionUpdatable + * @param {TemplateVersionUpdatable} templateVersionUpdatable * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof TemplateVersionsApi */ - public update(tmplId: string, vrsnId: string, templateVersionUpdatable: TemplateVersionUpdatable, options?: AxiosRequestConfig) { - return TemplateVersionsApiFp(this.configuration).templateVersionUpdate(tmplId, vrsnId, templateVersionUpdatable, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new TemplateVersion(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } - + async templateVersionUpdate( + tmplId: string, + vrsnId: string, + templateVersionUpdatable: TemplateVersionUpdatable, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.templateVersionUpdate( + tmplId, + vrsnId, + templateVersionUpdatable, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** - * Returns a list of template versions for the given template ID. The template versions are sorted by creation date, with the most recently created appearing first. + * Returns a list of template versions for the given template ID. The template versions are sorted by creation date, with the most recently created appearing first. * @summary list * @param {string} tmplId The ID of the template associated with the retrieved versions * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. * @param {*} [options] Override http request option. * @throws {RequiredError} - * @memberof TemplateVersionsApi */ - public list(tmplId: string, limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, options?: AxiosRequestConfig) { - return TemplateVersionsApiFp(this.configuration).templateVersionsList(tmplId, limit, before, after, include, dateCreated, options).then((request) => request(this.axios, this.basePath)) - .then(function (response) { - return new TemplateVersionList(response.data); - }).catch(error => { - if (error.response?.data?.error?.message) { - error.message = error.response.data.error.message; - } - throw error; - }); - } + async templateVersionsList( + tmplId: string, + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + options?: AxiosRequestConfig + ): Promise< + ( + axios?: AxiosInstance, + basePath?: string + ) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.templateVersionsList( + tmplId, + limit, + before, + after, + include, + dateCreated, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + }; +}; + +/** + * TemplateVersionsApi - object-oriented interface + * @export + * @class TemplateVersionsApi + * @extends {BaseAPI} + */ +export class TemplateVersionsApi extends BaseAPI { + /** + * Creates a new template version attached to the specified template. + * @summary create + * @param {string} tmplId The ID of the template the new version will be attached to + * @param {TemplateVersionWritable} templateVersionWritable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof TemplateVersionsApi + */ + public create( + tmplId: string, + templateVersionWritable: TemplateVersionWritable, + options?: AxiosRequestConfig + ) { + return TemplateVersionsApiFp(this.configuration) + .createTemplateVersion(tmplId, templateVersionWritable, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new TemplateVersion(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Permanently deletes a template version. A template\'s `published_version` can not be deleted. + * @summary delete + * @param {string} tmplId The ID of the template to which the version belongs. + * @param {string} vrsnId id of the template_version + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof TemplateVersionsApi + */ + public delete(tmplId: string, vrsnId: string, options?: AxiosRequestConfig) { + return TemplateVersionsApiFp(this.configuration) + .templateVersionDelete(tmplId, vrsnId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new TemplateVersionDeletion(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Retrieves the template version with the given template and version ids. + * @summary get + * @param {string} tmplId The ID of the template to which the version belongs. + * @param {string} vrsnId id of the template_version + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof TemplateVersionsApi + */ + public get(tmplId: string, vrsnId: string, options?: AxiosRequestConfig) { + return TemplateVersionsApiFp(this.configuration) + .templateVersionRetrieve(tmplId, vrsnId, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new TemplateVersion(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Updates the template version with the given template and version ids. + * @summary update + * @param {string} tmplId The ID of the template to which the version belongs. + * @param {string} vrsnId id of the template_version + * @param {TemplateVersionUpdatable} templateVersionUpdatable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof TemplateVersionsApi + */ + public update( + tmplId: string, + vrsnId: string, + templateVersionUpdatable: TemplateVersionUpdatable, + options?: AxiosRequestConfig + ) { + return TemplateVersionsApiFp(this.configuration) + .templateVersionUpdate(tmplId, vrsnId, templateVersionUpdatable, options) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new TemplateVersion(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } + + /** + * Returns a list of template versions for the given template ID. The template versions are sorted by creation date, with the most recently created appearing first. + * @summary list + * @param {string} tmplId The ID of the template associated with the retrieved versions + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof TemplateVersionsApi + */ + public list( + tmplId: string, + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + options?: AxiosRequestConfig + ) { + return TemplateVersionsApiFp(this.configuration) + .templateVersionsList( + tmplId, + limit, + before, + after, + include, + dateCreated, + options + ) + .then((request) => request(this.axios, this.basePath)) + .then(function (response) { + return new TemplateVersionList(response.data); + }) + .catch((error) => { + if (error.response?.data?.error?.message) { + error.message = error.response.data.error.message; + } + throw error; + }); + } } /** @@ -479,4 +728,3 @@ export class TemplateVersionsApi extends BaseAPI { * https://openapi-generator.tech * Do not edit the class manually. */ - diff --git a/api/templates-api.ts b/api/templates-api.ts index ceee750..7d26032 100644 --- a/api/templates-api.ts +++ b/api/templates-api.ts @@ -2,7 +2,7 @@ /* eslint-disable */ /** * Lob - * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? + * The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.

Looking for our [previous documentation](https://lob.github.io/legacy-docs/)? * * The version of the OpenAPI document: 1.3.0 * Contact: lob-openapi@lob.com @@ -12,443 +12,653 @@ * Do not edit the class manually. */ - -import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; -import { Configuration } from '../configuration'; -import FormData = require("form-data") +import globalAxios, { + AxiosPromise, + AxiosInstance, + AxiosRequestConfig, +} from "axios"; +import { Configuration } from "../configuration"; +import FormData = require("form-data"); // Some imports not used depending on template conditions // @ts-ignore -import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, valueToString } from '../common'; +import { + DUMMY_BASE_URL, + assertParamExists, + setApiKeyToObject, + setBasicAuthToObject, + setBearerAuthToObject, + setOAuthToObject, + setSearchParams, + serializeDataIfNeeded, + toPathString, + createRequestFunction, + valueToString, +} from "../common"; // @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base'; +import { + BASE_PATH, + COLLECTION_FORMATS, + RequestArgs, + BaseAPI, + RequiredError, +} from "../base"; // @ts-ignore -import { LobError } from '../models'; +import { LobError } from "../models"; // @ts-ignore -import { Template } from '../models'; +import { Template } from "../models"; // @ts-ignore -import { TemplateDeletion } from '../models'; +import { TemplateDeletion } from "../models"; // @ts-ignore -import { TemplateList } from '../models'; +import { TemplateList } from "../models"; // @ts-ignore -import { TemplateUpdate } from '../models'; +import { TemplateUpdate } from "../models"; // @ts-ignore -import { TemplateWritable } from '../models'; +import { TemplateWritable } from "../models"; /** * TemplatesApi - axios parameter creator * @export */ -export const TemplatesApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * Creates a new template for use with the Print & Mail API. In Live mode, you can only have as many non-deleted templates as allotted in your current [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions). If you attempt to create a template past your limit, you will receive a `403` error. There is no limit in Test mode. - * @summary create - * @param {TemplateWritable} templateWritable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - createTemplate: async (templateWritable: TemplateWritable, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'templateWritable' is not null or undefined - assertParamExists('createTemplate', 'templateWritable', templateWritable) - const localVarPath = `/templates`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(templateWritable, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Permanently deletes a template. - * @summary delete - * @param {string} tmplId id of the template - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - templateDelete: async (tmplId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'tmplId' is not null or undefined - assertParamExists('templateDelete', 'tmplId', tmplId) - const localVarPath = `/templates/{tmpl_id}` - .replace(`{${"tmpl_id"}}`, encodeURIComponent(String(tmplId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Retrieves the details of an existing template. - * @summary get - * @param {string} tmplId id of the template - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - templateRetrieve: async (tmplId: string, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'tmplId' is not null or undefined - assertParamExists('templateRetrieve', 'tmplId', tmplId) - const localVarPath = `/templates/{tmpl_id}` - .replace(`{${"tmpl_id"}}`, encodeURIComponent(String(tmplId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Updates the description and/or published version of the template with the given id. - * @summary update - * @param {string} tmplId id of the template - * @param {TemplateUpdate} templateUpdate - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - templateUpdate: async (tmplId: string, templateUpdate: TemplateUpdate, options: AxiosRequestConfig = {}): Promise => { - // verify required parameter 'tmplId' is not null or undefined - assertParamExists('templateUpdate', 'tmplId', tmplId) - // verify required parameter 'templateUpdate' is not null or undefined - assertParamExists('templateUpdate', 'templateUpdate', templateUpdate) - const localVarPath = `/templates/{tmpl_id}` - .replace(`{${"tmpl_id"}}`, encodeURIComponent(String(tmplId))); - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, 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(templateUpdate, localVarRequestOptions, configuration) - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - /** - * Returns a list of your templates. The templates are returned sorted by creation date, with the most recently created templates appearing first. - * @summary list - * @param {number} [limit] How many results to return. - * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. - * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. - * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. - * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. - * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - templatesList: async (limit?: number, before?: string, after?: string, include?: Array, dateCreated?: { [key: string]: string; }, metadata?: { [key: string]: string; }, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/templates`; - // 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 basicAuth required - // http basic authentication required - setBasicAuthToObject(localVarRequestOptions, configuration) - - if (limit !== undefined) { - localVarQueryParameter['limit'] = limit; - } - - if (before !== undefined) { - localVarQueryParameter['before'] = before; - } - - if (after !== undefined) { - localVarQueryParameter['after'] = after; - } - - if (include) { - localVarQueryParameter['include'] = valueToString(include); - } - - if (dateCreated !== undefined) { - localVarQueryParameter['date_created'] = valueToString(dateCreated); - } - - if (metadata !== undefined) { - localVarQueryParameter['metadata'] = valueToString(metadata); - } - - - - setSearchParams(localVarUrlObj, localVarQueryParameter); - let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; - localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - - return { - url: toPathString(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } +export const TemplatesApiAxiosParamCreator = function ( + configuration?: Configuration +) { + return { + /** + * Creates a new template for use with the Print & Mail API. In Live mode, you can only have as many non-deleted templates as allotted in your current [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions). If you attempt to create a template past your limit, you will receive a `403` error. There is no limit in Test mode. + * @summary create + * @param {TemplateWritable} templateWritable + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createTemplate: async ( + templateWritable: TemplateWritable, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'templateWritable' is not null or undefined + assertParamExists("createTemplate", "templateWritable", templateWritable); + const localVarPath = `/templates`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + templateWritable, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Permanently deletes a template. + * @summary delete + * @param {string} tmplId id of the template + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + templateDelete: async ( + tmplId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'tmplId' is not null or undefined + assertParamExists("templateDelete", "tmplId", tmplId); + const localVarPath = `/templates/{tmpl_id}`.replace( + `{${"tmpl_id"}}`, + encodeURIComponent(String(tmplId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the details of an existing template. + * @summary get + * @param {string} tmplId id of the template + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + templateRetrieve: async ( + tmplId: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'tmplId' is not null or undefined + assertParamExists("templateRetrieve", "tmplId", tmplId); + const localVarPath = `/templates/{tmpl_id}`.replace( + `{${"tmpl_id"}}`, + encodeURIComponent(String(tmplId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Updates the description and/or published version of the template with the given id. + * @summary update + * @param {string} tmplId id of the template + * @param {TemplateUpdate} templateUpdate + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + templateUpdate: async ( + tmplId: string, + templateUpdate: TemplateUpdate, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'tmplId' is not null or undefined + assertParamExists("templateUpdate", "tmplId", tmplId); + // verify required parameter 'templateUpdate' is not null or undefined + assertParamExists("templateUpdate", "templateUpdate", templateUpdate); + const localVarPath = `/templates/{tmpl_id}`.replace( + `{${"tmpl_id"}}`, + encodeURIComponent(String(tmplId)) + ); + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, 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( + templateUpdate, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of your templates. The templates are returned sorted by creation date, with the most recently created templates appearing first. + * @summary list + * @param {number} [limit] How many results to return. + * @param {string} [before] A reference to a list entry used for paginating to the previous set of entries. This field is pre-populated in the `previous_url` field in the return response. + * @param {string} [after] A reference to a list entry used for paginating to the next set of entries. This field is pre-populated in the `next_url` field in the return response. + * @param {Array} [include] Request that the response include the total count by specifying `include[]=total_count`. + * @param {{ [key: string]: string; }} [dateCreated] Filter by date created. + * @param {{ [key: string]: string; }} [metadata] Filter by metadata key-value pair`. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + templatesList: async ( + limit?: number, + before?: string, + after?: string, + include?: Array, + dateCreated?: { [key: string]: string }, + metadata?: { [key: string]: string }, + options: AxiosRequestConfig = {} + ): Promise => { + const localVarPath = `/templates`; + // 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 basicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + if (limit !== undefined) { + localVarQueryParameter["limit"] = limit; + } + + if (before !== undefined) { + localVarQueryParameter["before"] = before; + } + + if (after !== undefined) { + localVarQueryParameter["after"] = after; + } + + if (include) { + localVarQueryParameter["include"] = valueToString(include); + } + + if (dateCreated !== undefined) { + localVarQueryParameter["date_created"] = valueToString(dateCreated); + } + + if (metadata !== undefined) { + localVarQueryParameter["metadata"] = valueToString(metadata); + } + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + }; }; /** * TemplatesApi - functional programming interface * @export */ -export const TemplatesApiFp = function(configuration?: Configuration) { - const localVarAxiosParamCreator = TemplatesApiAxiosParamCreator(configuration) - return { - /** - * Creates a new template for use with the Print & Mail API. In Live mode, you can only have as many non-deleted templates as allotted in your current [Print & Mail Edition](https://dashboard.lob.com/#/settings/editions). If you attempt to create a template past your limit, you will receive a `403` error. There is no limit in Test mode. - * @summary create - * @param {TemplateWritable} templateWritable - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async createTemplate(templateWritable: TemplateWritable, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise