diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index d19955eba0..0d159cba92 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -62,11 +62,21 @@ import { accountContactOperations } from "./AccountContactDescription"; +import { + contactListFields, + contactListOperations, +} from "./ContactListDescription"; + import { contactTagFields, contactTagOperations, } from "./ContactTagDescription"; +import { + listFields, + listOperations, +} from "./ListDescription"; + interface CustomProperty { name: string; value: string; @@ -136,6 +146,10 @@ export class ActiveCampaign implements INodeType { name: 'Contact', value: 'contact', }, + { + name: 'Contact List', + value: 'contactList', + }, { name: 'Contact Tag', value: 'contactTag', @@ -160,6 +174,10 @@ export class ActiveCampaign implements INodeType { name: 'E-commerce Order Products', value: 'ecommerceOrderProducts', }, + { + name: 'List', + value: 'list', + }, { name: 'Tag', value: 'tag', @@ -175,7 +193,9 @@ export class ActiveCampaign implements INodeType { ...accountOperations, ...contactOperations, ...accountContactOperations, + ...contactListOperations, ...contactTagOperations, + ...listOperations, ...tagOperations, ...dealOperations, ...connectionOperations, @@ -190,12 +210,19 @@ export class ActiveCampaign implements INodeType { // tag // ---------------------------------- ...tagFields, - + // ---------------------------------- + // list + // ---------------------------------- + ...listFields, + // ---------------------------------- // ---------------------------------- // tag // ---------------------------------- ...contactTagFields, - + // ---------------------------------- + // Contact List + // ---------------------------------- + ...contactListFields, // ---------------------------------- // account // ---------------------------------- @@ -554,6 +581,67 @@ export class ActiveCampaign implements INodeType { } else { throw new Error(`The operation "${operation}" is not known`); } + } else if (resource === 'contactList') { + if (operation === 'add') { + // ---------------------------------- + // contactList:add + // ---------------------------------- + + requestMethod = 'POST'; + + endpoint = '/api/3/contactLists'; + + dataKey = 'contactTag'; + + body.contactList = { + list: this.getNodeParameter('listId', i) as string, + contact: this.getNodeParameter('contactId', i) as string, + status: 1, + } as IDataObject; + + } else if (operation === 'remove') { + // ---------------------------------- + // contactList:remove + // ---------------------------------- + + requestMethod = 'POST'; + + endpoint = '/api/3/contactLists'; + + body.contactList = { + list: this.getNodeParameter('listId', i) as string, + contact: this.getNodeParameter('contactId', i) as string, + status: 2, + } as IDataObject; + + dataKey = 'contacts'; + + } else { + throw new Error(`The operation "${operation}" is not known`); + } + } else if (resource === 'list') { + if (operation === 'getAll') { + // ---------------------------------- + // list:getAll + // ---------------------------------- + + requestMethod = 'GET'; + + 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; + } + + if (simple === true) { + dataKey = 'lists'; + } + + endpoint = `/api/3/lists`; + } + } else if (resource === 'tag') { if (operation === 'create') { // ---------------------------------- @@ -1073,6 +1161,10 @@ export class ActiveCampaign implements INodeType { responseData = await activeCampaignApiRequest.call(this, requestMethod, endpoint, body, qs, dataKey); } + if (resource === 'contactList' && operation === 'add' && responseData === undefined) { + responseData = { success: true }; + } + if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); } else { diff --git a/packages/nodes-base/nodes/ActiveCampaign/ContactListDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ContactListDescription.ts new file mode 100644 index 0000000000..ab3279ea14 --- /dev/null +++ b/packages/nodes-base/nodes/ActiveCampaign/ContactListDescription.ts @@ -0,0 +1,113 @@ +import { + INodeProperties, +} from 'n8n-workflow'; + +export const contactListOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'contactList', + ], + }, + }, + options: [ + { + name: 'Add', + value: 'add', + description: 'Add contactt to a list', + }, + { + name: 'Remove', + value: 'remove', + description: 'Remove contactt from a list', + }, + ], + default: 'add', + description: 'The operation to perform.', + }, +] as INodeProperties[]; + +export const contactListFields = [ + // ---------------------------------- + // contactList:add + // ---------------------------------- + { + displayName: 'List ID', + name: 'listId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'add', + ], + resource: [ + 'contactList', + ], + }, + }, + description: 'List ID', + }, + { + displayName: 'Contact ID', + name: 'contactId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'add', + ], + resource: [ + 'contactList', + ], + }, + }, + description: 'Contact ID', + }, + // ---------------------------------- + // contactList:remove + // ---------------------------------- + { + displayName: 'List ID', + name: 'listId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'remove', + ], + resource: [ + 'contactList', + ], + }, + }, + description: 'List ID', + }, + { + displayName: 'Contact ID', + name: 'contactId', + type: 'number', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'remove', + ], + resource: [ + 'contactList', + ], + }, + }, + description: 'Contact ID', + }, +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/ActiveCampaign/ListDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ListDescription.ts new file mode 100644 index 0000000000..ced126b341 --- /dev/null +++ b/packages/nodes-base/nodes/ActiveCampaign/ListDescription.ts @@ -0,0 +1,38 @@ +import { + INodeProperties, +} from 'n8n-workflow'; + +import { + activeCampaignDefaultGetAllProperties, +} from './GenericFunctions'; + +export const listOperations = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'list', + ], + }, + }, + options: [ + { + name: 'Get All', + value: 'getAll', + description: 'Get all lists', + }, + ], + default: 'getAll', + description: 'The operation to perform.', + }, +] as INodeProperties[]; + +export const listFields = [ + // ---------------------------------- + // list:getAll + // ---------------------------------- + ...activeCampaignDefaultGetAllProperties('list', 'getAll'), +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/EditImage.node.ts b/packages/nodes-base/nodes/EditImage.node.ts index 65e4bef23e..382fa4097a 100644 --- a/packages/nodes-base/nodes/EditImage.node.ts +++ b/packages/nodes-base/nodes/EditImage.node.ts @@ -861,7 +861,7 @@ export class EditImage implements INodeType { cleanupFunctions.push(cleanup); fsWriteFileAsync(fd, Buffer.from(item.binary![dataPropertyNameComposite as string].data, BINARY_ENCODING)); - gmInstance = gmInstance.composite(path).geometry(geometryString); + gmInstance = gmInstance.compose(path).geometry(geometryString); } else if (operation === 'crop') { const width = this.getNodeParameter('width') as number; const height = this.getNodeParameter('height') as number;