fix(Xero Node): Fix some operations and add support for setting address and phone number (#3048)

* 🐛 Fix issue when sending Organization ID - Xero node

* 👕 Fix linting issue
This commit is contained in:
Ricardo Espinoza
2022-03-27 04:38:49 -04:00
committed by GitHub
parent bd9064cd0e
commit ab08c0df15
4 changed files with 374 additions and 370 deletions

View File

@@ -9,7 +9,9 @@ import {
} from 'n8n-core';
import {
IDataObject, NodeApiError,
IDataObject,
JsonObject,
NodeApiError,
} from 'n8n-workflow';
export async function xeroApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
@@ -26,6 +28,7 @@ export async function xeroApiRequest(this: IExecuteFunctions | IExecuteSingleFun
try {
if (body.organizationId) {
options.headers = { ...options.headers, 'Xero-tenant-id': body.organizationId };
delete body.organizationId;
}
if (Object.keys(headers).length !== 0) {
options.headers = Object.assign({}, options.headers, headers);
@@ -36,7 +39,7 @@ export async function xeroApiRequest(this: IExecuteFunctions | IExecuteSingleFun
//@ts-ignore
return await this.helpers.requestOAuth2.call(this, 'xeroOAuth2Api', options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}