🐛 Fix issue sending parameter Opt In Reason on Keap Node (#1674)

This commit is contained in:
Ricardo Espinoza 2021-04-17 10:52:56 -04:00 committed by GitHub
parent 0c779de704
commit 3fe52c84d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 17 deletions

View file

@ -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<any> { // 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<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[] = [];
@ -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];
}

View file

@ -57,7 +57,7 @@ import {
import {
companyFields,
companyOperations,
} from './CompanyDescription';
} from './CompanyDescription';
import {
IAddress,
@ -310,7 +310,7 @@ export class Keap implements INodeType {
keysToSnakeCase(additionalFields);
Object.assign(body, additionalFields);
if (addresses) {
body.address = keysToSnakeCase(addresses)[0] ;
body.address = keysToSnakeCase(addresses)[0];
}
if (faxes) {
body.fax_number = faxes[0];
@ -407,6 +407,9 @@ 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[];
}