mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
✨ Add Mautic Campaings to Node Actions (#2164)
* added mautic campaings node actions * Changed campaign contact term and fixed typos Co-authored-by: Luiz Eduardo de Oliveira Fonseca <luizeof@gmail.com>
This commit is contained in:
@@ -39,6 +39,11 @@ import {
|
||||
contactSegmentOperations,
|
||||
} from './ContactSegmentDescription';
|
||||
|
||||
import {
|
||||
campaignContactFields,
|
||||
campaignContactOperations,
|
||||
} from './CampaignContactDescription';
|
||||
|
||||
import {
|
||||
snakeCase,
|
||||
} from 'change-case';
|
||||
@@ -104,6 +109,11 @@ export class Mautic implements INodeType {
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Campaign Contact',
|
||||
value: 'campaignContact',
|
||||
description: 'Add/remove contacts to/from a campaign',
|
||||
},
|
||||
{
|
||||
name: 'Company',
|
||||
value: 'company',
|
||||
@@ -134,6 +144,8 @@ export class Mautic implements INodeType {
|
||||
...contactFields,
|
||||
...contactSegmentOperations,
|
||||
...contactSegmentFields,
|
||||
...campaignContactOperations,
|
||||
...campaignContactFields,
|
||||
...companyContactOperations,
|
||||
...companyContactFields,
|
||||
],
|
||||
@@ -234,6 +246,19 @@ export class Mautic implements INodeType {
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the available campaings to display them to user so that he can
|
||||
// select them easily
|
||||
async getCampaigns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const campaings = await mauticApiRequestAllItems.call(this, 'campaigns', 'GET', '/campaigns');
|
||||
for (const campaign of campaings) {
|
||||
returnData.push({
|
||||
name: campaign.name,
|
||||
value: campaign.id,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -774,6 +799,21 @@ export class Mautic implements INodeType {
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'campaignContact') {
|
||||
//https://developer.mautic.org/#add-contact-to-a-campaign
|
||||
if (operation === 'add') {
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
const campaignId = this.getNodeParameter('campaignId', i) as string;
|
||||
responseData = await mauticApiRequest.call(this, 'POST', `/campaigns/${campaignId}/contact/${contactId}/add`);
|
||||
}
|
||||
//https://developer.mautic.org/#remove-contact-from-a-campaign
|
||||
if (operation === 'remove') {
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
const campaignId = this.getNodeParameter('campaignId', i) as string;
|
||||
responseData = await mauticApiRequest.call(this, 'POST', `/campaigns/${campaignId}/contact/${contactId}/remove`);
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'companyContact') {
|
||||
//https://developer.mautic.org/#add-contact-to-a-company
|
||||
if (operation === 'add') {
|
||||
|
||||
Reference in New Issue
Block a user