From 75950267993391e5a7bbc0ea5e602795b139d93b Mon Sep 17 00:00:00 2001 From: ricardo Date: Sat, 17 Apr 2021 10:08:58 -0400 Subject: [PATCH] :bug: Fix issue sending parameter Opt In Reason --- .../nodes-base/nodes/Keap/GenericFunctions.ts | 8 ++--- packages/nodes-base/nodes/Keap/Keap.node.ts | 29 ++++++++++--------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/packages/nodes-base/nodes/Keap/GenericFunctions.ts b/packages/nodes-base/nodes/Keap/GenericFunctions.ts index c2a4c24970e64..bf8fd324e923a 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 = { @@ -47,7 +47,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[] = []; @@ -66,7 +66,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 59692d0df5805..1f9924ded6abe 100644 --- a/packages/nodes-base/nodes/Keap/Keap.node.ts +++ b/packages/nodes-base/nodes/Keap/Keap.node.ts @@ -56,7 +56,7 @@ import { import { companyFields, companyOperations, - } from './CompanyDescription'; +} from './CompanyDescription'; import { IAddress, @@ -77,9 +77,9 @@ import { } from './ContactNoteInterface'; import { - IEcommerceOrder, - IItem, - IShippingAddress, + IEcommerceOrder, + IItem, + IShippingAddress, } from './EcommerceOrderInterface'; import { @@ -309,9 +309,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) { @@ -406,13 +406,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) { @@ -705,7 +708,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 Error('No binary data exists on item!');