From f268380415dd87ef3ceb9c411a9f64debcd50e02 Mon Sep 17 00:00:00 2001 From: sangeet-joy-tw <157606431+sangeet-joy-tw@users.noreply.github.com> Date: Tue, 30 Jan 2024 18:49:31 +0530 Subject: [PATCH] 579-added the global error class and axios request and response types --- src/gen/api/accountingApi.ts | 6873 +++++----------------------- src/gen/api/appStoreApi.ts | 119 +- src/gen/api/assetApi.ts | 177 +- src/gen/api/bankfeedsApi.ts | 206 +- src/gen/api/filesApi.ts | 526 +-- src/gen/api/financeApi.ts | 351 +- src/gen/api/payrollAUApi.ts | 931 +--- src/gen/api/payrollNZApi.ts | 1975 ++------ src/gen/api/payrollUKApi.ts | 2033 ++------ src/gen/api/projectApi.ts | 467 +- src/gen/model/accounting/models.ts | 14 +- src/gen/model/appstore/models.ts | 14 +- src/gen/model/assets/models.ts | 14 +- src/gen/model/bankfeeds/models.ts | 14 +- src/gen/model/files/models.ts | 14 +- src/gen/model/finance/models.ts | 14 +- src/gen/model/payroll-au/models.ts | 14 +- src/gen/model/payroll-nz/models.ts | 14 +- src/gen/model/payroll-uk/models.ts | 14 +- src/gen/model/projects/models.ts | 14 +- src/model/ApiError.ts | 61 + 21 files changed, 2496 insertions(+), 11363 deletions(-) create mode 100644 src/model/ApiError.ts diff --git a/src/gen/api/accountingApi.ts b/src/gen/api/accountingApi.ts index 514f80de..b7622f3f 100644 --- a/src/gen/api/accountingApi.ts +++ b/src/gen/api/accountingApi.ts @@ -10,7 +10,6 @@ * Do not edit the class manually. */ -const axios = require('axios'); import http = require('http'); import fs = require('fs'); @@ -70,6 +69,8 @@ import { TrackingOptions } from '../model/accounting/trackingOptions'; import { Users } from '../model/accounting/users'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/accounting/models'; +import { ApiError } from '../../model/ApiError'; +import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import { OAuth } from '../model/accounting/models'; let defaultBasePath = 'https://api.xero.com/api.xro/2.0'; @@ -136,7 +137,7 @@ export class AccountingApi { * @param account Account object in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createAccount (xeroTenantId: string, account: Account, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Accounts; }> { + public async createAccount (xeroTenantId: string, account: Account, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Accounts; }> { const localVarPath = this.basePath + '/Accounts'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -162,7 +163,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -171,26 +172,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(account, "Account"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -205,7 +186,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Accounts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Accounts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -217,7 +198,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -231,7 +213,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createAccountAttachmentByFileName (xeroTenantId: string, accountID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async createAccountAttachmentByFileName (xeroTenantId: string, accountID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Accounts/{AccountID}/Attachments/{FileName}' .replace('{' + 'AccountID' + '}', encodeURIComponent(String(accountID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -270,7 +252,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -279,26 +261,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -330,7 +292,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -347,7 +309,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -361,7 +324,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createBankTransactionAttachmentByFileName (xeroTenantId: string, bankTransactionID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async createBankTransactionAttachmentByFileName (xeroTenantId: string, bankTransactionID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/BankTransactions/{BankTransactionID}/Attachments/{FileName}' .replace('{' + 'BankTransactionID' + '}', encodeURIComponent(String(bankTransactionID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -400,7 +363,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -409,26 +372,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -460,7 +403,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -477,7 +420,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -490,7 +434,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createBankTransactionHistoryRecord (xeroTenantId: string, bankTransactionID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createBankTransactionHistoryRecord (xeroTenantId: string, bankTransactionID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/BankTransactions/{BankTransactionID}/History' .replace('{' + 'BankTransactionID' + '}', encodeURIComponent(String(bankTransactionID))); let localVarQueryParameters: any = {}; @@ -522,7 +466,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -531,26 +475,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -565,7 +489,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -577,7 +501,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -591,7 +516,7 @@ export class AccountingApi { * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async createBankTransactions (xeroTenantId: string, bankTransactions: BankTransactions, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BankTransactions; }> { + public async createBankTransactions (xeroTenantId: string, bankTransactions: BankTransactions, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BankTransactions; }> { const localVarPath = this.basePath + '/BankTransactions'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -625,7 +550,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -634,26 +559,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(bankTransactions, "BankTransactions"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -668,7 +573,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BankTransactions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BankTransactions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -680,7 +585,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -692,7 +598,7 @@ export class AccountingApi { * @param bankTransfers BankTransfers with array of BankTransfer objects in request body * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createBankTransfer (xeroTenantId: string, bankTransfers: BankTransfers, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BankTransfers; }> { + public async createBankTransfer (xeroTenantId: string, bankTransfers: BankTransfers, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BankTransfers; }> { const localVarPath = this.basePath + '/BankTransfers'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -718,7 +624,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -727,26 +633,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(bankTransfers, "BankTransfers"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -761,7 +647,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BankTransfers; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BankTransfers; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -773,7 +659,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -786,7 +673,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createBankTransferAttachmentByFileName (xeroTenantId: string, bankTransferID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async createBankTransferAttachmentByFileName (xeroTenantId: string, bankTransferID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/BankTransfers/{BankTransferID}/Attachments/{FileName}' .replace('{' + 'BankTransferID' + '}', encodeURIComponent(String(bankTransferID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -825,7 +712,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -834,26 +721,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -885,7 +752,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -902,7 +769,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -915,7 +783,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createBankTransferHistoryRecord (xeroTenantId: string, bankTransferID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createBankTransferHistoryRecord (xeroTenantId: string, bankTransferID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/BankTransfers/{BankTransferID}/History' .replace('{' + 'BankTransferID' + '}', encodeURIComponent(String(bankTransferID))); let localVarQueryParameters: any = {}; @@ -947,7 +815,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -956,26 +824,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -990,7 +838,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1002,7 +850,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1015,7 +864,7 @@ export class AccountingApi { * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createBatchPayment (xeroTenantId: string, batchPayments: BatchPayments, summarizeErrors?: boolean, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BatchPayments; }> { + public async createBatchPayment (xeroTenantId: string, batchPayments: BatchPayments, summarizeErrors?: boolean, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BatchPayments; }> { const localVarPath = this.basePath + '/BatchPayments'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1045,7 +894,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1054,26 +903,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(batchPayments, "BatchPayments"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1088,7 +917,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BatchPayments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BatchPayments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1100,7 +929,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1113,7 +943,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createBatchPaymentHistoryRecord (xeroTenantId: string, batchPaymentID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createBatchPaymentHistoryRecord (xeroTenantId: string, batchPaymentID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/BatchPayments/{BatchPaymentID}/History' .replace('{' + 'BatchPaymentID' + '}', encodeURIComponent(String(batchPaymentID))); let localVarQueryParameters: any = {}; @@ -1145,7 +975,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1154,26 +984,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1188,7 +998,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1200,7 +1010,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1213,7 +1024,7 @@ export class AccountingApi { * @param paymentServices PaymentServices array with PaymentService object in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createBrandingThemePaymentServices (xeroTenantId: string, brandingThemeID: string, paymentServices: PaymentServices, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PaymentServices; }> { + public async createBrandingThemePaymentServices (xeroTenantId: string, brandingThemeID: string, paymentServices: PaymentServices, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PaymentServices; }> { const localVarPath = this.basePath + '/BrandingThemes/{BrandingThemeID}/PaymentServices' .replace('{' + 'BrandingThemeID' + '}', encodeURIComponent(String(brandingThemeID))); let localVarQueryParameters: any = {}; @@ -1245,7 +1056,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1254,26 +1065,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(paymentServices, "PaymentServices"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1288,7 +1079,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PaymentServices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PaymentServices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1300,7 +1091,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1313,7 +1105,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createContactAttachmentByFileName (xeroTenantId: string, contactID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async createContactAttachmentByFileName (xeroTenantId: string, contactID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Contacts/{ContactID}/Attachments/{FileName}' .replace('{' + 'ContactID' + '}', encodeURIComponent(String(contactID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -1352,7 +1144,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1361,26 +1153,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1412,7 +1184,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1429,7 +1201,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1441,7 +1214,7 @@ export class AccountingApi { * @param contactGroups ContactGroups with an array of names in request body * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createContactGroup (xeroTenantId: string, contactGroups: ContactGroups, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ContactGroups; }> { + public async createContactGroup (xeroTenantId: string, contactGroups: ContactGroups, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ContactGroups; }> { const localVarPath = this.basePath + '/ContactGroups'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1467,7 +1240,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1476,26 +1249,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(contactGroups, "ContactGroups"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1510,7 +1263,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ContactGroups; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ContactGroups; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1522,7 +1275,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1535,7 +1289,7 @@ export class AccountingApi { * @param contacts Contacts with array of contacts specifying the ContactID to be added to ContactGroup in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createContactGroupContacts (xeroTenantId: string, contactGroupID: string, contacts: Contacts, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Contacts; }> { + public async createContactGroupContacts (xeroTenantId: string, contactGroupID: string, contacts: Contacts, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Contacts; }> { const localVarPath = this.basePath + '/ContactGroups/{ContactGroupID}/Contacts' .replace('{' + 'ContactGroupID' + '}', encodeURIComponent(String(contactGroupID))); let localVarQueryParameters: any = {}; @@ -1567,7 +1321,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1576,26 +1330,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(contacts, "Contacts"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1610,7 +1344,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Contacts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Contacts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1622,7 +1356,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1635,7 +1370,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createContactHistory (xeroTenantId: string, contactID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createContactHistory (xeroTenantId: string, contactID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Contacts/{ContactID}/History' .replace('{' + 'ContactID' + '}', encodeURIComponent(String(contactID))); let localVarQueryParameters: any = {}; @@ -1667,7 +1402,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1676,26 +1411,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1710,7 +1425,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1722,7 +1437,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1735,7 +1451,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async createContacts (xeroTenantId: string, contacts: Contacts, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Contacts; }> { + public async createContacts (xeroTenantId: string, contacts: Contacts, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Contacts; }> { const localVarPath = this.basePath + '/Contacts'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1765,7 +1481,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1774,26 +1490,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(contacts, "Contacts"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1808,7 +1504,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Contacts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Contacts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1820,7 +1516,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1834,7 +1531,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async createCreditNoteAllocation (xeroTenantId: string, creditNoteID: string, allocations: Allocations, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Allocations; }> { + public async createCreditNoteAllocation (xeroTenantId: string, creditNoteID: string, allocations: Allocations, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Allocations; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}/Allocations' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))); let localVarQueryParameters: any = {}; @@ -1870,7 +1567,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1879,26 +1576,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(allocations, "Allocations"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1913,7 +1590,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Allocations; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Allocations; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1925,7 +1602,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1940,7 +1618,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param includeOnline Allows an attachment to be seen by the end customer within their online invoice */ - public async createCreditNoteAttachmentByFileName (xeroTenantId: string, creditNoteID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, includeOnline?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async createCreditNoteAttachmentByFileName (xeroTenantId: string, creditNoteID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, includeOnline?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}/Attachments/{FileName}' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -1983,7 +1661,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1992,26 +1670,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2043,7 +1701,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2060,7 +1718,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2073,7 +1732,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createCreditNoteHistory (xeroTenantId: string, creditNoteID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createCreditNoteHistory (xeroTenantId: string, creditNoteID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}/History' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))); let localVarQueryParameters: any = {}; @@ -2105,7 +1764,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2114,26 +1773,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2148,7 +1787,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2160,7 +1799,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2174,7 +1814,7 @@ export class AccountingApi { * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async createCreditNotes (xeroTenantId: string, creditNotes: CreditNotes, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: CreditNotes; }> { + public async createCreditNotes (xeroTenantId: string, creditNotes: CreditNotes, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: CreditNotes; }> { const localVarPath = this.basePath + '/CreditNotes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2208,7 +1848,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2217,26 +1857,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(creditNotes, "CreditNotes"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2251,7 +1871,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: CreditNotes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: CreditNotes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2263,7 +1883,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2275,7 +1896,7 @@ export class AccountingApi { * @param currency Currency object in the body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createCurrency (xeroTenantId: string, currency: Currency, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Currencies; }> { + public async createCurrency (xeroTenantId: string, currency: Currency, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Currencies; }> { const localVarPath = this.basePath + '/Currencies'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2301,7 +1922,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2310,26 +1931,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(currency, "Currency"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2344,7 +1945,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Currencies; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Currencies; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2356,7 +1957,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2369,7 +1971,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async createEmployees (xeroTenantId: string, employees: Employees, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Employees; }> { + public async createEmployees (xeroTenantId: string, employees: Employees, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Employees; }> { const localVarPath = this.basePath + '/Employees'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2399,7 +2001,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2408,26 +2010,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(employees, "Employees"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2442,7 +2024,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Employees; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Employees; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2454,7 +2036,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2467,7 +2050,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createExpenseClaimHistory (xeroTenantId: string, expenseClaimID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createExpenseClaimHistory (xeroTenantId: string, expenseClaimID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/ExpenseClaims/{ExpenseClaimID}/History' .replace('{' + 'ExpenseClaimID' + '}', encodeURIComponent(String(expenseClaimID))); let localVarQueryParameters: any = {}; @@ -2499,7 +2082,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2508,26 +2091,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2542,7 +2105,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2554,7 +2117,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2566,7 +2130,7 @@ export class AccountingApi { * @param expenseClaims ExpenseClaims with array of ExpenseClaim object in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createExpenseClaims (xeroTenantId: string, expenseClaims: ExpenseClaims, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ExpenseClaims; }> { + public async createExpenseClaims (xeroTenantId: string, expenseClaims: ExpenseClaims, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ExpenseClaims; }> { const localVarPath = this.basePath + '/ExpenseClaims'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2592,7 +2156,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2601,26 +2165,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(expenseClaims, "ExpenseClaims"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2635,7 +2179,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ExpenseClaims; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ExpenseClaims; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2647,7 +2191,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2662,7 +2207,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param includeOnline Allows an attachment to be seen by the end customer within their online invoice */ - public async createInvoiceAttachmentByFileName (xeroTenantId: string, invoiceID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, includeOnline?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async createInvoiceAttachmentByFileName (xeroTenantId: string, invoiceID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, includeOnline?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}/Attachments/{FileName}' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -2705,7 +2250,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2714,26 +2259,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2765,7 +2290,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2782,7 +2307,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2795,7 +2321,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createInvoiceHistory (xeroTenantId: string, invoiceID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createInvoiceHistory (xeroTenantId: string, invoiceID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}/History' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))); let localVarQueryParameters: any = {}; @@ -2827,7 +2353,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2836,26 +2362,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2870,7 +2376,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2882,7 +2388,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2896,7 +2403,7 @@ export class AccountingApi { * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async createInvoices (xeroTenantId: string, invoices: Invoices, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Invoices; }> { + public async createInvoices (xeroTenantId: string, invoices: Invoices, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Invoices; }> { const localVarPath = this.basePath + '/Invoices'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2930,7 +2437,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2939,26 +2446,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(invoices, "Invoices"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2973,7 +2460,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Invoices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Invoices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2985,7 +2472,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2998,7 +2486,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createItemHistory (xeroTenantId: string, itemID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createItemHistory (xeroTenantId: string, itemID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Items/{ItemID}/History' .replace('{' + 'ItemID' + '}', encodeURIComponent(String(itemID))); let localVarQueryParameters: any = {}; @@ -3030,7 +2518,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3039,26 +2527,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3073,7 +2541,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3085,7 +2553,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3099,7 +2568,7 @@ export class AccountingApi { * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async createItems (xeroTenantId: string, items: Items, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Items; }> { + public async createItems (xeroTenantId: string, items: Items, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Items; }> { const localVarPath = this.basePath + '/Items'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -3133,7 +2602,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3142,26 +2611,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(items, "Items"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3176,7 +2625,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Items; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Items; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3188,7 +2637,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3200,7 +2650,7 @@ export class AccountingApi { * @param linkedTransaction LinkedTransaction object in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createLinkedTransaction (xeroTenantId: string, linkedTransaction: LinkedTransaction, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LinkedTransactions; }> { + public async createLinkedTransaction (xeroTenantId: string, linkedTransaction: LinkedTransaction, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LinkedTransactions; }> { const localVarPath = this.basePath + '/LinkedTransactions'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -3226,7 +2676,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3235,26 +2685,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(linkedTransaction, "LinkedTransaction"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3269,7 +2699,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LinkedTransactions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LinkedTransactions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3281,7 +2711,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3295,7 +2726,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createManualJournalAttachmentByFileName (xeroTenantId: string, manualJournalID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async createManualJournalAttachmentByFileName (xeroTenantId: string, manualJournalID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/ManualJournals/{ManualJournalID}/Attachments/{FileName}' .replace('{' + 'ManualJournalID' + '}', encodeURIComponent(String(manualJournalID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -3334,7 +2765,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3343,26 +2774,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3394,7 +2805,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3411,7 +2822,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3424,7 +2836,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createManualJournalHistoryRecord (xeroTenantId: string, manualJournalID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createManualJournalHistoryRecord (xeroTenantId: string, manualJournalID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/ManualJournals/{ManualJournalID}/History' .replace('{' + 'ManualJournalID' + '}', encodeURIComponent(String(manualJournalID))); let localVarQueryParameters: any = {}; @@ -3456,7 +2868,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3465,26 +2877,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3499,7 +2891,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3511,7 +2903,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3524,7 +2917,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async createManualJournals (xeroTenantId: string, manualJournals: ManualJournals, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ManualJournals; }> { + public async createManualJournals (xeroTenantId: string, manualJournals: ManualJournals, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ManualJournals; }> { const localVarPath = this.basePath + '/ManualJournals'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -3554,7 +2947,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3563,26 +2956,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(manualJournals, "ManualJournals"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3597,7 +2970,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ManualJournals; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ManualJournals; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3609,7 +2982,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3623,7 +2997,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async createOverpaymentAllocations (xeroTenantId: string, overpaymentID: string, allocations: Allocations, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Allocations; }> { + public async createOverpaymentAllocations (xeroTenantId: string, overpaymentID: string, allocations: Allocations, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Allocations; }> { const localVarPath = this.basePath + '/Overpayments/{OverpaymentID}/Allocations' .replace('{' + 'OverpaymentID' + '}', encodeURIComponent(String(overpaymentID))); let localVarQueryParameters: any = {}; @@ -3659,7 +3033,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3668,26 +3042,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(allocations, "Allocations"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3702,7 +3056,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Allocations; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Allocations; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3714,7 +3068,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3727,7 +3082,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createOverpaymentHistory (xeroTenantId: string, overpaymentID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createOverpaymentHistory (xeroTenantId: string, overpaymentID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Overpayments/{OverpaymentID}/History' .replace('{' + 'OverpaymentID' + '}', encodeURIComponent(String(overpaymentID))); let localVarQueryParameters: any = {}; @@ -3759,7 +3114,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3768,26 +3123,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3802,7 +3137,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3814,7 +3149,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3826,7 +3162,7 @@ export class AccountingApi { * @param payment Request body with a single Payment object * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPayment (xeroTenantId: string, payment: Payment, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Payments; }> { + public async createPayment (xeroTenantId: string, payment: Payment, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Payments; }> { const localVarPath = this.basePath + '/Payments'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -3852,7 +3188,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3861,26 +3197,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(payment, "Payment"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3895,7 +3211,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Payments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Payments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3907,7 +3223,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3920,7 +3237,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPaymentHistory (xeroTenantId: string, paymentID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createPaymentHistory (xeroTenantId: string, paymentID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Payments/{PaymentID}/History' .replace('{' + 'PaymentID' + '}', encodeURIComponent(String(paymentID))); let localVarQueryParameters: any = {}; @@ -3952,7 +3269,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3961,26 +3278,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3995,7 +3292,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4007,7 +3304,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4019,7 +3317,7 @@ export class AccountingApi { * @param paymentServices PaymentServices array with PaymentService object in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPaymentService (xeroTenantId: string, paymentServices: PaymentServices, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PaymentServices; }> { + public async createPaymentService (xeroTenantId: string, paymentServices: PaymentServices, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PaymentServices; }> { const localVarPath = this.basePath + '/PaymentServices'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -4045,7 +3343,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4054,26 +3352,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(paymentServices, "PaymentServices"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4088,7 +3366,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PaymentServices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PaymentServices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4100,7 +3378,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4113,7 +3392,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async createPayments (xeroTenantId: string, payments: Payments, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Payments; }> { + public async createPayments (xeroTenantId: string, payments: Payments, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Payments; }> { const localVarPath = this.basePath + '/Payments'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -4143,7 +3422,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4152,26 +3431,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(payments, "Payments"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4186,7 +3445,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Payments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Payments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4198,7 +3457,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4212,7 +3472,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async createPrepaymentAllocations (xeroTenantId: string, prepaymentID: string, allocations: Allocations, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Allocations; }> { + public async createPrepaymentAllocations (xeroTenantId: string, prepaymentID: string, allocations: Allocations, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Allocations; }> { const localVarPath = this.basePath + '/Prepayments/{PrepaymentID}/Allocations' .replace('{' + 'PrepaymentID' + '}', encodeURIComponent(String(prepaymentID))); let localVarQueryParameters: any = {}; @@ -4248,7 +3508,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4257,26 +3517,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(allocations, "Allocations"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4291,7 +3531,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Allocations; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Allocations; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4303,7 +3543,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4316,7 +3557,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPrepaymentHistory (xeroTenantId: string, prepaymentID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createPrepaymentHistory (xeroTenantId: string, prepaymentID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Prepayments/{PrepaymentID}/History' .replace('{' + 'PrepaymentID' + '}', encodeURIComponent(String(prepaymentID))); let localVarQueryParameters: any = {}; @@ -4348,7 +3589,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4357,26 +3598,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4391,7 +3612,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4403,7 +3624,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4417,7 +3639,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPurchaseOrderAttachmentByFileName (xeroTenantId: string, purchaseOrderID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async createPurchaseOrderAttachmentByFileName (xeroTenantId: string, purchaseOrderID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/PurchaseOrders/{PurchaseOrderID}/Attachments/{FileName}' .replace('{' + 'PurchaseOrderID' + '}', encodeURIComponent(String(purchaseOrderID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -4456,7 +3678,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4465,26 +3687,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4516,7 +3718,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4533,7 +3735,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4546,7 +3749,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPurchaseOrderHistory (xeroTenantId: string, purchaseOrderID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createPurchaseOrderHistory (xeroTenantId: string, purchaseOrderID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/PurchaseOrders/{PurchaseOrderID}/History' .replace('{' + 'PurchaseOrderID' + '}', encodeURIComponent(String(purchaseOrderID))); let localVarQueryParameters: any = {}; @@ -4578,7 +3781,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4587,26 +3790,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4621,7 +3804,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4633,7 +3816,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4646,7 +3830,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async createPurchaseOrders (xeroTenantId: string, purchaseOrders: PurchaseOrders, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }> { + public async createPurchaseOrders (xeroTenantId: string, purchaseOrders: PurchaseOrders, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PurchaseOrders; }> { const localVarPath = this.basePath + '/PurchaseOrders'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -4676,7 +3860,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4685,26 +3869,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(purchaseOrders, "PurchaseOrders"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4719,7 +3883,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PurchaseOrders; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4731,7 +3895,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4745,7 +3910,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createQuoteAttachmentByFileName (xeroTenantId: string, quoteID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async createQuoteAttachmentByFileName (xeroTenantId: string, quoteID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Quotes/{QuoteID}/Attachments/{FileName}' .replace('{' + 'QuoteID' + '}', encodeURIComponent(String(quoteID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -4784,7 +3949,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4793,26 +3958,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4844,7 +3989,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4861,7 +4006,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4874,7 +4020,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createQuoteHistory (xeroTenantId: string, quoteID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createQuoteHistory (xeroTenantId: string, quoteID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Quotes/{QuoteID}/History' .replace('{' + 'QuoteID' + '}', encodeURIComponent(String(quoteID))); let localVarQueryParameters: any = {}; @@ -4906,7 +4052,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4915,26 +4061,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4949,7 +4075,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4961,7 +4087,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4974,7 +4101,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async createQuotes (xeroTenantId: string, quotes: Quotes, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Quotes; }> { + public async createQuotes (xeroTenantId: string, quotes: Quotes, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Quotes; }> { const localVarPath = this.basePath + '/Quotes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5004,7 +4131,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5013,26 +4140,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(quotes, "Quotes"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5047,7 +4154,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Quotes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Quotes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5059,7 +4166,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5072,7 +4180,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async createReceipt (xeroTenantId: string, receipts: Receipts, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Receipts; }> { + public async createReceipt (xeroTenantId: string, receipts: Receipts, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Receipts; }> { const localVarPath = this.basePath + '/Receipts'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5102,7 +4210,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5111,26 +4219,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(receipts, "Receipts"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5145,7 +4233,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Receipts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Receipts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5157,7 +4245,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5171,7 +4260,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createReceiptAttachmentByFileName (xeroTenantId: string, receiptID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async createReceiptAttachmentByFileName (xeroTenantId: string, receiptID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Receipts/{ReceiptID}/Attachments/{FileName}' .replace('{' + 'ReceiptID' + '}', encodeURIComponent(String(receiptID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -5210,7 +4299,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5219,26 +4308,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5270,7 +4339,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5287,7 +4356,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5300,7 +4370,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createReceiptHistory (xeroTenantId: string, receiptID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createReceiptHistory (xeroTenantId: string, receiptID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Receipts/{ReceiptID}/History' .replace('{' + 'ReceiptID' + '}', encodeURIComponent(String(receiptID))); let localVarQueryParameters: any = {}; @@ -5332,7 +4402,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5341,26 +4411,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5375,7 +4425,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5387,7 +4437,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5401,7 +4452,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createRepeatingInvoiceAttachmentByFileName (xeroTenantId: string, repeatingInvoiceID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async createRepeatingInvoiceAttachmentByFileName (xeroTenantId: string, repeatingInvoiceID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/RepeatingInvoices/{RepeatingInvoiceID}/Attachments/{FileName}' .replace('{' + 'RepeatingInvoiceID' + '}', encodeURIComponent(String(repeatingInvoiceID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -5440,7 +4491,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5449,26 +4500,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5500,7 +4531,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5517,7 +4548,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5530,7 +4562,7 @@ export class AccountingApi { * @param historyRecords HistoryRecords containing an array of HistoryRecord objects in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createRepeatingInvoiceHistory (xeroTenantId: string, repeatingInvoiceID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async createRepeatingInvoiceHistory (xeroTenantId: string, repeatingInvoiceID: string, historyRecords: HistoryRecords, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/RepeatingInvoices/{RepeatingInvoiceID}/History' .replace('{' + 'RepeatingInvoiceID' + '}', encodeURIComponent(String(repeatingInvoiceID))); let localVarQueryParameters: any = {}; @@ -5562,7 +4594,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5571,26 +4603,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(historyRecords, "HistoryRecords"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5605,7 +4617,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5617,7 +4629,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5630,7 +4643,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async createRepeatingInvoices (xeroTenantId: string, repeatingInvoices: RepeatingInvoices, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: RepeatingInvoices; }> { + public async createRepeatingInvoices (xeroTenantId: string, repeatingInvoices: RepeatingInvoices, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: RepeatingInvoices; }> { const localVarPath = this.basePath + '/RepeatingInvoices'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5660,7 +4673,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5669,26 +4682,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(repeatingInvoices, "RepeatingInvoices"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5703,7 +4696,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: RepeatingInvoices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: RepeatingInvoices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5715,7 +4708,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5727,7 +4721,7 @@ export class AccountingApi { * @param taxRates TaxRates array with TaxRate object in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createTaxRates (xeroTenantId: string, taxRates: TaxRates, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TaxRates; }> { + public async createTaxRates (xeroTenantId: string, taxRates: TaxRates, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TaxRates; }> { const localVarPath = this.basePath + '/TaxRates'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5753,7 +4747,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5762,26 +4756,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(taxRates, "TaxRates"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5796,7 +4770,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TaxRates; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TaxRates; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5808,7 +4782,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5820,7 +4795,7 @@ export class AccountingApi { * @param trackingCategory TrackingCategory object in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createTrackingCategory (xeroTenantId: string, trackingCategory: TrackingCategory, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TrackingCategories; }> { + public async createTrackingCategory (xeroTenantId: string, trackingCategory: TrackingCategory, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TrackingCategories; }> { const localVarPath = this.basePath + '/TrackingCategories'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5846,7 +4821,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5855,26 +4830,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(trackingCategory, "TrackingCategory"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5889,7 +4844,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TrackingCategories; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TrackingCategories; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5901,7 +4856,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5914,7 +4870,7 @@ export class AccountingApi { * @param trackingOption TrackingOption object in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createTrackingOptions (xeroTenantId: string, trackingCategoryID: string, trackingOption: TrackingOption, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TrackingOptions; }> { + public async createTrackingOptions (xeroTenantId: string, trackingCategoryID: string, trackingOption: TrackingOption, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TrackingOptions; }> { const localVarPath = this.basePath + '/TrackingCategories/{TrackingCategoryID}/Options' .replace('{' + 'TrackingCategoryID' + '}', encodeURIComponent(String(trackingCategoryID))); let localVarQueryParameters: any = {}; @@ -5946,7 +4902,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5955,26 +4911,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(trackingOption, "TrackingOption"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5989,7 +4925,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TrackingOptions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TrackingOptions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6001,7 +4937,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6012,7 +4949,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param accountID Unique identifier for Account object */ - public async deleteAccount (xeroTenantId: string, accountID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Accounts; }> { + public async deleteAccount (xeroTenantId: string, accountID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Accounts; }> { const localVarPath = this.basePath + '/Accounts/{AccountID}' .replace('{' + 'AccountID' + '}', encodeURIComponent(String(accountID))); let localVarQueryParameters: any = {}; @@ -6038,7 +4975,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6047,26 +4984,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6081,7 +4998,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Accounts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Accounts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6093,7 +5010,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6105,7 +5023,7 @@ export class AccountingApi { * @param batchPaymentDelete * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async deleteBatchPayment (xeroTenantId: string, batchPaymentDelete: BatchPaymentDelete, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BatchPayments; }> { + public async deleteBatchPayment (xeroTenantId: string, batchPaymentDelete: BatchPaymentDelete, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BatchPayments; }> { const localVarPath = this.basePath + '/BatchPayments'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -6131,7 +5049,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6140,26 +5058,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(batchPaymentDelete, "BatchPaymentDelete"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6174,7 +5072,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BatchPayments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BatchPayments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6186,7 +5084,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6199,7 +5098,7 @@ export class AccountingApi { * @param batchPaymentDeleteByUrlParam * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async deleteBatchPaymentByUrlParam (xeroTenantId: string, batchPaymentID: string, batchPaymentDeleteByUrlParam: BatchPaymentDeleteByUrlParam, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BatchPayments; }> { + public async deleteBatchPaymentByUrlParam (xeroTenantId: string, batchPaymentID: string, batchPaymentDeleteByUrlParam: BatchPaymentDeleteByUrlParam, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BatchPayments; }> { const localVarPath = this.basePath + '/BatchPayments/{BatchPaymentID}' .replace('{' + 'BatchPaymentID' + '}', encodeURIComponent(String(batchPaymentID))); let localVarQueryParameters: any = {}; @@ -6231,7 +5130,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6240,26 +5139,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(batchPaymentDeleteByUrlParam, "BatchPaymentDeleteByUrlParam"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6274,7 +5153,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BatchPayments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BatchPayments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6286,7 +5165,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6298,7 +5178,7 @@ export class AccountingApi { * @param contactGroupID Unique identifier for a Contact Group * @param contactID Unique identifier for a Contact */ - public async deleteContactGroupContact (xeroTenantId: string, contactGroupID: string, contactID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async deleteContactGroupContact (xeroTenantId: string, contactGroupID: string, contactID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/ContactGroups/{ContactGroupID}/Contacts/{ContactID}' .replace('{' + 'ContactGroupID' + '}', encodeURIComponent(String(contactGroupID))) .replace('{' + 'ContactID' + '}', encodeURIComponent(String(contactID))); @@ -6330,7 +5210,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6339,26 +5219,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6373,7 +5233,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6385,7 +5245,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6396,7 +5257,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param contactGroupID Unique identifier for a Contact Group */ - public async deleteContactGroupContacts (xeroTenantId: string, contactGroupID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async deleteContactGroupContacts (xeroTenantId: string, contactGroupID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/ContactGroups/{ContactGroupID}/Contacts' .replace('{' + 'ContactGroupID' + '}', encodeURIComponent(String(contactGroupID))); let localVarQueryParameters: any = {}; @@ -6421,7 +5282,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6430,26 +5291,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6464,7 +5305,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6476,7 +5317,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6488,7 +5330,7 @@ export class AccountingApi { * @param creditNoteID Unique identifier for a Credit Note * @param allocationID Unique identifier for Allocation object */ - public async deleteCreditNoteAllocations (xeroTenantId: string, creditNoteID: string, allocationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Allocation; }> { + public async deleteCreditNoteAllocations (xeroTenantId: string, creditNoteID: string, allocationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Allocation; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}/Allocations/{AllocationID}' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))) .replace('{' + 'AllocationID' + '}', encodeURIComponent(String(allocationID))); @@ -6520,7 +5362,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6529,26 +5371,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6563,7 +5385,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Allocation; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Allocation; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6575,7 +5397,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6586,7 +5409,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param itemID Unique identifier for an Item */ - public async deleteItem (xeroTenantId: string, itemID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async deleteItem (xeroTenantId: string, itemID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Items/{ItemID}' .replace('{' + 'ItemID' + '}', encodeURIComponent(String(itemID))); let localVarQueryParameters: any = {}; @@ -6612,7 +5435,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6621,26 +5444,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6655,7 +5458,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6667,7 +5470,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6678,7 +5482,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param linkedTransactionID Unique identifier for a LinkedTransaction */ - public async deleteLinkedTransaction (xeroTenantId: string, linkedTransactionID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async deleteLinkedTransaction (xeroTenantId: string, linkedTransactionID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/LinkedTransactions/{LinkedTransactionID}' .replace('{' + 'LinkedTransactionID' + '}', encodeURIComponent(String(linkedTransactionID))); let localVarQueryParameters: any = {}; @@ -6704,7 +5508,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6713,26 +5517,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6747,7 +5531,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6759,7 +5543,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6771,7 +5556,7 @@ export class AccountingApi { * @param overpaymentID Unique identifier for a Overpayment * @param allocationID Unique identifier for Allocation object */ - public async deleteOverpaymentAllocations (xeroTenantId: string, overpaymentID: string, allocationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Allocation; }> { + public async deleteOverpaymentAllocations (xeroTenantId: string, overpaymentID: string, allocationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Allocation; }> { const localVarPath = this.basePath + '/Overpayments/{OverpaymentID}/Allocations/{AllocationID}' .replace('{' + 'OverpaymentID' + '}', encodeURIComponent(String(overpaymentID))) .replace('{' + 'AllocationID' + '}', encodeURIComponent(String(allocationID))); @@ -6803,7 +5588,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6812,26 +5597,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6846,7 +5611,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Allocation; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Allocation; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6858,7 +5623,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6871,7 +5637,7 @@ export class AccountingApi { * @param paymentDelete * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async deletePayment (xeroTenantId: string, paymentID: string, paymentDelete: PaymentDelete, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Payments; }> { + public async deletePayment (xeroTenantId: string, paymentID: string, paymentDelete: PaymentDelete, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Payments; }> { const localVarPath = this.basePath + '/Payments/{PaymentID}' .replace('{' + 'PaymentID' + '}', encodeURIComponent(String(paymentID))); let localVarQueryParameters: any = {}; @@ -6903,7 +5669,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6912,26 +5678,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(paymentDelete, "PaymentDelete"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6946,7 +5692,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Payments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Payments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6958,7 +5704,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6970,7 +5717,7 @@ export class AccountingApi { * @param prepaymentID Unique identifier for a PrePayment * @param allocationID Unique identifier for Allocation object */ - public async deletePrepaymentAllocations (xeroTenantId: string, prepaymentID: string, allocationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Allocation; }> { + public async deletePrepaymentAllocations (xeroTenantId: string, prepaymentID: string, allocationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Allocation; }> { const localVarPath = this.basePath + '/Prepayments/{PrepaymentID}/Allocations/{AllocationID}' .replace('{' + 'PrepaymentID' + '}', encodeURIComponent(String(prepaymentID))) .replace('{' + 'AllocationID' + '}', encodeURIComponent(String(allocationID))); @@ -7002,7 +5749,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -7011,26 +5758,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -7045,7 +5772,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Allocation; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Allocation; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -7057,7 +5784,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -7068,7 +5796,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param trackingCategoryID Unique identifier for a TrackingCategory */ - public async deleteTrackingCategory (xeroTenantId: string, trackingCategoryID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TrackingCategories; }> { + public async deleteTrackingCategory (xeroTenantId: string, trackingCategoryID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TrackingCategories; }> { const localVarPath = this.basePath + '/TrackingCategories/{TrackingCategoryID}' .replace('{' + 'TrackingCategoryID' + '}', encodeURIComponent(String(trackingCategoryID))); let localVarQueryParameters: any = {}; @@ -7094,7 +5822,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -7103,26 +5831,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -7137,7 +5845,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TrackingCategories; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TrackingCategories; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -7149,7 +5857,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -7161,7 +5870,7 @@ export class AccountingApi { * @param trackingCategoryID Unique identifier for a TrackingCategory * @param trackingOptionID Unique identifier for a Tracking Option */ - public async deleteTrackingOptions (xeroTenantId: string, trackingCategoryID: string, trackingOptionID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TrackingOptions; }> { + public async deleteTrackingOptions (xeroTenantId: string, trackingCategoryID: string, trackingOptionID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TrackingOptions; }> { const localVarPath = this.basePath + '/TrackingCategories/{TrackingCategoryID}/Options/{TrackingOptionID}' .replace('{' + 'TrackingCategoryID' + '}', encodeURIComponent(String(trackingCategoryID))) .replace('{' + 'TrackingOptionID' + '}', encodeURIComponent(String(trackingOptionID))); @@ -7193,7 +5902,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -7202,26 +5911,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -7236,7 +5925,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TrackingOptions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TrackingOptions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -7248,7 +5937,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -7261,7 +5951,7 @@ export class AccountingApi { * @param requestEmpty * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async emailInvoice (xeroTenantId: string, invoiceID: string, requestEmpty: RequestEmpty, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async emailInvoice (xeroTenantId: string, invoiceID: string, requestEmpty: RequestEmpty, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}/Email' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))); let localVarQueryParameters: any = {}; @@ -7293,7 +5983,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -7302,26 +5992,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(requestEmpty, "RequestEmpty"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -7336,7 +6006,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -7348,7 +6018,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -7359,7 +6030,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param accountID Unique identifier for Account object */ - public async getAccount (xeroTenantId: string, accountID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Accounts; }> { + public async getAccount (xeroTenantId: string, accountID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Accounts; }> { const localVarPath = this.basePath + '/Accounts/{AccountID}' .replace('{' + 'AccountID' + '}', encodeURIComponent(String(accountID))); let localVarQueryParameters: any = {}; @@ -7385,7 +6056,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -7394,26 +6065,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -7428,7 +6079,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Accounts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Accounts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -7440,7 +6091,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -7453,7 +6105,7 @@ export class AccountingApi { * @param fileName Name of the attachment * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getAccountAttachmentByFileName (xeroTenantId: string, accountID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getAccountAttachmentByFileName (xeroTenantId: string, accountID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Accounts/{AccountID}/Attachments/{FileName}' .replace('{' + 'AccountID' + '}', encodeURIComponent(String(accountID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -7491,36 +6143,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -7535,7 +6166,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -7547,7 +6178,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -7560,7 +6192,7 @@ export class AccountingApi { * @param attachmentID Unique identifier for Attachment object * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getAccountAttachmentById (xeroTenantId: string, accountID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getAccountAttachmentById (xeroTenantId: string, accountID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Accounts/{AccountID}/Attachments/{AttachmentID}' .replace('{' + 'AccountID' + '}', encodeURIComponent(String(accountID))) .replace('{' + 'AttachmentID' + '}', encodeURIComponent(String(attachmentID))); @@ -7598,36 +6230,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -7642,7 +6253,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -7654,7 +6265,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -7665,7 +6277,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param accountID Unique identifier for Account object */ - public async getAccountAttachments (xeroTenantId: string, accountID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async getAccountAttachments (xeroTenantId: string, accountID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Accounts/{AccountID}/Attachments' .replace('{' + 'AccountID' + '}', encodeURIComponent(String(accountID))); let localVarQueryParameters: any = {}; @@ -7691,7 +6303,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -7700,26 +6312,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -7734,7 +6326,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -7751,7 +6343,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -7764,7 +6357,7 @@ export class AccountingApi { * @param where Filter by an any element * @param order Order by an any element */ - public async getAccounts (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Accounts; }> { + public async getAccounts (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Accounts; }> { const localVarPath = this.basePath + '/Accounts'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -7793,7 +6386,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -7802,26 +6395,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -7836,7 +6409,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Accounts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Accounts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -7848,7 +6421,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -7860,7 +6434,7 @@ export class AccountingApi { * @param bankTransactionID Xero generated unique identifier for a bank transaction * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async getBankTransaction (xeroTenantId: string, bankTransactionID: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BankTransactions; }> { + public async getBankTransaction (xeroTenantId: string, bankTransactionID: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BankTransactions; }> { const localVarPath = this.basePath + '/BankTransactions/{BankTransactionID}' .replace('{' + 'BankTransactionID' + '}', encodeURIComponent(String(bankTransactionID))); let localVarQueryParameters: any = {}; @@ -7890,7 +6464,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -7899,26 +6473,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -7933,7 +6487,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BankTransactions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BankTransactions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -7945,7 +6499,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -7958,7 +6513,7 @@ export class AccountingApi { * @param fileName Name of the attachment * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getBankTransactionAttachmentByFileName (xeroTenantId: string, bankTransactionID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getBankTransactionAttachmentByFileName (xeroTenantId: string, bankTransactionID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/BankTransactions/{BankTransactionID}/Attachments/{FileName}' .replace('{' + 'BankTransactionID' + '}', encodeURIComponent(String(bankTransactionID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -7996,36 +6551,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -8040,7 +6574,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -8052,7 +6586,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -8065,7 +6600,7 @@ export class AccountingApi { * @param attachmentID Unique identifier for Attachment object * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getBankTransactionAttachmentById (xeroTenantId: string, bankTransactionID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getBankTransactionAttachmentById (xeroTenantId: string, bankTransactionID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/BankTransactions/{BankTransactionID}/Attachments/{AttachmentID}' .replace('{' + 'BankTransactionID' + '}', encodeURIComponent(String(bankTransactionID))) .replace('{' + 'AttachmentID' + '}', encodeURIComponent(String(attachmentID))); @@ -8103,36 +6638,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -8147,7 +6661,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -8159,7 +6673,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -8170,7 +6685,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param bankTransactionID Xero generated unique identifier for a bank transaction */ - public async getBankTransactionAttachments (xeroTenantId: string, bankTransactionID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async getBankTransactionAttachments (xeroTenantId: string, bankTransactionID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/BankTransactions/{BankTransactionID}/Attachments' .replace('{' + 'BankTransactionID' + '}', encodeURIComponent(String(bankTransactionID))); let localVarQueryParameters: any = {}; @@ -8196,7 +6711,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -8205,26 +6720,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -8239,7 +6734,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -8256,7 +6751,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -8271,7 +6767,7 @@ export class AccountingApi { * @param page Up to 100 bank transactions will be returned in a single API call with line items details * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async getBankTransactions (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BankTransactions; }> { + public async getBankTransactions (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BankTransactions; }> { const localVarPath = this.basePath + '/BankTransactions'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -8308,7 +6804,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -8317,26 +6813,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -8351,7 +6827,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BankTransactions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BankTransactions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -8363,7 +6839,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -8374,7 +6851,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param bankTransactionID Xero generated unique identifier for a bank transaction */ - public async getBankTransactionsHistory (xeroTenantId: string, bankTransactionID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getBankTransactionsHistory (xeroTenantId: string, bankTransactionID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/BankTransactions/{BankTransactionID}/History' .replace('{' + 'BankTransactionID' + '}', encodeURIComponent(String(bankTransactionID))); let localVarQueryParameters: any = {}; @@ -8400,7 +6877,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -8409,26 +6886,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -8443,7 +6900,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -8455,7 +6912,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -8466,7 +6924,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param bankTransferID Xero generated unique identifier for a bank transfer */ - public async getBankTransfer (xeroTenantId: string, bankTransferID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BankTransfers; }> { + public async getBankTransfer (xeroTenantId: string, bankTransferID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BankTransfers; }> { const localVarPath = this.basePath + '/BankTransfers/{BankTransferID}' .replace('{' + 'BankTransferID' + '}', encodeURIComponent(String(bankTransferID))); let localVarQueryParameters: any = {}; @@ -8492,7 +6950,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -8501,26 +6959,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -8535,7 +6973,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BankTransfers; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BankTransfers; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -8547,7 +6985,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -8560,7 +6999,7 @@ export class AccountingApi { * @param fileName Name of the attachment * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getBankTransferAttachmentByFileName (xeroTenantId: string, bankTransferID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getBankTransferAttachmentByFileName (xeroTenantId: string, bankTransferID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/BankTransfers/{BankTransferID}/Attachments/{FileName}' .replace('{' + 'BankTransferID' + '}', encodeURIComponent(String(bankTransferID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -8598,36 +7037,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -8642,7 +7060,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -8654,7 +7072,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -8667,7 +7086,7 @@ export class AccountingApi { * @param attachmentID Unique identifier for Attachment object * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getBankTransferAttachmentById (xeroTenantId: string, bankTransferID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getBankTransferAttachmentById (xeroTenantId: string, bankTransferID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/BankTransfers/{BankTransferID}/Attachments/{AttachmentID}' .replace('{' + 'BankTransferID' + '}', encodeURIComponent(String(bankTransferID))) .replace('{' + 'AttachmentID' + '}', encodeURIComponent(String(attachmentID))); @@ -8705,36 +7124,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -8749,7 +7147,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -8761,7 +7159,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -8772,7 +7171,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param bankTransferID Xero generated unique identifier for a bank transfer */ - public async getBankTransferAttachments (xeroTenantId: string, bankTransferID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async getBankTransferAttachments (xeroTenantId: string, bankTransferID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/BankTransfers/{BankTransferID}/Attachments' .replace('{' + 'BankTransferID' + '}', encodeURIComponent(String(bankTransferID))); let localVarQueryParameters: any = {}; @@ -8798,7 +7197,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -8807,26 +7206,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -8841,7 +7220,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -8858,7 +7237,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -8869,7 +7249,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param bankTransferID Xero generated unique identifier for a bank transfer */ - public async getBankTransferHistory (xeroTenantId: string, bankTransferID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getBankTransferHistory (xeroTenantId: string, bankTransferID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/BankTransfers/{BankTransferID}/History' .replace('{' + 'BankTransferID' + '}', encodeURIComponent(String(bankTransferID))); let localVarQueryParameters: any = {}; @@ -8895,7 +7275,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -8904,26 +7284,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -8938,7 +7298,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -8950,7 +7310,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -8963,7 +7324,7 @@ export class AccountingApi { * @param where Filter by an any element * @param order Order by an any element */ - public async getBankTransfers (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BankTransfers; }> { + public async getBankTransfers (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BankTransfers; }> { const localVarPath = this.basePath + '/BankTransfers'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -8992,7 +7353,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -9001,26 +7362,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -9035,7 +7376,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BankTransfers; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BankTransfers; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -9047,7 +7388,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -9058,7 +7400,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param batchPaymentID Unique identifier for BatchPayment */ - public async getBatchPayment (xeroTenantId: string, batchPaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BatchPayments; }> { + public async getBatchPayment (xeroTenantId: string, batchPaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BatchPayments; }> { const localVarPath = this.basePath + '/BatchPayments/{BatchPaymentID}' .replace('{' + 'BatchPaymentID' + '}', encodeURIComponent(String(batchPaymentID))); let localVarQueryParameters: any = {}; @@ -9084,7 +7426,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -9093,26 +7435,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -9127,7 +7449,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BatchPayments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BatchPayments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -9139,7 +7461,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -9150,7 +7473,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param batchPaymentID Unique identifier for BatchPayment */ - public async getBatchPaymentHistory (xeroTenantId: string, batchPaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getBatchPaymentHistory (xeroTenantId: string, batchPaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/BatchPayments/{BatchPaymentID}/History' .replace('{' + 'BatchPaymentID' + '}', encodeURIComponent(String(batchPaymentID))); let localVarQueryParameters: any = {}; @@ -9176,7 +7499,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -9185,26 +7508,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -9219,7 +7522,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -9231,7 +7534,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -9244,7 +7548,7 @@ export class AccountingApi { * @param where Filter by an any element * @param order Order by an any element */ - public async getBatchPayments (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BatchPayments; }> { + public async getBatchPayments (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BatchPayments; }> { const localVarPath = this.basePath + '/BatchPayments'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -9273,7 +7577,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -9282,26 +7586,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -9316,7 +7600,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BatchPayments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BatchPayments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -9328,7 +7612,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -9339,7 +7624,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param brandingThemeID Unique identifier for a Branding Theme */ - public async getBrandingTheme (xeroTenantId: string, brandingThemeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BrandingThemes; }> { + public async getBrandingTheme (xeroTenantId: string, brandingThemeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BrandingThemes; }> { const localVarPath = this.basePath + '/BrandingThemes/{BrandingThemeID}' .replace('{' + 'BrandingThemeID' + '}', encodeURIComponent(String(brandingThemeID))); let localVarQueryParameters: any = {}; @@ -9365,7 +7650,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -9374,26 +7659,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -9408,7 +7673,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BrandingThemes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BrandingThemes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -9420,7 +7685,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -9431,7 +7697,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param brandingThemeID Unique identifier for a Branding Theme */ - public async getBrandingThemePaymentServices (xeroTenantId: string, brandingThemeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PaymentServices; }> { + public async getBrandingThemePaymentServices (xeroTenantId: string, brandingThemeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PaymentServices; }> { const localVarPath = this.basePath + '/BrandingThemes/{BrandingThemeID}/PaymentServices' .replace('{' + 'BrandingThemeID' + '}', encodeURIComponent(String(brandingThemeID))); let localVarQueryParameters: any = {}; @@ -9457,7 +7723,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -9466,26 +7732,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -9500,7 +7746,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PaymentServices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PaymentServices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -9512,7 +7758,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -9522,7 +7769,7 @@ export class AccountingApi { * @summary Retrieves all the branding themes * @param xeroTenantId Xero identifier for Tenant */ - public async getBrandingThemes (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BrandingThemes; }> { + public async getBrandingThemes (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BrandingThemes; }> { const localVarPath = this.basePath + '/BrandingThemes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -9542,7 +7789,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -9551,26 +7798,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -9585,7 +7812,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BrandingThemes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BrandingThemes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -9597,7 +7824,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -9610,7 +7838,7 @@ export class AccountingApi { * @param dateTo Filter by start date * @param dateFrom Filter by end date */ - public async getBudget (xeroTenantId: string, budgetID: string, dateTo?: string, dateFrom?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Budgets; }> { + public async getBudget (xeroTenantId: string, budgetID: string, dateTo?: string, dateFrom?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Budgets; }> { const localVarPath = this.basePath + '/Budgets/{BudgetID}' .replace('{' + 'BudgetID' + '}', encodeURIComponent(String(budgetID))); let localVarQueryParameters: any = {}; @@ -9644,7 +7872,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -9653,26 +7881,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -9687,7 +7895,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Budgets; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Budgets; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -9699,7 +7907,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -9712,7 +7921,7 @@ export class AccountingApi { * @param dateTo Filter by start date * @param dateFrom Filter by end date */ - public async getBudgets (xeroTenantId: string, iDs?: Array, dateTo?: string, dateFrom?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Budgets; }> { + public async getBudgets (xeroTenantId: string, iDs?: Array, dateTo?: string, dateFrom?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Budgets; }> { const localVarPath = this.basePath + '/Budgets'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -9744,7 +7953,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -9753,26 +7962,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -9787,7 +7976,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Budgets; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Budgets; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -9799,7 +7988,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -9810,7 +8000,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param contactID Unique identifier for a Contact */ - public async getContact (xeroTenantId: string, contactID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Contacts; }> { + public async getContact (xeroTenantId: string, contactID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Contacts; }> { const localVarPath = this.basePath + '/Contacts/{ContactID}' .replace('{' + 'ContactID' + '}', encodeURIComponent(String(contactID))); let localVarQueryParameters: any = {}; @@ -9836,7 +8026,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -9845,26 +8035,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -9879,7 +8049,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Contacts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Contacts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -9891,7 +8061,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -9904,7 +8075,7 @@ export class AccountingApi { * @param fileName Name of the attachment * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getContactAttachmentByFileName (xeroTenantId: string, contactID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getContactAttachmentByFileName (xeroTenantId: string, contactID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Contacts/{ContactID}/Attachments/{FileName}' .replace('{' + 'ContactID' + '}', encodeURIComponent(String(contactID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -9942,36 +8113,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -9986,7 +8136,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -9998,7 +8148,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -10011,7 +8162,7 @@ export class AccountingApi { * @param attachmentID Unique identifier for Attachment object * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getContactAttachmentById (xeroTenantId: string, contactID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getContactAttachmentById (xeroTenantId: string, contactID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Contacts/{ContactID}/Attachments/{AttachmentID}' .replace('{' + 'ContactID' + '}', encodeURIComponent(String(contactID))) .replace('{' + 'AttachmentID' + '}', encodeURIComponent(String(attachmentID))); @@ -10049,36 +8200,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -10093,7 +8223,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -10105,7 +8235,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -10116,7 +8247,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param contactID Unique identifier for a Contact */ - public async getContactAttachments (xeroTenantId: string, contactID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async getContactAttachments (xeroTenantId: string, contactID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Contacts/{ContactID}/Attachments' .replace('{' + 'ContactID' + '}', encodeURIComponent(String(contactID))); let localVarQueryParameters: any = {}; @@ -10142,7 +8273,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -10151,26 +8282,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -10185,7 +8296,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -10202,7 +8313,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -10213,7 +8325,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param contactNumber This field is read only on the Xero contact screen, used to identify contacts in external systems (max length = 50). */ - public async getContactByContactNumber (xeroTenantId: string, contactNumber: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Contacts; }> { + public async getContactByContactNumber (xeroTenantId: string, contactNumber: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Contacts; }> { const localVarPath = this.basePath + '/Contacts/{ContactNumber}' .replace('{' + 'ContactNumber' + '}', encodeURIComponent(String(contactNumber))); let localVarQueryParameters: any = {}; @@ -10239,7 +8351,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -10248,26 +8360,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -10282,7 +8374,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Contacts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Contacts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -10294,7 +8386,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -10305,7 +8398,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param contactID Unique identifier for a Contact */ - public async getContactCISSettings (xeroTenantId: string, contactID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: CISSettings; }> { + public async getContactCISSettings (xeroTenantId: string, contactID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: CISSettings; }> { const localVarPath = this.basePath + '/Contacts/{ContactID}/CISSettings' .replace('{' + 'ContactID' + '}', encodeURIComponent(String(contactID))); let localVarQueryParameters: any = {}; @@ -10331,7 +8424,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -10340,26 +8433,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -10374,7 +8447,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: CISSettings; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: CISSettings; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -10386,7 +8459,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -10397,7 +8471,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param contactGroupID Unique identifier for a Contact Group */ - public async getContactGroup (xeroTenantId: string, contactGroupID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ContactGroups; }> { + public async getContactGroup (xeroTenantId: string, contactGroupID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ContactGroups; }> { const localVarPath = this.basePath + '/ContactGroups/{ContactGroupID}' .replace('{' + 'ContactGroupID' + '}', encodeURIComponent(String(contactGroupID))); let localVarQueryParameters: any = {}; @@ -10423,7 +8497,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -10432,26 +8506,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -10466,7 +8520,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ContactGroups; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ContactGroups; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -10478,7 +8532,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -10490,7 +8545,7 @@ export class AccountingApi { * @param where Filter by an any element * @param order Order by an any element */ - public async getContactGroups (xeroTenantId: string, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ContactGroups; }> { + public async getContactGroups (xeroTenantId: string, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ContactGroups; }> { const localVarPath = this.basePath + '/ContactGroups'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -10518,7 +8573,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -10527,26 +8582,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -10561,7 +8596,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ContactGroups; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ContactGroups; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -10573,7 +8608,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -10584,7 +8620,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param contactID Unique identifier for a Contact */ - public async getContactHistory (xeroTenantId: string, contactID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getContactHistory (xeroTenantId: string, contactID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Contacts/{ContactID}/History' .replace('{' + 'ContactID' + '}', encodeURIComponent(String(contactID))); let localVarQueryParameters: any = {}; @@ -10610,7 +8646,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -10619,26 +8655,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -10653,7 +8669,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -10665,7 +8681,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -10683,7 +8700,7 @@ export class AccountingApi { * @param summaryOnly Use summaryOnly=true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient. * @param searchTerm Search parameter that performs a case-insensitive text search across the Name, FirstName, LastName, ContactNumber and EmailAddress fields. */ - public async getContacts (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, iDs?: Array, page?: number, includeArchived?: boolean, summaryOnly?: boolean, searchTerm?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Contacts; }> { + public async getContacts (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, iDs?: Array, page?: number, includeArchived?: boolean, summaryOnly?: boolean, searchTerm?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Contacts; }> { const localVarPath = this.basePath + '/Contacts'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -10732,7 +8749,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -10741,26 +8758,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -10775,7 +8772,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Contacts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Contacts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -10787,7 +8784,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -10799,7 +8797,7 @@ export class AccountingApi { * @param creditNoteID Unique identifier for a Credit Note * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async getCreditNote (xeroTenantId: string, creditNoteID: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: CreditNotes; }> { + public async getCreditNote (xeroTenantId: string, creditNoteID: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: CreditNotes; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))); let localVarQueryParameters: any = {}; @@ -10829,7 +8827,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -10838,26 +8836,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -10872,7 +8850,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: CreditNotes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: CreditNotes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -10884,7 +8862,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -10895,7 +8874,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param creditNoteID Unique identifier for a Credit Note */ - public async getCreditNoteAsPdf (xeroTenantId: string, creditNoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getCreditNoteAsPdf (xeroTenantId: string, creditNoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))); let localVarQueryParameters: any = {}; @@ -10921,36 +8900,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -10965,7 +8923,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -10977,7 +8935,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -10990,7 +8949,7 @@ export class AccountingApi { * @param fileName Name of the attachment * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getCreditNoteAttachmentByFileName (xeroTenantId: string, creditNoteID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getCreditNoteAttachmentByFileName (xeroTenantId: string, creditNoteID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}/Attachments/{FileName}' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -11028,36 +8987,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -11072,7 +9010,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -11084,7 +9022,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -11097,7 +9036,7 @@ export class AccountingApi { * @param attachmentID Unique identifier for Attachment object * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getCreditNoteAttachmentById (xeroTenantId: string, creditNoteID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getCreditNoteAttachmentById (xeroTenantId: string, creditNoteID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}/Attachments/{AttachmentID}' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))) .replace('{' + 'AttachmentID' + '}', encodeURIComponent(String(attachmentID))); @@ -11135,36 +9074,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -11179,7 +9097,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -11191,7 +9109,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -11202,7 +9121,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param creditNoteID Unique identifier for a Credit Note */ - public async getCreditNoteAttachments (xeroTenantId: string, creditNoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async getCreditNoteAttachments (xeroTenantId: string, creditNoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}/Attachments' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))); let localVarQueryParameters: any = {}; @@ -11228,7 +9147,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -11237,26 +9156,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -11271,7 +9170,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -11288,7 +9187,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -11299,7 +9199,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param creditNoteID Unique identifier for a Credit Note */ - public async getCreditNoteHistory (xeroTenantId: string, creditNoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getCreditNoteHistory (xeroTenantId: string, creditNoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}/History' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))); let localVarQueryParameters: any = {}; @@ -11325,7 +9225,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -11334,26 +9234,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -11368,7 +9248,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -11380,7 +9260,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -11395,7 +9276,7 @@ export class AccountingApi { * @param page e.g. page=1 – Up to 100 credit notes will be returned in a single API call with line items shown for each credit note * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async getCreditNotes (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: CreditNotes; }> { + public async getCreditNotes (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: CreditNotes; }> { const localVarPath = this.basePath + '/CreditNotes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -11432,7 +9313,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -11441,26 +9322,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -11475,7 +9336,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: CreditNotes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: CreditNotes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -11487,7 +9348,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -11499,7 +9361,7 @@ export class AccountingApi { * @param where Filter by an any element * @param order Order by an any element */ - public async getCurrencies (xeroTenantId: string, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Currencies; }> { + public async getCurrencies (xeroTenantId: string, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Currencies; }> { const localVarPath = this.basePath + '/Currencies'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -11527,7 +9389,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -11536,26 +9398,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -11570,7 +9412,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Currencies; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Currencies; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -11582,7 +9424,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -11593,7 +9436,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Unique identifier for a Employee */ - public async getEmployee (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Employees; }> { + public async getEmployee (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Employees; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -11619,7 +9462,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -11628,26 +9471,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -11662,7 +9485,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Employees; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Employees; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -11674,7 +9497,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -11687,7 +9511,7 @@ export class AccountingApi { * @param where Filter by an any element * @param order Order by an any element */ - public async getEmployees (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Employees; }> { + public async getEmployees (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Employees; }> { const localVarPath = this.basePath + '/Employees'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -11716,7 +9540,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -11725,26 +9549,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -11759,7 +9563,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Employees; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Employees; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -11771,7 +9575,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -11782,7 +9587,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param expenseClaimID Unique identifier for a ExpenseClaim */ - public async getExpenseClaim (xeroTenantId: string, expenseClaimID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ExpenseClaims; }> { + public async getExpenseClaim (xeroTenantId: string, expenseClaimID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ExpenseClaims; }> { const localVarPath = this.basePath + '/ExpenseClaims/{ExpenseClaimID}' .replace('{' + 'ExpenseClaimID' + '}', encodeURIComponent(String(expenseClaimID))); let localVarQueryParameters: any = {}; @@ -11808,7 +9613,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -11817,26 +9622,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -11851,7 +9636,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ExpenseClaims; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ExpenseClaims; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -11863,7 +9648,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -11874,7 +9660,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param expenseClaimID Unique identifier for a ExpenseClaim */ - public async getExpenseClaimHistory (xeroTenantId: string, expenseClaimID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getExpenseClaimHistory (xeroTenantId: string, expenseClaimID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/ExpenseClaims/{ExpenseClaimID}/History' .replace('{' + 'ExpenseClaimID' + '}', encodeURIComponent(String(expenseClaimID))); let localVarQueryParameters: any = {}; @@ -11900,7 +9686,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -11909,26 +9695,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -11943,7 +9709,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -11955,7 +9721,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -11968,7 +9735,7 @@ export class AccountingApi { * @param where Filter by an any element * @param order Order by an any element */ - public async getExpenseClaims (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ExpenseClaims; }> { + public async getExpenseClaims (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ExpenseClaims; }> { const localVarPath = this.basePath + '/ExpenseClaims'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -11997,7 +9764,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -12006,26 +9773,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -12040,7 +9787,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ExpenseClaims; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ExpenseClaims; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -12052,7 +9799,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -12064,7 +9812,7 @@ export class AccountingApi { * @param invoiceID Unique identifier for an Invoice * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async getInvoice (xeroTenantId: string, invoiceID: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Invoices; }> { + public async getInvoice (xeroTenantId: string, invoiceID: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Invoices; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))); let localVarQueryParameters: any = {}; @@ -12094,7 +9842,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -12103,26 +9851,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -12137,7 +9865,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Invoices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Invoices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -12149,7 +9877,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -12160,7 +9889,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param invoiceID Unique identifier for an Invoice */ - public async getInvoiceAsPdf (xeroTenantId: string, invoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getInvoiceAsPdf (xeroTenantId: string, invoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))); let localVarQueryParameters: any = {}; @@ -12186,36 +9915,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -12230,7 +9938,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -12242,7 +9950,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -12255,7 +9964,7 @@ export class AccountingApi { * @param fileName Name of the attachment * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getInvoiceAttachmentByFileName (xeroTenantId: string, invoiceID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getInvoiceAttachmentByFileName (xeroTenantId: string, invoiceID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}/Attachments/{FileName}' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -12293,36 +10002,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -12337,7 +10025,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -12349,7 +10037,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -12362,7 +10051,7 @@ export class AccountingApi { * @param attachmentID Unique identifier for Attachment object * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getInvoiceAttachmentById (xeroTenantId: string, invoiceID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getInvoiceAttachmentById (xeroTenantId: string, invoiceID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}/Attachments/{AttachmentID}' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))) .replace('{' + 'AttachmentID' + '}', encodeURIComponent(String(attachmentID))); @@ -12400,36 +10089,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -12444,7 +10112,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -12456,7 +10124,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -12467,7 +10136,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param invoiceID Unique identifier for an Invoice */ - public async getInvoiceAttachments (xeroTenantId: string, invoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async getInvoiceAttachments (xeroTenantId: string, invoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}/Attachments' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))); let localVarQueryParameters: any = {}; @@ -12493,7 +10162,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -12502,26 +10171,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -12536,7 +10185,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -12553,7 +10202,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -12564,7 +10214,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param invoiceID Unique identifier for an Invoice */ - public async getInvoiceHistory (xeroTenantId: string, invoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getInvoiceHistory (xeroTenantId: string, invoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}/History' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))); let localVarQueryParameters: any = {}; @@ -12590,7 +10240,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -12599,26 +10249,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -12633,7 +10263,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -12645,7 +10275,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -12655,7 +10286,7 @@ export class AccountingApi { * @summary Retrieves invoice reminder settings * @param xeroTenantId Xero identifier for Tenant */ - public async getInvoiceReminders (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: InvoiceReminders; }> { + public async getInvoiceReminders (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: InvoiceReminders; }> { const localVarPath = this.basePath + '/InvoiceReminders/Settings'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -12675,7 +10306,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -12684,26 +10315,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -12718,7 +10329,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: InvoiceReminders; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: InvoiceReminders; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -12730,7 +10341,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -12752,7 +10364,7 @@ export class AccountingApi { * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts * @param summaryOnly Use summaryOnly=true in GET Contacts and Invoices endpoint to retrieve a smaller version of the response object. This returns only lightweight fields, excluding computation-heavy fields from the response, making the API calls quick and efficient. */ - public async getInvoices (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, iDs?: Array, invoiceNumbers?: Array, contactIDs?: Array, statuses?: Array, page?: number, includeArchived?: boolean, createdByMyApp?: boolean, unitdp?: number, summaryOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Invoices; }> { + public async getInvoices (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, iDs?: Array, invoiceNumbers?: Array, contactIDs?: Array, statuses?: Array, page?: number, includeArchived?: boolean, createdByMyApp?: boolean, unitdp?: number, summaryOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Invoices; }> { const localVarPath = this.basePath + '/Invoices'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -12817,7 +10429,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -12826,26 +10438,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -12860,7 +10452,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Invoices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Invoices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -12872,7 +10464,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -12884,7 +10477,7 @@ export class AccountingApi { * @param itemID Unique identifier for an Item * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async getItem (xeroTenantId: string, itemID: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Items; }> { + public async getItem (xeroTenantId: string, itemID: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Items; }> { const localVarPath = this.basePath + '/Items/{ItemID}' .replace('{' + 'ItemID' + '}', encodeURIComponent(String(itemID))); let localVarQueryParameters: any = {}; @@ -12914,7 +10507,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -12923,26 +10516,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -12957,7 +10530,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Items; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Items; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -12969,7 +10542,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -12980,7 +10554,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param itemID Unique identifier for an Item */ - public async getItemHistory (xeroTenantId: string, itemID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getItemHistory (xeroTenantId: string, itemID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Items/{ItemID}/History' .replace('{' + 'ItemID' + '}', encodeURIComponent(String(itemID))); let localVarQueryParameters: any = {}; @@ -13006,7 +10580,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -13015,26 +10589,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -13049,7 +10603,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -13061,7 +10615,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -13075,7 +10630,7 @@ export class AccountingApi { * @param order Order by an any element * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async getItems (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Items; }> { + public async getItems (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Items; }> { const localVarPath = this.basePath + '/Items'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -13108,7 +10663,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -13117,26 +10672,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -13151,7 +10686,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Items; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Items; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -13163,7 +10698,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -13174,7 +10710,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param journalID Unique identifier for a Journal */ - public async getJournal (xeroTenantId: string, journalID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Journals; }> { + public async getJournal (xeroTenantId: string, journalID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Journals; }> { const localVarPath = this.basePath + '/Journals/{JournalID}' .replace('{' + 'JournalID' + '}', encodeURIComponent(String(journalID))); let localVarQueryParameters: any = {}; @@ -13200,7 +10736,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -13209,26 +10745,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -13243,7 +10759,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Journals; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Journals; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -13255,7 +10771,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -13266,7 +10783,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param journalNumber Number of a Journal */ - public async getJournalByNumber (xeroTenantId: string, journalNumber: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Journals; }> { + public async getJournalByNumber (xeroTenantId: string, journalNumber: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Journals; }> { const localVarPath = this.basePath + '/Journals/{JournalNumber}' .replace('{' + 'JournalNumber' + '}', encodeURIComponent(String(journalNumber))); let localVarQueryParameters: any = {}; @@ -13292,7 +10809,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -13301,26 +10818,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -13335,7 +10832,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Journals; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Journals; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -13347,7 +10844,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -13360,7 +10858,7 @@ export class AccountingApi { * @param offset Offset by a specified journal number. e.g. journals with a JournalNumber greater than the offset will be returned * @param paymentsOnly Filter to retrieve journals on a cash basis. Journals are returned on an accrual basis by default. */ - public async getJournals (xeroTenantId: string, ifModifiedSince?: Date, offset?: number, paymentsOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Journals; }> { + public async getJournals (xeroTenantId: string, ifModifiedSince?: Date, offset?: number, paymentsOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Journals; }> { const localVarPath = this.basePath + '/Journals'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -13389,7 +10887,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -13398,26 +10896,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -13432,7 +10910,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Journals; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Journals; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -13444,7 +10922,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -13455,7 +10934,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param linkedTransactionID Unique identifier for a LinkedTransaction */ - public async getLinkedTransaction (xeroTenantId: string, linkedTransactionID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LinkedTransactions; }> { + public async getLinkedTransaction (xeroTenantId: string, linkedTransactionID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LinkedTransactions; }> { const localVarPath = this.basePath + '/LinkedTransactions/{LinkedTransactionID}' .replace('{' + 'LinkedTransactionID' + '}', encodeURIComponent(String(linkedTransactionID))); let localVarQueryParameters: any = {}; @@ -13481,7 +10960,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -13490,26 +10969,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -13524,7 +10983,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LinkedTransactions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LinkedTransactions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -13536,7 +10995,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -13552,7 +11012,7 @@ export class AccountingApi { * @param status Filter by the combination of ContactID and Status. Get the linked transactions associated to a customer and with a status * @param targetTransactionID Filter by the TargetTransactionID. Get all the linked transactions allocated to a particular ACCREC invoice */ - public async getLinkedTransactions (xeroTenantId: string, page?: number, linkedTransactionID?: string, sourceTransactionID?: string, contactID?: string, status?: string, targetTransactionID?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LinkedTransactions; }> { + public async getLinkedTransactions (xeroTenantId: string, page?: number, linkedTransactionID?: string, sourceTransactionID?: string, contactID?: string, status?: string, targetTransactionID?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LinkedTransactions; }> { const localVarPath = this.basePath + '/LinkedTransactions'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -13596,7 +11056,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -13605,26 +11065,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -13639,7 +11079,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LinkedTransactions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LinkedTransactions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -13651,7 +11091,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -13662,7 +11103,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param manualJournalID Unique identifier for a ManualJournal */ - public async getManualJournal (xeroTenantId: string, manualJournalID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ManualJournals; }> { + public async getManualJournal (xeroTenantId: string, manualJournalID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ManualJournals; }> { const localVarPath = this.basePath + '/ManualJournals/{ManualJournalID}' .replace('{' + 'ManualJournalID' + '}', encodeURIComponent(String(manualJournalID))); let localVarQueryParameters: any = {}; @@ -13688,7 +11129,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -13697,26 +11138,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -13731,7 +11152,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ManualJournals; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ManualJournals; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -13743,7 +11164,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -13756,7 +11178,7 @@ export class AccountingApi { * @param fileName Name of the attachment * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getManualJournalAttachmentByFileName (xeroTenantId: string, manualJournalID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getManualJournalAttachmentByFileName (xeroTenantId: string, manualJournalID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/ManualJournals/{ManualJournalID}/Attachments/{FileName}' .replace('{' + 'ManualJournalID' + '}', encodeURIComponent(String(manualJournalID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -13794,36 +11216,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -13838,7 +11239,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -13850,7 +11251,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -13863,7 +11265,7 @@ export class AccountingApi { * @param attachmentID Unique identifier for Attachment object * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getManualJournalAttachmentById (xeroTenantId: string, manualJournalID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getManualJournalAttachmentById (xeroTenantId: string, manualJournalID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/ManualJournals/{ManualJournalID}/Attachments/{AttachmentID}' .replace('{' + 'ManualJournalID' + '}', encodeURIComponent(String(manualJournalID))) .replace('{' + 'AttachmentID' + '}', encodeURIComponent(String(attachmentID))); @@ -13901,36 +11303,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -13945,7 +11326,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -13957,7 +11338,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -13968,7 +11350,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param manualJournalID Unique identifier for a ManualJournal */ - public async getManualJournalAttachments (xeroTenantId: string, manualJournalID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async getManualJournalAttachments (xeroTenantId: string, manualJournalID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/ManualJournals/{ManualJournalID}/Attachments' .replace('{' + 'ManualJournalID' + '}', encodeURIComponent(String(manualJournalID))); let localVarQueryParameters: any = {}; @@ -13994,7 +11376,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -14003,26 +11385,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -14037,7 +11399,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -14054,7 +11416,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -14068,7 +11431,7 @@ export class AccountingApi { * @param order Order by an any element * @param page e.g. page=1 – Up to 100 manual journals will be returned in a single API call with line items shown for each overpayment */ - public async getManualJournals (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ManualJournals; }> { + public async getManualJournals (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ManualJournals; }> { const localVarPath = this.basePath + '/ManualJournals'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -14101,7 +11464,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -14110,26 +11473,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -14144,7 +11487,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ManualJournals; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ManualJournals; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -14156,7 +11499,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -14167,7 +11511,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param manualJournalID Unique identifier for a ManualJournal */ - public async getManualJournalsHistory (xeroTenantId: string, manualJournalID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getManualJournalsHistory (xeroTenantId: string, manualJournalID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/ManualJournals/{ManualJournalID}/History' .replace('{' + 'ManualJournalID' + '}', encodeURIComponent(String(manualJournalID))); let localVarQueryParameters: any = {}; @@ -14193,7 +11537,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -14202,26 +11546,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -14236,7 +11560,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -14248,7 +11572,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -14259,7 +11584,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param invoiceID Unique identifier for an Invoice */ - public async getOnlineInvoice (xeroTenantId: string, invoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: OnlineInvoices; }> { + public async getOnlineInvoice (xeroTenantId: string, invoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: OnlineInvoices; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}/OnlineInvoice' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))); let localVarQueryParameters: any = {}; @@ -14285,7 +11610,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -14294,26 +11619,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -14328,7 +11633,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: OnlineInvoices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: OnlineInvoices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -14340,7 +11645,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -14350,7 +11656,7 @@ export class AccountingApi { * @summary Retrieves a list of the key actions your app has permission to perform in the connected Xero organisation. * @param xeroTenantId Xero identifier for Tenant */ - public async getOrganisationActions (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Actions; }> { + public async getOrganisationActions (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Actions; }> { const localVarPath = this.basePath + '/Organisation/Actions'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -14370,7 +11676,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -14379,26 +11685,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -14413,7 +11699,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Actions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Actions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -14425,7 +11711,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -14436,7 +11723,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param organisationID The unique Xero identifier for an organisation */ - public async getOrganisationCISSettings (xeroTenantId: string, organisationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: CISOrgSettings; }> { + public async getOrganisationCISSettings (xeroTenantId: string, organisationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: CISOrgSettings; }> { const localVarPath = this.basePath + '/Organisation/{OrganisationID}/CISSettings' .replace('{' + 'OrganisationID' + '}', encodeURIComponent(String(organisationID))); let localVarQueryParameters: any = {}; @@ -14462,7 +11749,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -14471,26 +11758,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -14505,7 +11772,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: CISOrgSettings; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: CISOrgSettings; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -14517,7 +11784,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -14527,7 +11795,7 @@ export class AccountingApi { * @summary Retrieves Xero organisation details * @param xeroTenantId Xero identifier for Tenant */ - public async getOrganisations (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Organisations; }> { + public async getOrganisations (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Organisations; }> { const localVarPath = this.basePath + '/Organisation'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -14547,7 +11815,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -14556,26 +11824,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -14590,7 +11838,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Organisations; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Organisations; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -14602,7 +11850,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -14613,7 +11862,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param overpaymentID Unique identifier for a Overpayment */ - public async getOverpayment (xeroTenantId: string, overpaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Overpayments; }> { + public async getOverpayment (xeroTenantId: string, overpaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Overpayments; }> { const localVarPath = this.basePath + '/Overpayments/{OverpaymentID}' .replace('{' + 'OverpaymentID' + '}', encodeURIComponent(String(overpaymentID))); let localVarQueryParameters: any = {}; @@ -14639,7 +11888,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -14648,26 +11897,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -14682,7 +11911,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Overpayments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Overpayments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -14694,7 +11923,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -14705,7 +11935,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param overpaymentID Unique identifier for a Overpayment */ - public async getOverpaymentHistory (xeroTenantId: string, overpaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getOverpaymentHistory (xeroTenantId: string, overpaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Overpayments/{OverpaymentID}/History' .replace('{' + 'OverpaymentID' + '}', encodeURIComponent(String(overpaymentID))); let localVarQueryParameters: any = {}; @@ -14731,7 +11961,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -14740,26 +11970,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -14774,7 +11984,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -14786,7 +11996,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -14801,7 +12012,7 @@ export class AccountingApi { * @param page e.g. page=1 – Up to 100 overpayments will be returned in a single API call with line items shown for each overpayment * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async getOverpayments (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Overpayments; }> { + public async getOverpayments (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Overpayments; }> { const localVarPath = this.basePath + '/Overpayments'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -14838,7 +12049,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -14847,26 +12058,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -14881,7 +12072,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Overpayments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Overpayments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -14893,7 +12084,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -14904,7 +12096,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param paymentID Unique identifier for a Payment */ - public async getPayment (xeroTenantId: string, paymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Payments; }> { + public async getPayment (xeroTenantId: string, paymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Payments; }> { const localVarPath = this.basePath + '/Payments/{PaymentID}' .replace('{' + 'PaymentID' + '}', encodeURIComponent(String(paymentID))); let localVarQueryParameters: any = {}; @@ -14930,7 +12122,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -14939,26 +12131,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -14973,7 +12145,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Payments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Payments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -14985,7 +12157,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -14996,7 +12169,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param paymentID Unique identifier for a Payment */ - public async getPaymentHistory (xeroTenantId: string, paymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getPaymentHistory (xeroTenantId: string, paymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Payments/{PaymentID}/History' .replace('{' + 'PaymentID' + '}', encodeURIComponent(String(paymentID))); let localVarQueryParameters: any = {}; @@ -15022,7 +12195,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -15031,26 +12204,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -15065,7 +12218,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -15077,7 +12230,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -15087,7 +12241,7 @@ export class AccountingApi { * @summary Retrieves payment services * @param xeroTenantId Xero identifier for Tenant */ - public async getPaymentServices (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PaymentServices; }> { + public async getPaymentServices (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PaymentServices; }> { const localVarPath = this.basePath + '/PaymentServices'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -15107,7 +12261,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -15116,26 +12270,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -15150,7 +12284,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PaymentServices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PaymentServices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -15162,7 +12296,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -15176,7 +12311,7 @@ export class AccountingApi { * @param order Order by an any element * @param page Up to 100 payments will be returned in a single API call */ - public async getPayments (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Payments; }> { + public async getPayments (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Payments; }> { const localVarPath = this.basePath + '/Payments'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -15209,7 +12344,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -15218,26 +12353,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -15252,7 +12367,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Payments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Payments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -15264,7 +12379,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -15275,7 +12391,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param prepaymentID Unique identifier for a PrePayment */ - public async getPrepayment (xeroTenantId: string, prepaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Prepayments; }> { + public async getPrepayment (xeroTenantId: string, prepaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Prepayments; }> { const localVarPath = this.basePath + '/Prepayments/{PrepaymentID}' .replace('{' + 'PrepaymentID' + '}', encodeURIComponent(String(prepaymentID))); let localVarQueryParameters: any = {}; @@ -15301,7 +12417,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -15310,26 +12426,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -15344,7 +12440,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Prepayments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Prepayments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -15356,7 +12452,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -15367,7 +12464,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param prepaymentID Unique identifier for a PrePayment */ - public async getPrepaymentHistory (xeroTenantId: string, prepaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getPrepaymentHistory (xeroTenantId: string, prepaymentID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Prepayments/{PrepaymentID}/History' .replace('{' + 'PrepaymentID' + '}', encodeURIComponent(String(prepaymentID))); let localVarQueryParameters: any = {}; @@ -15393,7 +12490,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -15402,26 +12499,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -15436,7 +12513,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -15448,7 +12525,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -15463,7 +12541,7 @@ export class AccountingApi { * @param page e.g. page=1 – Up to 100 prepayments will be returned in a single API call with line items shown for each overpayment * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async getPrepayments (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Prepayments; }> { + public async getPrepayments (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Prepayments; }> { const localVarPath = this.basePath + '/Prepayments'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -15500,7 +12578,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -15509,26 +12587,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -15543,7 +12601,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Prepayments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Prepayments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -15555,7 +12613,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -15566,7 +12625,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param purchaseOrderID Unique identifier for an Purchase Order */ - public async getPurchaseOrder (xeroTenantId: string, purchaseOrderID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }> { + public async getPurchaseOrder (xeroTenantId: string, purchaseOrderID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PurchaseOrders; }> { const localVarPath = this.basePath + '/PurchaseOrders/{PurchaseOrderID}' .replace('{' + 'PurchaseOrderID' + '}', encodeURIComponent(String(purchaseOrderID))); let localVarQueryParameters: any = {}; @@ -15592,7 +12651,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -15601,26 +12660,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -15635,7 +12674,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PurchaseOrders; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -15647,7 +12686,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -15658,7 +12698,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param purchaseOrderID Unique identifier for an Purchase Order */ - public async getPurchaseOrderAsPdf (xeroTenantId: string, purchaseOrderID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getPurchaseOrderAsPdf (xeroTenantId: string, purchaseOrderID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/PurchaseOrders/{PurchaseOrderID}' .replace('{' + 'PurchaseOrderID' + '}', encodeURIComponent(String(purchaseOrderID))); let localVarQueryParameters: any = {}; @@ -15684,36 +12724,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -15728,7 +12747,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -15740,7 +12759,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -15753,7 +12773,7 @@ export class AccountingApi { * @param fileName Name of the attachment * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getPurchaseOrderAttachmentByFileName (xeroTenantId: string, purchaseOrderID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getPurchaseOrderAttachmentByFileName (xeroTenantId: string, purchaseOrderID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/PurchaseOrders/{PurchaseOrderID}/Attachments/{FileName}' .replace('{' + 'PurchaseOrderID' + '}', encodeURIComponent(String(purchaseOrderID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -15791,36 +12811,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -15835,7 +12834,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -15847,7 +12846,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -15860,7 +12860,7 @@ export class AccountingApi { * @param attachmentID Unique identifier for Attachment object * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getPurchaseOrderAttachmentById (xeroTenantId: string, purchaseOrderID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getPurchaseOrderAttachmentById (xeroTenantId: string, purchaseOrderID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/PurchaseOrders/{PurchaseOrderID}/Attachments/{AttachmentID}' .replace('{' + 'PurchaseOrderID' + '}', encodeURIComponent(String(purchaseOrderID))) .replace('{' + 'AttachmentID' + '}', encodeURIComponent(String(attachmentID))); @@ -15898,36 +12898,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -15942,7 +12921,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -15954,7 +12933,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -15965,7 +12945,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param purchaseOrderID Unique identifier for an Purchase Order */ - public async getPurchaseOrderAttachments (xeroTenantId: string, purchaseOrderID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async getPurchaseOrderAttachments (xeroTenantId: string, purchaseOrderID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/PurchaseOrders/{PurchaseOrderID}/Attachments' .replace('{' + 'PurchaseOrderID' + '}', encodeURIComponent(String(purchaseOrderID))); let localVarQueryParameters: any = {}; @@ -15991,7 +12971,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -16000,26 +12980,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -16034,7 +12994,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -16051,7 +13011,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -16062,7 +13023,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param purchaseOrderNumber Unique identifier for a PurchaseOrder */ - public async getPurchaseOrderByNumber (xeroTenantId: string, purchaseOrderNumber: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }> { + public async getPurchaseOrderByNumber (xeroTenantId: string, purchaseOrderNumber: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PurchaseOrders; }> { const localVarPath = this.basePath + '/PurchaseOrders/{PurchaseOrderNumber}' .replace('{' + 'PurchaseOrderNumber' + '}', encodeURIComponent(String(purchaseOrderNumber))); let localVarQueryParameters: any = {}; @@ -16088,7 +13049,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -16097,26 +13058,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -16131,7 +13072,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PurchaseOrders; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -16143,7 +13084,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -16154,7 +13096,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param purchaseOrderID Unique identifier for an Purchase Order */ - public async getPurchaseOrderHistory (xeroTenantId: string, purchaseOrderID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getPurchaseOrderHistory (xeroTenantId: string, purchaseOrderID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/PurchaseOrders/{PurchaseOrderID}/History' .replace('{' + 'PurchaseOrderID' + '}', encodeURIComponent(String(purchaseOrderID))); let localVarQueryParameters: any = {}; @@ -16180,7 +13122,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -16189,26 +13131,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -16223,7 +13145,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -16235,7 +13157,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -16251,7 +13174,7 @@ export class AccountingApi { * @param order Order by an any element * @param page To specify a page, append the page parameter to the URL e.g. ?page=1. If there are 100 records in the response you will need to check if there is any more data by fetching the next page e.g ?page=2 and continuing this process until no more results are returned. */ - public async getPurchaseOrders (xeroTenantId: string, ifModifiedSince?: Date, status?: 'DRAFT' | 'SUBMITTED' | 'AUTHORISED' | 'BILLED' | 'DELETED', dateFrom?: string, dateTo?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }> { + public async getPurchaseOrders (xeroTenantId: string, ifModifiedSince?: Date, status?: 'DRAFT' | 'SUBMITTED' | 'AUTHORISED' | 'BILLED' | 'DELETED', dateFrom?: string, dateTo?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PurchaseOrders; }> { const localVarPath = this.basePath + '/PurchaseOrders'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -16292,7 +13215,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -16301,26 +13224,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -16335,7 +13238,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PurchaseOrders; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -16347,7 +13250,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -16358,7 +13262,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param quoteID Unique identifier for an Quote */ - public async getQuote (xeroTenantId: string, quoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Quotes; }> { + public async getQuote (xeroTenantId: string, quoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Quotes; }> { const localVarPath = this.basePath + '/Quotes/{QuoteID}' .replace('{' + 'QuoteID' + '}', encodeURIComponent(String(quoteID))); let localVarQueryParameters: any = {}; @@ -16384,7 +13288,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -16393,26 +13297,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -16427,7 +13311,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Quotes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Quotes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -16439,7 +13323,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -16450,7 +13335,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param quoteID Unique identifier for an Quote */ - public async getQuoteAsPdf (xeroTenantId: string, quoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getQuoteAsPdf (xeroTenantId: string, quoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Quotes/{QuoteID}' .replace('{' + 'QuoteID' + '}', encodeURIComponent(String(quoteID))); let localVarQueryParameters: any = {}; @@ -16476,36 +13361,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -16520,7 +13384,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -16532,7 +13396,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -16545,7 +13410,7 @@ export class AccountingApi { * @param fileName Name of the attachment * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getQuoteAttachmentByFileName (xeroTenantId: string, quoteID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getQuoteAttachmentByFileName (xeroTenantId: string, quoteID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Quotes/{QuoteID}/Attachments/{FileName}' .replace('{' + 'QuoteID' + '}', encodeURIComponent(String(quoteID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -16583,36 +13448,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -16627,7 +13471,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -16639,7 +13483,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -16652,7 +13497,7 @@ export class AccountingApi { * @param attachmentID Unique identifier for Attachment object * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getQuoteAttachmentById (xeroTenantId: string, quoteID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getQuoteAttachmentById (xeroTenantId: string, quoteID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Quotes/{QuoteID}/Attachments/{AttachmentID}' .replace('{' + 'QuoteID' + '}', encodeURIComponent(String(quoteID))) .replace('{' + 'AttachmentID' + '}', encodeURIComponent(String(attachmentID))); @@ -16690,36 +13535,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -16734,7 +13558,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -16746,7 +13570,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -16757,7 +13582,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param quoteID Unique identifier for an Quote */ - public async getQuoteAttachments (xeroTenantId: string, quoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async getQuoteAttachments (xeroTenantId: string, quoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Quotes/{QuoteID}/Attachments' .replace('{' + 'QuoteID' + '}', encodeURIComponent(String(quoteID))); let localVarQueryParameters: any = {}; @@ -16783,7 +13608,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -16792,26 +13617,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -16826,7 +13631,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -16843,7 +13648,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -16854,7 +13660,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param quoteID Unique identifier for an Quote */ - public async getQuoteHistory (xeroTenantId: string, quoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getQuoteHistory (xeroTenantId: string, quoteID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Quotes/{QuoteID}/History' .replace('{' + 'QuoteID' + '}', encodeURIComponent(String(quoteID))); let localVarQueryParameters: any = {}; @@ -16880,7 +13686,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -16889,26 +13695,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -16923,7 +13709,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -16935,7 +13721,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -16955,7 +13742,7 @@ export class AccountingApi { * @param order Order by an any element * @param quoteNumber Filter by quote number (e.g. GET https://.../Quotes?QuoteNumber=QU-0001) */ - public async getQuotes (xeroTenantId: string, ifModifiedSince?: Date, dateFrom?: string, dateTo?: string, expiryDateFrom?: string, expiryDateTo?: string, contactID?: string, status?: string, page?: number, order?: string, quoteNumber?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Quotes; }> { + public async getQuotes (xeroTenantId: string, ifModifiedSince?: Date, dateFrom?: string, dateTo?: string, expiryDateFrom?: string, expiryDateTo?: string, contactID?: string, status?: string, page?: number, order?: string, quoteNumber?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Quotes; }> { const localVarPath = this.basePath + '/Quotes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -17012,7 +13799,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -17021,26 +13808,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -17055,7 +13822,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Quotes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Quotes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -17067,7 +13834,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -17079,7 +13847,7 @@ export class AccountingApi { * @param receiptID Unique identifier for a Receipt * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async getReceipt (xeroTenantId: string, receiptID: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Receipts; }> { + public async getReceipt (xeroTenantId: string, receiptID: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Receipts; }> { const localVarPath = this.basePath + '/Receipts/{ReceiptID}' .replace('{' + 'ReceiptID' + '}', encodeURIComponent(String(receiptID))); let localVarQueryParameters: any = {}; @@ -17109,7 +13877,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -17118,26 +13886,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -17152,7 +13900,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Receipts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Receipts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -17164,7 +13912,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -17177,7 +13926,7 @@ export class AccountingApi { * @param fileName Name of the attachment * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getReceiptAttachmentByFileName (xeroTenantId: string, receiptID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getReceiptAttachmentByFileName (xeroTenantId: string, receiptID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Receipts/{ReceiptID}/Attachments/{FileName}' .replace('{' + 'ReceiptID' + '}', encodeURIComponent(String(receiptID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -17215,36 +13964,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -17259,7 +13987,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -17271,7 +13999,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -17284,7 +14013,7 @@ export class AccountingApi { * @param attachmentID Unique identifier for Attachment object * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getReceiptAttachmentById (xeroTenantId: string, receiptID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getReceiptAttachmentById (xeroTenantId: string, receiptID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Receipts/{ReceiptID}/Attachments/{AttachmentID}' .replace('{' + 'ReceiptID' + '}', encodeURIComponent(String(receiptID))) .replace('{' + 'AttachmentID' + '}', encodeURIComponent(String(attachmentID))); @@ -17322,36 +14051,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -17366,7 +14074,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -17378,7 +14086,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -17389,7 +14098,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param receiptID Unique identifier for a Receipt */ - public async getReceiptAttachments (xeroTenantId: string, receiptID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async getReceiptAttachments (xeroTenantId: string, receiptID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Receipts/{ReceiptID}/Attachments' .replace('{' + 'ReceiptID' + '}', encodeURIComponent(String(receiptID))); let localVarQueryParameters: any = {}; @@ -17415,7 +14124,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -17424,26 +14133,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -17458,7 +14147,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -17475,7 +14164,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -17486,7 +14176,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param receiptID Unique identifier for a Receipt */ - public async getReceiptHistory (xeroTenantId: string, receiptID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getReceiptHistory (xeroTenantId: string, receiptID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/Receipts/{ReceiptID}/History' .replace('{' + 'ReceiptID' + '}', encodeURIComponent(String(receiptID))); let localVarQueryParameters: any = {}; @@ -17512,7 +14202,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -17521,26 +14211,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -17555,7 +14225,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -17567,7 +14237,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -17581,7 +14252,7 @@ export class AccountingApi { * @param order Order by an any element * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async getReceipts (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Receipts; }> { + public async getReceipts (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Receipts; }> { const localVarPath = this.basePath + '/Receipts'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -17614,7 +14285,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -17623,26 +14294,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -17657,7 +14308,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Receipts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Receipts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -17669,7 +14320,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -17680,7 +14332,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param repeatingInvoiceID Unique identifier for a Repeating Invoice */ - public async getRepeatingInvoice (xeroTenantId: string, repeatingInvoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: RepeatingInvoices; }> { + public async getRepeatingInvoice (xeroTenantId: string, repeatingInvoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: RepeatingInvoices; }> { const localVarPath = this.basePath + '/RepeatingInvoices/{RepeatingInvoiceID}' .replace('{' + 'RepeatingInvoiceID' + '}', encodeURIComponent(String(repeatingInvoiceID))); let localVarQueryParameters: any = {}; @@ -17706,7 +14358,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -17715,26 +14367,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -17749,7 +14381,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: RepeatingInvoices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: RepeatingInvoices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -17761,7 +14393,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -17774,7 +14407,7 @@ export class AccountingApi { * @param fileName Name of the attachment * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getRepeatingInvoiceAttachmentByFileName (xeroTenantId: string, repeatingInvoiceID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getRepeatingInvoiceAttachmentByFileName (xeroTenantId: string, repeatingInvoiceID: string, fileName: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/RepeatingInvoices/{RepeatingInvoiceID}/Attachments/{FileName}' .replace('{' + 'RepeatingInvoiceID' + '}', encodeURIComponent(String(repeatingInvoiceID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -17812,36 +14445,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -17856,7 +14468,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -17868,7 +14480,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -17881,7 +14494,7 @@ export class AccountingApi { * @param attachmentID Unique identifier for Attachment object * @param contentType The mime type of the attachment file you are retrieving i.e image/jpg, application/pdf */ - public async getRepeatingInvoiceAttachmentById (xeroTenantId: string, repeatingInvoiceID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getRepeatingInvoiceAttachmentById (xeroTenantId: string, repeatingInvoiceID: string, attachmentID: string, contentType: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/RepeatingInvoices/{RepeatingInvoiceID}/Attachments/{AttachmentID}' .replace('{' + 'RepeatingInvoiceID' + '}', encodeURIComponent(String(repeatingInvoiceID))) .replace('{' + 'AttachmentID' + '}', encodeURIComponent(String(attachmentID))); @@ -17919,36 +14532,15 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -17963,7 +14555,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -17975,7 +14567,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -17986,7 +14579,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param repeatingInvoiceID Unique identifier for a Repeating Invoice */ - public async getRepeatingInvoiceAttachments (xeroTenantId: string, repeatingInvoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async getRepeatingInvoiceAttachments (xeroTenantId: string, repeatingInvoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/RepeatingInvoices/{RepeatingInvoiceID}/Attachments' .replace('{' + 'RepeatingInvoiceID' + '}', encodeURIComponent(String(repeatingInvoiceID))); let localVarQueryParameters: any = {}; @@ -18012,7 +14605,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -18021,26 +14614,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -18055,7 +14628,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -18072,7 +14645,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -18083,7 +14657,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param repeatingInvoiceID Unique identifier for a Repeating Invoice */ - public async getRepeatingInvoiceHistory (xeroTenantId: string, repeatingInvoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: HistoryRecords; }> { + public async getRepeatingInvoiceHistory (xeroTenantId: string, repeatingInvoiceID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: HistoryRecords; }> { const localVarPath = this.basePath + '/RepeatingInvoices/{RepeatingInvoiceID}/History' .replace('{' + 'RepeatingInvoiceID' + '}', encodeURIComponent(String(repeatingInvoiceID))); let localVarQueryParameters: any = {}; @@ -18109,7 +14683,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -18118,26 +14692,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -18152,7 +14706,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: HistoryRecords; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: HistoryRecords; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -18164,7 +14718,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -18176,7 +14731,7 @@ export class AccountingApi { * @param where Filter by an any element * @param order Order by an any element */ - public async getRepeatingInvoices (xeroTenantId: string, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: RepeatingInvoices; }> { + public async getRepeatingInvoices (xeroTenantId: string, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: RepeatingInvoices; }> { const localVarPath = this.basePath + '/RepeatingInvoices'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -18204,7 +14759,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -18213,26 +14768,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -18247,7 +14782,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: RepeatingInvoices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: RepeatingInvoices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -18259,7 +14794,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -18273,7 +14809,7 @@ export class AccountingApi { * @param fromDate filter by the from date of the report e.g. 2021-02-01 * @param toDate filter by the to date of the report e.g. 2021-02-28 */ - public async getReportAgedPayablesByContact (xeroTenantId: string, contactId: string, date?: string, fromDate?: string, toDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReportWithRows; }> { + public async getReportAgedPayablesByContact (xeroTenantId: string, contactId: string, date?: string, fromDate?: string, toDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReportWithRows; }> { const localVarPath = this.basePath + '/Reports/AgedPayablesByContact'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -18314,7 +14850,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -18323,26 +14859,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -18357,7 +14873,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReportWithRows; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReportWithRows; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -18369,7 +14885,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -18383,7 +14900,7 @@ export class AccountingApi { * @param fromDate filter by the from date of the report e.g. 2021-02-01 * @param toDate filter by the to date of the report e.g. 2021-02-28 */ - public async getReportAgedReceivablesByContact (xeroTenantId: string, contactId: string, date?: string, fromDate?: string, toDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReportWithRows; }> { + public async getReportAgedReceivablesByContact (xeroTenantId: string, contactId: string, date?: string, fromDate?: string, toDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReportWithRows; }> { const localVarPath = this.basePath + '/Reports/AgedReceivablesByContact'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -18424,7 +14941,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -18433,26 +14950,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -18467,7 +14964,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReportWithRows; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReportWithRows; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -18479,7 +14976,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -18496,7 +14994,7 @@ export class AccountingApi { * @param standardLayout The standard layout boolean for the Balance Sheet report * @param paymentsOnly return a cash basis for the Balance Sheet report */ - public async getReportBalanceSheet (xeroTenantId: string, date?: string, periods?: number, timeframe?: 'MONTH' | 'QUARTER' | 'YEAR', trackingOptionID1?: string, trackingOptionID2?: string, standardLayout?: boolean, paymentsOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReportWithRows; }> { + public async getReportBalanceSheet (xeroTenantId: string, date?: string, periods?: number, timeframe?: 'MONTH' | 'QUARTER' | 'YEAR', trackingOptionID1?: string, trackingOptionID2?: string, standardLayout?: boolean, paymentsOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReportWithRows; }> { const localVarPath = this.basePath + '/Reports/BalanceSheet'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -18544,7 +15042,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -18553,26 +15051,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -18587,7 +15065,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReportWithRows; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReportWithRows; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -18599,7 +15077,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -18611,7 +15090,7 @@ export class AccountingApi { * @param fromDate filter by the from date of the report e.g. 2021-02-01 * @param toDate filter by the to date of the report e.g. 2021-02-28 */ - public async getReportBankSummary (xeroTenantId: string, fromDate?: string, toDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReportWithRows; }> { + public async getReportBankSummary (xeroTenantId: string, fromDate?: string, toDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReportWithRows; }> { const localVarPath = this.basePath + '/Reports/BankSummary'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -18639,7 +15118,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -18648,26 +15127,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -18682,7 +15141,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReportWithRows; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReportWithRows; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -18694,7 +15153,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -18707,7 +15167,7 @@ export class AccountingApi { * @param periods The number of periods to compare (integer between 1 and 12) * @param timeframe The period size to compare to (1=month, 3=quarter, 12=year) */ - public async getReportBudgetSummary (xeroTenantId: string, date?: string, periods?: number, timeframe?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReportWithRows; }> { + public async getReportBudgetSummary (xeroTenantId: string, date?: string, periods?: number, timeframe?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReportWithRows; }> { const localVarPath = this.basePath + '/Reports/BudgetSummary'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -18739,7 +15199,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -18748,26 +15208,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -18782,7 +15222,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReportWithRows; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReportWithRows; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -18794,7 +15234,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -18805,7 +15246,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param date The date for the Bank Summary report e.g. 2018-03-31 */ - public async getReportExecutiveSummary (xeroTenantId: string, date?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReportWithRows; }> { + public async getReportExecutiveSummary (xeroTenantId: string, date?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReportWithRows; }> { const localVarPath = this.basePath + '/Reports/ExecutiveSummary'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -18829,7 +15270,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -18838,26 +15279,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -18872,7 +15293,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReportWithRows; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReportWithRows; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -18884,7 +15305,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -18895,7 +15317,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param reportID Unique identifier for a Report */ - public async getReportFromId (xeroTenantId: string, reportID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReportWithRows; }> { + public async getReportFromId (xeroTenantId: string, reportID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReportWithRows; }> { const localVarPath = this.basePath + '/Reports/{ReportID}' .replace('{' + 'ReportID' + '}', encodeURIComponent(String(reportID))); let localVarQueryParameters: any = {}; @@ -18921,7 +15343,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -18930,26 +15352,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -18964,7 +15366,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReportWithRows; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReportWithRows; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -18976,7 +15378,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -18996,7 +15399,7 @@ export class AccountingApi { * @param standardLayout Return the standard layout for the ProfitAndLoss report * @param paymentsOnly Return cash only basis for the ProfitAndLoss report */ - public async getReportProfitAndLoss (xeroTenantId: string, fromDate?: string, toDate?: string, periods?: number, timeframe?: 'MONTH' | 'QUARTER' | 'YEAR', trackingCategoryID?: string, trackingCategoryID2?: string, trackingOptionID?: string, trackingOptionID2?: string, standardLayout?: boolean, paymentsOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReportWithRows; }> { + public async getReportProfitAndLoss (xeroTenantId: string, fromDate?: string, toDate?: string, periods?: number, timeframe?: 'MONTH' | 'QUARTER' | 'YEAR', trackingCategoryID?: string, trackingCategoryID2?: string, trackingOptionID?: string, trackingOptionID2?: string, standardLayout?: boolean, paymentsOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReportWithRows; }> { const localVarPath = this.basePath + '/Reports/ProfitAndLoss'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -19056,7 +15459,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -19065,26 +15468,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -19099,7 +15482,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReportWithRows; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReportWithRows; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -19111,7 +15494,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -19122,7 +15506,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param reportYear The year of the 1099 report */ - public async getReportTenNinetyNine (xeroTenantId: string, reportYear?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Reports; }> { + public async getReportTenNinetyNine (xeroTenantId: string, reportYear?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Reports; }> { const localVarPath = this.basePath + '/Reports/TenNinetyNine'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -19146,7 +15530,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -19155,26 +15539,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -19189,7 +15553,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Reports; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Reports; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -19201,7 +15565,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -19213,7 +15578,7 @@ export class AccountingApi { * @param date The date for the Trial Balance report e.g. 2018-03-31 * @param paymentsOnly Return cash only basis for the Trial Balance report */ - public async getReportTrialBalance (xeroTenantId: string, date?: string, paymentsOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReportWithRows; }> { + public async getReportTrialBalance (xeroTenantId: string, date?: string, paymentsOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReportWithRows; }> { const localVarPath = this.basePath + '/Reports/TrialBalance'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -19241,7 +15606,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -19250,26 +15615,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -19284,7 +15629,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReportWithRows; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReportWithRows; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -19296,7 +15641,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -19306,7 +15652,7 @@ export class AccountingApi { * @summary Retrieves a list of the organistaions unique reports that require a uuid to fetch * @param xeroTenantId Xero identifier for Tenant */ - public async getReportsList (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReportWithRows; }> { + public async getReportsList (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReportWithRows; }> { const localVarPath = this.basePath + '/Reports'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -19326,7 +15672,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -19335,26 +15681,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -19369,7 +15695,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReportWithRows; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReportWithRows; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -19381,7 +15707,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -19394,7 +15721,7 @@ export class AccountingApi { * @param order Order by an any element * @param taxType Filter by tax type */ - public async getTaxRates (xeroTenantId: string, where?: string, order?: string, taxType?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TaxRates; }> { + public async getTaxRates (xeroTenantId: string, where?: string, order?: string, taxType?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TaxRates; }> { const localVarPath = this.basePath + '/TaxRates'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -19426,7 +15753,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -19435,26 +15762,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -19469,7 +15776,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TaxRates; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TaxRates; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -19481,7 +15788,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -19494,7 +15802,7 @@ export class AccountingApi { * @param order Order by an any element * @param includeArchived e.g. includeArchived=true - Categories and options with a status of ARCHIVED will be included in the response */ - public async getTrackingCategories (xeroTenantId: string, where?: string, order?: string, includeArchived?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TrackingCategories; }> { + public async getTrackingCategories (xeroTenantId: string, where?: string, order?: string, includeArchived?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TrackingCategories; }> { const localVarPath = this.basePath + '/TrackingCategories'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -19526,7 +15834,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -19535,26 +15843,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -19569,7 +15857,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TrackingCategories; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TrackingCategories; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -19581,7 +15869,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -19592,7 +15881,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param trackingCategoryID Unique identifier for a TrackingCategory */ - public async getTrackingCategory (xeroTenantId: string, trackingCategoryID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TrackingCategories; }> { + public async getTrackingCategory (xeroTenantId: string, trackingCategoryID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TrackingCategories; }> { const localVarPath = this.basePath + '/TrackingCategories/{TrackingCategoryID}' .replace('{' + 'TrackingCategoryID' + '}', encodeURIComponent(String(trackingCategoryID))); let localVarQueryParameters: any = {}; @@ -19618,7 +15907,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -19627,26 +15916,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -19661,7 +15930,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TrackingCategories; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TrackingCategories; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -19673,7 +15942,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -19684,7 +15954,7 @@ export class AccountingApi { * @param xeroTenantId Xero identifier for Tenant * @param userID Unique identifier for a User */ - public async getUser (xeroTenantId: string, userID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Users; }> { + public async getUser (xeroTenantId: string, userID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Users; }> { const localVarPath = this.basePath + '/Users/{UserID}' .replace('{' + 'UserID' + '}', encodeURIComponent(String(userID))); let localVarQueryParameters: any = {}; @@ -19710,7 +15980,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -19719,26 +15989,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -19753,7 +16003,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Users; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Users; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -19765,7 +16015,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -19778,7 +16029,7 @@ export class AccountingApi { * @param where Filter by an any element * @param order Order by an any element */ - public async getUsers (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Users; }> { + public async getUsers (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Users; }> { const localVarPath = this.basePath + '/Users'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -19807,7 +16058,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -19816,26 +16067,6 @@ export class AccountingApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -19850,7 +16081,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Users; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Users; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -19862,7 +16093,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -19874,7 +16106,7 @@ export class AccountingApi { * @param setup Object including an accounts array, a conversion balances array and a conversion date object in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async postSetup (xeroTenantId: string, setup: Setup, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ImportSummaryObject; }> { + public async postSetup (xeroTenantId: string, setup: Setup, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ImportSummaryObject; }> { const localVarPath = this.basePath + '/Setup'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -19900,7 +16132,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -19909,26 +16141,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(setup, "Setup"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -19943,7 +16155,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ImportSummaryObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ImportSummaryObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -19955,7 +16167,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -19968,7 +16181,7 @@ export class AccountingApi { * @param accounts Request of type Accounts array with one Account * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateAccount (xeroTenantId: string, accountID: string, accounts: Accounts, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Accounts; }> { + public async updateAccount (xeroTenantId: string, accountID: string, accounts: Accounts, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Accounts; }> { const localVarPath = this.basePath + '/Accounts/{AccountID}' .replace('{' + 'AccountID' + '}', encodeURIComponent(String(accountID))); let localVarQueryParameters: any = {}; @@ -20000,7 +16213,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -20009,26 +16222,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(accounts, "Accounts"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -20043,7 +16236,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Accounts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Accounts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -20055,7 +16248,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -20069,7 +16263,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateAccountAttachmentByFileName (xeroTenantId: string, accountID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async updateAccountAttachmentByFileName (xeroTenantId: string, accountID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Accounts/{AccountID}/Attachments/{FileName}' .replace('{' + 'AccountID' + '}', encodeURIComponent(String(accountID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -20108,7 +16302,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -20117,26 +16311,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -20168,7 +16342,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -20185,7 +16359,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -20199,7 +16374,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async updateBankTransaction (xeroTenantId: string, bankTransactionID: string, bankTransactions: BankTransactions, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BankTransactions; }> { + public async updateBankTransaction (xeroTenantId: string, bankTransactionID: string, bankTransactions: BankTransactions, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BankTransactions; }> { const localVarPath = this.basePath + '/BankTransactions/{BankTransactionID}' .replace('{' + 'BankTransactionID' + '}', encodeURIComponent(String(bankTransactionID))); let localVarQueryParameters: any = {}; @@ -20235,7 +16410,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -20244,26 +16419,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(bankTransactions, "BankTransactions"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -20278,7 +16433,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BankTransactions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BankTransactions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -20290,7 +16445,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -20304,7 +16460,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateBankTransactionAttachmentByFileName (xeroTenantId: string, bankTransactionID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async updateBankTransactionAttachmentByFileName (xeroTenantId: string, bankTransactionID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/BankTransactions/{BankTransactionID}/Attachments/{FileName}' .replace('{' + 'BankTransactionID' + '}', encodeURIComponent(String(bankTransactionID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -20343,7 +16499,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -20352,26 +16508,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -20403,7 +16539,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -20420,7 +16556,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -20433,7 +16570,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateBankTransferAttachmentByFileName (xeroTenantId: string, bankTransferID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async updateBankTransferAttachmentByFileName (xeroTenantId: string, bankTransferID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/BankTransfers/{BankTransferID}/Attachments/{FileName}' .replace('{' + 'BankTransferID' + '}', encodeURIComponent(String(bankTransferID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -20472,7 +16609,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -20481,26 +16618,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -20532,7 +16649,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -20549,7 +16666,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -20562,7 +16680,7 @@ export class AccountingApi { * @param contacts an array of Contacts containing single Contact object with properties to update * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateContact (xeroTenantId: string, contactID: string, contacts: Contacts, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Contacts; }> { + public async updateContact (xeroTenantId: string, contactID: string, contacts: Contacts, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Contacts; }> { const localVarPath = this.basePath + '/Contacts/{ContactID}' .replace('{' + 'ContactID' + '}', encodeURIComponent(String(contactID))); let localVarQueryParameters: any = {}; @@ -20594,7 +16712,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -20603,26 +16721,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(contacts, "Contacts"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -20637,7 +16735,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Contacts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Contacts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -20649,7 +16747,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -20662,7 +16761,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateContactAttachmentByFileName (xeroTenantId: string, contactID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async updateContactAttachmentByFileName (xeroTenantId: string, contactID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Contacts/{ContactID}/Attachments/{FileName}' .replace('{' + 'ContactID' + '}', encodeURIComponent(String(contactID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -20701,7 +16800,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -20710,26 +16809,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -20761,7 +16840,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -20778,7 +16857,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -20791,7 +16871,7 @@ export class AccountingApi { * @param contactGroups an array of Contact groups with Name of specific group to update * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateContactGroup (xeroTenantId: string, contactGroupID: string, contactGroups: ContactGroups, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ContactGroups; }> { + public async updateContactGroup (xeroTenantId: string, contactGroupID: string, contactGroups: ContactGroups, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ContactGroups; }> { const localVarPath = this.basePath + '/ContactGroups/{ContactGroupID}' .replace('{' + 'ContactGroupID' + '}', encodeURIComponent(String(contactGroupID))); let localVarQueryParameters: any = {}; @@ -20823,7 +16903,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -20832,26 +16912,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(contactGroups, "ContactGroups"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -20866,7 +16926,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ContactGroups; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ContactGroups; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -20878,7 +16938,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -20892,7 +16953,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async updateCreditNote (xeroTenantId: string, creditNoteID: string, creditNotes: CreditNotes, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: CreditNotes; }> { + public async updateCreditNote (xeroTenantId: string, creditNoteID: string, creditNotes: CreditNotes, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: CreditNotes; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))); let localVarQueryParameters: any = {}; @@ -20928,7 +16989,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -20937,26 +16998,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(creditNotes, "CreditNotes"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -20971,7 +17012,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: CreditNotes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: CreditNotes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -20983,7 +17024,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -20997,7 +17039,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateCreditNoteAttachmentByFileName (xeroTenantId: string, creditNoteID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async updateCreditNoteAttachmentByFileName (xeroTenantId: string, creditNoteID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/CreditNotes/{CreditNoteID}/Attachments/{FileName}' .replace('{' + 'CreditNoteID' + '}', encodeURIComponent(String(creditNoteID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -21036,7 +17078,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -21045,26 +17087,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -21096,7 +17118,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -21113,7 +17135,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -21126,7 +17149,7 @@ export class AccountingApi { * @param expenseClaims * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateExpenseClaim (xeroTenantId: string, expenseClaimID: string, expenseClaims: ExpenseClaims, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ExpenseClaims; }> { + public async updateExpenseClaim (xeroTenantId: string, expenseClaimID: string, expenseClaims: ExpenseClaims, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ExpenseClaims; }> { const localVarPath = this.basePath + '/ExpenseClaims/{ExpenseClaimID}' .replace('{' + 'ExpenseClaimID' + '}', encodeURIComponent(String(expenseClaimID))); let localVarQueryParameters: any = {}; @@ -21158,7 +17181,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -21167,26 +17190,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(expenseClaims, "ExpenseClaims"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -21201,7 +17204,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ExpenseClaims; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ExpenseClaims; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -21213,7 +17216,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -21227,7 +17231,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async updateInvoice (xeroTenantId: string, invoiceID: string, invoices: Invoices, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Invoices; }> { + public async updateInvoice (xeroTenantId: string, invoiceID: string, invoices: Invoices, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Invoices; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))); let localVarQueryParameters: any = {}; @@ -21263,7 +17267,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -21272,26 +17276,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(invoices, "Invoices"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -21306,7 +17290,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Invoices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Invoices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -21318,7 +17302,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -21332,7 +17317,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateInvoiceAttachmentByFileName (xeroTenantId: string, invoiceID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async updateInvoiceAttachmentByFileName (xeroTenantId: string, invoiceID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Invoices/{InvoiceID}/Attachments/{FileName}' .replace('{' + 'InvoiceID' + '}', encodeURIComponent(String(invoiceID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -21371,7 +17356,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -21380,26 +17365,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -21431,7 +17396,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -21448,7 +17413,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -21462,7 +17428,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async updateItem (xeroTenantId: string, itemID: string, items: Items, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Items; }> { + public async updateItem (xeroTenantId: string, itemID: string, items: Items, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Items; }> { const localVarPath = this.basePath + '/Items/{ItemID}' .replace('{' + 'ItemID' + '}', encodeURIComponent(String(itemID))); let localVarQueryParameters: any = {}; @@ -21498,7 +17464,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -21507,26 +17473,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(items, "Items"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -21541,7 +17487,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Items; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Items; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -21553,7 +17499,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -21566,7 +17513,7 @@ export class AccountingApi { * @param linkedTransactions * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateLinkedTransaction (xeroTenantId: string, linkedTransactionID: string, linkedTransactions: LinkedTransactions, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LinkedTransactions; }> { + public async updateLinkedTransaction (xeroTenantId: string, linkedTransactionID: string, linkedTransactions: LinkedTransactions, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LinkedTransactions; }> { const localVarPath = this.basePath + '/LinkedTransactions/{LinkedTransactionID}' .replace('{' + 'LinkedTransactionID' + '}', encodeURIComponent(String(linkedTransactionID))); let localVarQueryParameters: any = {}; @@ -21598,7 +17545,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -21607,26 +17554,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(linkedTransactions, "LinkedTransactions"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -21641,7 +17568,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LinkedTransactions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LinkedTransactions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -21653,7 +17580,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -21666,7 +17594,7 @@ export class AccountingApi { * @param manualJournals * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateManualJournal (xeroTenantId: string, manualJournalID: string, manualJournals: ManualJournals, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ManualJournals; }> { + public async updateManualJournal (xeroTenantId: string, manualJournalID: string, manualJournals: ManualJournals, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ManualJournals; }> { const localVarPath = this.basePath + '/ManualJournals/{ManualJournalID}' .replace('{' + 'ManualJournalID' + '}', encodeURIComponent(String(manualJournalID))); let localVarQueryParameters: any = {}; @@ -21698,7 +17626,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -21707,26 +17635,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(manualJournals, "ManualJournals"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -21741,7 +17649,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ManualJournals; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ManualJournals; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -21753,7 +17661,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -21767,7 +17676,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateManualJournalAttachmentByFileName (xeroTenantId: string, manualJournalID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async updateManualJournalAttachmentByFileName (xeroTenantId: string, manualJournalID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/ManualJournals/{ManualJournalID}/Attachments/{FileName}' .replace('{' + 'ManualJournalID' + '}', encodeURIComponent(String(manualJournalID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -21806,7 +17715,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -21815,26 +17724,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -21866,7 +17755,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -21883,7 +17772,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -21897,7 +17787,7 @@ export class AccountingApi { * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async updateOrCreateBankTransactions (xeroTenantId: string, bankTransactions: BankTransactions, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BankTransactions; }> { + public async updateOrCreateBankTransactions (xeroTenantId: string, bankTransactions: BankTransactions, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BankTransactions; }> { const localVarPath = this.basePath + '/BankTransactions'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -21931,7 +17821,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -21940,26 +17830,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(bankTransactions, "BankTransactions"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -21974,7 +17844,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BankTransactions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BankTransactions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -21986,7 +17856,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -21999,7 +17870,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async updateOrCreateContacts (xeroTenantId: string, contacts: Contacts, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Contacts; }> { + public async updateOrCreateContacts (xeroTenantId: string, contacts: Contacts, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Contacts; }> { const localVarPath = this.basePath + '/Contacts'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -22029,7 +17900,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -22038,26 +17909,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(contacts, "Contacts"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -22072,7 +17923,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Contacts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Contacts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -22084,7 +17935,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -22098,7 +17950,7 @@ export class AccountingApi { * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async updateOrCreateCreditNotes (xeroTenantId: string, creditNotes: CreditNotes, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: CreditNotes; }> { + public async updateOrCreateCreditNotes (xeroTenantId: string, creditNotes: CreditNotes, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: CreditNotes; }> { const localVarPath = this.basePath + '/CreditNotes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -22132,7 +17984,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -22141,26 +17993,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(creditNotes, "CreditNotes"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -22175,7 +18007,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: CreditNotes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: CreditNotes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -22187,7 +18019,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -22200,7 +18033,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async updateOrCreateEmployees (xeroTenantId: string, employees: Employees, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Employees; }> { + public async updateOrCreateEmployees (xeroTenantId: string, employees: Employees, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Employees; }> { const localVarPath = this.basePath + '/Employees'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -22230,7 +18063,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -22239,26 +18072,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(employees, "Employees"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -22273,7 +18086,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Employees; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Employees; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -22285,7 +18098,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -22299,7 +18113,7 @@ export class AccountingApi { * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async updateOrCreateInvoices (xeroTenantId: string, invoices: Invoices, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Invoices; }> { + public async updateOrCreateInvoices (xeroTenantId: string, invoices: Invoices, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Invoices; }> { const localVarPath = this.basePath + '/Invoices'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -22333,7 +18147,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -22342,26 +18156,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(invoices, "Invoices"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -22376,7 +18170,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Invoices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Invoices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -22388,7 +18182,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -22402,7 +18197,7 @@ export class AccountingApi { * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async updateOrCreateItems (xeroTenantId: string, items: Items, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Items; }> { + public async updateOrCreateItems (xeroTenantId: string, items: Items, idempotencyKey?: string, summarizeErrors?: boolean, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Items; }> { const localVarPath = this.basePath + '/Items'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -22436,7 +18231,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -22445,26 +18240,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(items, "Items"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -22479,7 +18254,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Items; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Items; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -22491,7 +18266,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -22504,7 +18280,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async updateOrCreateManualJournals (xeroTenantId: string, manualJournals: ManualJournals, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ManualJournals; }> { + public async updateOrCreateManualJournals (xeroTenantId: string, manualJournals: ManualJournals, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ManualJournals; }> { const localVarPath = this.basePath + '/ManualJournals'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -22534,7 +18310,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -22543,26 +18319,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(manualJournals, "ManualJournals"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -22577,7 +18333,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ManualJournals; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ManualJournals; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -22589,7 +18345,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -22602,7 +18359,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async updateOrCreatePurchaseOrders (xeroTenantId: string, purchaseOrders: PurchaseOrders, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }> { + public async updateOrCreatePurchaseOrders (xeroTenantId: string, purchaseOrders: PurchaseOrders, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PurchaseOrders; }> { const localVarPath = this.basePath + '/PurchaseOrders'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -22632,7 +18389,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -22641,26 +18398,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(purchaseOrders, "PurchaseOrders"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -22675,7 +18412,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PurchaseOrders; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -22687,7 +18424,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -22700,7 +18438,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async updateOrCreateQuotes (xeroTenantId: string, quotes: Quotes, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Quotes; }> { + public async updateOrCreateQuotes (xeroTenantId: string, quotes: Quotes, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Quotes; }> { const localVarPath = this.basePath + '/Quotes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -22730,7 +18468,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -22739,26 +18477,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(quotes, "Quotes"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -22773,7 +18491,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Quotes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Quotes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -22785,7 +18503,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -22798,7 +18517,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param summarizeErrors If false return 200 OK and mix of successfully created objects and any with validation errors */ - public async updateOrCreateRepeatingInvoices (xeroTenantId: string, repeatingInvoices: RepeatingInvoices, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: RepeatingInvoices; }> { + public async updateOrCreateRepeatingInvoices (xeroTenantId: string, repeatingInvoices: RepeatingInvoices, idempotencyKey?: string, summarizeErrors?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: RepeatingInvoices; }> { const localVarPath = this.basePath + '/RepeatingInvoices'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -22828,7 +18547,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -22837,26 +18556,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(repeatingInvoices, "RepeatingInvoices"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -22871,7 +18570,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: RepeatingInvoices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: RepeatingInvoices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -22883,7 +18582,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -22896,7 +18596,7 @@ export class AccountingApi { * @param purchaseOrders * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updatePurchaseOrder (xeroTenantId: string, purchaseOrderID: string, purchaseOrders: PurchaseOrders, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }> { + public async updatePurchaseOrder (xeroTenantId: string, purchaseOrderID: string, purchaseOrders: PurchaseOrders, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PurchaseOrders; }> { const localVarPath = this.basePath + '/PurchaseOrders/{PurchaseOrderID}' .replace('{' + 'PurchaseOrderID' + '}', encodeURIComponent(String(purchaseOrderID))); let localVarQueryParameters: any = {}; @@ -22928,7 +18628,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -22937,26 +18637,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(purchaseOrders, "PurchaseOrders"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -22971,7 +18651,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PurchaseOrders; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PurchaseOrders; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -22983,7 +18663,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -22997,7 +18678,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updatePurchaseOrderAttachmentByFileName (xeroTenantId: string, purchaseOrderID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async updatePurchaseOrderAttachmentByFileName (xeroTenantId: string, purchaseOrderID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/PurchaseOrders/{PurchaseOrderID}/Attachments/{FileName}' .replace('{' + 'PurchaseOrderID' + '}', encodeURIComponent(String(purchaseOrderID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -23036,7 +18717,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -23045,26 +18726,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -23096,7 +18757,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -23113,7 +18774,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -23126,7 +18788,7 @@ export class AccountingApi { * @param quotes * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateQuote (xeroTenantId: string, quoteID: string, quotes: Quotes, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Quotes; }> { + public async updateQuote (xeroTenantId: string, quoteID: string, quotes: Quotes, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Quotes; }> { const localVarPath = this.basePath + '/Quotes/{QuoteID}' .replace('{' + 'QuoteID' + '}', encodeURIComponent(String(quoteID))); let localVarQueryParameters: any = {}; @@ -23158,7 +18820,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -23167,26 +18829,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(quotes, "Quotes"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -23201,7 +18843,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Quotes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Quotes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -23213,7 +18855,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -23227,7 +18870,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateQuoteAttachmentByFileName (xeroTenantId: string, quoteID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async updateQuoteAttachmentByFileName (xeroTenantId: string, quoteID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Quotes/{QuoteID}/Attachments/{FileName}' .replace('{' + 'QuoteID' + '}', encodeURIComponent(String(quoteID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -23266,7 +18909,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -23275,26 +18918,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -23326,7 +18949,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -23343,7 +18966,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -23357,7 +18981,7 @@ export class AccountingApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param unitdp e.g. unitdp=4 – (Unit Decimal Places) You can opt in to use four decimal places for unit amounts */ - public async updateReceipt (xeroTenantId: string, receiptID: string, receipts: Receipts, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Receipts; }> { + public async updateReceipt (xeroTenantId: string, receiptID: string, receipts: Receipts, idempotencyKey?: string, unitdp?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Receipts; }> { const localVarPath = this.basePath + '/Receipts/{ReceiptID}' .replace('{' + 'ReceiptID' + '}', encodeURIComponent(String(receiptID))); let localVarQueryParameters: any = {}; @@ -23393,7 +19017,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -23402,26 +19026,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(receipts, "Receipts"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -23436,7 +19040,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Receipts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Receipts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -23448,7 +19052,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -23462,7 +19067,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateReceiptAttachmentByFileName (xeroTenantId: string, receiptID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async updateReceiptAttachmentByFileName (xeroTenantId: string, receiptID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/Receipts/{ReceiptID}/Attachments/{FileName}' .replace('{' + 'ReceiptID' + '}', encodeURIComponent(String(receiptID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -23501,7 +19106,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -23510,26 +19115,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -23561,7 +19146,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -23578,7 +19163,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -23591,7 +19177,7 @@ export class AccountingApi { * @param repeatingInvoices * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateRepeatingInvoice (xeroTenantId: string, repeatingInvoiceID: string, repeatingInvoices: RepeatingInvoices, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: RepeatingInvoices; }> { + public async updateRepeatingInvoice (xeroTenantId: string, repeatingInvoiceID: string, repeatingInvoices: RepeatingInvoices, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: RepeatingInvoices; }> { const localVarPath = this.basePath + '/RepeatingInvoices/{RepeatingInvoiceID}' .replace('{' + 'RepeatingInvoiceID' + '}', encodeURIComponent(String(repeatingInvoiceID))); let localVarQueryParameters: any = {}; @@ -23623,7 +19209,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -23632,26 +19218,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(repeatingInvoices, "RepeatingInvoices"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -23666,7 +19232,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: RepeatingInvoices; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: RepeatingInvoices; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -23678,7 +19244,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -23692,7 +19259,7 @@ export class AccountingApi { * @param body Byte array of file in body of request * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateRepeatingInvoiceAttachmentByFileName (xeroTenantId: string, repeatingInvoiceID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Attachments; }> { + public async updateRepeatingInvoiceAttachmentByFileName (xeroTenantId: string, repeatingInvoiceID: string, fileName: string, body: fs.ReadStream, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Attachments; }> { const localVarPath = this.basePath + '/RepeatingInvoices/{RepeatingInvoiceID}/Attachments/{FileName}' .replace('{' + 'RepeatingInvoiceID' + '}', encodeURIComponent(String(repeatingInvoiceID))) .replace('{' + 'FileName' + '}', encodeURIComponent(String(fileName))); @@ -23731,7 +19298,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -23740,26 +19307,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(body, "string"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -23791,7 +19338,7 @@ export class AccountingApi { }); }).then((fileContents) => { localVarRequestOptions.data = fileContents; - return new Promise<{ response: http.IncomingMessage; body: Attachments; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Attachments; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -23808,7 +19355,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -23820,7 +19368,7 @@ export class AccountingApi { * @param taxRates * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateTaxRate (xeroTenantId: string, taxRates: TaxRates, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TaxRates; }> { + public async updateTaxRate (xeroTenantId: string, taxRates: TaxRates, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TaxRates; }> { const localVarPath = this.basePath + '/TaxRates'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -23846,7 +19394,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -23855,26 +19403,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(taxRates, "TaxRates"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -23889,7 +19417,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TaxRates; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TaxRates; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -23901,7 +19429,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -23914,7 +19443,7 @@ export class AccountingApi { * @param trackingCategory * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateTrackingCategory (xeroTenantId: string, trackingCategoryID: string, trackingCategory: TrackingCategory, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TrackingCategories; }> { + public async updateTrackingCategory (xeroTenantId: string, trackingCategoryID: string, trackingCategory: TrackingCategory, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TrackingCategories; }> { const localVarPath = this.basePath + '/TrackingCategories/{TrackingCategoryID}' .replace('{' + 'TrackingCategoryID' + '}', encodeURIComponent(String(trackingCategoryID))); let localVarQueryParameters: any = {}; @@ -23946,7 +19475,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -23955,26 +19484,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(trackingCategory, "TrackingCategory"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -23989,7 +19498,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TrackingCategories; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TrackingCategories; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -24001,7 +19510,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -24015,7 +19525,7 @@ export class AccountingApi { * @param trackingOption * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateTrackingOptions (xeroTenantId: string, trackingCategoryID: string, trackingOptionID: string, trackingOption: TrackingOption, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TrackingOptions; }> { + public async updateTrackingOptions (xeroTenantId: string, trackingCategoryID: string, trackingOptionID: string, trackingOption: TrackingOption, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TrackingOptions; }> { const localVarPath = this.basePath + '/TrackingCategories/{TrackingCategoryID}/Options/{TrackingOptionID}' .replace('{' + 'TrackingCategoryID' + '}', encodeURIComponent(String(trackingCategoryID))) .replace('{' + 'TrackingOptionID' + '}', encodeURIComponent(String(trackingOptionID))); @@ -24053,7 +19563,7 @@ export class AccountingApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -24062,26 +19572,6 @@ export class AccountingApi { data: ObjectSerializer.serialize(trackingOption, "TrackingOption"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -24096,7 +19586,7 @@ export class AccountingApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TrackingOptions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TrackingOptions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -24108,7 +19598,8 @@ export class AccountingApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); diff --git a/src/gen/api/appStoreApi.ts b/src/gen/api/appStoreApi.ts index e36c52cb..8bd1d2f7 100644 --- a/src/gen/api/appStoreApi.ts +++ b/src/gen/api/appStoreApi.ts @@ -10,7 +10,6 @@ * Do not edit the class manually. */ -const axios = require('axios'); import http = require('http'); import fs = require('fs'); @@ -23,6 +22,8 @@ import { UsageRecord } from '../model/appstore/usageRecord'; import { UsageRecordsList } from '../model/appstore/usageRecordsList'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/appstore/models'; +import { ApiError } from '../../model/ApiError'; +import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import { OAuth } from '../model/appstore/models'; let defaultBasePath = 'https://api.xero.com/appstore/2.0'; @@ -87,7 +88,7 @@ export class AppStoreApi { * @summary Retrieves a subscription for a given subscriptionId * @param subscriptionId Unique identifier for Subscription object */ - public async getSubscription (subscriptionId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Subscription; }> { + public async getSubscription (subscriptionId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Subscription; }> { const localVarPath = this.basePath + '/subscriptions/{subscriptionId}' .replace('{' + 'subscriptionId' + '}', encodeURIComponent(String(subscriptionId))); let localVarQueryParameters: any = {}; @@ -107,7 +108,7 @@ export class AppStoreApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -116,26 +117,6 @@ export class AppStoreApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -150,7 +131,7 @@ export class AppStoreApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Subscription; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Subscription; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -162,7 +143,8 @@ export class AppStoreApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -172,7 +154,7 @@ export class AppStoreApi { * @summary Gets all usage records related to the subscription * @param subscriptionId Unique identifier for Subscription object */ - public async getUsageRecords (subscriptionId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: UsageRecordsList; }> { + public async getUsageRecords (subscriptionId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: UsageRecordsList; }> { const localVarPath = this.basePath + '/subscriptions/{subscriptionId}/usage-records' .replace('{' + 'subscriptionId' + '}', encodeURIComponent(String(subscriptionId))); let localVarQueryParameters: any = {}; @@ -192,7 +174,7 @@ export class AppStoreApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -201,26 +183,6 @@ export class AppStoreApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -235,7 +197,7 @@ export class AppStoreApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: UsageRecordsList; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: UsageRecordsList; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -247,7 +209,8 @@ export class AppStoreApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -260,7 +223,7 @@ export class AppStoreApi { * @param createUsageRecord Contains the quantity for the usage record to create * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async postUsageRecords (subscriptionId: string, subscriptionItemId: string, createUsageRecord: CreateUsageRecord, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: UsageRecord; }> { + public async postUsageRecords (subscriptionId: string, subscriptionItemId: string, createUsageRecord: CreateUsageRecord, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: UsageRecord; }> { const localVarPath = this.basePath + '/subscriptions/{subscriptionId}/items/{subscriptionItemId}/usage-records' .replace('{' + 'subscriptionId' + '}', encodeURIComponent(String(subscriptionId))) .replace('{' + 'subscriptionItemId' + '}', encodeURIComponent(String(subscriptionItemId))); @@ -292,7 +255,7 @@ export class AppStoreApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -301,26 +264,6 @@ export class AppStoreApi { data: ObjectSerializer.serialize(createUsageRecord, "CreateUsageRecord"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -335,7 +278,7 @@ export class AppStoreApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: UsageRecord; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: UsageRecord; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -347,7 +290,8 @@ export class AppStoreApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -361,7 +305,7 @@ export class AppStoreApi { * @param updateUsageRecord Contains the quantity for the usage record to update * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async putUsageRecords (subscriptionId: string, subscriptionItemId: string, usageRecordId: string, updateUsageRecord: UpdateUsageRecord, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: UsageRecord; }> { + public async putUsageRecords (subscriptionId: string, subscriptionItemId: string, usageRecordId: string, updateUsageRecord: UpdateUsageRecord, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: UsageRecord; }> { const localVarPath = this.basePath + '/subscriptions/{subscriptionId}/items/{subscriptionItemId}/usage-records/{usageRecordId}' .replace('{' + 'subscriptionId' + '}', encodeURIComponent(String(subscriptionId))) .replace('{' + 'subscriptionItemId' + '}', encodeURIComponent(String(subscriptionItemId))) @@ -399,7 +343,7 @@ export class AppStoreApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -408,26 +352,6 @@ export class AppStoreApi { data: ObjectSerializer.serialize(updateUsageRecord, "UpdateUsageRecord"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -442,7 +366,7 @@ export class AppStoreApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: UsageRecord; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: UsageRecord; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -454,7 +378,8 @@ export class AppStoreApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); diff --git a/src/gen/api/assetApi.ts b/src/gen/api/assetApi.ts index 4cc12736..239c843d 100644 --- a/src/gen/api/assetApi.ts +++ b/src/gen/api/assetApi.ts @@ -10,7 +10,6 @@ * Do not edit the class manually. */ -const axios = require('axios'); import http = require('http'); import fs = require('fs'); @@ -22,6 +21,8 @@ import { Assets } from '../model/assets/assets'; import { Setting } from '../model/assets/setting'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/assets/models'; +import { ApiError } from '../../model/ApiError'; +import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import { OAuth } from '../model/assets/models'; let defaultBasePath = 'https://api.xero.com/assets.xro/1.0'; @@ -88,7 +89,7 @@ export class AssetApi { * @param asset Fixed asset you are creating * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createAsset (xeroTenantId: string, asset: Asset, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Asset; }> { + public async createAsset (xeroTenantId: string, asset: Asset, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Asset; }> { const localVarPath = this.basePath + '/Assets'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -114,7 +115,7 @@ export class AssetApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -123,26 +124,6 @@ export class AssetApi { data: ObjectSerializer.serialize(asset, "Asset"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -157,7 +138,7 @@ export class AssetApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Asset; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Asset; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -169,7 +150,8 @@ export class AssetApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -181,7 +163,7 @@ export class AssetApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param assetType Asset type to add */ - public async createAssetType (xeroTenantId: string, idempotencyKey?: string, assetType?: AssetType, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: AssetType; }> { + public async createAssetType (xeroTenantId: string, idempotencyKey?: string, assetType?: AssetType, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: AssetType; }> { const localVarPath = this.basePath + '/AssetTypes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -202,7 +184,7 @@ export class AssetApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -211,26 +193,6 @@ export class AssetApi { data: ObjectSerializer.serialize(assetType, "AssetType"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -245,7 +207,7 @@ export class AssetApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: AssetType; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: AssetType; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -257,7 +219,8 @@ export class AssetApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -268,7 +231,7 @@ export class AssetApi { * @param xeroTenantId Xero identifier for Tenant * @param id fixed asset id for single object */ - public async getAssetById (xeroTenantId: string, id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Asset; }> { + public async getAssetById (xeroTenantId: string, id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Asset; }> { const localVarPath = this.basePath + '/Assets/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; @@ -294,7 +257,7 @@ export class AssetApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -303,26 +266,6 @@ export class AssetApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -337,7 +280,7 @@ export class AssetApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Asset; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Asset; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -349,7 +292,8 @@ export class AssetApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -359,7 +303,7 @@ export class AssetApi { * @summary searches fixed asset settings * @param xeroTenantId Xero identifier for Tenant */ - public async getAssetSettings (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Setting; }> { + public async getAssetSettings (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Setting; }> { const localVarPath = this.basePath + '/Settings'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -379,7 +323,7 @@ export class AssetApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -388,26 +332,6 @@ export class AssetApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -422,7 +346,7 @@ export class AssetApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Setting; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Setting; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -434,7 +358,8 @@ export class AssetApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -444,7 +369,7 @@ export class AssetApi { * @summary searches fixed asset types * @param xeroTenantId Xero identifier for Tenant */ - public async getAssetTypes (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { + public async getAssetTypes (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Array; }> { const localVarPath = this.basePath + '/AssetTypes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -464,7 +389,7 @@ export class AssetApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -473,26 +398,6 @@ export class AssetApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -507,7 +412,7 @@ export class AssetApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Array; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Array; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -519,7 +424,8 @@ export class AssetApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -535,7 +441,7 @@ export class AssetApi { * @param sortDirection ASC or DESC * @param filterBy A string that can be used to filter the list to only return assets containing the text. Checks it against the AssetName, AssetNumber, Description and AssetTypeName fields. */ - public async getAssets (xeroTenantId: string, status: AssetStatusQueryParam, page?: number, pageSize?: number, orderBy?: 'AssetType' | 'AssetName' | 'AssetNumber' | 'PurchaseDate' | 'PurchasePrice' | 'DisposalDate' | 'DisposalPrice', sortDirection?: 'asc' | 'desc', filterBy?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Assets; }> { + public async getAssets (xeroTenantId: string, status: AssetStatusQueryParam, page?: number, pageSize?: number, orderBy?: 'AssetType' | 'AssetName' | 'AssetNumber' | 'PurchaseDate' | 'PurchasePrice' | 'DisposalDate' | 'DisposalPrice', sortDirection?: 'asc' | 'desc', filterBy?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Assets; }> { const localVarPath = this.basePath + '/Assets'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -584,7 +490,7 @@ export class AssetApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -593,26 +499,6 @@ export class AssetApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -627,7 +513,7 @@ export class AssetApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Assets; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Assets; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -639,7 +525,8 @@ export class AssetApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); diff --git a/src/gen/api/bankfeedsApi.ts b/src/gen/api/bankfeedsApi.ts index 16b9a227..7403b26f 100644 --- a/src/gen/api/bankfeedsApi.ts +++ b/src/gen/api/bankfeedsApi.ts @@ -10,7 +10,6 @@ * Do not edit the class manually. */ -const axios = require('axios'); import http = require('http'); import fs = require('fs'); @@ -21,6 +20,8 @@ import { Statement } from '../model/bankfeeds/statement'; import { Statements } from '../model/bankfeeds/statements'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/bankfeeds/models'; +import { ApiError } from '../../model/ApiError'; +import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import { OAuth } from '../model/bankfeeds/models'; let defaultBasePath = 'https://api.xero.com/bankfeeds.xro/1.0'; @@ -87,7 +88,7 @@ export class BankFeedsApi { * @param feedConnections Feed Connection(s) array object in the body * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createFeedConnections (xeroTenantId: string, feedConnections: FeedConnections, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: FeedConnections; }> { + public async createFeedConnections (xeroTenantId: string, feedConnections: FeedConnections, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: FeedConnections; }> { const localVarPath = this.basePath + '/FeedConnections'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -113,7 +114,7 @@ export class BankFeedsApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -122,26 +123,6 @@ export class BankFeedsApi { data: ObjectSerializer.serialize(feedConnections, "FeedConnections"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -156,7 +137,7 @@ export class BankFeedsApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: FeedConnections; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: FeedConnections; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -168,7 +149,8 @@ export class BankFeedsApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -180,7 +162,7 @@ export class BankFeedsApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param statements Statements array of objects in the body */ - public async createStatements (xeroTenantId: string, idempotencyKey?: string, statements?: Statements, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Statements; }> { + public async createStatements (xeroTenantId: string, idempotencyKey?: string, statements?: Statements, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Statements; }> { const localVarPath = this.basePath + '/Statements'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -202,7 +184,7 @@ export class BankFeedsApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -211,26 +193,6 @@ export class BankFeedsApi { data: ObjectSerializer.serialize(statements, "Statements"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -245,7 +207,7 @@ export class BankFeedsApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Statements; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Statements; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -257,7 +219,8 @@ export class BankFeedsApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -269,7 +232,7 @@ export class BankFeedsApi { * @param feedConnections Feed Connections array object in the body * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async deleteFeedConnections (xeroTenantId: string, feedConnections: FeedConnections, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: FeedConnections; }> { + public async deleteFeedConnections (xeroTenantId: string, feedConnections: FeedConnections, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: FeedConnections; }> { const localVarPath = this.basePath + '/FeedConnections/DeleteRequests'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -295,7 +258,7 @@ export class BankFeedsApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -304,26 +267,6 @@ export class BankFeedsApi { data: ObjectSerializer.serialize(feedConnections, "FeedConnections"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -338,7 +281,7 @@ export class BankFeedsApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: FeedConnections; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: FeedConnections; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -350,7 +293,8 @@ export class BankFeedsApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -361,7 +305,7 @@ export class BankFeedsApi { * @param xeroTenantId Xero identifier for Tenant * @param id Unique identifier for retrieving single object */ - public async getFeedConnection (xeroTenantId: string, id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: FeedConnection; }> { + public async getFeedConnection (xeroTenantId: string, id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: FeedConnection; }> { const localVarPath = this.basePath + '/FeedConnections/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; @@ -387,7 +331,7 @@ export class BankFeedsApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -396,26 +340,6 @@ export class BankFeedsApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -430,7 +354,7 @@ export class BankFeedsApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: FeedConnection; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: FeedConnection; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -442,7 +366,8 @@ export class BankFeedsApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -454,7 +379,7 @@ export class BankFeedsApi { * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 10. Example - https://api.xero.com/bankfeeds.xro/1.0/FeedConnections?page=1 to get the second set of the records. When page value is not a number or a negative number, by default, the first set of records is returned. * @param pageSize Page size which specifies how many records per page will be returned (default 10). Example - https://api.xero.com/bankfeeds.xro/1.0/FeedConnections?pageSize=100 to specify page size of 100. */ - public async getFeedConnections (xeroTenantId: string, page?: number, pageSize?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: FeedConnections; }> { + public async getFeedConnections (xeroTenantId: string, page?: number, pageSize?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: FeedConnections; }> { const localVarPath = this.basePath + '/FeedConnections'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -482,7 +407,7 @@ export class BankFeedsApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -491,26 +416,6 @@ export class BankFeedsApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -525,7 +430,7 @@ export class BankFeedsApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: FeedConnections; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: FeedConnections; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -537,7 +442,8 @@ export class BankFeedsApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -548,7 +454,7 @@ export class BankFeedsApi { * @param xeroTenantId Xero identifier for Tenant * @param statementId statement id for single object */ - public async getStatement (xeroTenantId: string, statementId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Statement; }> { + public async getStatement (xeroTenantId: string, statementId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Statement; }> { const localVarPath = this.basePath + '/Statements/{statementId}' .replace('{' + 'statementId' + '}', encodeURIComponent(String(statementId))); let localVarQueryParameters: any = {}; @@ -574,7 +480,7 @@ export class BankFeedsApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -583,26 +489,6 @@ export class BankFeedsApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -617,7 +503,7 @@ export class BankFeedsApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Statement; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Statement; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -629,7 +515,8 @@ export class BankFeedsApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -643,7 +530,7 @@ export class BankFeedsApi { * @param xeroApplicationId * @param xeroUserId */ - public async getStatements (xeroTenantId: string, page?: number, pageSize?: number, xeroApplicationId?: string, xeroUserId?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Statements; }> { + public async getStatements (xeroTenantId: string, page?: number, pageSize?: number, xeroApplicationId?: string, xeroUserId?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Statements; }> { const localVarPath = this.basePath + '/Statements'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -674,7 +561,7 @@ export class BankFeedsApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -683,26 +570,6 @@ export class BankFeedsApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -717,7 +584,7 @@ export class BankFeedsApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Statements; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Statements; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -729,7 +596,8 @@ export class BankFeedsApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); diff --git a/src/gen/api/filesApi.ts b/src/gen/api/filesApi.ts index 0796a198..82058529 100644 --- a/src/gen/api/filesApi.ts +++ b/src/gen/api/filesApi.ts @@ -10,7 +10,6 @@ * Do not edit the class manually. */ -const axios = require('axios'); import http = require('http'); import fs = require('fs'); @@ -21,6 +20,8 @@ import { Files } from '../model/files/files'; import { Folder } from '../model/files/folder'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/files/models'; +import { ApiError } from '../../model/ApiError'; +import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import { OAuth } from '../model/files/models'; let defaultBasePath = 'https://api.xero.com/files.xro/1.0'; @@ -88,7 +89,7 @@ export class FilesApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param association */ - public async createFileAssociation (xeroTenantId: string, fileId: string, idempotencyKey?: string, association?: Association, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Association; }> { + public async createFileAssociation (xeroTenantId: string, fileId: string, idempotencyKey?: string, association?: Association, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Association; }> { const localVarPath = this.basePath + '/Files/{FileId}/Associations' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))); let localVarQueryParameters: any = {}; @@ -115,7 +116,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -124,26 +125,6 @@ export class FilesApi { data: ObjectSerializer.serialize(association, "Association"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -158,7 +139,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Association; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Association; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -170,7 +151,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -182,7 +164,7 @@ export class FilesApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param folder */ - public async createFolder (xeroTenantId: string, idempotencyKey?: string, folder?: Folder, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Folder; }> { + public async createFolder (xeroTenantId: string, idempotencyKey?: string, folder?: Folder, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Folder; }> { const localVarPath = this.basePath + '/Folders'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -203,7 +185,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -212,26 +194,6 @@ export class FilesApi { data: ObjectSerializer.serialize(folder, "Folder"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -246,7 +208,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Folder; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Folder; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -258,7 +220,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -269,7 +232,7 @@ export class FilesApi { * @param xeroTenantId Xero identifier for Tenant * @param fileId File id for single object */ - public async deleteFile (xeroTenantId: string, fileId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async deleteFile (xeroTenantId: string, fileId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Files/{FileId}' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))); let localVarQueryParameters: any = {}; @@ -294,7 +257,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -303,26 +266,6 @@ export class FilesApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -337,7 +280,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -349,7 +292,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -361,7 +305,7 @@ export class FilesApi { * @param fileId File id for single object * @param objectId Object id for single object */ - public async deleteFileAssociation (xeroTenantId: string, fileId: string, objectId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async deleteFileAssociation (xeroTenantId: string, fileId: string, objectId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Files/{FileId}/Associations/{ObjectId}' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))) .replace('{' + 'ObjectId' + '}', encodeURIComponent(String(objectId))); @@ -392,7 +336,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -401,26 +345,6 @@ export class FilesApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -435,7 +359,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -447,7 +371,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -458,7 +383,7 @@ export class FilesApi { * @param xeroTenantId Xero identifier for Tenant * @param folderId Folder id for single object */ - public async deleteFolder (xeroTenantId: string, folderId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async deleteFolder (xeroTenantId: string, folderId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Folders/{FolderId}' .replace('{' + 'FolderId' + '}', encodeURIComponent(String(folderId))); let localVarQueryParameters: any = {}; @@ -483,7 +408,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -492,26 +417,6 @@ export class FilesApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -526,7 +431,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -538,7 +443,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -553,7 +459,7 @@ export class FilesApi { * @param sort values to sort by * @param direction direction to sort by */ - public async getAssociationsByObject (xeroTenantId: string, objectId: string, pagesize?: number, page?: number, sort?: 'Name' | 'CreatedDateUTC', direction?: 'ASC' | 'DESC', options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { + public async getAssociationsByObject (xeroTenantId: string, objectId: string, pagesize?: number, page?: number, sort?: 'Name' | 'CreatedDateUTC', direction?: 'ASC' | 'DESC', options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Array; }> { const localVarPath = this.basePath + '/Associations/{ObjectId}' .replace('{' + 'ObjectId' + '}', encodeURIComponent(String(objectId))); let localVarQueryParameters: any = {}; @@ -595,7 +501,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -604,26 +510,6 @@ export class FilesApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -638,7 +524,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Array; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Array; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -650,7 +536,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -661,7 +548,7 @@ export class FilesApi { * @param xeroTenantId Xero identifier for Tenant * @param objectIds A comma-separated list of object ids */ - public async getAssociationsCount (xeroTenantId: string, objectIds: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: object; }> { + public async getAssociationsCount (xeroTenantId: string, objectIds: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: object; }> { const localVarPath = this.basePath + '/Associations/Count'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -690,7 +577,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -699,26 +586,6 @@ export class FilesApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -733,7 +600,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: object; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: object; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -745,7 +612,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -756,7 +624,7 @@ export class FilesApi { * @param xeroTenantId Xero identifier for Tenant * @param fileId File id for single object */ - public async getFile (xeroTenantId: string, fileId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: FileObject; }> { + public async getFile (xeroTenantId: string, fileId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: FileObject; }> { const localVarPath = this.basePath + '/Files/{FileId}' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))); let localVarQueryParameters: any = {}; @@ -782,7 +650,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -791,26 +659,6 @@ export class FilesApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -825,7 +673,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: FileObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: FileObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -837,7 +685,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -848,7 +697,7 @@ export class FilesApi { * @param xeroTenantId Xero identifier for Tenant * @param fileId File id for single object */ - public async getFileAssociations (xeroTenantId: string, fileId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { + public async getFileAssociations (xeroTenantId: string, fileId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Array; }> { const localVarPath = this.basePath + '/Files/{FileId}/Associations' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))); let localVarQueryParameters: any = {}; @@ -874,7 +723,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -883,26 +732,6 @@ export class FilesApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -917,7 +746,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Array; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Array; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -929,7 +758,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -940,7 +770,7 @@ export class FilesApi { * @param xeroTenantId Xero identifier for Tenant * @param fileId File id for single object */ - public async getFileContent (xeroTenantId: string, fileId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Buffer; }> { + public async getFileContent (xeroTenantId: string, fileId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Buffer; }> { const localVarPath = this.basePath + '/Files/{FileId}/Content' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))); let localVarQueryParameters: any = {}; @@ -966,36 +796,15 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, url: localVarPath, responseType: responseTypeOption, - encoding: null, data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1010,7 +819,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Buffer; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Buffer; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1022,7 +831,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1035,7 +845,7 @@ export class FilesApi { * @param page number of records to skip for pagination * @param sort values to sort by */ - public async getFiles (xeroTenantId: string, pagesize?: number, page?: number, sort?: 'Name' | 'Size' | 'CreatedDateUTC', options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Files; }> { + public async getFiles (xeroTenantId: string, pagesize?: number, page?: number, sort?: 'Name' | 'Size' | 'CreatedDateUTC', options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Files; }> { const localVarPath = this.basePath + '/Files'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1067,7 +877,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1076,26 +886,6 @@ export class FilesApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1110,7 +900,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Files; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Files; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1122,7 +912,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1133,7 +924,7 @@ export class FilesApi { * @param xeroTenantId Xero identifier for Tenant * @param folderId Folder id for single object */ - public async getFolder (xeroTenantId: string, folderId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Folder; }> { + public async getFolder (xeroTenantId: string, folderId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Folder; }> { const localVarPath = this.basePath + '/Folders/{FolderId}' .replace('{' + 'FolderId' + '}', encodeURIComponent(String(folderId))); let localVarQueryParameters: any = {}; @@ -1159,7 +950,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1168,26 +959,6 @@ export class FilesApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1202,7 +973,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Folder; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Folder; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1214,7 +985,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1225,7 +997,7 @@ export class FilesApi { * @param xeroTenantId Xero identifier for Tenant * @param sort values to sort by */ - public async getFolders (xeroTenantId: string, sort?: 'Name' | 'Size' | 'CreatedDateUTC', options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { + public async getFolders (xeroTenantId: string, sort?: 'Name' | 'Size' | 'CreatedDateUTC', options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Array; }> { const localVarPath = this.basePath + '/Folders'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1249,7 +1021,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1258,26 +1030,6 @@ export class FilesApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1292,7 +1044,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Array; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Array; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1304,7 +1056,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1314,7 +1067,7 @@ export class FilesApi { * @summary Retrieves inbox folder * @param xeroTenantId Xero identifier for Tenant */ - public async getInbox (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Folder; }> { + public async getInbox (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Folder; }> { const localVarPath = this.basePath + '/Inbox'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1334,7 +1087,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1343,26 +1096,6 @@ export class FilesApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1377,7 +1110,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Folder; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Folder; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1389,7 +1122,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1402,7 +1136,7 @@ export class FilesApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param fileObject */ - public async updateFile (xeroTenantId: string, fileId: string, idempotencyKey?: string, fileObject?: FileObject, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: FileObject; }> { + public async updateFile (xeroTenantId: string, fileId: string, idempotencyKey?: string, fileObject?: FileObject, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: FileObject; }> { const localVarPath = this.basePath + '/Files/{FileId}' .replace('{' + 'FileId' + '}', encodeURIComponent(String(fileId))); let localVarQueryParameters: any = {}; @@ -1429,7 +1163,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1438,26 +1172,6 @@ export class FilesApi { data: ObjectSerializer.serialize(fileObject, "FileObject"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1472,7 +1186,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: FileObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: FileObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1484,7 +1198,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1497,7 +1212,7 @@ export class FilesApi { * @param folder * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateFolder (xeroTenantId: string, folderId: string, folder: Folder, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Folder; }> { + public async updateFolder (xeroTenantId: string, folderId: string, folder: Folder, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Folder; }> { const localVarPath = this.basePath + '/Folders/{FolderId}' .replace('{' + 'FolderId' + '}', encodeURIComponent(String(folderId))); let localVarQueryParameters: any = {}; @@ -1529,7 +1244,7 @@ export class FilesApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1538,26 +1253,6 @@ export class FilesApi { data: ObjectSerializer.serialize(folder, "Folder"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1572,7 +1267,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Folder; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Folder; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1584,7 +1279,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1599,7 +1295,7 @@ export class FilesApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param mimeType */ - public async uploadFile (xeroTenantId: string, body: fs.ReadStream, name: string, filename: string, idempotencyKey?: string, mimeType?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: FileObject; }> { + public async uploadFile (xeroTenantId: string, body: fs.ReadStream, name: string, filename: string, idempotencyKey?: string, mimeType?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: FileObject; }> { const localVarPath = this.basePath + '/Files'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1648,7 +1344,7 @@ export class FilesApi { localVarFormParams['mimeType'] = ObjectSerializer.serialize(mimeType, "string"); } - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1661,26 +1357,6 @@ export class FilesApi { localVarHeaderParams["Content-Type"] = "multipart/form-data"; delete localVarFormParams['body'] localVarFormParams[name] = ObjectSerializer.serialize(body, "string"); - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1695,7 +1371,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: FileObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: FileObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1707,7 +1383,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1723,7 +1400,7 @@ export class FilesApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param mimeType */ - public async uploadFileToFolder (xeroTenantId: string, folderId: string, body: fs.ReadStream, name: string, filename: string, idempotencyKey?: string, mimeType?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: FileObject; }> { + public async uploadFileToFolder (xeroTenantId: string, folderId: string, body: fs.ReadStream, name: string, filename: string, idempotencyKey?: string, mimeType?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: FileObject; }> { const localVarPath = this.basePath + '/Files/{FolderId}' .replace('{' + 'FolderId' + '}', encodeURIComponent(String(folderId))); let localVarQueryParameters: any = {}; @@ -1778,7 +1455,7 @@ export class FilesApi { localVarFormParams['mimeType'] = ObjectSerializer.serialize(mimeType, "string"); } - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1791,26 +1468,6 @@ export class FilesApi { localVarHeaderParams["Content-Type"] = "multipart/form-data"; delete localVarFormParams['body'] localVarFormParams[name] = ObjectSerializer.serialize(body, "string"); - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1825,7 +1482,7 @@ export class FilesApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: FileObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: FileObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1837,7 +1494,8 @@ export class FilesApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); diff --git a/src/gen/api/financeApi.ts b/src/gen/api/financeApi.ts index dc4efcc9..57255af2 100644 --- a/src/gen/api/financeApi.ts +++ b/src/gen/api/financeApi.ts @@ -10,7 +10,6 @@ * Do not edit the class manually. */ -const axios = require('axios'); import http = require('http'); import fs = require('fs'); @@ -29,6 +28,8 @@ import { TrialBalanceResponse } from '../model/finance/trialBalanceResponse'; import { UserActivitiesResponse } from '../model/finance/userActivitiesResponse'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/finance/models'; +import { ApiError } from '../../model/ApiError'; +import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import { OAuth } from '../model/finance/models'; let defaultBasePath = 'https://api.xero.com/finance.xro/1.0'; @@ -95,7 +96,7 @@ export class FinanceApi { * @param startMonth date, yyyy-MM If no parameter is provided, the month 12 months prior to the end month will be used. Account usage for up to 12 months from this date will be returned. * @param endMonth date, yyyy-MM If no parameter is provided, the current month will be used. Account usage for up to 12 months prior to this date will be returned. */ - public async getAccountingActivityAccountUsage (xeroTenantId: string, startMonth?: string, endMonth?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: AccountUsageResponse; }> { + public async getAccountingActivityAccountUsage (xeroTenantId: string, startMonth?: string, endMonth?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: AccountUsageResponse; }> { const localVarPath = this.basePath + '/AccountingActivities/AccountUsage'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -123,7 +124,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -132,26 +133,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -166,7 +147,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: AccountUsageResponse; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: AccountUsageResponse; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -178,7 +159,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -189,7 +171,7 @@ export class FinanceApi { * @param xeroTenantId Xero identifier for Tenant * @param endDate date, yyyy-MM-dd If no parameter is provided, the current date will be used. Any changes to hard or soft lock dates that were made within the period up to 12 months before this date will be returned. Please be aware that there may be a delay of up to 3 days before a change is visible from this API. */ - public async getAccountingActivityLockHistory (xeroTenantId: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LockHistoryResponse; }> { + public async getAccountingActivityLockHistory (xeroTenantId: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LockHistoryResponse; }> { const localVarPath = this.basePath + '/AccountingActivities/LockHistory'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -213,7 +195,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -222,26 +204,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -256,7 +218,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LockHistoryResponse; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LockHistoryResponse; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -268,7 +230,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -279,7 +242,7 @@ export class FinanceApi { * @param xeroTenantId Xero identifier for Tenant * @param endDate date, yyyy-MM-dd If no parameter is provided, the current date will be used. Any reports that were published within the period up to 12 months before this date will be returned. Please be aware that there may be a delay of up to 3 days before a published report is visible from this API. */ - public async getAccountingActivityReportHistory (xeroTenantId: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReportHistoryResponse; }> { + public async getAccountingActivityReportHistory (xeroTenantId: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReportHistoryResponse; }> { const localVarPath = this.basePath + '/AccountingActivities/ReportHistory'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -303,7 +266,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -312,26 +275,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -346,7 +289,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReportHistoryResponse; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReportHistoryResponse; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -358,7 +301,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -369,7 +313,7 @@ export class FinanceApi { * @param xeroTenantId Xero identifier for Tenant * @param dataMonth date, yyyy-MM The specified month must be complete (in the past); The current month cannot be specified since it is not complete. If no parameter is provided, the month immediately previous to the current month will be used. Any user activities occurring within the specified month will be returned. Please be aware that there may be a delay of up to 3 days before a user activity is visible from this API. */ - public async getAccountingActivityUserActivities (xeroTenantId: string, dataMonth?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: UserActivitiesResponse; }> { + public async getAccountingActivityUserActivities (xeroTenantId: string, dataMonth?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: UserActivitiesResponse; }> { const localVarPath = this.basePath + '/AccountingActivities/UserActivities'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -393,7 +337,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -402,26 +346,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -436,7 +360,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: UserActivitiesResponse; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: UserActivitiesResponse; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -448,7 +372,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -462,7 +387,7 @@ export class FinanceApi { * @param toDate date, yyyy-MM-dd Specifies the end date of the query period. If the end date is a future date, the request will be rejected. * @param summaryOnly boolean, true/false The default value is true if no parameter is provided. In summary mode, the response will exclude the computation-heavy LineItems fields from bank transaction, invoice, credit note, prepayment and overpayment data, making the API calls quicker and more efficient. */ - public async getBankStatementAccounting (xeroTenantId: string, bankAccountID: string, fromDate: string, toDate: string, summaryOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BankStatementAccountingResponse; }> { + public async getBankStatementAccounting (xeroTenantId: string, bankAccountID: string, fromDate: string, toDate: string, summaryOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BankStatementAccountingResponse; }> { const localVarPath = this.basePath + '/BankStatementsPlus/statements'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -513,7 +438,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -522,26 +447,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -556,7 +461,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BankStatementAccountingResponse; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BankStatementAccountingResponse; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -568,7 +473,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -581,7 +487,7 @@ export class FinanceApi { * @param asAtSystemDate date, yyyy-MM-dd If no parameter is provided, the current date will be used. The ‘as at’ date will return transactions based on the creation date. It reflects the date the transactions were entered into Xero, not the accounting date. The ‘as at’ date can not be overridden by the user. This can be used to estimate a ‘historical frequency of reconciliation’. The ‘as at’ date will affect the current statement in the response, as any candidate statements created after this date will be filtered out. Thus the current statement returned will be the most recent statement prior to the specified ‘as at’ date. Be aware that neither the begin date, nor the balance date, will affect the current statement. Note; information is only presented when system architecture allows, meaning historical cash validation information will be an estimate. In addition, delete events are not aware of the ‘as at’ functionality in this endpoint, meaning that transactions deleted at the time the API is accessed will be considered to always have been deleted. * @param beginDate date, yyyy-MM-dd If no parameter is provided, the aggregate results will be drawn from the user’s total history. The ‘begin date’ will return transactions based on the accounting date entered by the user. Transactions after the beginDate will be included. The user has discretion as to which accounting period the transaction relates to. */ - public async getCashValidation (xeroTenantId: string, balanceDate?: string, asAtSystemDate?: string, beginDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array; }> { + public async getCashValidation (xeroTenantId: string, balanceDate?: string, asAtSystemDate?: string, beginDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Array; }> { const localVarPath = this.basePath + '/CashValidation'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -613,7 +519,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -622,26 +528,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -656,7 +542,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Array; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Array; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -668,7 +554,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -679,7 +566,7 @@ export class FinanceApi { * @param xeroTenantId Xero identifier for Tenant * @param balanceDate Specifies the date for balance sheet report. Format yyyy-MM-dd. If no parameter is provided, the current date will be used. */ - public async getFinancialStatementBalanceSheet (xeroTenantId: string, balanceDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BalanceSheetResponse; }> { + public async getFinancialStatementBalanceSheet (xeroTenantId: string, balanceDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BalanceSheetResponse; }> { const localVarPath = this.basePath + '/FinancialStatements/BalanceSheet'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -703,7 +590,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -712,26 +599,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -746,7 +613,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BalanceSheetResponse; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BalanceSheetResponse; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -758,7 +625,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -770,7 +638,7 @@ export class FinanceApi { * @param startDate Date e.g. yyyy-MM-dd Specifies the start date for cash flow report. If no parameter is provided, the date of 12 months before the end date will be used. * @param endDate Date e.g. yyyy-MM-dd Specifies the end date for cash flow report. If no parameter is provided, the current date will be used. */ - public async getFinancialStatementCashflow (xeroTenantId: string, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: CashflowResponse; }> { + public async getFinancialStatementCashflow (xeroTenantId: string, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: CashflowResponse; }> { const localVarPath = this.basePath + '/FinancialStatements/Cashflow'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -798,7 +666,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -807,26 +675,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -841,7 +689,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: CashflowResponse; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: CashflowResponse; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -853,7 +701,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -867,7 +716,7 @@ export class FinanceApi { * @param startDate Date yyyy-MM-dd Specifies the start date for the report. If no parameter is provided, the date of 12 months before the end date will be used. It is recommended to always specify both a start date and end date; While the initial range may be set to 12 months, this may need to be reduced for high volume organisations in order to improve latency. * @param endDate Date yyyy-MM-dd Specifies the end date for the report. If no parameter is provided, the current date will be used. It is recommended to always specify both a start date and end date; While the initial range may be set to 12 months, this may need to be reduced for high volume organisations in order to improve latency. */ - public async getFinancialStatementContactsExpense (xeroTenantId: string, contactIds?: Array, includeManualJournals?: boolean, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: IncomeByContactResponse; }> { + public async getFinancialStatementContactsExpense (xeroTenantId: string, contactIds?: Array, includeManualJournals?: boolean, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: IncomeByContactResponse; }> { const localVarPath = this.basePath + '/FinancialStatements/contacts/expense'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -903,7 +752,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -912,26 +761,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -946,7 +775,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: IncomeByContactResponse; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: IncomeByContactResponse; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -958,7 +787,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -972,7 +802,7 @@ export class FinanceApi { * @param startDate Date yyyy-MM-dd Specifies the start date for the report. If no parameter is provided, the date of 12 months before the end date will be used. It is recommended to always specify both a start date and end date; While the initial range may be set to 12 months, this may need to be reduced for high volume organisations in order to improve latency. * @param endDate Date yyyy-MM-dd Specifies the end date for the report. If no parameter is provided, the current date will be used. It is recommended to always specify both a start date and end date; While the initial range may be set to 12 months, this may need to be reduced for high volume organisations in order to improve latency. */ - public async getFinancialStatementContactsRevenue (xeroTenantId: string, contactIds?: Array, includeManualJournals?: boolean, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: IncomeByContactResponse; }> { + public async getFinancialStatementContactsRevenue (xeroTenantId: string, contactIds?: Array, includeManualJournals?: boolean, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: IncomeByContactResponse; }> { const localVarPath = this.basePath + '/FinancialStatements/contacts/revenue'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1008,7 +838,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1017,26 +847,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1051,7 +861,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: IncomeByContactResponse; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: IncomeByContactResponse; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1063,7 +873,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1075,7 +886,7 @@ export class FinanceApi { * @param startDate Date e.g. yyyy-MM-dd Specifies the start date for profit and loss report If no parameter is provided, the date of 12 months before the end date will be used. * @param endDate Date e.g. yyyy-MM-dd Specifies the end date for profit and loss report If no parameter is provided, the current date will be used. */ - public async getFinancialStatementProfitAndLoss (xeroTenantId: string, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ProfitAndLossResponse; }> { + public async getFinancialStatementProfitAndLoss (xeroTenantId: string, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ProfitAndLossResponse; }> { const localVarPath = this.basePath + '/FinancialStatements/ProfitAndLoss'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1103,7 +914,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1112,26 +923,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1146,7 +937,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ProfitAndLossResponse; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ProfitAndLossResponse; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1158,7 +949,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1169,7 +961,7 @@ export class FinanceApi { * @param xeroTenantId Xero identifier for Tenant * @param endDate Date e.g. yyyy-MM-dd Specifies the end date for trial balance report If no parameter is provided, the current date will be used. */ - public async getFinancialStatementTrialBalance (xeroTenantId: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TrialBalanceResponse; }> { + public async getFinancialStatementTrialBalance (xeroTenantId: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TrialBalanceResponse; }> { const localVarPath = this.basePath + '/FinancialStatements/TrialBalance'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1193,7 +985,7 @@ export class FinanceApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1202,26 +994,6 @@ export class FinanceApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1236,7 +1008,7 @@ export class FinanceApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TrialBalanceResponse; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TrialBalanceResponse; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1248,7 +1020,8 @@ export class FinanceApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); diff --git a/src/gen/api/payrollAUApi.ts b/src/gen/api/payrollAUApi.ts index ec89ccea..4dc13008 100644 --- a/src/gen/api/payrollAUApi.ts +++ b/src/gen/api/payrollAUApi.ts @@ -10,7 +10,6 @@ * Do not edit the class manually. */ -const axios = require('axios'); import http = require('http'); import fs = require('fs'); @@ -38,6 +37,8 @@ import { TimesheetObject } from '../model/payroll-au/timesheetObject'; import { Timesheets } from '../model/payroll-au/timesheets'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/payroll-au/models'; +import { ApiError } from '../../model/ApiError'; +import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import { OAuth } from '../model/payroll-au/models'; let defaultBasePath = 'https://api.xero.com/payroll.xro/1.0'; @@ -104,7 +105,7 @@ export class PayrollAuApi { * @param leaveApplicationID Leave Application id for single object * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async approveLeaveApplication (xeroTenantId: string, leaveApplicationID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveApplications; }> { + public async approveLeaveApplication (xeroTenantId: string, leaveApplicationID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveApplications; }> { const localVarPath = this.basePath + '/LeaveApplications/{LeaveApplicationID}/approve' .replace('{' + 'LeaveApplicationID' + '}', encodeURIComponent(String(leaveApplicationID))); let localVarQueryParameters: any = {}; @@ -131,7 +132,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -140,26 +141,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -174,7 +155,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveApplications; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveApplications; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -186,7 +167,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -198,7 +180,7 @@ export class PayrollAuApi { * @param employee * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployee (xeroTenantId: string, employee: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Employees; }> { + public async createEmployee (xeroTenantId: string, employee: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Employees; }> { const localVarPath = this.basePath + '/Employees'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -224,7 +206,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -233,26 +215,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(employee, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -267,7 +229,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Employees; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Employees; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -279,7 +241,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -291,7 +254,7 @@ export class PayrollAuApi { * @param leaveApplication * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createLeaveApplication (xeroTenantId: string, leaveApplication: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveApplications; }> { + public async createLeaveApplication (xeroTenantId: string, leaveApplication: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveApplications; }> { const localVarPath = this.basePath + '/LeaveApplications'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -317,7 +280,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -326,26 +289,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(leaveApplication, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -360,7 +303,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveApplications; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveApplications; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -372,7 +315,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -384,7 +328,7 @@ export class PayrollAuApi { * @param payItem * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPayItem (xeroTenantId: string, payItem: PayItem, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayItems; }> { + public async createPayItem (xeroTenantId: string, payItem: PayItem, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayItems; }> { const localVarPath = this.basePath + '/PayItems'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -410,7 +354,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -419,26 +363,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(payItem, "PayItem"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -453,7 +377,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayItems; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayItems; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -465,7 +389,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -477,7 +402,7 @@ export class PayrollAuApi { * @param payRun * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPayRun (xeroTenantId: string, payRun: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRuns; }> { + public async createPayRun (xeroTenantId: string, payRun: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRuns; }> { const localVarPath = this.basePath + '/PayRuns'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -503,7 +428,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -512,26 +437,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(payRun, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -546,7 +451,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRuns; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRuns; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -558,7 +463,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -570,7 +476,7 @@ export class PayrollAuApi { * @param payrollCalendar * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPayrollCalendar (xeroTenantId: string, payrollCalendar: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayrollCalendars; }> { + public async createPayrollCalendar (xeroTenantId: string, payrollCalendar: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayrollCalendars; }> { const localVarPath = this.basePath + '/PayrollCalendars'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -596,7 +502,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -605,26 +511,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(payrollCalendar, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -639,7 +525,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayrollCalendars; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayrollCalendars; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -651,7 +537,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -663,7 +550,7 @@ export class PayrollAuApi { * @param superFund * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createSuperfund (xeroTenantId: string, superFund: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SuperFunds; }> { + public async createSuperfund (xeroTenantId: string, superFund: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SuperFunds; }> { const localVarPath = this.basePath + '/Superfunds'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -689,7 +576,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -698,26 +585,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(superFund, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -732,7 +599,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SuperFunds; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SuperFunds; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -744,7 +611,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -756,7 +624,7 @@ export class PayrollAuApi { * @param timesheet * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createTimesheet (xeroTenantId: string, timesheet: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Timesheets; }> { + public async createTimesheet (xeroTenantId: string, timesheet: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Timesheets; }> { const localVarPath = this.basePath + '/Timesheets'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -782,7 +650,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -791,26 +659,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(timesheet, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -825,7 +673,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Timesheets; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Timesheets; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -837,7 +685,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -848,7 +697,7 @@ export class PayrollAuApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployee (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Employees; }> { + public async getEmployee (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Employees; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -874,7 +723,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -883,26 +732,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -917,7 +746,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Employees; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Employees; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -929,7 +758,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -943,7 +773,7 @@ export class PayrollAuApi { * @param order Order by an any element * @param page e.g. page=1 – Up to 100 employees will be returned in a single API call */ - public async getEmployees (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Employees; }> { + public async getEmployees (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Employees; }> { const localVarPath = this.basePath + '/Employees'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -976,7 +806,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -985,26 +815,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1019,7 +829,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Employees; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Employees; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1031,7 +841,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1042,7 +853,7 @@ export class PayrollAuApi { * @param xeroTenantId Xero identifier for Tenant * @param leaveApplicationID Leave Application id for single object */ - public async getLeaveApplication (xeroTenantId: string, leaveApplicationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveApplications; }> { + public async getLeaveApplication (xeroTenantId: string, leaveApplicationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveApplications; }> { const localVarPath = this.basePath + '/LeaveApplications/{LeaveApplicationID}' .replace('{' + 'LeaveApplicationID' + '}', encodeURIComponent(String(leaveApplicationID))); let localVarQueryParameters: any = {}; @@ -1068,7 +879,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1077,26 +888,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1111,7 +902,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveApplications; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveApplications; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1123,7 +914,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1137,7 +929,7 @@ export class PayrollAuApi { * @param order Order by an any element * @param page e.g. page=1 – Up to 100 objects will be returned in a single API call */ - public async getLeaveApplications (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveApplications; }> { + public async getLeaveApplications (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveApplications; }> { const localVarPath = this.basePath + '/LeaveApplications'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1170,7 +962,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1179,26 +971,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1213,7 +985,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveApplications; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveApplications; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1225,7 +997,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1239,7 +1012,7 @@ export class PayrollAuApi { * @param order Order by an any element * @param page e.g. page=1 – Up to 100 objects will be returned in a single API call */ - public async getLeaveApplicationsV2 (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveApplications; }> { + public async getLeaveApplicationsV2 (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveApplications; }> { const localVarPath = this.basePath + '/LeaveApplications/v2'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1272,7 +1045,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1281,26 +1054,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1315,7 +1068,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveApplications; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveApplications; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1327,7 +1080,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1341,7 +1095,7 @@ export class PayrollAuApi { * @param order Order by an any element * @param page e.g. page=1 – Up to 100 objects will be returned in a single API call */ - public async getPayItems (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayItems; }> { + public async getPayItems (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayItems; }> { const localVarPath = this.basePath + '/PayItems'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1374,7 +1128,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1383,26 +1137,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1417,7 +1151,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayItems; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayItems; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1429,7 +1163,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1440,7 +1175,7 @@ export class PayrollAuApi { * @param xeroTenantId Xero identifier for Tenant * @param payRunID PayRun id for single object */ - public async getPayRun (xeroTenantId: string, payRunID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRuns; }> { + public async getPayRun (xeroTenantId: string, payRunID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRuns; }> { const localVarPath = this.basePath + '/PayRuns/{PayRunID}' .replace('{' + 'PayRunID' + '}', encodeURIComponent(String(payRunID))); let localVarQueryParameters: any = {}; @@ -1466,7 +1201,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1475,26 +1210,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1509,7 +1224,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRuns; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRuns; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1521,7 +1236,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1535,7 +1251,7 @@ export class PayrollAuApi { * @param order Order by an any element * @param page e.g. page=1 – Up to 100 PayRuns will be returned in a single API call */ - public async getPayRuns (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRuns; }> { + public async getPayRuns (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRuns; }> { const localVarPath = this.basePath + '/PayRuns'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1568,7 +1284,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1577,26 +1293,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1611,7 +1307,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRuns; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRuns; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1623,7 +1319,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1634,7 +1331,7 @@ export class PayrollAuApi { * @param xeroTenantId Xero identifier for Tenant * @param payrollCalendarID Payroll Calendar id for single object */ - public async getPayrollCalendar (xeroTenantId: string, payrollCalendarID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayrollCalendars; }> { + public async getPayrollCalendar (xeroTenantId: string, payrollCalendarID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayrollCalendars; }> { const localVarPath = this.basePath + '/PayrollCalendars/{PayrollCalendarID}' .replace('{' + 'PayrollCalendarID' + '}', encodeURIComponent(String(payrollCalendarID))); let localVarQueryParameters: any = {}; @@ -1660,7 +1357,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1669,26 +1366,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1703,7 +1380,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayrollCalendars; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayrollCalendars; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1715,7 +1392,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1729,7 +1407,7 @@ export class PayrollAuApi { * @param order Order by an any element * @param page e.g. page=1 – Up to 100 objects will be returned in a single API call */ - public async getPayrollCalendars (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayrollCalendars; }> { + public async getPayrollCalendars (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayrollCalendars; }> { const localVarPath = this.basePath + '/PayrollCalendars'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1762,7 +1440,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1771,26 +1449,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1805,7 +1463,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayrollCalendars; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayrollCalendars; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1817,7 +1475,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1828,7 +1487,7 @@ export class PayrollAuApi { * @param xeroTenantId Xero identifier for Tenant * @param payslipID Payslip id for single object */ - public async getPayslip (xeroTenantId: string, payslipID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayslipObject; }> { + public async getPayslip (xeroTenantId: string, payslipID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayslipObject; }> { const localVarPath = this.basePath + '/Payslip/{PayslipID}' .replace('{' + 'PayslipID' + '}', encodeURIComponent(String(payslipID))); let localVarQueryParameters: any = {}; @@ -1854,7 +1513,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1863,26 +1522,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1897,7 +1536,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayslipObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayslipObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1909,7 +1548,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1919,7 +1559,7 @@ export class PayrollAuApi { * @summary Retrieves payroll settings * @param xeroTenantId Xero identifier for Tenant */ - public async getSettings (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SettingsObject; }> { + public async getSettings (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SettingsObject; }> { const localVarPath = this.basePath + '/Settings'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1939,7 +1579,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1948,26 +1588,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1982,7 +1602,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SettingsObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SettingsObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1994,7 +1614,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2005,7 +1626,7 @@ export class PayrollAuApi { * @param xeroTenantId Xero identifier for Tenant * @param superFundID Superfund id for single object */ - public async getSuperfund (xeroTenantId: string, superFundID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SuperFunds; }> { + public async getSuperfund (xeroTenantId: string, superFundID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SuperFunds; }> { const localVarPath = this.basePath + '/Superfunds/{SuperFundID}' .replace('{' + 'SuperFundID' + '}', encodeURIComponent(String(superFundID))); let localVarQueryParameters: any = {}; @@ -2031,7 +1652,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2040,26 +1661,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2074,7 +1675,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SuperFunds; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SuperFunds; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2086,7 +1687,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2098,7 +1700,7 @@ export class PayrollAuApi { * @param aBN The ABN of the Regulated SuperFund * @param uSI The USI of the Regulated SuperFund */ - public async getSuperfundProducts (xeroTenantId: string, aBN?: string, uSI?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SuperFundProducts; }> { + public async getSuperfundProducts (xeroTenantId: string, aBN?: string, uSI?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SuperFundProducts; }> { const localVarPath = this.basePath + '/SuperfundProducts'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2126,7 +1728,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2135,26 +1737,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2169,7 +1751,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SuperFundProducts; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SuperFundProducts; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2181,7 +1763,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2195,7 +1778,7 @@ export class PayrollAuApi { * @param order Order by an any element * @param page e.g. page=1 – Up to 100 SuperFunds will be returned in a single API call */ - public async getSuperfunds (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SuperFunds; }> { + public async getSuperfunds (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SuperFunds; }> { const localVarPath = this.basePath + '/Superfunds'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2228,7 +1811,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2237,26 +1820,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2271,7 +1834,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SuperFunds; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SuperFunds; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2283,7 +1846,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2294,7 +1858,7 @@ export class PayrollAuApi { * @param xeroTenantId Xero identifier for Tenant * @param timesheetID Timesheet id for single object */ - public async getTimesheet (xeroTenantId: string, timesheetID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetObject; }> { + public async getTimesheet (xeroTenantId: string, timesheetID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetObject; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -2320,7 +1884,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2329,26 +1893,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2363,7 +1907,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2375,7 +1919,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2389,7 +1934,7 @@ export class PayrollAuApi { * @param order Order by an any element * @param page e.g. page=1 – Up to 100 timesheets will be returned in a single API call */ - public async getTimesheets (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Timesheets; }> { + public async getTimesheets (xeroTenantId: string, ifModifiedSince?: Date, where?: string, order?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Timesheets; }> { const localVarPath = this.basePath + '/Timesheets'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2422,7 +1967,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2431,26 +1976,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2465,7 +1990,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Timesheets; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Timesheets; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2477,7 +2002,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2489,7 +2015,7 @@ export class PayrollAuApi { * @param leaveApplicationID Leave Application id for single object * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async rejectLeaveApplication (xeroTenantId: string, leaveApplicationID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveApplications; }> { + public async rejectLeaveApplication (xeroTenantId: string, leaveApplicationID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveApplications; }> { const localVarPath = this.basePath + '/LeaveApplications/{LeaveApplicationID}/reject' .replace('{' + 'LeaveApplicationID' + '}', encodeURIComponent(String(leaveApplicationID))); let localVarQueryParameters: any = {}; @@ -2516,7 +2042,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2525,26 +2051,6 @@ export class PayrollAuApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2559,7 +2065,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveApplications; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveApplications; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2571,7 +2077,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2584,7 +2091,7 @@ export class PayrollAuApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param employee */ - public async updateEmployee (xeroTenantId: string, employeeID: string, idempotencyKey?: string, employee?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Employees; }> { + public async updateEmployee (xeroTenantId: string, employeeID: string, idempotencyKey?: string, employee?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Employees; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -2611,7 +2118,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2620,26 +2127,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(employee, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2654,7 +2141,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Employees; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Employees; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2666,7 +2153,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2679,7 +2167,7 @@ export class PayrollAuApi { * @param leaveApplication * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateLeaveApplication (xeroTenantId: string, leaveApplicationID: string, leaveApplication: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveApplications; }> { + public async updateLeaveApplication (xeroTenantId: string, leaveApplicationID: string, leaveApplication: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveApplications; }> { const localVarPath = this.basePath + '/LeaveApplications/{LeaveApplicationID}' .replace('{' + 'LeaveApplicationID' + '}', encodeURIComponent(String(leaveApplicationID))); let localVarQueryParameters: any = {}; @@ -2711,7 +2199,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2720,26 +2208,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(leaveApplication, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2754,7 +2222,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveApplications; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveApplications; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2766,7 +2234,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2779,7 +2248,7 @@ export class PayrollAuApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param payRun */ - public async updatePayRun (xeroTenantId: string, payRunID: string, idempotencyKey?: string, payRun?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRuns; }> { + public async updatePayRun (xeroTenantId: string, payRunID: string, idempotencyKey?: string, payRun?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRuns; }> { const localVarPath = this.basePath + '/PayRuns/{PayRunID}' .replace('{' + 'PayRunID' + '}', encodeURIComponent(String(payRunID))); let localVarQueryParameters: any = {}; @@ -2806,7 +2275,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2815,26 +2284,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(payRun, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2849,7 +2298,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRuns; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRuns; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2861,7 +2310,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2874,7 +2324,7 @@ export class PayrollAuApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param payslipLines */ - public async updatePayslip (xeroTenantId: string, payslipID: string, idempotencyKey?: string, payslipLines?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Payslips; }> { + public async updatePayslip (xeroTenantId: string, payslipID: string, idempotencyKey?: string, payslipLines?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Payslips; }> { const localVarPath = this.basePath + '/Payslip/{PayslipID}' .replace('{' + 'PayslipID' + '}', encodeURIComponent(String(payslipID))); let localVarQueryParameters: any = {}; @@ -2901,7 +2351,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2910,26 +2360,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(payslipLines, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2944,7 +2374,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Payslips; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Payslips; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2956,7 +2386,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2969,7 +2400,7 @@ export class PayrollAuApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param superFund */ - public async updateSuperfund (xeroTenantId: string, superFundID: string, idempotencyKey?: string, superFund?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SuperFunds; }> { + public async updateSuperfund (xeroTenantId: string, superFundID: string, idempotencyKey?: string, superFund?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SuperFunds; }> { const localVarPath = this.basePath + '/Superfunds/{SuperFundID}' .replace('{' + 'SuperFundID' + '}', encodeURIComponent(String(superFundID))); let localVarQueryParameters: any = {}; @@ -2996,7 +2427,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3005,26 +2436,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(superFund, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3039,7 +2450,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SuperFunds; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SuperFunds; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3051,7 +2462,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3064,7 +2476,7 @@ export class PayrollAuApi { * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. * @param timesheet */ - public async updateTimesheet (xeroTenantId: string, timesheetID: string, idempotencyKey?: string, timesheet?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Timesheets; }> { + public async updateTimesheet (xeroTenantId: string, timesheetID: string, idempotencyKey?: string, timesheet?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Timesheets; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -3091,7 +2503,7 @@ export class PayrollAuApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3100,26 +2512,6 @@ export class PayrollAuApi { data: ObjectSerializer.serialize(timesheet, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3134,7 +2526,7 @@ export class PayrollAuApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Timesheets; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Timesheets; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3146,7 +2538,8 @@ export class PayrollAuApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); diff --git a/src/gen/api/payrollNZApi.ts b/src/gen/api/payrollNZApi.ts index 872aa4f3..ee5df394 100644 --- a/src/gen/api/payrollNZApi.ts +++ b/src/gen/api/payrollNZApi.ts @@ -10,7 +10,6 @@ * Do not edit the class manually. */ -const axios = require('axios'); import http = require('http'); import fs = require('fs'); @@ -79,6 +78,8 @@ import { Timesheets } from '../model/payroll-nz/timesheets'; import { TrackingCategories } from '../model/payroll-nz/trackingCategories'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/payroll-nz/models'; +import { ApiError } from '../../model/ApiError'; +import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import { OAuth } from '../model/payroll-nz/models'; let defaultBasePath = 'https://api.xero.com/payroll.xro/2.0'; @@ -145,7 +146,7 @@ export class PayrollNzApi { * @param timesheetID Identifier for the timesheet * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async approveTimesheet (xeroTenantId: string, timesheetID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetObject; }> { + public async approveTimesheet (xeroTenantId: string, timesheetID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetObject; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/Approve' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -172,7 +173,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -181,26 +182,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -215,7 +196,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -227,7 +208,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -239,7 +221,7 @@ export class PayrollNzApi { * @param deduction * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createDeduction (xeroTenantId: string, deduction: Deduction, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: DeductionObject; }> { + public async createDeduction (xeroTenantId: string, deduction: Deduction, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: DeductionObject; }> { const localVarPath = this.basePath + '/Deductions'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -265,7 +247,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -274,26 +256,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(deduction, "Deduction"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -308,7 +270,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: DeductionObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: DeductionObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -320,7 +282,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -332,7 +295,7 @@ export class PayrollNzApi { * @param earningsRate * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEarningsRate (xeroTenantId: string, earningsRate: EarningsRate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsRateObject; }> { + public async createEarningsRate (xeroTenantId: string, earningsRate: EarningsRate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsRateObject; }> { const localVarPath = this.basePath + '/EarningsRates'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -358,7 +321,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -367,26 +330,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(earningsRate, "EarningsRate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -401,7 +344,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsRateObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsRateObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -413,7 +356,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -425,7 +369,7 @@ export class PayrollNzApi { * @param employee * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployee (xeroTenantId: string, employee: Employee, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeObject; }> { + public async createEmployee (xeroTenantId: string, employee: Employee, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeObject; }> { const localVarPath = this.basePath + '/Employees'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -451,7 +395,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -460,26 +404,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(employee, "Employee"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -494,7 +418,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -506,7 +430,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -519,7 +444,7 @@ export class PayrollNzApi { * @param earningsTemplate * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, earningsTemplate: EarningsTemplate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsTemplateObject; }> { + public async createEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, earningsTemplate: EarningsTemplate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsTemplateObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PayTemplates/earnings' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -551,7 +476,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -560,26 +485,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(earningsTemplate, "EarningsTemplate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -594,7 +499,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsTemplateObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsTemplateObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -606,7 +511,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -619,7 +525,7 @@ export class PayrollNzApi { * @param employeeLeave * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeLeave (xeroTenantId: string, employeeID: string, employeeLeave: EmployeeLeave, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }> { + public async createEmployeeLeave (xeroTenantId: string, employeeID: string, employeeLeave: EmployeeLeave, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Leave' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -651,7 +557,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -660,26 +566,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(employeeLeave, "EmployeeLeave"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -694,7 +580,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -706,7 +592,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -719,7 +606,7 @@ export class PayrollNzApi { * @param employeeLeaveSetup * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeLeaveSetup (xeroTenantId: string, employeeID: string, employeeLeaveSetup: EmployeeLeaveSetup, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveSetupObject; }> { + public async createEmployeeLeaveSetup (xeroTenantId: string, employeeID: string, employeeLeaveSetup: EmployeeLeaveSetup, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveSetupObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/leaveSetup' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -751,7 +638,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -760,26 +647,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(employeeLeaveSetup, "EmployeeLeaveSetup"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -794,7 +661,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveSetupObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveSetupObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -806,7 +673,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -819,7 +687,7 @@ export class PayrollNzApi { * @param employeeLeaveType * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeLeaveType (xeroTenantId: string, employeeID: string, employeeLeaveType: EmployeeLeaveType, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveTypeObject; }> { + public async createEmployeeLeaveType (xeroTenantId: string, employeeID: string, employeeLeaveType: EmployeeLeaveType, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveTypeObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/LeaveTypes' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -851,7 +719,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -860,26 +728,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(employeeLeaveType, "EmployeeLeaveType"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -894,7 +742,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveTypeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveTypeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -906,7 +754,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -919,7 +768,7 @@ export class PayrollNzApi { * @param employeeOpeningBalance * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeOpeningBalances (xeroTenantId: string, employeeID: string, employeeOpeningBalance: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeOpeningBalancesObject; }> { + public async createEmployeeOpeningBalances (xeroTenantId: string, employeeID: string, employeeOpeningBalance: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeOpeningBalancesObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/openingBalances' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -951,7 +800,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -960,26 +809,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(employeeOpeningBalance, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -994,7 +823,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeOpeningBalancesObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeOpeningBalancesObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1006,7 +835,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1019,7 +849,7 @@ export class PayrollNzApi { * @param paymentMethod * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeePaymentMethod (xeroTenantId: string, employeeID: string, paymentMethod: PaymentMethod, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PaymentMethodObject; }> { + public async createEmployeePaymentMethod (xeroTenantId: string, employeeID: string, paymentMethod: PaymentMethod, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PaymentMethodObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PaymentMethods' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -1051,7 +881,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1060,26 +890,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(paymentMethod, "PaymentMethod"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1094,7 +904,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PaymentMethodObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PaymentMethodObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1106,7 +916,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1119,7 +930,7 @@ export class PayrollNzApi { * @param salaryAndWage * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWage: SalaryAndWage, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SalaryAndWageObject; }> { + public async createEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWage: SalaryAndWage, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SalaryAndWageObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/SalaryAndWages' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -1151,7 +962,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1160,26 +971,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(salaryAndWage, "SalaryAndWage"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1194,7 +985,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SalaryAndWageObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SalaryAndWageObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1206,7 +997,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1219,7 +1011,7 @@ export class PayrollNzApi { * @param employment * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployment (xeroTenantId: string, employeeID: string, employment: Employment, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmploymentObject; }> { + public async createEmployment (xeroTenantId: string, employeeID: string, employment: Employment, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmploymentObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Employment' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -1251,7 +1043,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1260,26 +1052,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(employment, "Employment"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1294,7 +1066,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmploymentObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmploymentObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1306,7 +1078,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1318,7 +1091,7 @@ export class PayrollNzApi { * @param leaveType * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createLeaveType (xeroTenantId: string, leaveType: LeaveType, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveTypeObject; }> { + public async createLeaveType (xeroTenantId: string, leaveType: LeaveType, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveTypeObject; }> { const localVarPath = this.basePath + '/LeaveTypes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1344,7 +1117,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1353,26 +1126,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(leaveType, "LeaveType"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1387,7 +1140,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveTypeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveTypeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1399,7 +1152,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1412,7 +1166,7 @@ export class PayrollNzApi { * @param earningsTemplate * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createMultipleEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, earningsTemplate: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeEarningsTemplates; }> { + public async createMultipleEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, earningsTemplate: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeEarningsTemplates; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/paytemplateearnings' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -1444,7 +1198,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1453,26 +1207,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(earningsTemplate, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1487,7 +1221,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeEarningsTemplates; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeEarningsTemplates; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1499,7 +1233,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1511,7 +1246,7 @@ export class PayrollNzApi { * @param payRun * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPayRun (xeroTenantId: string, payRun: PayRun, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRunObject; }> { + public async createPayRun (xeroTenantId: string, payRun: PayRun, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRunObject; }> { const localVarPath = this.basePath + '/PayRuns'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1537,7 +1272,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1546,26 +1281,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(payRun, "PayRun"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1580,7 +1295,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRunObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRunObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1592,7 +1307,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1604,7 +1320,7 @@ export class PayrollNzApi { * @param payRunCalendar * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPayRunCalendar (xeroTenantId: string, payRunCalendar: PayRunCalendar, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRunCalendarObject; }> { + public async createPayRunCalendar (xeroTenantId: string, payRunCalendar: PayRunCalendar, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRunCalendarObject; }> { const localVarPath = this.basePath + '/PayRunCalendars'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1630,7 +1346,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1639,26 +1355,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(payRunCalendar, "PayRunCalendar"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1673,7 +1369,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRunCalendarObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRunCalendarObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1685,7 +1381,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1697,7 +1394,7 @@ export class PayrollNzApi { * @param reimbursement * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createReimbursement (xeroTenantId: string, reimbursement: Reimbursement, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReimbursementObject; }> { + public async createReimbursement (xeroTenantId: string, reimbursement: Reimbursement, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReimbursementObject; }> { const localVarPath = this.basePath + '/Reimbursements'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1723,7 +1420,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1732,26 +1429,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(reimbursement, "Reimbursement"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1766,7 +1443,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReimbursementObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReimbursementObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1778,7 +1455,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1790,7 +1468,7 @@ export class PayrollNzApi { * @param benefit * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createSuperannuation (xeroTenantId: string, benefit: Benefit, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SuperannuationObject; }> { + public async createSuperannuation (xeroTenantId: string, benefit: Benefit, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SuperannuationObject; }> { const localVarPath = this.basePath + '/Superannuations'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1816,7 +1494,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1825,26 +1503,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(benefit, "Benefit"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1859,7 +1517,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SuperannuationObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SuperannuationObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1871,7 +1529,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1883,7 +1542,7 @@ export class PayrollNzApi { * @param timesheet * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createTimesheet (xeroTenantId: string, timesheet: Timesheet, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetObject; }> { + public async createTimesheet (xeroTenantId: string, timesheet: Timesheet, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetObject; }> { const localVarPath = this.basePath + '/Timesheets'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1909,7 +1568,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1918,26 +1577,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(timesheet, "Timesheet"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1952,7 +1591,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1964,7 +1603,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1977,7 +1617,7 @@ export class PayrollNzApi { * @param timesheetLine * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLine: TimesheetLine, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetLineObject; }> { + public async createTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLine: TimesheetLine, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetLineObject; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/Lines' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -2009,7 +1649,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2018,26 +1658,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(timesheetLine, "TimesheetLine"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2052,7 +1672,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetLineObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetLineObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2064,7 +1684,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2076,7 +1697,7 @@ export class PayrollNzApi { * @param employeeID Employee id for single object * @param payTemplateEarningID Id for single pay template earnings object */ - public async deleteEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, payTemplateEarningID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsTemplateObject; }> { + public async deleteEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, payTemplateEarningID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsTemplateObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PayTemplates/earnings/{PayTemplateEarningID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'PayTemplateEarningID' + '}', encodeURIComponent(String(payTemplateEarningID))); @@ -2108,7 +1729,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2117,26 +1738,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2151,7 +1752,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsTemplateObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsTemplateObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2163,7 +1764,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2175,7 +1777,7 @@ export class PayrollNzApi { * @param employeeID Employee id for single object * @param leaveID Leave id for single object */ - public async deleteEmployeeLeave (xeroTenantId: string, employeeID: string, leaveID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }> { + public async deleteEmployeeLeave (xeroTenantId: string, employeeID: string, leaveID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Leave/{LeaveID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'LeaveID' + '}', encodeURIComponent(String(leaveID))); @@ -2207,7 +1809,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2216,26 +1818,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2250,7 +1832,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2262,7 +1844,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2274,7 +1857,7 @@ export class PayrollNzApi { * @param employeeID Employee id for single object * @param salaryAndWagesID Id for single salary and wages object */ - public async deleteEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SalaryAndWageObject; }> { + public async deleteEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SalaryAndWageObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/SalaryAndWages/{SalaryAndWagesID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'SalaryAndWagesID' + '}', encodeURIComponent(String(salaryAndWagesID))); @@ -2306,7 +1889,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2315,26 +1898,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2349,7 +1912,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SalaryAndWageObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SalaryAndWageObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2361,7 +1924,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2372,7 +1936,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param timesheetID Identifier for the timesheet */ - public async deleteTimesheet (xeroTenantId: string, timesheetID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetLine; }> { + public async deleteTimesheet (xeroTenantId: string, timesheetID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetLine; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -2398,7 +1962,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2407,26 +1971,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2441,7 +1985,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetLine; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetLine; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2453,7 +1997,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2465,7 +2010,7 @@ export class PayrollNzApi { * @param timesheetID Identifier for the timesheet * @param timesheetLineID Identifier for the timesheet line */ - public async deleteTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLineID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetLine; }> { + public async deleteTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLineID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetLine; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/Lines/{TimesheetLineID}' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))) .replace('{' + 'TimesheetLineID' + '}', encodeURIComponent(String(timesheetLineID))); @@ -2497,7 +2042,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2506,26 +2051,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2540,7 +2065,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetLine; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetLine; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2552,7 +2077,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2563,7 +2089,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param deductionId Identifier for the deduction */ - public async getDeduction (xeroTenantId: string, deductionId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: DeductionObject; }> { + public async getDeduction (xeroTenantId: string, deductionId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: DeductionObject; }> { const localVarPath = this.basePath + '/Deductions/{deductionId}' .replace('{' + 'deductionId' + '}', encodeURIComponent(String(deductionId))); let localVarQueryParameters: any = {}; @@ -2589,7 +2115,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2598,26 +2124,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2632,7 +2138,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: DeductionObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: DeductionObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2644,7 +2150,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2655,7 +2162,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getDeductions (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Deductions; }> { + public async getDeductions (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Deductions; }> { const localVarPath = this.basePath + '/Deductions'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2679,7 +2186,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2688,26 +2195,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2722,7 +2209,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Deductions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Deductions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2734,7 +2221,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2745,7 +2233,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param earningsRateID Identifier for the earnings rate */ - public async getEarningsRate (xeroTenantId: string, earningsRateID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsRateObject; }> { + public async getEarningsRate (xeroTenantId: string, earningsRateID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsRateObject; }> { const localVarPath = this.basePath + '/EarningsRates/{EarningsRateID}' .replace('{' + 'EarningsRateID' + '}', encodeURIComponent(String(earningsRateID))); let localVarQueryParameters: any = {}; @@ -2771,7 +2259,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2780,26 +2268,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2814,7 +2282,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsRateObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsRateObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2826,7 +2294,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2837,7 +2306,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getEarningsRates (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsRates; }> { + public async getEarningsRates (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsRates; }> { const localVarPath = this.basePath + '/EarningsRates'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2861,7 +2330,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2870,26 +2339,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2904,7 +2353,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsRates; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsRates; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2916,7 +2365,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2927,7 +2377,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployee (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeObject; }> { + public async getEmployee (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -2953,7 +2403,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2962,26 +2412,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2996,7 +2426,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3008,7 +2438,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3019,7 +2450,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeeLeaveBalances (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveBalances; }> { + public async getEmployeeLeaveBalances (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveBalances; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/LeaveBalances' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3045,7 +2476,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3054,26 +2485,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3088,7 +2499,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveBalances; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveBalances; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3100,7 +2511,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3113,7 +2525,7 @@ export class PayrollNzApi { * @param startDate Filter by start date * @param endDate Filter by end date */ - public async getEmployeeLeavePeriods (xeroTenantId: string, employeeID: string, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeavePeriods; }> { + public async getEmployeeLeavePeriods (xeroTenantId: string, employeeID: string, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeavePeriods; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/LeavePeriods' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3147,7 +2559,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3156,26 +2568,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3190,7 +2582,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeavePeriods; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeavePeriods; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3202,7 +2594,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3213,7 +2606,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeeLeaveTypes (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveTypes; }> { + public async getEmployeeLeaveTypes (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveTypes; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/LeaveTypes' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3239,7 +2632,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3248,26 +2641,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3282,7 +2655,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveTypes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveTypes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3294,7 +2667,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3305,7 +2679,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeeLeaves (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaves; }> { + public async getEmployeeLeaves (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaves; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Leave' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3331,7 +2705,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3340,26 +2714,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3374,7 +2728,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaves; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaves; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3386,7 +2740,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3397,7 +2752,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeeOpeningBalances (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeOpeningBalancesObject; }> { + public async getEmployeeOpeningBalances (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeOpeningBalancesObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/openingBalances' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3423,7 +2778,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3432,26 +2787,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3466,7 +2801,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeOpeningBalancesObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeOpeningBalancesObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3478,7 +2813,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3489,7 +2825,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeePayTemplates (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeePayTemplates; }> { + public async getEmployeePayTemplates (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeePayTemplates; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PayTemplates' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3515,7 +2851,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3524,26 +2860,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3558,7 +2874,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeePayTemplates; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeePayTemplates; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3570,7 +2886,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3581,7 +2898,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeePaymentMethod (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PaymentMethodObject; }> { + public async getEmployeePaymentMethod (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PaymentMethodObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PaymentMethods' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3607,7 +2924,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3616,26 +2933,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3650,7 +2947,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PaymentMethodObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PaymentMethodObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3662,7 +2959,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3674,7 +2972,7 @@ export class PayrollNzApi { * @param employeeID Employee id for single object * @param salaryAndWagesID Id for single pay template earnings object */ - public async getEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SalaryAndWages; }> { + public async getEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SalaryAndWages; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/SalaryAndWages/{SalaryAndWagesID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'SalaryAndWagesID' + '}', encodeURIComponent(String(salaryAndWagesID))); @@ -3706,7 +3004,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3715,26 +3013,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3749,7 +3027,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SalaryAndWages; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SalaryAndWages; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3761,7 +3039,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3773,7 +3052,7 @@ export class PayrollNzApi { * @param employeeID Employee id for single object * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getEmployeeSalaryAndWages (xeroTenantId: string, employeeID: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SalaryAndWages; }> { + public async getEmployeeSalaryAndWages (xeroTenantId: string, employeeID: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SalaryAndWages; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/SalaryAndWages' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3803,7 +3082,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3812,26 +3091,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3846,7 +3105,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SalaryAndWages; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SalaryAndWages; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3858,7 +3117,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3869,7 +3129,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeeTax (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeTaxObject; }> { + public async getEmployeeTax (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeTaxObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Tax' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3895,7 +3155,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3904,26 +3164,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3938,7 +3178,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeTaxObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeTaxObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3950,7 +3190,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3962,7 +3203,7 @@ export class PayrollNzApi { * @param filter Filter by first name and/or lastname * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getEmployees (xeroTenantId: string, filter?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Employees; }> { + public async getEmployees (xeroTenantId: string, filter?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Employees; }> { const localVarPath = this.basePath + '/Employees'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -3990,7 +3231,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3999,26 +3240,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4033,7 +3254,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Employees; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Employees; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4045,7 +3266,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4056,7 +3278,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param leaveTypeID Identifier for the leave type */ - public async getLeaveType (xeroTenantId: string, leaveTypeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveTypeObject; }> { + public async getLeaveType (xeroTenantId: string, leaveTypeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveTypeObject; }> { const localVarPath = this.basePath + '/LeaveTypes/{LeaveTypeID}' .replace('{' + 'LeaveTypeID' + '}', encodeURIComponent(String(leaveTypeID))); let localVarQueryParameters: any = {}; @@ -4082,7 +3304,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4091,26 +3313,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4125,7 +3327,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveTypeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveTypeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4137,7 +3339,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4149,7 +3352,7 @@ export class PayrollNzApi { * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. * @param activeOnly Filters leave types by active status. By default the API returns all leave types. */ - public async getLeaveTypes (xeroTenantId: string, page?: number, activeOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveTypes; }> { + public async getLeaveTypes (xeroTenantId: string, page?: number, activeOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveTypes; }> { const localVarPath = this.basePath + '/LeaveTypes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -4177,7 +3380,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4186,26 +3389,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4220,7 +3403,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveTypes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveTypes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4232,7 +3415,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4243,7 +3427,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param payRunID Identifier for the pay run */ - public async getPayRun (xeroTenantId: string, payRunID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRunObject; }> { + public async getPayRun (xeroTenantId: string, payRunID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRunObject; }> { const localVarPath = this.basePath + '/PayRuns/{PayRunID}' .replace('{' + 'PayRunID' + '}', encodeURIComponent(String(payRunID))); let localVarQueryParameters: any = {}; @@ -4269,7 +3453,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4278,26 +3462,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4312,7 +3476,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRunObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRunObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4324,7 +3488,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4335,7 +3500,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param payrollCalendarID Identifier for the payrun calendars */ - public async getPayRunCalendar (xeroTenantId: string, payrollCalendarID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRunCalendarObject; }> { + public async getPayRunCalendar (xeroTenantId: string, payrollCalendarID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRunCalendarObject; }> { const localVarPath = this.basePath + '/PayRunCalendars/{PayrollCalendarID}' .replace('{' + 'PayrollCalendarID' + '}', encodeURIComponent(String(payrollCalendarID))); let localVarQueryParameters: any = {}; @@ -4361,7 +3526,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4370,26 +3535,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4404,7 +3549,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRunCalendarObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRunCalendarObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4416,7 +3561,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4427,7 +3573,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getPayRunCalendars (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRunCalendars; }> { + public async getPayRunCalendars (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRunCalendars; }> { const localVarPath = this.basePath + '/PayRunCalendars'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -4451,7 +3597,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4460,26 +3606,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4494,7 +3620,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRunCalendars; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRunCalendars; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4506,7 +3632,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4518,7 +3645,7 @@ export class PayrollNzApi { * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. * @param status By default get payruns will return all the payruns for an organization. You can add GET https://api.xero.com/payroll.xro/2.0/payRuns?statu={PayRunStatus} to filter the payruns by status. */ - public async getPayRuns (xeroTenantId: string, page?: number, status?: 'Draft' | 'Posted', options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRuns; }> { + public async getPayRuns (xeroTenantId: string, page?: number, status?: 'Draft' | 'Posted', options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRuns; }> { const localVarPath = this.basePath + '/PayRuns'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -4546,7 +3673,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4555,26 +3682,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4589,7 +3696,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRuns; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRuns; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4601,7 +3708,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4612,7 +3720,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param paySlipID Identifier for the payslip */ - public async getPaySlip (xeroTenantId: string, paySlipID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PaySlipObject; }> { + public async getPaySlip (xeroTenantId: string, paySlipID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PaySlipObject; }> { const localVarPath = this.basePath + '/PaySlips/{PaySlipID}' .replace('{' + 'PaySlipID' + '}', encodeURIComponent(String(paySlipID))); let localVarQueryParameters: any = {}; @@ -4638,7 +3746,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4647,26 +3755,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4681,7 +3769,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PaySlipObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PaySlipObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4693,7 +3781,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4705,7 +3794,7 @@ export class PayrollNzApi { * @param payRunID PayrunID which specifies the containing payrun of payslips to retrieve. By default, the API does not group payslips by payrun. * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getPaySlips (xeroTenantId: string, payRunID: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PaySlips; }> { + public async getPaySlips (xeroTenantId: string, payRunID: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PaySlips; }> { const localVarPath = this.basePath + '/PaySlips'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -4738,7 +3827,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4747,26 +3836,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4781,7 +3850,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PaySlips; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PaySlips; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4793,7 +3862,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4804,7 +3874,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param reimbursementID Identifier for the reimbursement */ - public async getReimbursement (xeroTenantId: string, reimbursementID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReimbursementObject; }> { + public async getReimbursement (xeroTenantId: string, reimbursementID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReimbursementObject; }> { const localVarPath = this.basePath + '/Reimbursements/{ReimbursementID}' .replace('{' + 'ReimbursementID' + '}', encodeURIComponent(String(reimbursementID))); let localVarQueryParameters: any = {}; @@ -4830,7 +3900,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4839,26 +3909,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4873,7 +3923,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReimbursementObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReimbursementObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4885,7 +3935,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4896,7 +3947,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getReimbursements (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Reimbursements; }> { + public async getReimbursements (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Reimbursements; }> { const localVarPath = this.basePath + '/Reimbursements'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -4920,7 +3971,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4929,26 +3980,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4963,7 +3994,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Reimbursements; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Reimbursements; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4975,7 +4006,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4985,7 +4017,7 @@ export class PayrollNzApi { * @summary Retrieves settings * @param xeroTenantId Xero identifier for Tenant */ - public async getSettings (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Settings; }> { + public async getSettings (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Settings; }> { const localVarPath = this.basePath + '/Settings'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5005,7 +4037,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5014,26 +4046,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5048,7 +4060,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Settings; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Settings; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5060,7 +4072,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5071,7 +4084,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param id Identifier for the statutory deduction */ - public async getStatutoryDeduction (xeroTenantId: string, id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: StatutoryDeductionObject; }> { + public async getStatutoryDeduction (xeroTenantId: string, id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: StatutoryDeductionObject; }> { const localVarPath = this.basePath + '/StatutoryDeductions/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; @@ -5097,7 +4110,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5106,26 +4119,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5140,7 +4133,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: StatutoryDeductionObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: StatutoryDeductionObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5152,7 +4145,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5163,7 +4157,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getStatutoryDeductions (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: StatutoryDeductions; }> { + public async getStatutoryDeductions (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: StatutoryDeductions; }> { const localVarPath = this.basePath + '/StatutoryDeductions'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5187,7 +4181,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5196,26 +4190,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5230,7 +4204,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: StatutoryDeductions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: StatutoryDeductions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5242,7 +4216,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5253,7 +4228,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param superannuationID Identifier for the superannuation */ - public async getSuperannuation (xeroTenantId: string, superannuationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SuperannuationObject; }> { + public async getSuperannuation (xeroTenantId: string, superannuationID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SuperannuationObject; }> { const localVarPath = this.basePath + '/Superannuations/{SuperannuationID}' .replace('{' + 'SuperannuationID' + '}', encodeURIComponent(String(superannuationID))); let localVarQueryParameters: any = {}; @@ -5279,7 +4254,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5288,26 +4263,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5322,7 +4277,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SuperannuationObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SuperannuationObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5334,7 +4289,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5345,7 +4301,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getSuperannuations (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Superannuations; }> { + public async getSuperannuations (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Superannuations; }> { const localVarPath = this.basePath + '/Superannuations'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5369,7 +4325,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5378,26 +4334,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5412,7 +4348,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Superannuations; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Superannuations; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5424,7 +4360,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5435,7 +4372,7 @@ export class PayrollNzApi { * @param xeroTenantId Xero identifier for Tenant * @param timesheetID Identifier for the timesheet */ - public async getTimesheet (xeroTenantId: string, timesheetID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetObject; }> { + public async getTimesheet (xeroTenantId: string, timesheetID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetObject; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -5461,7 +4398,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5470,26 +4407,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5504,7 +4421,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5516,7 +4433,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5532,7 +4450,7 @@ export class PayrollNzApi { * @param endDate filter results by any timesheets with a endDate on or before the provided date * @param sort sort the order of timesheets returned. The default is based on the timesheets createdDate, sorted oldest to newest. Currently, the only other option is to reverse the order based on the timesheets startDate, sorted newest to oldest. */ - public async getTimesheets (xeroTenantId: string, page?: number, filter?: string, status?: string, startDate?: string, endDate?: string, sort?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Timesheets; }> { + public async getTimesheets (xeroTenantId: string, page?: number, filter?: string, status?: string, startDate?: string, endDate?: string, sort?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Timesheets; }> { const localVarPath = this.basePath + '/Timesheets'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5576,7 +4494,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5585,26 +4503,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5619,7 +4517,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Timesheets; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Timesheets; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5631,7 +4529,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5641,7 +4540,7 @@ export class PayrollNzApi { * @summary Retrieves tracking categories * @param xeroTenantId Xero identifier for Tenant */ - public async getTrackingCategories (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TrackingCategories; }> { + public async getTrackingCategories (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TrackingCategories; }> { const localVarPath = this.basePath + '/Settings/TrackingCategories'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5661,7 +4560,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5670,26 +4569,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5704,7 +4583,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TrackingCategories; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TrackingCategories; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5716,7 +4595,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5728,7 +4608,7 @@ export class PayrollNzApi { * @param timesheetID Identifier for the timesheet * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async revertTimesheet (xeroTenantId: string, timesheetID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetObject; }> { + public async revertTimesheet (xeroTenantId: string, timesheetID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetObject; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/RevertToDraft' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -5755,7 +4635,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5764,26 +4644,6 @@ export class PayrollNzApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5798,7 +4658,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5810,7 +4670,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5823,7 +4684,7 @@ export class PayrollNzApi { * @param employee * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateEmployee (xeroTenantId: string, employeeID: string, employee: Employee, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeObject; }> { + public async updateEmployee (xeroTenantId: string, employeeID: string, employee: Employee, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -5855,7 +4716,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5864,26 +4725,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(employee, "Employee"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5898,7 +4739,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5910,7 +4751,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5924,7 +4766,7 @@ export class PayrollNzApi { * @param earningsTemplate * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, payTemplateEarningID: string, earningsTemplate: EarningsTemplate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsTemplateObject; }> { + public async updateEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, payTemplateEarningID: string, earningsTemplate: EarningsTemplate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsTemplateObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PayTemplates/earnings/{PayTemplateEarningID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'PayTemplateEarningID' + '}', encodeURIComponent(String(payTemplateEarningID))); @@ -5962,7 +4804,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5971,26 +4813,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(earningsTemplate, "EarningsTemplate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6005,7 +4827,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsTemplateObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsTemplateObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6017,7 +4839,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6031,7 +4854,7 @@ export class PayrollNzApi { * @param employeeLeave * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateEmployeeLeave (xeroTenantId: string, employeeID: string, leaveID: string, employeeLeave: EmployeeLeave, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }> { + public async updateEmployeeLeave (xeroTenantId: string, employeeID: string, leaveID: string, employeeLeave: EmployeeLeave, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Leave/{LeaveID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'LeaveID' + '}', encodeURIComponent(String(leaveID))); @@ -6069,7 +4892,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6078,26 +4901,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(employeeLeave, "EmployeeLeave"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6112,7 +4915,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6124,7 +4927,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6138,7 +4942,7 @@ export class PayrollNzApi { * @param salaryAndWage * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, salaryAndWage: SalaryAndWage, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SalaryAndWageObject; }> { + public async updateEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, salaryAndWage: SalaryAndWage, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SalaryAndWageObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/SalaryAndWages/{SalaryAndWagesID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'SalaryAndWagesID' + '}', encodeURIComponent(String(salaryAndWagesID))); @@ -6176,7 +4980,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6185,26 +4989,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(salaryAndWage, "SalaryAndWage"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6219,7 +5003,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SalaryAndWageObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SalaryAndWageObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6231,7 +5015,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6244,7 +5029,7 @@ export class PayrollNzApi { * @param employeeTax * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateEmployeeTax (xeroTenantId: string, employeeID: string, employeeTax: EmployeeTax, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeTaxObject; }> { + public async updateEmployeeTax (xeroTenantId: string, employeeID: string, employeeTax: EmployeeTax, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeTaxObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Tax' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -6276,7 +5061,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6285,26 +5070,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(employeeTax, "EmployeeTax"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6319,7 +5084,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeTaxObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeTaxObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6331,7 +5096,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6344,7 +5110,7 @@ export class PayrollNzApi { * @param payRun * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updatePayRun (xeroTenantId: string, payRunID: string, payRun: PayRun, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRunObject; }> { + public async updatePayRun (xeroTenantId: string, payRunID: string, payRun: PayRun, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRunObject; }> { const localVarPath = this.basePath + '/PayRuns/{PayRunID}' .replace('{' + 'PayRunID' + '}', encodeURIComponent(String(payRunID))); let localVarQueryParameters: any = {}; @@ -6376,7 +5142,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6385,26 +5151,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(payRun, "PayRun"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6419,7 +5165,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRunObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRunObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6431,7 +5177,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6444,7 +5191,7 @@ export class PayrollNzApi { * @param paySlip * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updatePaySlipLineItems (xeroTenantId: string, paySlipID: string, paySlip: PaySlip, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PaySlipObject; }> { + public async updatePaySlipLineItems (xeroTenantId: string, paySlipID: string, paySlip: PaySlip, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PaySlipObject; }> { const localVarPath = this.basePath + '/PaySlips/{PaySlipID}' .replace('{' + 'PaySlipID' + '}', encodeURIComponent(String(paySlipID))); let localVarQueryParameters: any = {}; @@ -6476,7 +5223,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6485,26 +5232,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(paySlip, "PaySlip"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6519,7 +5246,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PaySlipObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PaySlipObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6531,7 +5258,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6545,7 +5273,7 @@ export class PayrollNzApi { * @param timesheetLine * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLineID: string, timesheetLine: TimesheetLine, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetLineObject; }> { + public async updateTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLineID: string, timesheetLine: TimesheetLine, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetLineObject; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/Lines/{TimesheetLineID}' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))) .replace('{' + 'TimesheetLineID' + '}', encodeURIComponent(String(timesheetLineID))); @@ -6583,7 +5311,7 @@ export class PayrollNzApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6592,26 +5320,6 @@ export class PayrollNzApi { data: ObjectSerializer.serialize(timesheetLine, "TimesheetLine"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6626,7 +5334,7 @@ export class PayrollNzApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetLineObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetLineObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6638,7 +5346,8 @@ export class PayrollNzApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); diff --git a/src/gen/api/payrollUKApi.ts b/src/gen/api/payrollUKApi.ts index c2bb7399..290d3c6f 100644 --- a/src/gen/api/payrollUKApi.ts +++ b/src/gen/api/payrollUKApi.ts @@ -10,7 +10,6 @@ * Do not edit the class manually. */ -const axios = require('axios'); import http = require('http'); import fs = require('fs'); @@ -79,6 +78,8 @@ import { Timesheets } from '../model/payroll-uk/timesheets'; import { TrackingCategories } from '../model/payroll-uk/trackingCategories'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/payroll-uk/models'; +import { ApiError } from '../../model/ApiError'; +import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import { OAuth } from '../model/payroll-uk/models'; let defaultBasePath = 'https://api.xero.com/payroll.xro/2.0'; @@ -145,7 +146,7 @@ export class PayrollUkApi { * @param timesheetID Identifier for the timesheet * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async approveTimesheet (xeroTenantId: string, timesheetID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetObject; }> { + public async approveTimesheet (xeroTenantId: string, timesheetID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetObject; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/Approve' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -172,7 +173,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -181,26 +182,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -215,7 +196,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -227,7 +208,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -239,7 +221,7 @@ export class PayrollUkApi { * @param benefit * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createBenefit (xeroTenantId: string, benefit: Benefit, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BenefitObject; }> { + public async createBenefit (xeroTenantId: string, benefit: Benefit, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BenefitObject; }> { const localVarPath = this.basePath + '/Benefits'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -265,7 +247,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -274,26 +256,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(benefit, "Benefit"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -308,7 +270,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BenefitObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BenefitObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -320,7 +282,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -332,7 +295,7 @@ export class PayrollUkApi { * @param deduction * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createDeduction (xeroTenantId: string, deduction: Deduction, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: DeductionObject; }> { + public async createDeduction (xeroTenantId: string, deduction: Deduction, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: DeductionObject; }> { const localVarPath = this.basePath + '/Deductions'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -358,7 +321,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -367,26 +330,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(deduction, "Deduction"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -401,7 +344,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: DeductionObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: DeductionObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -413,7 +356,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -425,7 +369,7 @@ export class PayrollUkApi { * @param earningsRate * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEarningsRate (xeroTenantId: string, earningsRate: EarningsRate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsRateObject; }> { + public async createEarningsRate (xeroTenantId: string, earningsRate: EarningsRate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsRateObject; }> { const localVarPath = this.basePath + '/EarningsRates'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -451,7 +395,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -460,26 +404,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(earningsRate, "EarningsRate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -494,7 +418,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsRateObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsRateObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -506,7 +430,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -518,7 +443,7 @@ export class PayrollUkApi { * @param employee * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployee (xeroTenantId: string, employee: Employee, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeObject; }> { + public async createEmployee (xeroTenantId: string, employee: Employee, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeObject; }> { const localVarPath = this.basePath + '/Employees'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -544,7 +469,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -553,26 +478,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(employee, "Employee"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -587,7 +492,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -599,7 +504,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -612,7 +518,7 @@ export class PayrollUkApi { * @param earningsTemplate * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, earningsTemplate: EarningsTemplate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsTemplateObject; }> { + public async createEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, earningsTemplate: EarningsTemplate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsTemplateObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PayTemplates/earnings' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -644,7 +550,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -653,26 +559,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(earningsTemplate, "EarningsTemplate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -687,7 +573,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsTemplateObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsTemplateObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -699,7 +585,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -712,7 +599,7 @@ export class PayrollUkApi { * @param employeeLeave * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeLeave (xeroTenantId: string, employeeID: string, employeeLeave: EmployeeLeave, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }> { + public async createEmployeeLeave (xeroTenantId: string, employeeID: string, employeeLeave: EmployeeLeave, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Leave' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -744,7 +631,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -753,26 +640,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(employeeLeave, "EmployeeLeave"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -787,7 +654,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -799,7 +666,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -812,7 +680,7 @@ export class PayrollUkApi { * @param employeeLeaveType * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeLeaveType (xeroTenantId: string, employeeID: string, employeeLeaveType: EmployeeLeaveType, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveTypeObject; }> { + public async createEmployeeLeaveType (xeroTenantId: string, employeeID: string, employeeLeaveType: EmployeeLeaveType, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveTypeObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/LeaveTypes' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -844,7 +712,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -853,26 +721,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(employeeLeaveType, "EmployeeLeaveType"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -887,7 +735,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveTypeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveTypeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -899,7 +747,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -912,7 +761,7 @@ export class PayrollUkApi { * @param employeeOpeningBalances * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeOpeningBalances (xeroTenantId: string, employeeID: string, employeeOpeningBalances: EmployeeOpeningBalances, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeOpeningBalancesObject; }> { + public async createEmployeeOpeningBalances (xeroTenantId: string, employeeID: string, employeeOpeningBalances: EmployeeOpeningBalances, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeOpeningBalancesObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/ukopeningbalances' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -944,7 +793,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -953,26 +802,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(employeeOpeningBalances, "EmployeeOpeningBalances"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -987,7 +816,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeOpeningBalancesObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeOpeningBalancesObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -999,7 +828,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1012,7 +842,7 @@ export class PayrollUkApi { * @param paymentMethod * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeePaymentMethod (xeroTenantId: string, employeeID: string, paymentMethod: PaymentMethod, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PaymentMethodObject; }> { + public async createEmployeePaymentMethod (xeroTenantId: string, employeeID: string, paymentMethod: PaymentMethod, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PaymentMethodObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PaymentMethods' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -1044,7 +874,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1053,26 +883,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(paymentMethod, "PaymentMethod"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1087,7 +897,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PaymentMethodObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PaymentMethodObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1099,7 +909,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1112,7 +923,7 @@ export class PayrollUkApi { * @param salaryAndWage * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWage: SalaryAndWage, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SalaryAndWageObject; }> { + public async createEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWage: SalaryAndWage, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SalaryAndWageObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/SalaryAndWages' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -1144,7 +955,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1153,26 +964,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(salaryAndWage, "SalaryAndWage"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1187,7 +978,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SalaryAndWageObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SalaryAndWageObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1199,7 +990,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1211,7 +1003,7 @@ export class PayrollUkApi { * @param employeeStatutorySickLeave * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployeeStatutorySickLeave (xeroTenantId: string, employeeStatutorySickLeave: EmployeeStatutorySickLeave, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeStatutorySickLeaveObject; }> { + public async createEmployeeStatutorySickLeave (xeroTenantId: string, employeeStatutorySickLeave: EmployeeStatutorySickLeave, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeStatutorySickLeaveObject; }> { const localVarPath = this.basePath + '/StatutoryLeaves/Sick'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1237,7 +1029,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1246,26 +1038,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(employeeStatutorySickLeave, "EmployeeStatutorySickLeave"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1280,7 +1052,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeStatutorySickLeaveObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeStatutorySickLeaveObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1292,7 +1064,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1305,7 +1078,7 @@ export class PayrollUkApi { * @param employment * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createEmployment (xeroTenantId: string, employeeID: string, employment: Employment, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmploymentObject; }> { + public async createEmployment (xeroTenantId: string, employeeID: string, employment: Employment, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmploymentObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Employment' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -1337,7 +1110,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1346,26 +1119,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(employment, "Employment"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1380,7 +1133,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmploymentObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmploymentObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1392,7 +1145,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1404,7 +1158,7 @@ export class PayrollUkApi { * @param leaveType * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createLeaveType (xeroTenantId: string, leaveType: LeaveType, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveTypeObject; }> { + public async createLeaveType (xeroTenantId: string, leaveType: LeaveType, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveTypeObject; }> { const localVarPath = this.basePath + '/LeaveTypes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1430,7 +1184,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1439,26 +1193,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(leaveType, "LeaveType"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1473,7 +1207,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveTypeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveTypeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1485,7 +1219,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1498,7 +1233,7 @@ export class PayrollUkApi { * @param earningsTemplate * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createMultipleEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, earningsTemplate: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeePayTemplates; }> { + public async createMultipleEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, earningsTemplate: Array, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeePayTemplates; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/paytemplateearnings' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -1530,7 +1265,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1539,26 +1274,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(earningsTemplate, "Array"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1573,7 +1288,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeePayTemplates; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeePayTemplates; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1585,7 +1300,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1597,7 +1313,7 @@ export class PayrollUkApi { * @param payRunCalendar * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createPayRunCalendar (xeroTenantId: string, payRunCalendar: PayRunCalendar, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRunCalendarObject; }> { + public async createPayRunCalendar (xeroTenantId: string, payRunCalendar: PayRunCalendar, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRunCalendarObject; }> { const localVarPath = this.basePath + '/PayRunCalendars'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1623,7 +1339,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1632,26 +1348,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(payRunCalendar, "PayRunCalendar"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1666,7 +1362,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRunCalendarObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRunCalendarObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1678,7 +1374,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1690,7 +1387,7 @@ export class PayrollUkApi { * @param reimbursement * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createReimbursement (xeroTenantId: string, reimbursement: Reimbursement, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReimbursementObject; }> { + public async createReimbursement (xeroTenantId: string, reimbursement: Reimbursement, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReimbursementObject; }> { const localVarPath = this.basePath + '/Reimbursements'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1716,7 +1413,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1725,26 +1422,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(reimbursement, "Reimbursement"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1759,7 +1436,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReimbursementObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReimbursementObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1771,7 +1448,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1783,7 +1461,7 @@ export class PayrollUkApi { * @param timesheet * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createTimesheet (xeroTenantId: string, timesheet: Timesheet, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetObject; }> { + public async createTimesheet (xeroTenantId: string, timesheet: Timesheet, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetObject; }> { const localVarPath = this.basePath + '/Timesheets'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -1809,7 +1487,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1818,26 +1496,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(timesheet, "Timesheet"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1852,7 +1510,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1864,7 +1522,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1877,7 +1536,7 @@ export class PayrollUkApi { * @param timesheetLine * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLine: TimesheetLine, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetLineObject; }> { + public async createTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLine: TimesheetLine, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetLineObject; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/Lines' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -1909,7 +1568,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1918,26 +1577,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(timesheetLine, "TimesheetLine"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1952,7 +1591,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetLineObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetLineObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1964,7 +1603,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1976,7 +1616,7 @@ export class PayrollUkApi { * @param employeeID Employee id for single object * @param payTemplateEarningID Id for single pay template earnings object */ - public async deleteEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, payTemplateEarningID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async deleteEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, payTemplateEarningID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PayTemplates/earnings/{PayTemplateEarningID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'PayTemplateEarningID' + '}', encodeURIComponent(String(payTemplateEarningID))); @@ -2007,7 +1647,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2016,26 +1656,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2050,7 +1670,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2062,7 +1682,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2074,7 +1695,7 @@ export class PayrollUkApi { * @param employeeID Employee id for single object * @param leaveID Leave id for single object */ - public async deleteEmployeeLeave (xeroTenantId: string, employeeID: string, leaveID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }> { + public async deleteEmployeeLeave (xeroTenantId: string, employeeID: string, leaveID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Leave/{LeaveID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'LeaveID' + '}', encodeURIComponent(String(leaveID))); @@ -2106,7 +1727,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2115,26 +1736,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2149,7 +1750,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2161,7 +1762,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2173,7 +1775,7 @@ export class PayrollUkApi { * @param employeeID Employee id for single object * @param salaryAndWagesID Id for single salary and wages object */ - public async deleteEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async deleteEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/SalaryAndWages/{SalaryAndWagesID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'SalaryAndWagesID' + '}', encodeURIComponent(String(salaryAndWagesID))); @@ -2204,7 +1806,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2213,26 +1815,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2247,7 +1829,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2259,7 +1841,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2270,7 +1853,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param timesheetID Identifier for the timesheet */ - public async deleteTimesheet (xeroTenantId: string, timesheetID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetLine; }> { + public async deleteTimesheet (xeroTenantId: string, timesheetID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetLine; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -2296,7 +1879,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2305,26 +1888,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2339,7 +1902,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetLine; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetLine; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2351,7 +1914,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2363,7 +1927,7 @@ export class PayrollUkApi { * @param timesheetID Identifier for the timesheet * @param timesheetLineID Identifier for the timesheet line */ - public async deleteTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLineID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetLine; }> { + public async deleteTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLineID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetLine; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/Lines/{TimesheetLineID}' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))) .replace('{' + 'TimesheetLineID' + '}', encodeURIComponent(String(timesheetLineID))); @@ -2395,7 +1959,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2404,26 +1968,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2438,7 +1982,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetLine; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetLine; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2450,7 +1994,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2461,7 +2006,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param id Identifier for the benefit */ - public async getBenefit (xeroTenantId: string, id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BenefitObject; }> { + public async getBenefit (xeroTenantId: string, id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: BenefitObject; }> { const localVarPath = this.basePath + '/Benefits/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; @@ -2487,7 +2032,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2496,26 +2041,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2530,7 +2055,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: BenefitObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: BenefitObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2542,7 +2067,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2553,7 +2079,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getBenefits (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Benefits; }> { + public async getBenefits (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Benefits; }> { const localVarPath = this.basePath + '/Benefits'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2577,7 +2103,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2586,26 +2112,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2620,7 +2126,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Benefits; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Benefits; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2632,7 +2138,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2643,7 +2150,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param deductionId Identifier for the deduction */ - public async getDeduction (xeroTenantId: string, deductionId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: DeductionObject; }> { + public async getDeduction (xeroTenantId: string, deductionId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: DeductionObject; }> { const localVarPath = this.basePath + '/Deductions/{deductionId}' .replace('{' + 'deductionId' + '}', encodeURIComponent(String(deductionId))); let localVarQueryParameters: any = {}; @@ -2669,7 +2176,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2678,26 +2185,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2712,7 +2199,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: DeductionObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: DeductionObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2724,7 +2211,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2735,7 +2223,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getDeductions (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Deductions; }> { + public async getDeductions (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Deductions; }> { const localVarPath = this.basePath + '/Deductions'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2759,7 +2247,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2768,26 +2256,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2802,7 +2270,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Deductions; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Deductions; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2814,7 +2282,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2825,7 +2294,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param id Identifier for the deduction */ - public async getEarningsOrder (xeroTenantId: string, id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsOrderObject; }> { + public async getEarningsOrder (xeroTenantId: string, id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsOrderObject; }> { const localVarPath = this.basePath + '/EarningsOrders/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; @@ -2851,7 +2320,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2860,26 +2329,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2894,7 +2343,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsOrderObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsOrderObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2906,7 +2355,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -2917,7 +2367,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getEarningsOrders (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsOrders; }> { + public async getEarningsOrders (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsOrders; }> { const localVarPath = this.basePath + '/EarningsOrders'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -2941,7 +2391,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -2950,26 +2400,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -2984,7 +2414,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsOrders; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsOrders; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -2996,7 +2426,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3007,7 +2438,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param earningsRateID Identifier for the earnings rate */ - public async getEarningsRate (xeroTenantId: string, earningsRateID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsRateObject; }> { + public async getEarningsRate (xeroTenantId: string, earningsRateID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsRateObject; }> { const localVarPath = this.basePath + '/EarningsRates/{EarningsRateID}' .replace('{' + 'EarningsRateID' + '}', encodeURIComponent(String(earningsRateID))); let localVarQueryParameters: any = {}; @@ -3033,7 +2464,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3042,26 +2473,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3076,7 +2487,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsRateObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsRateObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3088,7 +2499,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3099,7 +2511,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getEarningsRates (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsRates; }> { + public async getEarningsRates (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsRates; }> { const localVarPath = this.basePath + '/EarningsRates'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -3123,7 +2535,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3132,26 +2544,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3166,7 +2558,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsRates; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsRates; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3178,7 +2570,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3189,7 +2582,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployee (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeObject; }> { + public async getEmployee (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3215,7 +2608,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3224,26 +2617,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3258,7 +2631,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3270,7 +2643,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3282,7 +2656,7 @@ export class PayrollUkApi { * @param employeeID Employee id for single object * @param leaveID Leave id for single object */ - public async getEmployeeLeave (xeroTenantId: string, employeeID: string, leaveID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }> { + public async getEmployeeLeave (xeroTenantId: string, employeeID: string, leaveID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Leave/{LeaveID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'LeaveID' + '}', encodeURIComponent(String(leaveID))); @@ -3314,7 +2688,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3323,26 +2697,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3357,7 +2711,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3369,7 +2723,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3380,7 +2735,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeeLeaveBalances (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveBalances; }> { + public async getEmployeeLeaveBalances (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveBalances; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/LeaveBalances' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3406,7 +2761,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3415,26 +2770,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3449,7 +2784,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveBalances; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveBalances; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3461,7 +2796,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3474,7 +2810,7 @@ export class PayrollUkApi { * @param startDate Filter by start date * @param endDate Filter by end date */ - public async getEmployeeLeavePeriods (xeroTenantId: string, employeeID: string, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeavePeriods; }> { + public async getEmployeeLeavePeriods (xeroTenantId: string, employeeID: string, startDate?: string, endDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeavePeriods; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/LeavePeriods' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3508,7 +2844,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3517,26 +2853,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3551,7 +2867,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeavePeriods; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeavePeriods; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3563,7 +2879,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3574,7 +2891,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeeLeaveTypes (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveTypes; }> { + public async getEmployeeLeaveTypes (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveTypes; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/LeaveTypes' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3600,7 +2917,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3609,26 +2926,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3643,7 +2940,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveTypes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveTypes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3655,7 +2952,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3666,7 +2964,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeeLeaves (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaves; }> { + public async getEmployeeLeaves (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaves; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Leave' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3692,7 +2990,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3701,26 +2999,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3735,7 +3013,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaves; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaves; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3747,7 +3025,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3758,7 +3037,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeeOpeningBalances (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeOpeningBalancesObject; }> { + public async getEmployeeOpeningBalances (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeOpeningBalancesObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/ukopeningbalances' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3784,7 +3063,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3793,26 +3072,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3827,7 +3086,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeOpeningBalancesObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeOpeningBalancesObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3839,7 +3098,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3850,7 +3110,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeePayTemplate (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeePayTemplateObject; }> { + public async getEmployeePayTemplate (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeePayTemplateObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PayTemplates' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3876,7 +3136,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3885,26 +3145,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -3919,7 +3159,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeePayTemplateObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeePayTemplateObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -3931,7 +3171,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -3942,7 +3183,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeePaymentMethod (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PaymentMethodObject; }> { + public async getEmployeePaymentMethod (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PaymentMethodObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PaymentMethods' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -3968,7 +3209,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -3977,26 +3218,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4011,7 +3232,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PaymentMethodObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PaymentMethodObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4023,7 +3244,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4035,7 +3257,7 @@ export class PayrollUkApi { * @param employeeID Employee id for single object * @param salaryAndWagesID Id for single pay template earnings object */ - public async getEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SalaryAndWages; }> { + public async getEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SalaryAndWages; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/SalaryAndWages/{SalaryAndWagesID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'SalaryAndWagesID' + '}', encodeURIComponent(String(salaryAndWagesID))); @@ -4067,7 +3289,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4076,26 +3298,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4110,7 +3312,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SalaryAndWages; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SalaryAndWages; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4122,7 +3324,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4134,7 +3337,7 @@ export class PayrollUkApi { * @param employeeID Employee id for single object * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getEmployeeSalaryAndWages (xeroTenantId: string, employeeID: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SalaryAndWages; }> { + public async getEmployeeSalaryAndWages (xeroTenantId: string, employeeID: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SalaryAndWages; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/SalaryAndWages' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -4164,7 +3367,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4173,26 +3376,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4207,7 +3390,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SalaryAndWages; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SalaryAndWages; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4219,7 +3402,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4232,7 +3416,7 @@ export class PayrollUkApi { * @param leaveType Filter by the type of statutory leave * @param asOfDate The date from which to calculate balance remaining. If not specified, current date UTC is used. */ - public async getEmployeeStatutoryLeaveBalances (xeroTenantId: string, employeeID: string, leaveType?: string, asOfDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeStatutoryLeaveBalanceObject; }> { + public async getEmployeeStatutoryLeaveBalances (xeroTenantId: string, employeeID: string, leaveType?: string, asOfDate?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeStatutoryLeaveBalanceObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/StatutoryLeaveBalance' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -4266,7 +3450,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4275,26 +3459,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4309,7 +3473,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeStatutoryLeaveBalanceObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeStatutoryLeaveBalanceObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4321,7 +3485,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4332,7 +3497,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param statutorySickLeaveID Statutory sick leave id for single object */ - public async getEmployeeStatutorySickLeave (xeroTenantId: string, statutorySickLeaveID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeStatutorySickLeaveObject; }> { + public async getEmployeeStatutorySickLeave (xeroTenantId: string, statutorySickLeaveID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeStatutorySickLeaveObject; }> { const localVarPath = this.basePath + '/StatutoryLeaves/Sick/{StatutorySickLeaveID}' .replace('{' + 'StatutorySickLeaveID' + '}', encodeURIComponent(String(statutorySickLeaveID))); let localVarQueryParameters: any = {}; @@ -4358,7 +3523,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4367,26 +3532,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4401,7 +3546,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeStatutorySickLeaveObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeStatutorySickLeaveObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4413,7 +3558,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4424,7 +3570,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param employeeID Employee id for single object */ - public async getEmployeeTax (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeTaxObject; }> { + public async getEmployeeTax (xeroTenantId: string, employeeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeTaxObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Tax' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -4450,7 +3596,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4459,26 +3605,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4493,7 +3619,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeTaxObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeTaxObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4505,7 +3631,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4517,7 +3644,7 @@ export class PayrollUkApi { * @param filter Filter by first name, lastname, and/or whether they are an off-payroll worker * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getEmployees (xeroTenantId: string, filter?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Employees; }> { + public async getEmployees (xeroTenantId: string, filter?: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Employees; }> { const localVarPath = this.basePath + '/Employees'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -4545,7 +3672,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4554,26 +3681,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4588,7 +3695,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Employees; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Employees; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4600,7 +3707,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4611,7 +3719,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param leaveTypeID Identifier for the leave type */ - public async getLeaveType (xeroTenantId: string, leaveTypeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveTypeObject; }> { + public async getLeaveType (xeroTenantId: string, leaveTypeID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveTypeObject; }> { const localVarPath = this.basePath + '/LeaveTypes/{LeaveTypeID}' .replace('{' + 'LeaveTypeID' + '}', encodeURIComponent(String(leaveTypeID))); let localVarQueryParameters: any = {}; @@ -4637,7 +3745,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4646,26 +3754,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4680,7 +3768,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveTypeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveTypeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4692,7 +3780,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4704,7 +3793,7 @@ export class PayrollUkApi { * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. * @param activeOnly Filters leave types by active status. By default the API returns all leave types. */ - public async getLeaveTypes (xeroTenantId: string, page?: number, activeOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: LeaveTypes; }> { + public async getLeaveTypes (xeroTenantId: string, page?: number, activeOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: LeaveTypes; }> { const localVarPath = this.basePath + '/LeaveTypes'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -4732,7 +3821,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4741,26 +3830,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4775,7 +3844,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: LeaveTypes; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: LeaveTypes; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4787,7 +3856,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4798,7 +3868,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param payRunID Identifier for the pay run */ - public async getPayRun (xeroTenantId: string, payRunID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRunObject; }> { + public async getPayRun (xeroTenantId: string, payRunID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRunObject; }> { const localVarPath = this.basePath + '/PayRuns/{PayRunID}' .replace('{' + 'PayRunID' + '}', encodeURIComponent(String(payRunID))); let localVarQueryParameters: any = {}; @@ -4824,7 +3894,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4833,26 +3903,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4867,7 +3917,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRunObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRunObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4879,7 +3929,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4890,7 +3941,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param payRunCalendarID Identifier for the payrun calendars */ - public async getPayRunCalendar (xeroTenantId: string, payRunCalendarID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRunCalendarObject; }> { + public async getPayRunCalendar (xeroTenantId: string, payRunCalendarID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRunCalendarObject; }> { const localVarPath = this.basePath + '/PayRunCalendars/{PayRunCalendarID}' .replace('{' + 'PayRunCalendarID' + '}', encodeURIComponent(String(payRunCalendarID))); let localVarQueryParameters: any = {}; @@ -4916,7 +3967,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -4925,26 +3976,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -4959,7 +3990,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRunCalendarObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRunCalendarObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -4971,7 +4002,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -4982,7 +4014,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getPayRunCalendars (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRunCalendars; }> { + public async getPayRunCalendars (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRunCalendars; }> { const localVarPath = this.basePath + '/PayRunCalendars'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5006,7 +4038,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5015,26 +4047,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5049,7 +4061,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRunCalendars; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRunCalendars; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5061,7 +4073,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5073,7 +4086,7 @@ export class PayrollUkApi { * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. * @param status By default get payruns will return all the payruns for an organization. You can add GET https://api.xero.com/payroll.xro/2.0/payRuns?statu={PayRunStatus} to filter the payruns by status. */ - public async getPayRuns (xeroTenantId: string, page?: number, status?: 'Draft' | 'Posted', options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRuns; }> { + public async getPayRuns (xeroTenantId: string, page?: number, status?: 'Draft' | 'Posted', options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRuns; }> { const localVarPath = this.basePath + '/PayRuns'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5101,7 +4114,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5110,26 +4123,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5144,7 +4137,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRuns; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRuns; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5156,7 +4149,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5167,7 +4161,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param payslipID Identifier for the payslip */ - public async getPaySlip (xeroTenantId: string, payslipID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayslipObject; }> { + public async getPaySlip (xeroTenantId: string, payslipID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayslipObject; }> { const localVarPath = this.basePath + '/Payslips/{PayslipID}' .replace('{' + 'PayslipID' + '}', encodeURIComponent(String(payslipID))); let localVarQueryParameters: any = {}; @@ -5193,7 +4187,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5202,26 +4196,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5236,7 +4210,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayslipObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayslipObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5248,7 +4222,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5260,7 +4235,7 @@ export class PayrollUkApi { * @param payRunID PayrunID which specifies the containing payrun of payslips to retrieve. By default, the API does not group payslips by payrun. * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getPaySlips (xeroTenantId: string, payRunID: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Payslips; }> { + public async getPaySlips (xeroTenantId: string, payRunID: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Payslips; }> { const localVarPath = this.basePath + '/Payslips'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5293,7 +4268,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5302,26 +4277,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5336,7 +4291,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Payslips; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Payslips; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5348,7 +4303,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5359,7 +4315,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param reimbursementID Identifier for the reimbursement */ - public async getReimbursement (xeroTenantId: string, reimbursementID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ReimbursementObject; }> { + public async getReimbursement (xeroTenantId: string, reimbursementID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ReimbursementObject; }> { const localVarPath = this.basePath + '/Reimbursements/{ReimbursementID}' .replace('{' + 'ReimbursementID' + '}', encodeURIComponent(String(reimbursementID))); let localVarQueryParameters: any = {}; @@ -5385,7 +4341,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5394,26 +4350,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5428,7 +4364,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ReimbursementObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ReimbursementObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5440,7 +4376,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5451,7 +4388,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param page Page number which specifies the set of records to retrieve. By default the number of the records per set is 100. */ - public async getReimbursements (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Reimbursements; }> { + public async getReimbursements (xeroTenantId: string, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Reimbursements; }> { const localVarPath = this.basePath + '/Reimbursements'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5475,7 +4412,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5484,26 +4421,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5518,7 +4435,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Reimbursements; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Reimbursements; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5530,7 +4447,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5540,7 +4458,7 @@ export class PayrollUkApi { * @summary Retrieves payroll settings * @param xeroTenantId Xero identifier for Tenant */ - public async getSettings (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Settings; }> { + public async getSettings (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Settings; }> { const localVarPath = this.basePath + '/Settings'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5560,7 +4478,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5569,26 +4487,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5603,7 +4501,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Settings; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Settings; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5615,7 +4513,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5627,7 +4526,7 @@ export class PayrollUkApi { * @param employeeID Employee id for single object * @param activeOnly Filter response with leaves that are currently active or yet to be taken. If not specified, all leaves (past, current, and future scheduled) are returned */ - public async getStatutoryLeaveSummary (xeroTenantId: string, employeeID: string, activeOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeStatutoryLeavesSummaries; }> { + public async getStatutoryLeaveSummary (xeroTenantId: string, employeeID: string, activeOnly?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeStatutoryLeavesSummaries; }> { const localVarPath = this.basePath + '/StatutoryLeaves/Summary/{EmployeeID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -5657,7 +4556,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5666,26 +4565,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5700,7 +4579,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeStatutoryLeavesSummaries; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeStatutoryLeavesSummaries; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5712,7 +4591,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5723,7 +4603,7 @@ export class PayrollUkApi { * @param xeroTenantId Xero identifier for Tenant * @param timesheetID Identifier for the timesheet */ - public async getTimesheet (xeroTenantId: string, timesheetID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetObject; }> { + public async getTimesheet (xeroTenantId: string, timesheetID: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetObject; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -5749,7 +4629,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5758,26 +4638,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5792,7 +4652,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5804,7 +4664,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5820,7 +4681,7 @@ export class PayrollUkApi { * @param endDate filter results by any timesheets with a endDate on or before the provided date * @param sort sort the order of timesheets returned. The default is based on the timesheets createdDate, sorted oldest to newest. Currently, the only other option is to reverse the order based on the timesheets startDate, sorted newest to oldest. */ - public async getTimesheets (xeroTenantId: string, page?: number, filter?: string, status?: string, startDate?: string, endDate?: string, sort?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Timesheets; }> { + public async getTimesheets (xeroTenantId: string, page?: number, filter?: string, status?: string, startDate?: string, endDate?: string, sort?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Timesheets; }> { const localVarPath = this.basePath + '/Timesheets'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5864,7 +4725,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5873,26 +4734,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5907,7 +4748,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Timesheets; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Timesheets; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -5919,7 +4760,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -5929,7 +4771,7 @@ export class PayrollUkApi { * @summary Retrieves tracking categories * @param xeroTenantId Xero identifier for Tenant */ - public async getTrackingCategories (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TrackingCategories; }> { + public async getTrackingCategories (xeroTenantId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TrackingCategories; }> { const localVarPath = this.basePath + '/Settings/trackingCategories'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -5949,7 +4791,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -5958,26 +4800,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -5992,7 +4814,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TrackingCategories; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TrackingCategories; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6004,7 +4826,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6016,7 +4839,7 @@ export class PayrollUkApi { * @param timesheetID Identifier for the timesheet * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async revertTimesheet (xeroTenantId: string, timesheetID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetObject; }> { + public async revertTimesheet (xeroTenantId: string, timesheetID: string, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetObject; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/RevertToDraft' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))); let localVarQueryParameters: any = {}; @@ -6043,7 +4866,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6052,26 +4875,6 @@ export class PayrollUkApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6086,7 +4889,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6098,7 +4901,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6111,7 +4915,7 @@ export class PayrollUkApi { * @param employee * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateEmployee (xeroTenantId: string, employeeID: string, employee: Employee, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeObject; }> { + public async updateEmployee (xeroTenantId: string, employeeID: string, employee: Employee, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -6143,7 +4947,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6152,26 +4956,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(employee, "Employee"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6186,7 +4970,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6198,7 +4982,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6212,7 +4997,7 @@ export class PayrollUkApi { * @param earningsTemplate * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, payTemplateEarningID: string, earningsTemplate: EarningsTemplate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EarningsTemplateObject; }> { + public async updateEmployeeEarningsTemplate (xeroTenantId: string, employeeID: string, payTemplateEarningID: string, earningsTemplate: EarningsTemplate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EarningsTemplateObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/PayTemplates/earnings/{PayTemplateEarningID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'PayTemplateEarningID' + '}', encodeURIComponent(String(payTemplateEarningID))); @@ -6250,7 +5035,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6259,26 +5044,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(earningsTemplate, "EarningsTemplate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6293,7 +5058,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EarningsTemplateObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EarningsTemplateObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6305,7 +5070,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6319,7 +5085,7 @@ export class PayrollUkApi { * @param employeeLeave * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateEmployeeLeave (xeroTenantId: string, employeeID: string, leaveID: string, employeeLeave: EmployeeLeave, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }> { + public async updateEmployeeLeave (xeroTenantId: string, employeeID: string, leaveID: string, employeeLeave: EmployeeLeave, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/Leave/{LeaveID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'LeaveID' + '}', encodeURIComponent(String(leaveID))); @@ -6357,7 +5123,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6366,26 +5132,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(employeeLeave, "EmployeeLeave"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6400,7 +5146,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeLeaveObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeLeaveObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6412,7 +5158,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6425,7 +5172,7 @@ export class PayrollUkApi { * @param employeeOpeningBalances * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateEmployeeOpeningBalances (xeroTenantId: string, employeeID: string, employeeOpeningBalances: EmployeeOpeningBalances, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: EmployeeOpeningBalancesObject; }> { + public async updateEmployeeOpeningBalances (xeroTenantId: string, employeeID: string, employeeOpeningBalances: EmployeeOpeningBalances, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: EmployeeOpeningBalancesObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/ukopeningbalances' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))); let localVarQueryParameters: any = {}; @@ -6457,7 +5204,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6466,26 +5213,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(employeeOpeningBalances, "EmployeeOpeningBalances"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6500,7 +5227,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: EmployeeOpeningBalancesObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: EmployeeOpeningBalancesObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6512,7 +5239,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6526,7 +5254,7 @@ export class PayrollUkApi { * @param salaryAndWage * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, salaryAndWage: SalaryAndWage, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SalaryAndWageObject; }> { + public async updateEmployeeSalaryAndWage (xeroTenantId: string, employeeID: string, salaryAndWagesID: string, salaryAndWage: SalaryAndWage, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: SalaryAndWageObject; }> { const localVarPath = this.basePath + '/Employees/{EmployeeID}/SalaryAndWages/{SalaryAndWagesID}' .replace('{' + 'EmployeeID' + '}', encodeURIComponent(String(employeeID))) .replace('{' + 'SalaryAndWagesID' + '}', encodeURIComponent(String(salaryAndWagesID))); @@ -6564,7 +5292,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6573,26 +5301,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(salaryAndWage, "SalaryAndWage"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6607,7 +5315,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: SalaryAndWageObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: SalaryAndWageObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6619,7 +5327,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6632,7 +5341,7 @@ export class PayrollUkApi { * @param payRun * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updatePayRun (xeroTenantId: string, payRunID: string, payRun: PayRun, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PayRunObject; }> { + public async updatePayRun (xeroTenantId: string, payRunID: string, payRun: PayRun, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: PayRunObject; }> { const localVarPath = this.basePath + '/PayRuns/{PayRunID}' .replace('{' + 'PayRunID' + '}', encodeURIComponent(String(payRunID))); let localVarQueryParameters: any = {}; @@ -6664,7 +5373,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6673,26 +5382,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(payRun, "PayRun"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6707,7 +5396,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: PayRunObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: PayRunObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6719,7 +5408,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -6733,7 +5423,7 @@ export class PayrollUkApi { * @param timesheetLine * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLineID: string, timesheetLine: TimesheetLine, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimesheetLineObject; }> { + public async updateTimesheetLine (xeroTenantId: string, timesheetID: string, timesheetLineID: string, timesheetLine: TimesheetLine, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimesheetLineObject; }> { const localVarPath = this.basePath + '/Timesheets/{TimesheetID}/Lines/{TimesheetLineID}' .replace('{' + 'TimesheetID' + '}', encodeURIComponent(String(timesheetID))) .replace('{' + 'TimesheetLineID' + '}', encodeURIComponent(String(timesheetLineID))); @@ -6771,7 +5461,7 @@ export class PayrollUkApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -6780,26 +5470,6 @@ export class PayrollUkApi { data: ObjectSerializer.serialize(timesheetLine, "TimesheetLine"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -6814,7 +5484,7 @@ export class PayrollUkApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimesheetLineObject; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimesheetLineObject; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -6826,7 +5496,8 @@ export class PayrollUkApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); diff --git a/src/gen/api/projectApi.ts b/src/gen/api/projectApi.ts index 507677fe..064015cd 100644 --- a/src/gen/api/projectApi.ts +++ b/src/gen/api/projectApi.ts @@ -10,7 +10,6 @@ * Do not edit the class manually. */ -const axios = require('axios'); import http = require('http'); import fs = require('fs'); @@ -29,6 +28,8 @@ import { TimeEntry } from '../model/projects/timeEntry'; import { TimeEntryCreateOrUpdate } from '../model/projects/timeEntryCreateOrUpdate'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/projects/models'; +import { ApiError } from '../../model/ApiError'; +import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import { OAuth } from '../model/projects/models'; let defaultBasePath = 'https://api.xero.com/projects.xro/2.0'; @@ -95,7 +96,7 @@ export class ProjectApi { * @param projectCreateOrUpdate Create a new project with ProjectCreateOrUpdate object * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createProject (xeroTenantId: string, projectCreateOrUpdate: ProjectCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Project; }> { + public async createProject (xeroTenantId: string, projectCreateOrUpdate: ProjectCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Project; }> { const localVarPath = this.basePath + '/Projects'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -121,7 +122,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -130,26 +131,6 @@ export class ProjectApi { data: ObjectSerializer.serialize(projectCreateOrUpdate, "ProjectCreateOrUpdate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -164,7 +145,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Project; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Project; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -176,7 +157,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -189,7 +171,7 @@ export class ProjectApi { * @param taskCreateOrUpdate The task object you are creating * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createTask (xeroTenantId: string, projectId: string, taskCreateOrUpdate: TaskCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Task; }> { + public async createTask (xeroTenantId: string, projectId: string, taskCreateOrUpdate: TaskCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Task; }> { const localVarPath = this.basePath + '/Projects/{projectId}/Tasks' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); let localVarQueryParameters: any = {}; @@ -221,7 +203,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -230,26 +212,6 @@ export class ProjectApi { data: ObjectSerializer.serialize(taskCreateOrUpdate, "TaskCreateOrUpdate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -264,7 +226,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Task; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Task; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -276,7 +238,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -289,7 +252,7 @@ export class ProjectApi { * @param timeEntryCreateOrUpdate The time entry object you are creating * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async createTimeEntry (xeroTenantId: string, projectId: string, timeEntryCreateOrUpdate: TimeEntryCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimeEntry; }> { + public async createTimeEntry (xeroTenantId: string, projectId: string, timeEntryCreateOrUpdate: TimeEntryCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimeEntry; }> { const localVarPath = this.basePath + '/Projects/{projectId}/Time' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); let localVarQueryParameters: any = {}; @@ -321,7 +284,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'POST', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -330,26 +293,6 @@ export class ProjectApi { data: ObjectSerializer.serialize(timeEntryCreateOrUpdate, "TimeEntryCreateOrUpdate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -364,7 +307,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimeEntry; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimeEntry; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -376,7 +319,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -388,7 +332,7 @@ export class ProjectApi { * @param projectId You can specify an individual project by appending the projectId to the endpoint * @param taskId You can specify an individual task by appending the id to the endpoint */ - public async deleteTask (xeroTenantId: string, projectId: string, taskId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async deleteTask (xeroTenantId: string, projectId: string, taskId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Projects/{projectId}/Tasks/{taskId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))) .replace('{' + 'taskId' + '}', encodeURIComponent(String(taskId))); @@ -420,7 +364,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -429,26 +373,6 @@ export class ProjectApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -463,7 +387,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -475,7 +399,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -487,7 +412,7 @@ export class ProjectApi { * @param projectId You can specify an individual project by appending the projectId to the endpoint * @param timeEntryId You can specify an individual task by appending the id to the endpoint */ - public async deleteTimeEntry (xeroTenantId: string, projectId: string, timeEntryId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async deleteTimeEntry (xeroTenantId: string, projectId: string, timeEntryId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Projects/{projectId}/Time/{timeEntryId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))) .replace('{' + 'timeEntryId' + '}', encodeURIComponent(String(timeEntryId))); @@ -519,7 +444,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'DELETE', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -528,26 +453,6 @@ export class ProjectApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -562,7 +467,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -574,7 +479,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -585,7 +491,7 @@ export class ProjectApi { * @param xeroTenantId Xero identifier for Tenant * @param projectId You can specify an individual project by appending the projectId to the endpoint */ - public async getProject (xeroTenantId: string, projectId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Project; }> { + public async getProject (xeroTenantId: string, projectId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Project; }> { const localVarPath = this.basePath + '/Projects/{projectId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); let localVarQueryParameters: any = {}; @@ -611,7 +517,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -620,26 +526,6 @@ export class ProjectApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -654,7 +540,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Project; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Project; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -666,7 +552,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -678,7 +565,7 @@ export class ProjectApi { * @param page set to 1 by default. The requested number of the page in paged response - Must be a number greater than 0. * @param pageSize Optional, it is set to 50 by default. The number of items to return per page in a paged response - Must be a number between 1 and 500. */ - public async getProjectUsers (xeroTenantId: string, page?: number, pageSize?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ProjectUsers; }> { + public async getProjectUsers (xeroTenantId: string, page?: number, pageSize?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: ProjectUsers; }> { const localVarPath = this.basePath + '/ProjectsUsers'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -706,7 +593,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -715,26 +602,6 @@ export class ProjectApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -749,7 +616,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: ProjectUsers; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: ProjectUsers; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -761,7 +628,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -776,7 +644,7 @@ export class ProjectApi { * @param page set to 1 by default. The requested number of the page in paged response - Must be a number greater than 0. * @param pageSize Optional, it is set to 50 by default. The number of items to return per page in a paged response - Must be a number between 1 and 500. */ - public async getProjects (xeroTenantId: string, projectIds?: Array, contactID?: string, states?: string, page?: number, pageSize?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Projects; }> { + public async getProjects (xeroTenantId: string, projectIds?: Array, contactID?: string, states?: string, page?: number, pageSize?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Projects; }> { const localVarPath = this.basePath + '/Projects'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); @@ -816,7 +684,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -825,26 +693,6 @@ export class ProjectApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -859,7 +707,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Projects; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Projects; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -871,7 +719,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -883,7 +732,7 @@ export class ProjectApi { * @param projectId You can specify an individual project by appending the projectId to the endpoint * @param taskId You can specify an individual task by appending the taskId to the endpoint, i.e. GET https://.../tasks/{taskID} */ - public async getTask (xeroTenantId: string, projectId: string, taskId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Task; }> { + public async getTask (xeroTenantId: string, projectId: string, taskId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Task; }> { const localVarPath = this.basePath + '/Projects/{projectId}/Tasks/{taskId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))) .replace('{' + 'taskId' + '}', encodeURIComponent(String(taskId))); @@ -915,7 +764,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -924,26 +773,6 @@ export class ProjectApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -958,7 +787,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Task; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Task; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -970,7 +799,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -985,7 +815,7 @@ export class ProjectApi { * @param taskIds Search for all tasks that match a comma separated list of taskIds, i.e. GET https://.../tasks?taskIds={taskID},{taskID} * @param chargeType */ - public async getTasks (xeroTenantId: string, projectId: string, page?: number, pageSize?: number, taskIds?: string, chargeType?: ChargeType, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Tasks; }> { + public async getTasks (xeroTenantId: string, projectId: string, page?: number, pageSize?: number, taskIds?: string, chargeType?: ChargeType, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: Tasks; }> { const localVarPath = this.basePath + '/Projects/{projectId}/Tasks' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); let localVarQueryParameters: any = {}; @@ -1027,7 +857,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1036,26 +866,6 @@ export class ProjectApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1070,7 +880,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: Tasks; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: Tasks; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1082,7 +892,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1103,7 +914,7 @@ export class ProjectApi { * @param dateAfterUtc ISO 8601 UTC date. Finds all time entries on or after this date filtered on the `dateUtc` field. * @param dateBeforeUtc ISO 8601 UTC date. Finds all time entries on or before this date filtered on the `dateUtc` field. */ - public async getTimeEntries (xeroTenantId: string, projectId: string, userId?: string, taskId?: string, invoiceId?: string, contactId?: string, page?: number, pageSize?: number, states?: Array, isChargeable?: boolean, dateAfterUtc?: Date, dateBeforeUtc?: Date, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimeEntries; }> { + public async getTimeEntries (xeroTenantId: string, projectId: string, userId?: string, taskId?: string, invoiceId?: string, contactId?: string, page?: number, pageSize?: number, states?: Array, isChargeable?: boolean, dateAfterUtc?: Date, dateBeforeUtc?: Date, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimeEntries; }> { const localVarPath = this.basePath + '/Projects/{projectId}/Time' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); let localVarQueryParameters: any = {}; @@ -1169,7 +980,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1178,26 +989,6 @@ export class ProjectApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1212,7 +1003,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimeEntries; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimeEntries; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1224,7 +1015,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1236,7 +1028,7 @@ export class ProjectApi { * @param projectId You can specify an individual project by appending the projectId to the endpoint * @param timeEntryId You can specify an individual time entry by appending the id to the endpoint */ - public async getTimeEntry (xeroTenantId: string, projectId: string, timeEntryId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: TimeEntry; }> { + public async getTimeEntry (xeroTenantId: string, projectId: string, timeEntryId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body: TimeEntry; }> { const localVarPath = this.basePath + '/Projects/{projectId}/Time/{timeEntryId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))) .replace('{' + 'timeEntryId' + '}', encodeURIComponent(String(timeEntryId))); @@ -1268,7 +1060,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'GET', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1277,26 +1069,6 @@ export class ProjectApi { data: {}, }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1311,7 +1083,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body: TimeEntry; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body: TimeEntry; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1323,7 +1095,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1336,7 +1109,7 @@ export class ProjectApi { * @param projectPatch Update the status of an existing Project * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async patchProject (xeroTenantId: string, projectId: string, projectPatch: ProjectPatch, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async patchProject (xeroTenantId: string, projectId: string, projectPatch: ProjectPatch, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Projects/{projectId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); let localVarQueryParameters: any = {}; @@ -1368,7 +1141,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PATCH', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1377,26 +1150,6 @@ export class ProjectApi { data: ObjectSerializer.serialize(projectPatch, "ProjectPatch"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1411,7 +1164,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1423,7 +1176,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1436,7 +1190,7 @@ export class ProjectApi { * @param projectCreateOrUpdate Request of type ProjectCreateOrUpdate * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateProject (xeroTenantId: string, projectId: string, projectCreateOrUpdate: ProjectCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async updateProject (xeroTenantId: string, projectId: string, projectCreateOrUpdate: ProjectCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Projects/{projectId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))); let localVarQueryParameters: any = {}; @@ -1468,7 +1222,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1477,26 +1231,6 @@ export class ProjectApi { data: ObjectSerializer.serialize(projectCreateOrUpdate, "ProjectCreateOrUpdate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1511,7 +1245,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1523,7 +1257,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1537,7 +1272,7 @@ export class ProjectApi { * @param taskCreateOrUpdate The task object you are updating * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateTask (xeroTenantId: string, projectId: string, taskId: string, taskCreateOrUpdate: TaskCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async updateTask (xeroTenantId: string, projectId: string, taskId: string, taskCreateOrUpdate: TaskCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Projects/{projectId}/Tasks/{taskId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))) .replace('{' + 'taskId' + '}', encodeURIComponent(String(taskId))); @@ -1575,7 +1310,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1584,26 +1319,6 @@ export class ProjectApi { data: ObjectSerializer.serialize(taskCreateOrUpdate, "TaskCreateOrUpdate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1618,7 +1333,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1630,7 +1345,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); @@ -1644,7 +1360,7 @@ export class ProjectApi { * @param timeEntryCreateOrUpdate The time entry object you are updating * @param idempotencyKey This allows you to safely retry requests without the risk of duplicate processing. 128 character max. */ - public async updateTimeEntry (xeroTenantId: string, projectId: string, timeEntryId: string, timeEntryCreateOrUpdate: TimeEntryCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { + public async updateTimeEntry (xeroTenantId: string, projectId: string, timeEntryId: string, timeEntryCreateOrUpdate: TimeEntryCreateOrUpdate, idempotencyKey?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/Projects/{projectId}/Time/{timeEntryId}' .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId))) .replace('{' + 'timeEntryId' + '}', encodeURIComponent(String(timeEntryId))); @@ -1682,7 +1398,7 @@ export class ProjectApi { (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; - let localVarRequestOptions = { + let localVarRequestOptions: AxiosRequestConfig = { method: 'PUT', params: localVarQueryParameters, headers: localVarHeaderParams, @@ -1691,26 +1407,6 @@ export class ProjectApi { data: ObjectSerializer.serialize(timeEntryCreateOrUpdate, "TimeEntryCreateOrUpdate"), }; - const generateCustomError = (error) => { - return JSON.stringify({ - response: { - statusCode: error.response.status, - body: error.response.data, - headers: error.response.headers, - request: { - url: { - protocol: error.request.protocol, - port: error.request.agent.defaultPort, - host: error.request.host, - path: error.request.path, - }, - headers: error.request.getHeaders(), - method: error.request.method - }, - }, - body: error.response.data - }); - } let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions)); @@ -1725,7 +1421,7 @@ export class ProjectApi { localVarRequestOptions.headers = { ...localVarRequestOptions.headers, 'content-type': 'application/x-www-form-urlencoded' }; } } - return new Promise<{ response: http.IncomingMessage; body?: any; }>(async (resolve, reject) => { + return new Promise<{ response: AxiosResponse; body?: any; }>(async (resolve, reject) => { let body = null try { const response = await axios(localVarRequestOptions) @@ -1737,7 +1433,8 @@ export class ProjectApi { } } catch(error) { - reject(generateCustomError(error)) + const errorResponse = new ApiError(error) + reject(JSON.stringify(errorResponse.generateError())) } }); }); diff --git a/src/gen/model/accounting/models.ts b/src/gen/model/accounting/models.ts index 98102ecf..10c11840 100644 --- a/src/gen/model/accounting/models.ts +++ b/src/gen/model/accounting/models.ts @@ -131,7 +131,7 @@ export * from '././trackingOptions'; export * from '././user'; export * from '././users'; export * from '././validationError'; - +import { AxiosRequestConfig } from 'axios'; import { Account } from '././account'; import { AccountType } from '././accountType'; import { Accounts } from '././accounts'; @@ -606,14 +606,14 @@ export interface Authentication { /** * Apply authentication settings to header and query params. */ - applyToRequest(requestOptions): Promise | void; + applyToRequest(requestOptions: AxiosRequestConfig): Promise | void; } export class HttpBasicAuth implements Authentication { public username: string = ''; public password: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { requestOptions.auth = { username: this.username, password: this.password } @@ -626,9 +626,9 @@ export class ApiKeyAuth implements Authentication { constructor(private location: string, private paramName: string) { } - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (this.location == "query") { - (requestOptions.qs)[this.paramName] = this.apiKey; + (requestOptions.params)[this.paramName] = this.apiKey; } else if (this.location == "header" && requestOptions && requestOptions.headers) { requestOptions.headers[this.paramName] = this.apiKey; } @@ -638,7 +638,7 @@ export class ApiKeyAuth implements Authentication { export class OAuth implements Authentication { public accessToken: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (requestOptions && requestOptions.headers) { requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; } @@ -652,4 +652,4 @@ export class VoidAuth implements Authentication { applyToRequest(_): void { // Do nothing } -} \ No newline at end of file +} diff --git a/src/gen/model/appstore/models.ts b/src/gen/model/appstore/models.ts index 35768c48..e1efdaab 100644 --- a/src/gen/model/appstore/models.ts +++ b/src/gen/model/appstore/models.ts @@ -8,7 +8,7 @@ export * from '././subscriptionItem'; export * from '././updateUsageRecord'; export * from '././usageRecord'; export * from '././usageRecordsList'; - +import { AxiosRequestConfig } from 'axios'; import { CreateUsageRecord } from '././createUsageRecord'; import { Plan } from '././plan'; import { Price } from '././price'; @@ -185,14 +185,14 @@ export interface Authentication { /** * Apply authentication settings to header and query params. */ - applyToRequest(requestOptions): Promise | void; + applyToRequest(requestOptions: AxiosRequestConfig): Promise | void; } export class HttpBasicAuth implements Authentication { public username: string = ''; public password: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { requestOptions.auth = { username: this.username, password: this.password } @@ -205,9 +205,9 @@ export class ApiKeyAuth implements Authentication { constructor(private location: string, private paramName: string) { } - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (this.location == "query") { - (requestOptions.qs)[this.paramName] = this.apiKey; + (requestOptions.params)[this.paramName] = this.apiKey; } else if (this.location == "header" && requestOptions && requestOptions.headers) { requestOptions.headers[this.paramName] = this.apiKey; } @@ -217,7 +217,7 @@ export class ApiKeyAuth implements Authentication { export class OAuth implements Authentication { public accessToken: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (requestOptions && requestOptions.headers) { requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; } @@ -231,4 +231,4 @@ export class VoidAuth implements Authentication { applyToRequest(_): void { // Do nothing } -} \ No newline at end of file +} diff --git a/src/gen/model/assets/models.ts b/src/gen/model/assets/models.ts index 9c0346e4..aba6faad 100644 --- a/src/gen/model/assets/models.ts +++ b/src/gen/model/assets/models.ts @@ -10,7 +10,7 @@ export * from '././modelError'; export * from '././pagination'; export * from '././resourceValidationErrorsElement'; export * from '././setting'; - +import { AxiosRequestConfig } from 'axios'; import { Asset } from '././asset'; import { AssetStatus } from '././assetStatus'; import { AssetStatusQueryParam } from '././assetStatusQueryParam'; @@ -190,14 +190,14 @@ export interface Authentication { /** * Apply authentication settings to header and query params. */ - applyToRequest(requestOptions): Promise | void; + applyToRequest(requestOptions: AxiosRequestConfig): Promise | void; } export class HttpBasicAuth implements Authentication { public username: string = ''; public password: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { requestOptions.auth = { username: this.username, password: this.password } @@ -210,9 +210,9 @@ export class ApiKeyAuth implements Authentication { constructor(private location: string, private paramName: string) { } - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (this.location == "query") { - (requestOptions.qs)[this.paramName] = this.apiKey; + (requestOptions.params)[this.paramName] = this.apiKey; } else if (this.location == "header" && requestOptions && requestOptions.headers) { requestOptions.headers[this.paramName] = this.apiKey; } @@ -222,7 +222,7 @@ export class ApiKeyAuth implements Authentication { export class OAuth implements Authentication { public accessToken: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (requestOptions && requestOptions.headers) { requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; } @@ -236,4 +236,4 @@ export class VoidAuth implements Authentication { applyToRequest(_): void { // Do nothing } -} \ No newline at end of file +} diff --git a/src/gen/model/bankfeeds/models.ts b/src/gen/model/bankfeeds/models.ts index c313de8b..109c0065 100644 --- a/src/gen/model/bankfeeds/models.ts +++ b/src/gen/model/bankfeeds/models.ts @@ -10,7 +10,7 @@ export * from '././startBalance'; export * from '././statement'; export * from '././statementLine'; export * from '././statements'; - +import { AxiosRequestConfig } from 'axios'; import { CountryCode } from '././countryCode'; import { CreditDebitIndicator } from '././creditDebitIndicator'; import { CurrencyCode } from '././currencyCode'; @@ -191,14 +191,14 @@ export interface Authentication { /** * Apply authentication settings to header and query params. */ - applyToRequest(requestOptions): Promise | void; + applyToRequest(requestOptions: AxiosRequestConfig): Promise | void; } export class HttpBasicAuth implements Authentication { public username: string = ''; public password: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { requestOptions.auth = { username: this.username, password: this.password } @@ -211,9 +211,9 @@ export class ApiKeyAuth implements Authentication { constructor(private location: string, private paramName: string) { } - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (this.location == "query") { - (requestOptions.qs)[this.paramName] = this.apiKey; + (requestOptions.params)[this.paramName] = this.apiKey; } else if (this.location == "header" && requestOptions && requestOptions.headers) { requestOptions.headers[this.paramName] = this.apiKey; } @@ -223,7 +223,7 @@ export class ApiKeyAuth implements Authentication { export class OAuth implements Authentication { public accessToken: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (requestOptions && requestOptions.headers) { requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; } @@ -237,4 +237,4 @@ export class VoidAuth implements Authentication { applyToRequest(_): void { // Do nothing } -} \ No newline at end of file +} diff --git a/src/gen/model/files/models.ts b/src/gen/model/files/models.ts index ff9bde0c..ce1fa497 100644 --- a/src/gen/model/files/models.ts +++ b/src/gen/model/files/models.ts @@ -7,7 +7,7 @@ export * from '././objectGroup'; export * from '././objectType'; export * from '././uploadObject'; export * from '././user'; - +import { AxiosRequestConfig } from 'axios'; import { Association } from '././association'; import { FileObject } from '././fileObject'; import { Files } from '././files'; @@ -178,14 +178,14 @@ export interface Authentication { /** * Apply authentication settings to header and query params. */ - applyToRequest(requestOptions): Promise | void; + applyToRequest(requestOptions: AxiosRequestConfig): Promise | void; } export class HttpBasicAuth implements Authentication { public username: string = ''; public password: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { requestOptions.auth = { username: this.username, password: this.password } @@ -198,9 +198,9 @@ export class ApiKeyAuth implements Authentication { constructor(private location: string, private paramName: string) { } - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (this.location == "query") { - (requestOptions.qs)[this.paramName] = this.apiKey; + (requestOptions.params)[this.paramName] = this.apiKey; } else if (this.location == "header" && requestOptions && requestOptions.headers) { requestOptions.headers[this.paramName] = this.apiKey; } @@ -210,7 +210,7 @@ export class ApiKeyAuth implements Authentication { export class OAuth implements Authentication { public accessToken: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (requestOptions && requestOptions.headers) { requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; } @@ -224,4 +224,4 @@ export class VoidAuth implements Authentication { applyToRequest(_): void { // Do nothing } -} \ No newline at end of file +} diff --git a/src/gen/model/finance/models.ts b/src/gen/model/finance/models.ts index 50bd32f8..0996263c 100644 --- a/src/gen/model/finance/models.ts +++ b/src/gen/model/finance/models.ts @@ -52,7 +52,7 @@ export * from '././trialBalanceMovement'; export * from '././trialBalanceResponse'; export * from '././userActivitiesResponse'; export * from '././userResponse'; - +import { AxiosRequestConfig } from 'axios'; import { AccountUsage } from '././accountUsage'; import { AccountUsageResponse } from '././accountUsageResponse'; import { BalanceSheetAccountDetail } from '././balanceSheetAccountDetail'; @@ -313,14 +313,14 @@ export interface Authentication { /** * Apply authentication settings to header and query params. */ - applyToRequest(requestOptions): Promise | void; + applyToRequest(requestOptions: AxiosRequestConfig): Promise | void; } export class HttpBasicAuth implements Authentication { public username: string = ''; public password: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { requestOptions.auth = { username: this.username, password: this.password } @@ -333,9 +333,9 @@ export class ApiKeyAuth implements Authentication { constructor(private location: string, private paramName: string) { } - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (this.location == "query") { - (requestOptions.qs)[this.paramName] = this.apiKey; + (requestOptions.params)[this.paramName] = this.apiKey; } else if (this.location == "header" && requestOptions && requestOptions.headers) { requestOptions.headers[this.paramName] = this.apiKey; } @@ -345,7 +345,7 @@ export class ApiKeyAuth implements Authentication { export class OAuth implements Authentication { public accessToken: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (requestOptions && requestOptions.headers) { requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; } @@ -359,4 +359,4 @@ export class VoidAuth implements Authentication { applyToRequest(_): void { // Do nothing } -} \ No newline at end of file +} diff --git a/src/gen/model/payroll-au/models.ts b/src/gen/model/payroll-au/models.ts index c65f633e..7da3e62f 100644 --- a/src/gen/model/payroll-au/models.ts +++ b/src/gen/model/payroll-au/models.ts @@ -86,7 +86,7 @@ export * from '././timesheetStatus'; export * from '././timesheets'; export * from '././validationError'; export * from '././workCondition'; - +import { AxiosRequestConfig } from 'axios'; import { APIException } from '././aPIException'; import { Account } from '././account'; import { AccountType } from '././accountType'; @@ -418,14 +418,14 @@ export interface Authentication { /** * Apply authentication settings to header and query params. */ - applyToRequest(requestOptions): Promise | void; + applyToRequest(requestOptions: AxiosRequestConfig): Promise | void; } export class HttpBasicAuth implements Authentication { public username: string = ''; public password: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { requestOptions.auth = { username: this.username, password: this.password } @@ -438,9 +438,9 @@ export class ApiKeyAuth implements Authentication { constructor(private location: string, private paramName: string) { } - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (this.location == "query") { - (requestOptions.qs)[this.paramName] = this.apiKey; + (requestOptions.params)[this.paramName] = this.apiKey; } else if (this.location == "header" && requestOptions && requestOptions.headers) { requestOptions.headers[this.paramName] = this.apiKey; } @@ -450,7 +450,7 @@ export class ApiKeyAuth implements Authentication { export class OAuth implements Authentication { public accessToken: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (requestOptions && requestOptions.headers) { requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; } @@ -464,4 +464,4 @@ export class VoidAuth implements Authentication { applyToRequest(_): void { // Do nothing } -} \ No newline at end of file +} diff --git a/src/gen/model/payroll-nz/models.ts b/src/gen/model/payroll-nz/models.ts index 6004c800..8e9044cd 100644 --- a/src/gen/model/payroll-nz/models.ts +++ b/src/gen/model/payroll-nz/models.ts @@ -97,7 +97,7 @@ export * from '././timesheetObject'; export * from '././timesheets'; export * from '././trackingCategories'; export * from '././trackingCategory'; - +import { AxiosRequestConfig } from 'axios'; import { Account } from '././account'; import { Accounts } from '././accounts'; import { Address } from '././address'; @@ -475,14 +475,14 @@ export interface Authentication { /** * Apply authentication settings to header and query params. */ - applyToRequest(requestOptions): Promise | void; + applyToRequest(requestOptions: AxiosRequestConfig): Promise | void; } export class HttpBasicAuth implements Authentication { public username: string = ''; public password: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { requestOptions.auth = { username: this.username, password: this.password } @@ -495,9 +495,9 @@ export class ApiKeyAuth implements Authentication { constructor(private location: string, private paramName: string) { } - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (this.location == "query") { - (requestOptions.qs)[this.paramName] = this.apiKey; + (requestOptions.params)[this.paramName] = this.apiKey; } else if (this.location == "header" && requestOptions && requestOptions.headers) { requestOptions.headers[this.paramName] = this.apiKey; } @@ -507,7 +507,7 @@ export class ApiKeyAuth implements Authentication { export class OAuth implements Authentication { public accessToken: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (requestOptions && requestOptions.headers) { requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; } @@ -521,4 +521,4 @@ export class VoidAuth implements Authentication { applyToRequest(_): void { // Do nothing } -} \ No newline at end of file +} diff --git a/src/gen/model/payroll-uk/models.ts b/src/gen/model/payroll-uk/models.ts index c898c48c..9b62edfc 100644 --- a/src/gen/model/payroll-uk/models.ts +++ b/src/gen/model/payroll-uk/models.ts @@ -88,7 +88,7 @@ export * from '././timesheetObject'; export * from '././timesheets'; export * from '././trackingCategories'; export * from '././trackingCategory'; - +import { AxiosRequestConfig } from 'axios'; import { Account } from '././account'; import { Accounts } from '././accounts'; import { Address } from '././address'; @@ -446,14 +446,14 @@ export interface Authentication { /** * Apply authentication settings to header and query params. */ - applyToRequest(requestOptions): Promise | void; + applyToRequest(requestOptions: AxiosRequestConfig): Promise | void; } export class HttpBasicAuth implements Authentication { public username: string = ''; public password: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { requestOptions.auth = { username: this.username, password: this.password } @@ -466,9 +466,9 @@ export class ApiKeyAuth implements Authentication { constructor(private location: string, private paramName: string) { } - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (this.location == "query") { - (requestOptions.qs)[this.paramName] = this.apiKey; + (requestOptions.params)[this.paramName] = this.apiKey; } else if (this.location == "header" && requestOptions && requestOptions.headers) { requestOptions.headers[this.paramName] = this.apiKey; } @@ -478,7 +478,7 @@ export class ApiKeyAuth implements Authentication { export class OAuth implements Authentication { public accessToken: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (requestOptions && requestOptions.headers) { requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; } @@ -492,4 +492,4 @@ export class VoidAuth implements Authentication { applyToRequest(_): void { // Do nothing } -} \ No newline at end of file +} diff --git a/src/gen/model/projects/models.ts b/src/gen/model/projects/models.ts index 1e827570..8c0992d0 100644 --- a/src/gen/model/projects/models.ts +++ b/src/gen/model/projects/models.ts @@ -16,7 +16,7 @@ export * from '././tasks'; export * from '././timeEntries'; export * from '././timeEntry'; export * from '././timeEntryCreateOrUpdate'; - +import { AxiosRequestConfig } from 'axios'; import { Amount } from '././amount'; import { ChargeType } from '././chargeType'; import { CurrencyCode } from '././currencyCode'; @@ -207,14 +207,14 @@ export interface Authentication { /** * Apply authentication settings to header and query params. */ - applyToRequest(requestOptions): Promise | void; + applyToRequest(requestOptions: AxiosRequestConfig): Promise | void; } export class HttpBasicAuth implements Authentication { public username: string = ''; public password: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { requestOptions.auth = { username: this.username, password: this.password } @@ -227,9 +227,9 @@ export class ApiKeyAuth implements Authentication { constructor(private location: string, private paramName: string) { } - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (this.location == "query") { - (requestOptions.qs)[this.paramName] = this.apiKey; + (requestOptions.params)[this.paramName] = this.apiKey; } else if (this.location == "header" && requestOptions && requestOptions.headers) { requestOptions.headers[this.paramName] = this.apiKey; } @@ -239,7 +239,7 @@ export class ApiKeyAuth implements Authentication { export class OAuth implements Authentication { public accessToken: string = ''; - applyToRequest(requestOptions): void { + applyToRequest(requestOptions: AxiosRequestConfig): void { if (requestOptions && requestOptions.headers) { requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; } @@ -253,4 +253,4 @@ export class VoidAuth implements Authentication { applyToRequest(_): void { // Do nothing } -} \ No newline at end of file +} diff --git a/src/model/ApiError.ts b/src/model/ApiError.ts new file mode 100644 index 00000000..e14bda53 --- /dev/null +++ b/src/model/ApiError.ts @@ -0,0 +1,61 @@ +interface RequestUrl { + protocol: string + port: number + host: string + path: string +} + +interface Request { + url: RequestUrl + headers: any + method: string +} + +interface Response { + statusCode: number, + body: any, + headers: any, + request: Request, +} + +interface ErrorResponse { + response: Response + body: any +} + +export class ApiError { + + statusCode: number + body: any + headers: any + request: Request + + constructor(axiosError) { + + this.statusCode = axiosError.response.status; + this.body = axiosError.response.data; + this.headers = axiosError.response.headers; + this.request = { + url: { + protocol: axiosError.request.protocol, + port: axiosError.request.agent.defaultPort, + host: axiosError.request.host, + path: axiosError.request.path, + }, + headers: axiosError.request.getHeaders(), + method: axiosError.request.method + } + } + + generateError(): ErrorResponse { + return { + response: { + statusCode: this.statusCode, + body: this.body, + headers: this.headers, + request: this.request, + }, + body: this.body + }; + } +}