mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
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:
parent
bd9064cd0e
commit
ab08c0df15
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const contactOperations: INodeProperties[] = [
|
||||
{
|
||||
|
@ -43,9 +43,9 @@ export const contactOperations: INodeProperties[] = [
|
|||
|
||||
export const contactFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
|
@ -108,82 +108,82 @@ export const contactFields: INodeProperties[] = [
|
|||
default: '',
|
||||
description: 'A user defined account number',
|
||||
},
|
||||
// {
|
||||
// displayName: 'Addresses',
|
||||
// name: 'addressesUi',
|
||||
// type: 'fixedCollection',
|
||||
// typeOptions: {
|
||||
// multipleValues: true,
|
||||
// },
|
||||
// default: '',
|
||||
// placeholder: 'Add Address',
|
||||
// options: [
|
||||
// {
|
||||
// name: 'addressesValues',
|
||||
// displayName: 'Address',
|
||||
// values: [
|
||||
// {
|
||||
// displayName: 'Type',
|
||||
// name: 'type',
|
||||
// type: 'options',
|
||||
// options: [
|
||||
// {
|
||||
// name: 'PO Box',
|
||||
// value: 'POBOX',
|
||||
// },
|
||||
// {
|
||||
// name: 'Street',
|
||||
// value: 'STREET',
|
||||
// },
|
||||
// ],
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Line 1',
|
||||
// name: 'line1',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Line 2',
|
||||
// name: 'line2',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'City',
|
||||
// name: 'city',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Region',
|
||||
// name: 'region',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Postal Code',
|
||||
// name: 'postalCode',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Country',
|
||||
// name: 'country',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Attention To',
|
||||
// name: 'attentionTo',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
{
|
||||
displayName: 'Addresses',
|
||||
name: 'addressesUi',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: '',
|
||||
placeholder: 'Add Address',
|
||||
options: [
|
||||
{
|
||||
name: 'addressesValues',
|
||||
displayName: 'Address',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'PO Box',
|
||||
value: 'POBOX',
|
||||
},
|
||||
{
|
||||
name: 'Street',
|
||||
value: 'STREET',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Line 1',
|
||||
name: 'line1',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Line 2',
|
||||
name: 'line2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'City',
|
||||
name: 'city',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Region',
|
||||
name: 'region',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Postal Code',
|
||||
name: 'postalCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Country',
|
||||
name: 'country',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Attention To',
|
||||
name: 'attentionTo',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Bank Account Details',
|
||||
name: 'bankAccountDetails',
|
||||
|
@ -250,66 +250,66 @@ export const contactFields: INodeProperties[] = [
|
|||
default: '',
|
||||
description: 'Last name of contact person (max length = 255)',
|
||||
},
|
||||
// {
|
||||
// displayName: 'Phones',
|
||||
// name: 'phonesUi',
|
||||
// type: 'fixedCollection',
|
||||
// typeOptions: {
|
||||
// multipleValues: true,
|
||||
// },
|
||||
// default: '',
|
||||
// placeholder: 'Add Phone',
|
||||
// options: [
|
||||
// {
|
||||
// name: 'phonesValues',
|
||||
// displayName: 'Phones',
|
||||
// values: [
|
||||
// {
|
||||
// displayName: 'Type',
|
||||
// name: 'type',
|
||||
// type: 'options',
|
||||
// options: [
|
||||
// {
|
||||
// name: 'Default',
|
||||
// value: 'DEFAULT',
|
||||
// },
|
||||
// {
|
||||
// name: 'DDI',
|
||||
// value: 'DDI',
|
||||
// },
|
||||
// {
|
||||
// name: 'Mobile',
|
||||
// value: 'MOBILE',
|
||||
// },
|
||||
// {
|
||||
// name: 'Fax',
|
||||
// value: 'FAX',
|
||||
// },
|
||||
// ],
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Number',
|
||||
// name: 'phoneNumber',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Area Code',
|
||||
// name: 'phoneAreaCode',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Country Code',
|
||||
// name: 'phoneCountryCode',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
{
|
||||
displayName: 'Phones',
|
||||
name: 'phonesUi',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: '',
|
||||
placeholder: 'Add Phone',
|
||||
options: [
|
||||
{
|
||||
name: 'phonesValues',
|
||||
displayName: 'Phones',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'phoneType',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Default',
|
||||
value: 'DEFAULT',
|
||||
},
|
||||
{
|
||||
name: 'DDI',
|
||||
value: 'DDI',
|
||||
},
|
||||
{
|
||||
name: 'Mobile',
|
||||
value: 'MOBILE',
|
||||
},
|
||||
{
|
||||
name: 'Fax',
|
||||
value: 'FAX',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Number',
|
||||
name: 'phoneNumber',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Area Code',
|
||||
name: 'phoneAreaCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Country Code',
|
||||
name: 'phoneCountryCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Purchase Default Account Code',
|
||||
name: 'purchasesDefaultAccountCode',
|
||||
|
@ -353,9 +353,9 @@ export const contactFields: INodeProperties[] = [
|
|||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
|
@ -393,9 +393,9 @@ export const contactFields: INodeProperties[] = [
|
|||
},
|
||||
required: true,
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
|
@ -519,9 +519,9 @@ export const contactFields: INodeProperties[] = [
|
|||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Organization ID',
|
||||
name: 'organizationId',
|
||||
|
@ -583,82 +583,82 @@ export const contactFields: INodeProperties[] = [
|
|||
default: '',
|
||||
description: 'A user defined account number',
|
||||
},
|
||||
// {
|
||||
// displayName: 'Addresses',
|
||||
// name: 'addressesUi',
|
||||
// type: 'fixedCollection',
|
||||
// typeOptions: {
|
||||
// multipleValues: true,
|
||||
// },
|
||||
// default: '',
|
||||
// placeholder: 'Add Address',
|
||||
// options: [
|
||||
// {
|
||||
// name: 'addressesValues',
|
||||
// displayName: 'Address',
|
||||
// values: [
|
||||
// {
|
||||
// displayName: 'Type',
|
||||
// name: 'type',
|
||||
// type: 'options',
|
||||
// options: [
|
||||
// {
|
||||
// name: 'PO Box',
|
||||
// value: 'POBOX',
|
||||
// },
|
||||
// {
|
||||
// name: 'Street',
|
||||
// value: 'STREET',
|
||||
// },
|
||||
// ],
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Line 1',
|
||||
// name: 'line1',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Line 2',
|
||||
// name: 'line2',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'City',
|
||||
// name: 'city',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Region',
|
||||
// name: 'region',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Postal Code',
|
||||
// name: 'postalCode',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Country',
|
||||
// name: 'country',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Attention To',
|
||||
// name: 'attentionTo',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
{
|
||||
displayName: 'Addresses',
|
||||
name: 'addressesUi',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: '',
|
||||
placeholder: 'Add Address',
|
||||
options: [
|
||||
{
|
||||
name: 'addressesValues',
|
||||
displayName: 'Address',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'PO Box',
|
||||
value: 'POBOX',
|
||||
},
|
||||
{
|
||||
name: 'Street',
|
||||
value: 'STREET',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Line 1',
|
||||
name: 'line1',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Line 2',
|
||||
name: 'line2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'City',
|
||||
name: 'city',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Region',
|
||||
name: 'region',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Postal Code',
|
||||
name: 'postalCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Country',
|
||||
name: 'country',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Attention To',
|
||||
name: 'attentionTo',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Bank Account Details',
|
||||
name: 'bankAccountDetails',
|
||||
|
@ -732,66 +732,66 @@ export const contactFields: INodeProperties[] = [
|
|||
default: '',
|
||||
description: 'Full name of contact/organisation',
|
||||
},
|
||||
// {
|
||||
// displayName: 'Phones',
|
||||
// name: 'phonesUi',
|
||||
// type: 'fixedCollection',
|
||||
// typeOptions: {
|
||||
// multipleValues: true,
|
||||
// },
|
||||
// default: '',
|
||||
// placeholder: 'Add Phone',
|
||||
// options: [
|
||||
// {
|
||||
// name: 'phonesValues',
|
||||
// displayName: 'Phones',
|
||||
// values: [
|
||||
// {
|
||||
// displayName: 'Type',
|
||||
// name: 'type',
|
||||
// type: 'options',
|
||||
// options: [
|
||||
// {
|
||||
// name: 'Default',
|
||||
// value: 'DEFAULT',
|
||||
// },
|
||||
// {
|
||||
// name: 'DDI',
|
||||
// value: 'DDI',
|
||||
// },
|
||||
// {
|
||||
// name: 'Mobile',
|
||||
// value: 'MOBILE',
|
||||
// },
|
||||
// {
|
||||
// name: 'Fax',
|
||||
// value: 'FAX',
|
||||
// },
|
||||
// ],
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Number',
|
||||
// name: 'phoneNumber',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Area Code',
|
||||
// name: 'phoneAreaCode',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Country Code',
|
||||
// name: 'phoneCountryCode',
|
||||
// type: 'string',
|
||||
// default: '',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
{
|
||||
displayName: 'Phones',
|
||||
name: 'phonesUi',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: '',
|
||||
placeholder: 'Add Phone',
|
||||
options: [
|
||||
{
|
||||
name: 'phonesValues',
|
||||
displayName: 'Phones',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'phoneType',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Default',
|
||||
value: 'DEFAULT',
|
||||
},
|
||||
{
|
||||
name: 'DDI',
|
||||
value: 'DDI',
|
||||
},
|
||||
{
|
||||
name: 'Mobile',
|
||||
value: 'MOBILE',
|
||||
},
|
||||
{
|
||||
name: 'Fax',
|
||||
value: 'FAX',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Number',
|
||||
name: 'phoneNumber',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Area Code',
|
||||
name: 'phoneAreaCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Country Code',
|
||||
name: 'phoneCountryCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Purchase Default Account Code',
|
||||
name: 'purchasesDefaultAccountCode',
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
export interface IAddress {
|
||||
Type?: string;
|
||||
AddressType?: string;
|
||||
AddressLine1?: string;
|
||||
AddressLine2?: string;
|
||||
City?: string;
|
||||
|
@ -11,7 +11,7 @@ export interface IAddress {
|
|||
}
|
||||
|
||||
export interface IPhone {
|
||||
Type?: string;
|
||||
PhoneType?: string;
|
||||
PhoneNumber?: string;
|
||||
PhoneAreaCode?: string;
|
||||
PhoneCountryCode?: string;
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
|
@ -32,9 +33,9 @@ import {
|
|||
} from './InvoiceInterface';
|
||||
|
||||
import {
|
||||
IAddress,
|
||||
IContact,
|
||||
// IPhone,
|
||||
// IAddress,
|
||||
IPhone,
|
||||
} from './IContactInterface';
|
||||
|
||||
export class Xero implements INodeType {
|
||||
|
@ -222,9 +223,9 @@ export class Xero implements INodeType {
|
|||
const lineItemsValues = ((this.getNodeParameter('lineItemsUi', i) as IDataObject).lineItemsValues as IDataObject[]);
|
||||
|
||||
const body: IInvoice = {
|
||||
organizationId,
|
||||
Type: type,
|
||||
Contact: { ContactID: contactId },
|
||||
organizationId,
|
||||
Type: type,
|
||||
Contact: { ContactID: contactId },
|
||||
};
|
||||
|
||||
if (lineItemsValues) {
|
||||
|
@ -311,7 +312,7 @@ export class Xero implements INodeType {
|
|||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
|
||||
const body: IInvoice = {
|
||||
organizationId,
|
||||
organizationId,
|
||||
};
|
||||
|
||||
if (updateFields.lineItemsUi) {
|
||||
|
@ -353,7 +354,7 @@ export class Xero implements INodeType {
|
|||
body.Type = updateFields.type as string;
|
||||
}
|
||||
if (updateFields.Contact) {
|
||||
body.Contact = { ContactID: updateFields.contactId as string };
|
||||
body.Contact = { ContactID: updateFields.contactId as string };
|
||||
}
|
||||
if (updateFields.brandingThemeId) {
|
||||
body.BrandingThemeID = updateFields.brandingThemeId as string;
|
||||
|
@ -438,11 +439,11 @@ export class Xero implements INodeType {
|
|||
const organizationId = this.getNodeParameter('organizationId', i) as string;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
// const addressesUi = additionalFields.addressesUi as IDataObject;
|
||||
// const phonesUi = additionalFields.phonesUi as IDataObject;
|
||||
const addressesUi = additionalFields.addressesUi as IDataObject;
|
||||
const phonesUi = additionalFields.phonesUi as IDataObject;
|
||||
|
||||
const body: IContact = {
|
||||
Name: name,
|
||||
Name: name,
|
||||
};
|
||||
|
||||
if (additionalFields.accountNumber) {
|
||||
|
@ -497,41 +498,41 @@ export class Xero implements INodeType {
|
|||
body.xeroNetworkKey = additionalFields.xeroNetworkKey as string;
|
||||
}
|
||||
|
||||
// if (phonesUi) {
|
||||
// const phoneValues = phonesUi?.phonesValues as IDataObject[];
|
||||
// if (phoneValues) {
|
||||
// const phones: IPhone[] = [];
|
||||
// for (const phoneValue of phoneValues) {
|
||||
// const phone: IPhone = {};
|
||||
// phone.Type = phoneValue.type as string;
|
||||
// phone.PhoneNumber = phoneValue.PhoneNumber as string;
|
||||
// phone.PhoneAreaCode = phoneValue.phoneAreaCode as string;
|
||||
// phone.PhoneCountryCode = phoneValue.phoneCountryCode as string;
|
||||
// phones.push(phone);
|
||||
// }
|
||||
// body.Phones = phones;
|
||||
// }
|
||||
// }
|
||||
if (phonesUi) {
|
||||
const phoneValues = phonesUi?.phonesValues as IDataObject[];
|
||||
if (phoneValues) {
|
||||
const phones: IPhone[] = [];
|
||||
for (const phoneValue of phoneValues) {
|
||||
const phone: IPhone = {};
|
||||
phone.PhoneType = phoneValue.phoneType as string;
|
||||
phone.PhoneNumber = phoneValue.phoneNumber as string;
|
||||
phone.PhoneAreaCode = phoneValue.phoneAreaCode as string;
|
||||
phone.PhoneCountryCode = phoneValue.phoneCountryCode as string;
|
||||
phones.push(phone);
|
||||
}
|
||||
body.Phones = phones;
|
||||
}
|
||||
}
|
||||
|
||||
// if (addressesUi) {
|
||||
// const addressValues = addressesUi?.addressesValues as IDataObject[];
|
||||
// if (addressValues) {
|
||||
// const addresses: IAddress[] = [];
|
||||
// for (const addressValue of addressValues) {
|
||||
// const address: IAddress = {};
|
||||
// address.Type = addressValue.type as string;
|
||||
// address.AddressLine1 = addressValue.line1 as string;
|
||||
// address.AddressLine2 = addressValue.line2 as string;
|
||||
// address.City = addressValue.city as string;
|
||||
// address.Region = addressValue.region as string;
|
||||
// address.PostalCode = addressValue.postalCode as string;
|
||||
// address.Country = addressValue.country as string;
|
||||
// address.AttentionTo = addressValue.attentionTo as string;
|
||||
// addresses.push(address);
|
||||
// }
|
||||
// body.Addresses = addresses;
|
||||
// }
|
||||
// }
|
||||
if (addressesUi) {
|
||||
const addressValues = addressesUi?.addressesValues as IDataObject[];
|
||||
if (addressValues) {
|
||||
const addresses: IAddress[] = [];
|
||||
for (const addressValue of addressValues) {
|
||||
const address: IAddress = {};
|
||||
address.AddressType = addressValue.type as string;
|
||||
address.AddressLine1 = addressValue.line1 as string;
|
||||
address.AddressLine2 = addressValue.line2 as string;
|
||||
address.City = addressValue.city as string;
|
||||
address.Region = addressValue.region as string;
|
||||
address.PostalCode = addressValue.postalCode as string;
|
||||
address.Country = addressValue.country as string;
|
||||
address.AttentionTo = addressValue.attentionTo as string;
|
||||
addresses.push(address);
|
||||
}
|
||||
body.Addresses = addresses;
|
||||
}
|
||||
}
|
||||
|
||||
responseData = await xeroApiRequest.call(this, 'POST', '/Contacts', { organizationId, Contacts: [body] });
|
||||
responseData = responseData.Contacts;
|
||||
|
@ -569,8 +570,8 @@ export class Xero implements INodeType {
|
|||
const organizationId = this.getNodeParameter('organizationId', i) as string;
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
// const addressesUi = updateFields.addressesUi as IDataObject;
|
||||
// const phonesUi = updateFields.phonesUi as IDataObject;
|
||||
const addressesUi = updateFields.addressesUi as IDataObject;
|
||||
const phonesUi = updateFields.phonesUi as IDataObject;
|
||||
|
||||
const body: IContact = {};
|
||||
|
||||
|
@ -630,41 +631,41 @@ export class Xero implements INodeType {
|
|||
body.xeroNetworkKey = updateFields.xeroNetworkKey as string;
|
||||
}
|
||||
|
||||
// if (phonesUi) {
|
||||
// const phoneValues = phonesUi?.phonesValues as IDataObject[];
|
||||
// if (phoneValues) {
|
||||
// const phones: IPhone[] = [];
|
||||
// for (const phoneValue of phoneValues) {
|
||||
// const phone: IPhone = {};
|
||||
// phone.Type = phoneValue.type as string;
|
||||
// phone.PhoneNumber = phoneValue.PhoneNumber as string;
|
||||
// phone.PhoneAreaCode = phoneValue.phoneAreaCode as string;
|
||||
// phone.PhoneCountryCode = phoneValue.phoneCountryCode as string;
|
||||
// phones.push(phone);
|
||||
// }
|
||||
// body.Phones = phones;
|
||||
// }
|
||||
// }
|
||||
if (phonesUi) {
|
||||
const phoneValues = phonesUi?.phonesValues as IDataObject[];
|
||||
if (phoneValues) {
|
||||
const phones: IPhone[] = [];
|
||||
for (const phoneValue of phoneValues) {
|
||||
const phone: IPhone = {};
|
||||
phone.PhoneType = phoneValue.phoneType as string;
|
||||
phone.PhoneNumber = phoneValue.phoneNumber as string;
|
||||
phone.PhoneAreaCode = phoneValue.phoneAreaCode as string;
|
||||
phone.PhoneCountryCode = phoneValue.phoneCountryCode as string;
|
||||
phones.push(phone);
|
||||
}
|
||||
body.Phones = phones;
|
||||
}
|
||||
}
|
||||
|
||||
// if (addressesUi) {
|
||||
// const addressValues = addressesUi?.addressesValues as IDataObject[];
|
||||
// if (addressValues) {
|
||||
// const addresses: IAddress[] = [];
|
||||
// for (const addressValue of addressValues) {
|
||||
// const address: IAddress = {};
|
||||
// address.Type = addressValue.type as string;
|
||||
// address.AddressLine1 = addressValue.line1 as string;
|
||||
// address.AddressLine2 = addressValue.line2 as string;
|
||||
// address.City = addressValue.city as string;
|
||||
// address.Region = addressValue.region as string;
|
||||
// address.PostalCode = addressValue.postalCode as string;
|
||||
// address.Country = addressValue.country as string;
|
||||
// address.AttentionTo = addressValue.attentionTo as string;
|
||||
// addresses.push(address);
|
||||
// }
|
||||
// body.Addresses = addresses;
|
||||
// }
|
||||
// }
|
||||
if (addressesUi) {
|
||||
const addressValues = addressesUi?.addressesValues as IDataObject[];
|
||||
if (addressValues) {
|
||||
const addresses: IAddress[] = [];
|
||||
for (const addressValue of addressValues) {
|
||||
const address: IAddress = {};
|
||||
address.AddressType = addressValue.type as string;
|
||||
address.AddressLine1 = addressValue.line1 as string;
|
||||
address.AddressLine2 = addressValue.line2 as string;
|
||||
address.City = addressValue.city as string;
|
||||
address.Region = addressValue.region as string;
|
||||
address.PostalCode = addressValue.postalCode as string;
|
||||
address.Country = addressValue.country as string;
|
||||
address.AttentionTo = addressValue.attentionTo as string;
|
||||
addresses.push(address);
|
||||
}
|
||||
body.Addresses = addresses;
|
||||
}
|
||||
}
|
||||
|
||||
responseData = await xeroApiRequest.call(this, 'POST', `/Contacts/${contactId}`, { organizationId, Contacts: [body] });
|
||||
responseData = responseData.Contacts;
|
||||
|
@ -677,7 +678,7 @@ export class Xero implements INodeType {
|
|||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.message });
|
||||
returnData.push({ error: (error as JsonObject).message });
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
|
|
Loading…
Reference in a new issue