refactor: Format nodes-base package (A-F) (#3800)
* 🔨 prettier formated nodes - A * 🔨 prettier formated nodes - B * ⚡ prettier formated nodes - C * ⚡ prettier formated nodes - D * ⚡ prettier formated nodes - E-F * 🎨 Adjust nodes-base formatting command (#3805) * Format additional files in nodes A-F (#3811) * ⚡ fixes * 🎨 Add Mindee to ignored dirs Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -18,65 +16,32 @@ import {
|
||||
IProduct,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
contactFields,
|
||||
contactOperations,
|
||||
} from './ContactDescription';
|
||||
import { contactFields, contactOperations } from './ContactDescription';
|
||||
|
||||
import {
|
||||
dealFields,
|
||||
dealOperations,
|
||||
} from './DealDescription';
|
||||
import { dealFields, dealOperations } from './DealDescription';
|
||||
|
||||
import {
|
||||
ecomOrderFields,
|
||||
ecomOrderOperations,
|
||||
} from './EcomOrderDescription';
|
||||
import { ecomOrderFields, ecomOrderOperations } from './EcomOrderDescription';
|
||||
|
||||
import {
|
||||
ecomCustomerFields,
|
||||
ecomCustomerOperations,
|
||||
} from './EcomCustomerDescription';
|
||||
import { ecomCustomerFields, ecomCustomerOperations } from './EcomCustomerDescription';
|
||||
|
||||
import {
|
||||
ecomOrderProductsFields,
|
||||
ecomOrderProductsOperations,
|
||||
} from './EcomOrderProductsDescription';
|
||||
|
||||
import {
|
||||
connectionFields,
|
||||
connectionOperations,
|
||||
} from './ConnectionDescription';
|
||||
import { connectionFields, connectionOperations } from './ConnectionDescription';
|
||||
|
||||
import {
|
||||
accountFields,
|
||||
accountOperations
|
||||
} from './AccountDescription';
|
||||
import { accountFields, accountOperations } from './AccountDescription';
|
||||
|
||||
import {
|
||||
tagFields,
|
||||
tagOperations
|
||||
} from './TagDescription';
|
||||
import { tagFields, tagOperations } from './TagDescription';
|
||||
|
||||
import {
|
||||
accountContactFields,
|
||||
accountContactOperations
|
||||
} from './AccountContactDescription';
|
||||
import { accountContactFields, accountContactOperations } from './AccountContactDescription';
|
||||
|
||||
import {
|
||||
contactListFields,
|
||||
contactListOperations,
|
||||
} from './ContactListDescription';
|
||||
import { contactListFields, contactListOperations } from './ContactListDescription';
|
||||
|
||||
import {
|
||||
contactTagFields,
|
||||
contactTagOperations,
|
||||
} from './ContactTagDescription';
|
||||
import { contactTagFields, contactTagOperations } from './ContactTagDescription';
|
||||
|
||||
import {
|
||||
listFields,
|
||||
listOperations,
|
||||
} from './ListDescription';
|
||||
import { listFields, listOperations } from './ListDescription';
|
||||
|
||||
interface CustomProperty {
|
||||
name: string;
|
||||
@@ -91,13 +56,23 @@ interface CustomProperty {
|
||||
*/
|
||||
function addAdditionalFields(body: IDataObject, additionalFields: IDataObject) {
|
||||
for (const key of Object.keys(additionalFields)) {
|
||||
if (key === 'customProperties' && (additionalFields.customProperties as IDataObject).property !== undefined) {
|
||||
for (const customProperty of (additionalFields.customProperties as IDataObject)!.property! as CustomProperty[]) {
|
||||
if (
|
||||
key === 'customProperties' &&
|
||||
(additionalFields.customProperties as IDataObject).property !== undefined
|
||||
) {
|
||||
for (const customProperty of (additionalFields.customProperties as IDataObject)!
|
||||
.property! as CustomProperty[]) {
|
||||
body[customProperty.name] = customProperty.value;
|
||||
}
|
||||
} else if (key === 'fieldValues' && (additionalFields.fieldValues as IDataObject).property !== undefined) {
|
||||
} else if (
|
||||
key === 'fieldValues' &&
|
||||
(additionalFields.fieldValues as IDataObject).property !== undefined
|
||||
) {
|
||||
body.fieldValues = (additionalFields.fieldValues as IDataObject).property;
|
||||
} else if (key === 'fields' && (additionalFields.fields as IDataObject).property !== undefined) {
|
||||
} else if (
|
||||
key === 'fields' &&
|
||||
(additionalFields.fields as IDataObject).property !== undefined
|
||||
) {
|
||||
body.fields = (additionalFields.fields as IDataObject).property;
|
||||
} else {
|
||||
body[key] = additionalFields[key];
|
||||
@@ -263,7 +238,6 @@ export class ActiveCampaign implements INodeType {
|
||||
// ecommerceOrderProducts
|
||||
// ----------------------------------
|
||||
...ecomOrderProductsFields,
|
||||
|
||||
],
|
||||
};
|
||||
|
||||
@@ -273,7 +247,13 @@ export class ActiveCampaign implements INodeType {
|
||||
// select them easily
|
||||
async getContactCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { fields } = await activeCampaignApiRequest.call(this, 'GET', '/api/3/fields', {}, { limit: 100 });
|
||||
const { fields } = await activeCampaignApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/api/3/fields',
|
||||
{},
|
||||
{ limit: 100 },
|
||||
);
|
||||
for (const field of fields) {
|
||||
const fieldName = field.title;
|
||||
const fieldId = field.id;
|
||||
@@ -288,7 +268,13 @@ export class ActiveCampaign implements INodeType {
|
||||
// select them easily
|
||||
async getAccountCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { accountCustomFieldMeta: fields } = await activeCampaignApiRequest.call(this, 'GET', '/api/3/accountCustomFieldMeta', {}, { limit: 100 });
|
||||
const { accountCustomFieldMeta: fields } = await activeCampaignApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/api/3/accountCustomFieldMeta',
|
||||
{},
|
||||
{ limit: 100 },
|
||||
);
|
||||
for (const field of fields) {
|
||||
const fieldName = field.fieldLabel;
|
||||
const fieldId = field.id;
|
||||
@@ -303,7 +289,13 @@ export class ActiveCampaign implements INodeType {
|
||||
// select them easily
|
||||
async getTags(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { tags } = await activeCampaignApiRequest.call(this, 'GET', '/api/3/tags', {}, { limit: 100 });
|
||||
const { tags } = await activeCampaignApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/api/3/tags',
|
||||
{},
|
||||
{ limit: 100 },
|
||||
);
|
||||
for (const tag of tags) {
|
||||
returnData.push({
|
||||
name: tag.tag,
|
||||
@@ -334,7 +326,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
|
||||
dataKey = undefined;
|
||||
resource = this.getNodeParameter('resource', 0) as string;
|
||||
operation = this.getNodeParameter('operation', 0) as string;
|
||||
@@ -367,7 +358,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
addAdditionalFields(body.contact as IDataObject, additionalFields);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// contact:delete
|
||||
@@ -377,7 +367,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const contactId = this.getNodeParameter('contactId', i) as number;
|
||||
endpoint = `/api/3/contacts/${contactId}`;
|
||||
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// contact:get
|
||||
@@ -387,7 +376,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const contactId = this.getNodeParameter('contactId', i) as number;
|
||||
endpoint = `/api/3/contacts/${contactId}`;
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// contacts:getAll
|
||||
@@ -415,7 +403,6 @@ export class ActiveCampaign implements INodeType {
|
||||
}
|
||||
|
||||
endpoint = `/api/3/contacts`;
|
||||
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// contact:update
|
||||
@@ -432,9 +419,12 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
addAdditionalFields(body.contact as IDataObject, updateFields);
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not known`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
} else if (resource === 'account') {
|
||||
if (operation === 'create') {
|
||||
@@ -454,7 +444,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
addAdditionalFields(body.account as IDataObject, additionalFields);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// account:delete
|
||||
@@ -464,7 +453,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const accountId = this.getNodeParameter('accountId', i) as number;
|
||||
endpoint = `/api/3/accounts/${accountId}`;
|
||||
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// account:get
|
||||
@@ -474,7 +462,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const accountId = this.getNodeParameter('accountId', i) as number;
|
||||
endpoint = `/api/3/accounts/${accountId}`;
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// account:getAll
|
||||
@@ -496,7 +483,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||
Object.assign(qs, filters);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// account:update
|
||||
@@ -513,9 +499,12 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
addAdditionalFields(body.account as IDataObject, updateFields);
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not known`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
} else if (resource === 'accountContact') {
|
||||
if (operation === 'create') {
|
||||
@@ -536,7 +525,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
addAdditionalFields(body.account as IDataObject, additionalFields);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// accountContact:update
|
||||
@@ -553,7 +541,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
addAdditionalFields(body.accountContact as IDataObject, updateFields);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// accountContact:delete
|
||||
@@ -563,9 +550,12 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const accountContactId = this.getNodeParameter('accountContactId', i) as number;
|
||||
endpoint = `/api/3/accountContacts/${accountContactId}`;
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not known`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
} else if (resource === 'contactTag') {
|
||||
if (operation === 'add') {
|
||||
@@ -583,7 +573,6 @@ export class ActiveCampaign implements INodeType {
|
||||
contact: this.getNodeParameter('contactId', i) as string,
|
||||
tag: this.getNodeParameter('tagId', i) as string,
|
||||
} as IDataObject;
|
||||
|
||||
} else if (operation === 'remove') {
|
||||
// ----------------------------------
|
||||
// contactTag:remove
|
||||
@@ -593,9 +582,12 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const contactTagId = this.getNodeParameter('contactTagId', i) as number;
|
||||
endpoint = `/api/3/contactTags/${contactTagId}`;
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not known`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
} else if (resource === 'contactList') {
|
||||
if (operation === 'add') {
|
||||
@@ -614,7 +606,6 @@ export class ActiveCampaign implements INodeType {
|
||||
contact: this.getNodeParameter('contactId', i) as string,
|
||||
status: 1,
|
||||
} as IDataObject;
|
||||
|
||||
} else if (operation === 'remove') {
|
||||
// ----------------------------------
|
||||
// contactList:remove
|
||||
@@ -631,9 +622,12 @@ export class ActiveCampaign implements INodeType {
|
||||
} as IDataObject;
|
||||
|
||||
dataKey = 'contacts';
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not known`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
} else if (resource === 'list') {
|
||||
if (operation === 'getAll') {
|
||||
@@ -646,7 +640,6 @@ export class ActiveCampaign implements INodeType {
|
||||
returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
const simple = this.getNodeParameter('simple', i, true) as boolean;
|
||||
|
||||
|
||||
if (returnAll === false) {
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
}
|
||||
@@ -657,7 +650,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
endpoint = `/api/3/lists`;
|
||||
}
|
||||
|
||||
} else if (resource === 'tag') {
|
||||
if (operation === 'create') {
|
||||
// ----------------------------------
|
||||
@@ -677,7 +669,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
addAdditionalFields(body.tag as IDataObject, additionalFields);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// tag:delete
|
||||
@@ -687,7 +678,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const tagId = this.getNodeParameter('tagId', i) as number;
|
||||
endpoint = `/api/3/tags/${tagId}`;
|
||||
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// tag:get
|
||||
@@ -697,7 +687,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const tagId = this.getNodeParameter('tagId', i) as number;
|
||||
endpoint = `/api/3/tags/${tagId}`;
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// tags:getAll
|
||||
@@ -716,7 +705,6 @@ export class ActiveCampaign implements INodeType {
|
||||
}
|
||||
|
||||
endpoint = `/api/3/tags`;
|
||||
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// tags:update
|
||||
@@ -733,9 +721,12 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
addAdditionalFields(body.tag as IDataObject, updateFields);
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not known`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
} else if (resource === 'deal') {
|
||||
if (operation === 'create') {
|
||||
@@ -771,7 +762,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
addAdditionalFields(body.deal as IDataObject, additionalFields);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// deal:update
|
||||
@@ -786,7 +776,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
addAdditionalFields(body.deal as IDataObject, updateFields);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// deal:delete
|
||||
@@ -796,7 +785,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const dealId = this.getNodeParameter('dealId', i) as number;
|
||||
endpoint = `/api/3/deals/${dealId}`;
|
||||
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// deal:get
|
||||
@@ -806,7 +794,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const dealId = this.getNodeParameter('dealId', i) as number;
|
||||
endpoint = `/api/3/deals/${dealId}`;
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// deals:getAll
|
||||
@@ -825,7 +812,6 @@ export class ActiveCampaign implements INodeType {
|
||||
}
|
||||
|
||||
endpoint = `/api/3/deals`;
|
||||
|
||||
} else if (operation === 'createNote') {
|
||||
// ----------------------------------
|
||||
// deal:createNote
|
||||
@@ -838,7 +824,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const dealId = this.getNodeParameter('dealId', i) as number;
|
||||
endpoint = `/api/3/deals/${dealId}/notes`;
|
||||
|
||||
} else if (operation === 'updateNote') {
|
||||
// ----------------------------------
|
||||
// deal:updateNote
|
||||
@@ -852,9 +837,12 @@ export class ActiveCampaign implements INodeType {
|
||||
const dealId = this.getNodeParameter('dealId', i) as number;
|
||||
const dealNoteId = this.getNodeParameter('dealNoteId', i) as number;
|
||||
endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`;
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not known`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
} else if (resource === 'connection') {
|
||||
if (operation === 'create') {
|
||||
@@ -873,7 +861,6 @@ export class ActiveCampaign implements INodeType {
|
||||
logoUrl: this.getNodeParameter('logoUrl', i) as string,
|
||||
linkUrl: this.getNodeParameter('linkUrl', i) as string,
|
||||
} as IDataObject;
|
||||
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// connection:update
|
||||
@@ -888,7 +875,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
addAdditionalFields(body.connection as IDataObject, updateFields);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// connection:delete
|
||||
@@ -898,7 +884,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const connectionId = this.getNodeParameter('connectionId', i) as number;
|
||||
endpoint = `/api/3/connections/${connectionId}`;
|
||||
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// connection:get
|
||||
@@ -908,7 +893,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const connectionId = this.getNodeParameter('connectionId', i) as number;
|
||||
endpoint = `/api/3/connections/${connectionId}`;
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// connections:getAll
|
||||
@@ -927,9 +911,12 @@ export class ActiveCampaign implements INodeType {
|
||||
}
|
||||
|
||||
endpoint = `/api/3/connections`;
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not known`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
} else if (resource === 'ecommerceOrder') {
|
||||
if (operation === 'create') {
|
||||
@@ -966,12 +953,14 @@ export class ActiveCampaign implements INodeType {
|
||||
addAdditionalFields(body.ecomOrder as IDataObject, { abandonedDate });
|
||||
}
|
||||
|
||||
const orderProducts = this.getNodeParameter('orderProducts', i) as unknown as IProduct[];
|
||||
const orderProducts = this.getNodeParameter(
|
||||
'orderProducts',
|
||||
i,
|
||||
) as unknown as IProduct[];
|
||||
addAdditionalFields(body.ecomOrder as IDataObject, { orderProducts });
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
addAdditionalFields(body.ecomOrder as IDataObject, additionalFields);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// ecommerceOrder:update
|
||||
@@ -986,7 +975,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
addAdditionalFields(body.ecomOrder as IDataObject, updateFields);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// ecommerceOrder:delete
|
||||
@@ -996,7 +984,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const orderId = this.getNodeParameter('orderId', i) as number;
|
||||
endpoint = `/api/3/ecomOrders/${orderId}`;
|
||||
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// ecommerceOrder:get
|
||||
@@ -1006,7 +993,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const orderId = this.getNodeParameter('orderId', i) as number;
|
||||
endpoint = `/api/3/ecomOrders/${orderId}`;
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// ecommerceOrders:getAll
|
||||
@@ -1025,9 +1011,12 @@ export class ActiveCampaign implements INodeType {
|
||||
}
|
||||
|
||||
endpoint = `/api/3/ecomOrders`;
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not known`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
} else if (resource === 'ecommerceCustomer') {
|
||||
if (operation === 'create') {
|
||||
@@ -1054,7 +1043,6 @@ export class ActiveCampaign implements INodeType {
|
||||
}
|
||||
}
|
||||
addAdditionalFields(body.ecomCustomer as IDataObject, additionalFields);
|
||||
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// ecommerceCustomer:update
|
||||
@@ -1076,7 +1064,6 @@ export class ActiveCampaign implements INodeType {
|
||||
}
|
||||
}
|
||||
addAdditionalFields(body.ecomCustomer as IDataObject, updateFields);
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// ecommerceCustomer:delete
|
||||
@@ -1086,7 +1073,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const ecommerceCustomerId = this.getNodeParameter('ecommerceCustomerId', i) as number;
|
||||
endpoint = `/api/3/ecomCustomers/${ecommerceCustomerId}`;
|
||||
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// ecommerceCustomer:get
|
||||
@@ -1096,7 +1082,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const ecommerceCustomerId = this.getNodeParameter('ecommerceCustomerId', i) as number;
|
||||
endpoint = `/api/3/ecomCustomers/${ecommerceCustomerId}`;
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// ecommerceCustomers:getAll
|
||||
@@ -1115,9 +1100,12 @@ export class ActiveCampaign implements INodeType {
|
||||
}
|
||||
|
||||
endpoint = `/api/3/ecomCustomers`;
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not known`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
} else if (resource === 'ecommerceOrderProducts') {
|
||||
if (operation === 'getByProductId') {
|
||||
@@ -1129,8 +1117,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const procuctId = this.getNodeParameter('procuctId', i) as number;
|
||||
endpoint = `/api/3/ecomOrderProducts/${procuctId}`;
|
||||
|
||||
|
||||
} else if (operation === 'getByOrderId') {
|
||||
// ----------------------------------
|
||||
// ecommerceOrderProducts:getByOrderId
|
||||
@@ -1142,7 +1128,6 @@ export class ActiveCampaign implements INodeType {
|
||||
|
||||
const orderId = this.getNodeParameter('orderId', i) as number;
|
||||
endpoint = `/api/3/ecomOrders/${orderId}/orderProducts`;
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// ecommerceOrderProductss:getAll
|
||||
@@ -1161,20 +1146,38 @@ export class ActiveCampaign implements INodeType {
|
||||
}
|
||||
|
||||
endpoint = `/api/3/ecomOrderProducts`;
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not known`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
|
||||
let responseData;
|
||||
if (returnAll === true) {
|
||||
responseData = await activeCampaignApiRequestAllItems.call(this, requestMethod, endpoint, body, qs, dataKey);
|
||||
responseData = await activeCampaignApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
endpoint,
|
||||
body,
|
||||
qs,
|
||||
dataKey,
|
||||
);
|
||||
} else {
|
||||
responseData = await activeCampaignApiRequest.call(this, requestMethod, endpoint, body, qs, dataKey);
|
||||
responseData = await activeCampaignApiRequest.call(
|
||||
this,
|
||||
requestMethod,
|
||||
endpoint,
|
||||
body,
|
||||
qs,
|
||||
dataKey,
|
||||
);
|
||||
}
|
||||
|
||||
if (resource === 'contactList' && operation === 'add' && responseData === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user