From 49914559f547431755ed33aa46de0697180fe358 Mon Sep 17 00:00:00 2001 From: Harshil Date: Sat, 3 Oct 2020 05:10:10 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Add=20Get=20and=20Delete=20opera?= =?UTF-8?q?tion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nodes/Mailchimp/Mailchimp.node.ts | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts index 09a960278d..086e341a39 100644 --- a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts +++ b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts @@ -113,6 +113,10 @@ export class Mailchimp implements INodeType { name: 'resource', type: 'options', options: [ + { + name: 'Campaign', + value: 'campaign' + }, { name: 'List Group', value: 'listGroup', @@ -125,10 +129,6 @@ export class Mailchimp implements INodeType { name: 'Member Tag', value: 'memberTag', }, - { - name: 'Campaign', - value: 'campaign' - } ], default: 'member', required: true, @@ -239,6 +239,16 @@ export class Mailchimp implements INodeType { }, options: [ + { + name: 'Delete', + value: 'delete', + description: 'Delete a campaign' + }, + { + name: 'Get', + value: 'get', + description: 'Get a campaign' + }, { name: 'Get All', value: 'getAll', @@ -1688,7 +1698,9 @@ export class Mailchimp implements INodeType { 'campaign' ], operation: [ - 'send' + 'send', + 'get', + 'delete' ] } }, @@ -1697,11 +1709,6 @@ export class Mailchimp implements INodeType { description: 'List of Campaigns', options:[], }, -/* -------------------------------------------------------------------------- */ -/* campaign:create */ -/* -------------------------------------------------------------------------- */ - - ], }; @@ -2145,6 +2152,19 @@ export class Mailchimp implements INodeType { const campaignId = this.getNodeParameter('campaignId', i) as string; responseData = await mailchimpApiRequest.call(this, `/campaigns/${campaignId}/actions/send`, 'POST', {}) } + if (operation === 'get') { + const campaignId = this.getNodeParameter('campaignId', i) as string; + if(!campaignId){ + // TODO + // Display error message. + throw new Error("Campaign ID is required"); + } + responseData = await mailchimpApiRequest.call(this, `/campaigns/${campaignId}`, 'GET', {}) + } + if (operation === 'delete') { + const campaignId = this.getNodeParameter('campaignId', i) as string; + responseData = await mailchimpApiRequest.call(this, `/campaigns/${campaignId}`, 'Delete', {}) + } } if (Array.isArray(responseData)) {