From afb66d3503c2a7f3ad41a2cf54f2bc218a6868d6 Mon Sep 17 00:00:00 2001 From: Jonathan Wenger Date: Fri, 3 Jan 2025 10:25:48 -0800 Subject: [PATCH] Update to handle optional AvalaraVersion --- package.json | 56 ++++++++++---------- src/apis/EInvoicing/V1/DataInputFieldsApi.ts | 5 +- src/apis/EInvoicing/V1/DocumentsApi.ts | 25 ++++----- src/apis/EInvoicing/V1/InteropApi.ts | 5 +- src/apis/EInvoicing/V1/MandatesApi.ts | 10 ++-- src/apis/EInvoicing/V1/TradingPartnersApi.ts | 25 ++++----- tests/einvoicing/index.spec.ts | 4 +- 7 files changed, 58 insertions(+), 72 deletions(-) diff --git a/package.json b/package.json index d20f9ae..3b93729 100644 --- a/package.json +++ b/package.json @@ -1,28 +1,28 @@ -{ - "name": "avalara-sdk", - "version": "24.12.10", - "description": "OpenAPI client for avalara-sdk", - "author": "OpenAPI-Generator", - "main": "./dist/index.js", - "typings": "./dist/index.d.ts", - "scripts": { - "build": "tsc", - "prepare": "npm run build", - "test": "jest" - }, - "dependencies": { - "node-fetch": "^2.7.0" - }, - "devDependencies": { - "@babel/preset-env": "^7.26.0", - "@types/jest": "^29.5.14", - "@types/node": "^18.0.0", - "babel-jest": "^29.7.0", - "dotenv": "^16.0.1", - "fetch-mock-jest": "^1.5.1", - "jest": "^29.7.0", - "ts-jest": "^29.2.5", - "ts-node": "^10.9.2", - "typescript": "^4.7.3" - } -} +{ + "name": "avalara-sdk", + "version": "24.12.11", + "description": "OpenAPI client for avalara-sdk", + "author": "OpenAPI-Generator", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts": { + "build": "tsc", + "prepare": "npm run build", + "test": "jest" + }, + "dependencies": { + "node-fetch": "^2.7.0" + }, + "devDependencies": { + "@babel/preset-env": "^7.26.0", + "@types/jest": "^29.5.14", + "@types/node": "^18.0.0", + "babel-jest": "^29.7.0", + "dotenv": "^16.0.1", + "fetch-mock-jest": "^1.5.1", + "jest": "^29.7.0", + "ts-jest": "^29.2.5", + "ts-node": "^10.9.2", + "typescript": "^4.7.3" + } +} diff --git a/src/apis/EInvoicing/V1/DataInputFieldsApi.ts b/src/apis/EInvoicing/V1/DataInputFieldsApi.ts index e198d5a..333c546 100644 --- a/src/apis/EInvoicing/V1/DataInputFieldsApi.ts +++ b/src/apis/EInvoicing/V1/DataInputFieldsApi.ts @@ -30,7 +30,7 @@ import { } from '../../../packages/EInvoicing/V1'; export interface GetDataInputFieldsInterface { - avalaraVersion: string; + avalaraVersion?: string; xAvalaraClient?: string; $filter?: string; $top?: number; @@ -54,6 +54,7 @@ export class DataInputFieldsApi extends runtime.ApiClient { * Returns the optionality of document fields for different country mandates */ async getDataInputFieldsRaw(requestParameters: GetDataInputFieldsInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling getDataInputFields.'); } @@ -83,8 +84,6 @@ export class DataInputFieldsApi extends runtime.ApiClient { const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } diff --git a/src/apis/EInvoicing/V1/DocumentsApi.ts b/src/apis/EInvoicing/V1/DocumentsApi.ts index b077b5e..71c8371 100644 --- a/src/apis/EInvoicing/V1/DocumentsApi.ts +++ b/src/apis/EInvoicing/V1/DocumentsApi.ts @@ -57,20 +57,20 @@ import { } from '../../../packages/EInvoicing/V1'; export interface DownloadDocumentInterface { - avalaraVersion: string; + avalaraVersion?: string; accept: string; documentId: string; xAvalaraClient?: string; } export interface FetchDocumentsInterface { - avalaraVersion: string; + avalaraVersion?: string; documentFetchRequest: DocumentFetchRequest; xAvalaraClient?: string; } export interface GetDocumentListInterface { - avalaraVersion: string; + avalaraVersion?: string; xAvalaraClient?: string; startDate?: Date; endDate?: Date; @@ -83,13 +83,13 @@ export interface GetDocumentListInterface { } export interface GetDocumentStatusInterface { - avalaraVersion: string; + avalaraVersion?: string; documentId: string; xAvalaraClient?: string; } export interface SubmitDocumentInterface { - avalaraVersion: string; + avalaraVersion?: string; metadata: SubmitDocumentMetadata; data: string; xAvalaraClient?: string; @@ -110,6 +110,7 @@ export class DocumentsApi extends runtime.ApiClient { * Returns a copy of the document */ async downloadDocumentRaw(requestParameters: DownloadDocumentInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling downloadDocument.'); } @@ -127,8 +128,6 @@ export class DocumentsApi extends runtime.ApiClient { const authNames: string[] = ['http']; const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } @@ -169,6 +168,7 @@ export class DocumentsApi extends runtime.ApiClient { * Fetch the inbound document from a tax authority */ async fetchDocumentsRaw(requestParameters: FetchDocumentsInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling fetchDocuments.'); } @@ -182,8 +182,6 @@ export class DocumentsApi extends runtime.ApiClient { const authNames: string[] = ['http']; const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - headerParameters['Content-Type'] = 'application/json'; if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { @@ -223,6 +221,7 @@ export class DocumentsApi extends runtime.ApiClient { * Returns a summary of documents for a date range */ async getDocumentListRaw(requestParameters: GetDocumentListInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling getDocumentList.'); } @@ -264,8 +263,6 @@ export class DocumentsApi extends runtime.ApiClient { const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } @@ -302,6 +299,7 @@ export class DocumentsApi extends runtime.ApiClient { * Checks the status of a document */ async getDocumentStatusRaw(requestParameters: GetDocumentStatusInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling getDocumentStatus.'); } @@ -315,8 +313,6 @@ export class DocumentsApi extends runtime.ApiClient { const authNames: string[] = ['http']; const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } @@ -353,6 +349,7 @@ export class DocumentsApi extends runtime.ApiClient { * Submits a document to Avalara E-Invoicing API */ async submitDocumentRaw(requestParameters: SubmitDocumentInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling submitDocument.'); } @@ -370,8 +367,6 @@ export class DocumentsApi extends runtime.ApiClient { const authNames: string[] = ['http']; const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } diff --git a/src/apis/EInvoicing/V1/InteropApi.ts b/src/apis/EInvoicing/V1/InteropApi.ts index 09e4f80..f191062 100644 --- a/src/apis/EInvoicing/V1/InteropApi.ts +++ b/src/apis/EInvoicing/V1/InteropApi.ts @@ -29,7 +29,7 @@ import { export interface SubmitInteropDocumentInterface { documentType: SubmitInteropDocumentDocumentTypeEnum; interchangeType: SubmitInteropDocumentInterchangeTypeEnum; - avalaraVersion: string; + avalaraVersion?: string; xAvalaraClient?: string; xCorrelationID?: string; fileName?: Blob; @@ -50,6 +50,7 @@ export class InteropApi extends runtime.ApiClient { * Submit a document */ async submitInteropDocumentRaw(requestParameters: SubmitInteropDocumentInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.documentType === null || requestParameters.documentType === undefined) { throw new runtime.RequiredError('documentType','Required parameter requestParameters.documentType was null or undefined when calling submitInteropDocument.'); } @@ -75,8 +76,6 @@ export class InteropApi extends runtime.ApiClient { const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } diff --git a/src/apis/EInvoicing/V1/MandatesApi.ts b/src/apis/EInvoicing/V1/MandatesApi.ts index 430b8a0..20ad791 100644 --- a/src/apis/EInvoicing/V1/MandatesApi.ts +++ b/src/apis/EInvoicing/V1/MandatesApi.ts @@ -39,7 +39,7 @@ import { } from '../../../packages/EInvoicing/V1'; export interface GetMandateDataInputFieldsInterface { - avalaraVersion: string; + avalaraVersion?: string; mandateId: string; documentType: string; documentVersion: string; @@ -47,7 +47,7 @@ export interface GetMandateDataInputFieldsInterface { } export interface GetMandatesInterface { - avalaraVersion: string; + avalaraVersion?: string; xAvalaraClient?: string; $filter?: string; $top?: number; @@ -71,6 +71,7 @@ export class MandatesApi extends runtime.ApiClient { * Returns document field information for a country mandate, a selected document type, and its version */ async getMandateDataInputFieldsRaw(requestParameters: GetMandateDataInputFieldsInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse>, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling getMandateDataInputFields.'); } @@ -100,8 +101,6 @@ export class MandatesApi extends runtime.ApiClient { const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } @@ -138,6 +137,7 @@ export class MandatesApi extends runtime.ApiClient { * List country mandates that are supported by the Avalara E-Invoicing platform */ async getMandatesRaw(requestParameters: GetMandatesInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling getMandates.'); } @@ -167,8 +167,6 @@ export class MandatesApi extends runtime.ApiClient { const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } diff --git a/src/apis/EInvoicing/V1/TradingPartnersApi.ts b/src/apis/EInvoicing/V1/TradingPartnersApi.ts index 75f56a5..6fb2f23 100644 --- a/src/apis/EInvoicing/V1/TradingPartnersApi.ts +++ b/src/apis/EInvoicing/V1/TradingPartnersApi.ts @@ -33,7 +33,7 @@ import { } from '../../../packages/EInvoicing/V1'; export interface BatchSearchParticipantsInterface { - avalaraVersion: string; + avalaraVersion?: string; name: string; notificationEmail: string; file: Blob; @@ -42,21 +42,21 @@ export interface BatchSearchParticipantsInterface { } export interface DownloadBatchSearchReportInterface { - avalaraVersion: string; + avalaraVersion?: string; id: string; xAvalaraClient?: string; xCorrelationID?: string; } export interface GetBatchSearchDetailInterface { - avalaraVersion: string; + avalaraVersion?: string; id: string; xAvalaraClient?: string; xCorrelationID?: string; } export interface ListBatchSearchesInterface { - avalaraVersion: string; + avalaraVersion?: string; xAvalaraClient?: string; $filter?: string; count?: boolean; @@ -67,7 +67,7 @@ export interface ListBatchSearchesInterface { } export interface SearchParticipantsInterface { - avalaraVersion: string; + avalaraVersion?: string; $search: string; xAvalaraClient?: string; count?: boolean; @@ -93,6 +93,7 @@ export class TradingPartnersApi extends runtime.ApiClient { * Creates a batch search and performs a batch search in the directory for participants in the background. */ async batchSearchParticipantsRaw(requestParameters: BatchSearchParticipantsInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling batchSearchParticipants.'); } @@ -122,8 +123,6 @@ export class TradingPartnersApi extends runtime.ApiClient { const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } @@ -183,6 +182,7 @@ export class TradingPartnersApi extends runtime.ApiClient { * Download batch search results in a csv file. */ async downloadBatchSearchReportRaw(requestParameters: DownloadBatchSearchReportInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling downloadBatchSearchReport.'); } @@ -196,8 +196,6 @@ export class TradingPartnersApi extends runtime.ApiClient { const authNames: string[] = ['http']; const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } @@ -238,6 +236,7 @@ export class TradingPartnersApi extends runtime.ApiClient { * Get the batch search details for a given id. */ async getBatchSearchDetailRaw(requestParameters: GetBatchSearchDetailInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling getBatchSearchDetail.'); } @@ -251,8 +250,6 @@ export class TradingPartnersApi extends runtime.ApiClient { const authNames: string[] = ['http']; const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } @@ -293,6 +290,7 @@ export class TradingPartnersApi extends runtime.ApiClient { * List all batch searches that were previously submitted. */ async listBatchSearchesRaw(requestParameters: ListBatchSearchesInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling listBatchSearches.'); } @@ -322,8 +320,6 @@ export class TradingPartnersApi extends runtime.ApiClient { const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } @@ -364,6 +360,7 @@ export class TradingPartnersApi extends runtime.ApiClient { * Returns a list of participants matching the input query. */ async searchParticipantsRaw(requestParameters: SearchParticipantsInterface, initOverrides?: RequestInit): Promise<{ response: runtime.ApiResponse, logObject: LogObject }> { + requestParameters.avalaraVersion = requestParameters.avalaraVersion || '1.2'; if (requestParameters.avalaraVersion === null || requestParameters.avalaraVersion === undefined) { throw new runtime.RequiredError('avalaraVersion','Required parameter requestParameters.avalaraVersion was null or undefined when calling searchParticipants.'); } @@ -401,8 +398,6 @@ export class TradingPartnersApi extends runtime.ApiClient { const headerParameters: runtime.HTTPHeaders = {}; - headerParameters['avalara-version'] = '1.2'; - if (requestParameters.avalaraVersion !== undefined && requestParameters.avalaraVersion !== null) { headerParameters['avalara-version'] = String(requestParameters.avalaraVersion); } diff --git a/tests/einvoicing/index.spec.ts b/tests/einvoicing/index.spec.ts index c96cfd4..5c78e62 100644 --- a/tests/einvoicing/index.spec.ts +++ b/tests/einvoicing/index.spec.ts @@ -20,14 +20,14 @@ describe("EInvoicing API ", () => { it("should be able retrieve a document from the Documents API", async () => { const runtime = new ApiClient(config); const api = new DocumentsApi(runtime); - const result = await api.getDocumentList({ avalaraVersion: "1.2" }); + const result = await api.getDocumentList({}); expect(result).toBeDefined(); }); it("should be able retrieve a document from the Mandates API", async () => { const runtime = new ApiClient(config); const api = new MandatesApi(runtime); - const result = await api.getMandates({ avalaraVersion: "1.2", $top: 10 }); + const result = await api.getMandates({ $top: 10 }); expect(result).toBeDefined(); expect(result.value?.length).toBeGreaterThan(0); });