/
Mandrill.node.ts
896 lines (858 loc) · 23.5 KB
/
Mandrill.node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
import {
IExecuteSingleFunctions,
} from 'n8n-core';
import {
IDataObject,
INodeTypeDescription,
INodeExecutionData,
INodeType,
ILoadOptionsFunctions,
INodePropertyOptions,
} from 'n8n-workflow';
import {
mandrillApiRequest,
getToEmailArray,
getGoogleAnalyticsDomainsArray,
getTags,
validateJSON
} from './GenericFunctions';
import * as moment from 'moment';
import * as _ from 'lodash';
interface Attachments {
type: string;
name: string;
content: string;
}
interface Message {
html?: string;
text?: string;
subject?: string;
from_name?: string;
from_email: string;
to: string[];
important?: boolean;
track_opens?: boolean;
track_clicks?: boolean;
auto_text?: boolean;
auto_html?: boolean;
inline_css?: boolean;
url_strip_qs?: boolean;
preserve_recipients?: boolean;
view_content_link?: boolean;
async?: boolean;
subaccount?: string;
google_analytics_campaign?: string;
google_analytics_domains?: string[];
tags?: string[];
ip_pool?: string;
bcc_address?: string;
tracking_domain?: string;
signing_domain?: string;
return_path_domain?: string;
headers?: IDataObject;
metadata?: IDataObject;
global_merge_vars?: [IDataObject];
attachments?: Attachments[];
}
interface Body {
template_content: [];
template_name?: string;
message: Message;
send_at?: string;
}
interface Options {
html: string;
fromName?: string;
text: string;
subject?: string;
important: boolean;
trackOpens: boolean;
trackClicks: boolean;
autoText: boolean;
autoHtml: boolean;
inlineCss: boolean;
urlStripQs: boolean;
preserveRecipients: boolean;
viewContentLink: boolean;
async: boolean;
subaccount: string;
googleAnalyticsCampaign: string;
googleAnalyticsDomains?: string;
tags: string;
ipPool: string;
bccAddress: string;
trackingDomain: string;
signingDomain: string;
returnPathDomain: string;
sendAt: string;
}
export class Mandrill implements INodeType {
//https://mandrillapp.com/api/docs/messages.JSON.html#method=send-template
description: INodeTypeDescription = {
displayName: 'Mandrill',
name: 'mandrill',
icon: 'file:mandrill.png',
group: ['output'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume mandrill API',
defaults: {
name: 'Mandrill',
color: '#c02428',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'mandrillApi',
required: true,
}
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
options: [
{
name: 'Message',
value: 'message',
description: 'Send a message.',
},
],
default: 'message',
description: 'Resource to consume.',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'message',
],
},
},
options: [
{
name: 'Send template',
value: 'sendTemplate',
description: 'Send message based on template.',
},
{
name: 'Send HTML',
value: 'sendHtml',
description: 'Send message based on HTML.',
},
],
default: 'sendTemplate',
description: 'The operation to perform.',
},
{
displayName: 'Template',
name: 'template',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getTemplates',
},
displayOptions: {
show: {
operation: [
'sendTemplate',
],
},
},
default: '',
options: [],
required: true,
description: 'The template you want to send',
},
{
displayName: 'From Email',
name: 'fromEmail',
type: 'string',
default: '',
required: true,
placeholder: 'Admin <example@yourdomain.com>',
description: 'Email address of the sender optional with name.',
displayOptions: {
show: {
operation: [
'sendHtml',
'sendTemplate',
],
},
},
},
{
displayName: 'To Email',
name: 'toEmail',
type: 'string',
default: '',
required: true,
placeholder: 'info@example.com',
description: 'Email address of the recipient. Multiple ones can be separated by comma.',
displayOptions: {
show: {
operation: [
'sendHtml',
'sendTemplate',
],
},
},
},
{
displayName: 'JSON Parameters',
name: 'jsonParameters',
type: 'boolean',
default: false,
description: '',
displayOptions: {
show: {
operation: [
'sendHtml',
'sendTemplate',
]
},
},
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
operation: [
'sendHtml',
'sendTemplate',
],
},
},
options: [
{
displayName: 'Subject',
name: 'subject',
type: 'string',
default: '',
placeholder: 'My subject line',
description: 'Subject line of the email.',
},
{
displayName: 'From name',
name: 'fromName',
type: 'string',
default: '',
placeholder: 'John Doe',
description: 'Optional from name to be used.',
},
{
displayName: 'HTML',
name: 'html',
type: 'string',
default: '',
typeOptions: {
rows: 5,
},
options: [],
description: 'The html you want to send.',
},
{
displayName: 'Text',
name: 'text',
type: 'string',
default: '',
typeOptions: {
rows: 5,
},
options: [],
description: 'Example text content.',
},
{
displayName: 'BCC Address',
name: 'bccAddress',
type: 'string',
default: '',
placeholder: 'message.bcc_address@example.com',
description: `An optional address to receive an exact copy of each recipient's email.`,
},
{
displayName: 'Tracking Domain',
name: 'trackingDomain',
type: 'string',
default: '',
placeholder: '',
description: `A custom domain to use for tracking opens and clicks instead of mandrillapp.com .`,
},
{
displayName: 'Signing Domain',
name: 'signingDomain',
type: 'string',
default: '',
placeholder: '',
description: `A custom domain to use for SPF/DKIM signing instead of<br />mandrill(for "via" or "on behalf of" in email clients).`,
},
{
displayName: 'Return Path Domain',
name: 'returnPathDomain',
type: 'string',
default: '',
placeholder: '',
description: `A custom domain to use for the messages's return-path.`,
},
{
displayName: 'Important',
name: 'important',
type: 'boolean',
default: false,
description: 'Whether or not this message is important, and should be<br />delivered ahead of non-important messages.',
},
{
displayName: 'Track Opens',
name: 'trackOpens',
type: 'boolean',
default: false,
description: 'Whether or not to turn on open tracking for the message.',
},
{
displayName: 'Track Clicks',
name: 'trackClicks',
type: 'boolean',
default: false,
description: 'Whether or not to turn on click tracking for the message.',
},
{
displayName: 'Auto Text',
name: 'autoText',
type: 'boolean',
default: false,
description: 'Whether or not to automatically generate a text<br />part for messages that are not given text.',
},
{
displayName: 'Auto HTML',
name: 'autoHtml',
type: 'boolean',
default: false,
description: 'Whether or not to automatically generate an HTML<br />part for messages that are not given HTML.',
},
{
displayName: 'Inline CSS',
name: 'inlineCss',
type: 'boolean',
default: false,
description: 'Whether or not to automatically inline all CSS styles provided in<br />the message HTML - only for HTML documents less than 256KB in size.',
},
{
displayName: 'Url Strip Qs',
name: 'urlStripQs',
type: 'boolean',
default: false,
description: 'Whether or not to strip the query string from<br />URLs when aggregating tracked URL data.',
},
{
displayName: 'Preserve Recipients',
name: 'preserveRecipients',
type: 'boolean',
default: false,
description: 'Whether or not to expose all recipients in to "To" header for each email.',
},
{
displayName: 'View Content Link',
name: 'viewContentLink',
type: 'boolean',
default: false,
description: 'Set to false to remove content logging for sensitive emails.',
},
{
displayName: 'Async',
name: 'async',
type: 'boolean',
default: false,
description: `Enable a background sending mode that is optimized for bulk sending.<br />In async mode, messages/send will immediately return a status of "queued"<br />for every recipient. To handle rejections when sending in async mode, set up<br />a webhook for the 'reject' event. Defaults to false for messages with<br />no more than 10 recipients; messages with more than 10 recipients are always sent<br />asynchronously, regardless of the value of async.`,
},
{
displayName: 'Subaccount',
name: 'subAccount',
type: 'string',
default: '',
placeholder: '',
description: 'The unique id of a subaccount for this message - must already exist or will fail with an error',
},
{
displayName: 'Google Analytics Campaign',
name: 'googleAnalyticsCampaign',
type: 'string',
default: '',
placeholder: '',
description: `Optional string indicating the value to set for the utm_campaign tracking parameter. If this isn't provided the email's from address will be used instead.`,
},
{
displayName: 'Google Analytics Domains',
name: 'googleAnalyticsDomains',
type: 'string',
default: '',
placeholder: '',
description: `An array of strings separated by , indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically.`,
},
{
displayName: 'Tags',
name: 'tags',
type: 'string',
default: '',
placeholder: '',
description: `An array of string separated by , to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less. Any tags starting with an underscore are reserved for internal use and will cause errors.`,
},
{
displayName: 'Ip Pool',
name: 'ipPool',
type: 'string',
default: '',
placeholder: '',
description: `The name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.`,
},
{
displayName: 'Sent At',
name: 'sendAt',
type: 'dateTime',
default: '',
placeholder: '',
description: `When this message should be sent as a UTC timestamp in<br />YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message<br />will be sent immediately. An additional fee applies for scheduled email,<br />and this feature is only available to accounts with a positive balance.`,
},
]
},
{
displayName: 'Merge Vars',
name: 'mergeVarsJson',
type: 'json',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
placeholder: `[
{
{ "name": "name", "content": "content" }
}
]`,
displayOptions: {
show: {
jsonParameters: [
true,
],
},
},
description: 'Global merge variables',
},
{
displayName: 'Merge Vars',
name: 'mergeVarsUi',
placeholder: 'Add Merge Vars',
type: 'fixedCollection',
default: '',
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
jsonParameters: [
false,
],
},
},
description: 'Per-recipient merge variables',
options: [
{
name: 'mergeVarsValues',
displayName: 'Vars',
values: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
{
displayName: 'Content',
name: 'content',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Metadata',
name: 'metadataUi',
placeholder: 'Add Metadata',
type: 'fixedCollection',
default: '',
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
jsonParameters: [
false,
],
},
},
description: 'Metadata an associative array of user metadata. Mandrill will store<br />this metadata and make it available for retrieval. In addition, you can select<br />up to 10 metadata fields to index and make searchable using the Mandrill search api.',
options: [
{
name: 'metadataValues',
displayName: 'Metadata',
values: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: 'Name of the metadata key to add.',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
description: 'Value to set for the metadata key.',
},
],
},
],
},
{
displayName: 'Metadata',
name: 'metadataJson',
type: 'json',
typeOptions: {
alwaysOpenEditWindow: true,
},
displayOptions: {
show: {
jsonParameters: [
true,
],
},
},
default: '',
placeholder: `{
"website": "www.example.com"
}`,
description: 'Metadata an associative array of user metadata. Mandrill will store this metadata<br />and make it available for retrieval. In addition, you can select up to<br />10 metadata fields to index and make searchable using the Mandrill search api.',
},
{
displayName: 'Attachments',
name: 'attachments',
type: 'json',
typeOptions: {
alwaysOpenEditWindow: true,
},
displayOptions: {
show: {
jsonParameters: [
true,
],
},
},
default: '',
placeholder: `[
{
"type": "text/plain" (the MIME type of the attachment),
"name": "myfile.txt" (the file name of the attachment),
"content": "ZXhhbXBsZSBmaWxl" (the content of the attachment as a base64-encoded string)
}
]`,
description: 'An array of supported attachments to add to the message',
},
{
displayName: 'Attachments',
name: 'attachmentsUi',
placeholder: 'Add Attachments',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
jsonParameters: [
false,
],
},
},
options: [
{
name: 'attachmentsValues',
displayName: 'Attachments Values',
values: [
{
displayName: 'Type',
name: 'type',
type: 'string',
default: '',
placeholder: 'text/plain',
description: 'The MIME type of the attachment.',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
placeholder: 'myfile.txt',
description: 'The file name of the attachment.',
},
{
displayName: 'Content',
name: 'content',
type: 'string',
default: '',
placeholder: 'ZXhhbXBsZSBmaWxl',
description: 'The content of the attachment as a base64-encoded string.',
},
],
},
{
name: 'attachmentsBinary',
displayName: 'Attachments Binary',
values: [
{
displayName: 'Property',
name: 'property',
type: 'string',
default: '',
description: 'Name of the binary properties which contain data which should be added to email as attachment',
},
],
},
],
default: '',
description: 'Array of supported attachments to add to the message.',
},
{
displayName: 'Headers',
name: 'headersJson',
type: 'json',
default: '',
placeholder: `{
"Reply-To": "replies@example.com"
}`,
displayOptions: {
show: {
jsonParameters: [
true
]
}
},
typeOptions: {
alwaysOpenEditWindow: true,
},
description: 'Optional extra headers to add to the message (most headers are allowed).',
},
{
displayName: 'Headers',
name: 'headersUi',
placeholder: 'Add Headers',
type: 'fixedCollection',
default: '',
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
jsonParameters: [
false,
],
},
},
options: [
{
name: 'headersValues',
displayName: 'Values',
values: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: '',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
description: '',
},
],
}
],
description: 'Optional extra headers to add to the message (most headers are allowed).',
},
],
};
methods = {
loadOptions: {
// Get all the available templates to display them to user so that he can
// select them easily
async getTemplates(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
let templates;
try {
templates = await mandrillApiRequest.call(this, '/templates', 'POST', '/list');
} catch (err) {
throw new Error(`Mandrill Error: ${err}`);
}
for (const template of templates) {
const templateName = template.name;
const templateSlug = template.slug;
returnData.push({
name: templateName,
value: templateSlug,
});
}
return returnData;
}
},
};
async executeSingle(this: IExecuteSingleFunctions): Promise<INodeExecutionData> {
const item = this.getInputData();
let emailSentResponse, response;
const resource = this.getNodeParameter('resource') as string;
if (resource === 'message') {
const options = this.getNodeParameter('options') as Options;
const operation = this.getNodeParameter('operation') as string;
const fromEmail = this.getNodeParameter('fromEmail') as string;
const toEmail = this.getNodeParameter('toEmail') as string;
const jsonActive = this.getNodeParameter('jsonParameters') as boolean;
const toEmailArray = getToEmailArray(toEmail);
const credentials = this.getCredentials('mandrillApi');
if (credentials === undefined) {
throw new Error('No credentials got returned!');
}
const message: Message = {
html: (options.html) ? options.html : '',
text: (options.text) ? options.text : '',
subject: (options.subject) ? options.subject : '',
from_email: fromEmail,
to: toEmailArray,
important: (options.important) ? options.important : false,
track_opens: (options.trackOpens) ? options.trackOpens : false,
track_clicks: (options.trackClicks) ? options.trackClicks : false,
auto_text: (options.autoText) ? options.autoText : false,
auto_html: (options.autoHtml) ? options.autoHtml : false,
inline_css: (options.inlineCss) ? options.inlineCss : false,
url_strip_qs: (options.urlStripQs) ? options.urlStripQs : false,
preserve_recipients: (options.preserveRecipients) ? options.preserveRecipients : false,
view_content_link: (options.viewContentLink) ? options.viewContentLink : false,
async: (options.async) ? options.async : false,
google_analytics_campaign: (options.googleAnalyticsCampaign) ? options.googleAnalyticsCampaign : '',
ip_pool: (options.ipPool) ? options.ipPool : '',
bcc_address: (options.bccAddress) ? options.bccAddress : '',
tracking_domain: (options.trackingDomain) ? options.trackingDomain : '',
signing_domain: (options.signingDomain) ? options.signingDomain : '',
return_path_domain: (options.returnPathDomain) ? options.returnPathDomain : '',
};
if (options.googleAnalyticsDomains) {
message.google_analytics_domains = getGoogleAnalyticsDomainsArray(options.googleAnalyticsDomains);
}
if (options.tags) {
message.tags = getTags(options.tags);
}
if (options.fromName) {
message.from_name = options.fromName;
}
if (options.subaccount) {
message.subaccount = options.subaccount;
}
const body: Body = {
template_content: [],
message,
};
if (options.sendAt) {
body.send_at = moment(options.sendAt).utc().format('YYYY-MM-DD HH:mm:ss');
}
if (jsonActive) {
body.message.headers = validateJSON(this.getNodeParameter('headersJson') as string);
body.message.metadata = validateJSON(this.getNodeParameter('metadataJson') as string);
body.message.global_merge_vars = validateJSON(this.getNodeParameter('mergeVarsJson') as string);
body.message.attachments = validateJSON(this.getNodeParameter('attachmentsJson') as string);
} else {
const headersUi = this.getNodeParameter('headersUi') as IDataObject;
if (!_.isEmpty(headersUi)) {
// @ts-ignore
body.message.headers = _.map(headersUi.headersValues, (o) => {
const aux: IDataObject = {};
// @ts-ignore
aux[o.name] = o.value;
return aux;
});
}
const metadataUi = this.getNodeParameter('metadataUi') as IDataObject;
if (!_.isEmpty(metadataUi)) {
// @ts-ignore
body.message.metadata = _.map(metadataUi.metadataValues, (o) => {
const aux: IDataObject = {};
aux[o.name] = o.value;
return aux;
});
}
const mergeVarsUi = this.getNodeParameter('mergeVarsUi') as IDataObject;
if (!_.isEmpty(mergeVarsUi)) {
// @ts-ignore
body.message.global_merge_vars = _.map(mergeVarsUi.mergeVarsValues, (o) => {
const aux: IDataObject = {};
aux.name = o.name;
aux.content = o.content;
return aux;
});
}
const attachmentsUi = this.getNodeParameter('attachmentsUi') as IDataObject;
let attachmentsBinary = [], attachmentsValues = [];
if (!_.isEmpty(attachmentsUi)) {
if (attachmentsUi.hasOwnProperty('attachmentsValues')
&& !_.isEmpty(attachmentsUi.attachmentsValues)) {
// @ts-ignore
attachmentsValues = _.map(attachmentsUi.attachmentsValues, (o) => {
const aux: IDataObject = {};
// @ts-ignore
aux.name = o.name;
aux.content = o.content;
aux.type = o.type;
return aux;
});
}
if (attachmentsUi.hasOwnProperty('attachmentsBinary')
&& !_.isEmpty(attachmentsUi.attachmentsBinary)
&& item.binary) {
// @ts-ignore
attachmentsBinary = _.map(attachmentsUi.attachmentsBinary, (o) => {
if (item.binary!.hasOwnProperty(o.property)) {
const aux: IDataObject = {};
aux.name = item.binary![o.property].fileName || 'unknown';
aux.content = item.binary![o.property].data;
aux.type = item.binary![o.property].mimeType;
return aux;
}
});
}
}
body.message.attachments = attachmentsBinary.concat(attachmentsValues);
}
if (operation === 'sendTemplate') {
const template = this.getNodeParameter('template') as string;
body.template_name = template;
emailSentResponse = mandrillApiRequest.call(this, '/messages', 'POST', '/send-template', body);
} else if (operation === 'sendHtml') {
emailSentResponse = mandrillApiRequest.call(this, '/messages', 'POST', '/send', body);
}
try {
response = await emailSentResponse;
} catch (err) {
throw new Error(`Mandrill Error: ${err}`);
}
}
return {
json: response,
};
}
}