diff --git a/packages/nodes-base/nodes/Keap/GenericFunctions.ts b/packages/nodes-base/nodes/Keap/GenericFunctions.ts index 63ad3ee0eb..61e6130877 100644 --- a/packages/nodes-base/nodes/Keap/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Keap/GenericFunctions.ts @@ -1,6 +1,6 @@ import { OptionsWithUri, - } from 'request'; +} from 'request'; import { IExecuteFunctions, @@ -15,7 +15,7 @@ import { import { snakeCase, - } from 'change-case'; +} from 'change-case'; export async function keapApiRequest(this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any let options: OptionsWithUri = { @@ -43,7 +43,7 @@ export async function keapApiRequest(this: IWebhookFunctions | IHookFunctions | } } -export async function keapApiRequestAllItems(this: IHookFunctions| IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function keapApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any const returnData: IDataObject[] = []; @@ -62,7 +62,7 @@ export async function keapApiRequestAllItems(this: IHookFunctions| IExecuteFunct return returnData; } -export function keysToSnakeCase(elements: IDataObject[] | IDataObject) : IDataObject[] { +export function keysToSnakeCase(elements: IDataObject[] | IDataObject): IDataObject[] { if (!Array.isArray(elements)) { elements = [elements]; } diff --git a/packages/nodes-base/nodes/Keap/Keap.node.ts b/packages/nodes-base/nodes/Keap/Keap.node.ts index d250f3a825..8ddcf53f13 100644 --- a/packages/nodes-base/nodes/Keap/Keap.node.ts +++ b/packages/nodes-base/nodes/Keap/Keap.node.ts @@ -57,7 +57,7 @@ import { import { companyFields, companyOperations, - } from './CompanyDescription'; +} from './CompanyDescription'; import { IAddress, @@ -78,9 +78,9 @@ import { } from './ContactNoteInterface'; import { - IEcommerceOrder, - IItem, - IShippingAddress, + IEcommerceOrder, + IItem, + IShippingAddress, } from './EcommerceOrderInterface'; import { @@ -310,9 +310,9 @@ export class Keap implements INodeType { keysToSnakeCase(additionalFields); Object.assign(body, additionalFields); if (addresses) { - body.address = keysToSnakeCase(addresses)[0] ; - } - if (faxes) { + body.address = keysToSnakeCase(addresses)[0]; + } + if (faxes) { body.fax_number = faxes[0]; } if (phones) { @@ -407,13 +407,16 @@ export class Keap implements INodeType { if (additionalFields.companyId) { body.company = { id: additionalFields.companyId as number }; } + if (additionalFields.optInReason) { + body.opt_in_reason = additionalFields.optInReason as string; + } if (addresses) { body.addresses = keysToSnakeCase(addresses) as IAddress[]; - } - if (emails) { - body.email_addresses = emails as IEmailContact[]; - } - if (faxes) { + } + if (emails) { + body.email_addresses = emails as IEmailContact[]; + } + if (faxes) { body.fax_numbers = faxes as IFax[]; } if (socialAccounts) { @@ -706,7 +709,7 @@ export class Keap implements INodeType { attachments = attachmentsUi.attachmentsValues as IAttachment[]; } if (attachmentsUi.attachmentsBinary - && (attachmentsUi.attachmentsBinary as IDataObject).length) { + && (attachmentsUi.attachmentsBinary as IDataObject).length) { if (items[i].binary === undefined) { throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');