mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
⚡ Add contact list and list resources to Active Campaign Node (#1187)
* ⬆️ Set google-fonts-webpack-plugin to latest version * ⚡ Add Contact List and List resources to Active Campaign Node
This commit is contained in:
parent
69a350e262
commit
db47892e77
|
@ -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 {
|
||||
|
|
|
@ -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[];
|
38
packages/nodes-base/nodes/ActiveCampaign/ListDescription.ts
Normal file
38
packages/nodes-base/nodes/ActiveCampaign/ListDescription.ts
Normal file
|
@ -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[];
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue