Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix issue sending parameter Opt In Reason #1674

Merged
merged 1 commit into from
Apr 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/nodes-base/nodes/Keap/GenericFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
OptionsWithUri,
} from 'request';
} from 'request';

import {
IExecuteFunctions,
Expand All @@ -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<any> { // tslint:disable-line:no-any
let options: OptionsWithUri = {
Expand Down Expand Up @@ -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<any> { // tslint:disable-line:no-any
export async function keapApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any

const returnData: IDataObject[] = [];

Expand All @@ -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];
}
Expand Down
29 changes: 16 additions & 13 deletions packages/nodes-base/nodes/Keap/Keap.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
import {
companyFields,
companyOperations,
} from './CompanyDescription';
} from './CompanyDescription';

import {
IAddress,
Expand All @@ -77,9 +77,9 @@ import {
} from './ContactNoteInterface';

import {
IEcommerceOrder,
IItem,
IShippingAddress,
IEcommerceOrder,
IItem,
IShippingAddress,
} from './EcommerceOrderInterface';

import {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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!');
Expand Down