Skip to content

Commit 5fc076b

Browse files
michelle0927lcaresia
authored andcommitted
New Components - campaign_monitor (#14635)
* init * new components * pnpm-lock.yaml * fix pagination * remove redundant clientId prop * add retry
1 parent 8c0269a commit 5fc076b

File tree

10 files changed

+687
-8
lines changed

10 files changed

+687
-8
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import campaignMonitor from "../../campaign_monitor.app.mjs";
2+
3+
export default {
4+
key: "campaign_monitor-add-subscriber",
5+
name: "Add Subscriber",
6+
description: "Creates a new subscriber on a specific list. [See the documentation](https://www.campaignmonitor.com/api/v3-3/subscribers/)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
campaignMonitor,
11+
clientId: {
12+
propDefinition: [
13+
campaignMonitor,
14+
"clientId",
15+
],
16+
},
17+
listId: {
18+
propDefinition: [
19+
campaignMonitor,
20+
"listId",
21+
(c) => ({
22+
clientId: c.clientId,
23+
}),
24+
],
25+
},
26+
email: {
27+
type: "string",
28+
label: "Email",
29+
description: "The email address of the subscriber",
30+
},
31+
name: {
32+
type: "string",
33+
label: "Name",
34+
description: "The name of the subscriber",
35+
optional: true,
36+
},
37+
phone: {
38+
type: "string",
39+
label: "Phone",
40+
description: "The phone number of the subscriber. Example: `+5012398752`",
41+
optional: true,
42+
},
43+
consentToTrack: {
44+
propDefinition: [
45+
campaignMonitor,
46+
"consentToTrack",
47+
],
48+
},
49+
consentToSendSMS: {
50+
type: "string",
51+
label: "Consent to Send SMS",
52+
description: "Indicates if consent has been granted by the subscriber to receive Sms",
53+
options: [
54+
"Yes",
55+
"No",
56+
"Unchanged",
57+
],
58+
default: "Unchanged",
59+
optional: true,
60+
},
61+
resubscribe: {
62+
type: "boolean",
63+
label: "Resubscribe",
64+
description: "Resubscribe if the email address has previously been unsubscribed",
65+
optional: true,
66+
},
67+
},
68+
async run({ $ }) {
69+
const response = await this.campaignMonitor.createSubscriber({
70+
$,
71+
listId: this.listId,
72+
data: {
73+
EmailAddress: this.email,
74+
Name: this.name,
75+
MobileNumber: this.phone,
76+
ConsentToTrack: this.consentToTrack,
77+
ConsentToSendSms: this.consentToSendSMS,
78+
Resubscribe: this.resubscribe,
79+
},
80+
});
81+
$.export("$summary", `Successfully added subscriber ${this.email}`);
82+
return response;
83+
},
84+
};
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import campaignMonitor from "../../campaign_monitor.app.mjs";
2+
3+
export default {
4+
key: "campaign_monitor-send-smart-transactional-email",
5+
name: "Send Smart Transactional Email",
6+
description: "Sends an intelligent transactional email to a specified recipient. [See the documentation](https://www.campaignmonitor.com/api/v3-3/transactional/#send-smart-email)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
campaignMonitor,
11+
clientId: {
12+
propDefinition: [
13+
campaignMonitor,
14+
"clientId",
15+
],
16+
},
17+
smartEmailId: {
18+
propDefinition: [
19+
campaignMonitor,
20+
"smartEmailId",
21+
(c) => ({
22+
clientId: c.clientId,
23+
}),
24+
],
25+
},
26+
to: {
27+
type: "string",
28+
label: "To",
29+
description: "An array of email addresses to send the email to",
30+
},
31+
cc: {
32+
type: "string",
33+
label: "CC",
34+
description: "An array of email address to carbon copy the email to",
35+
optional: true,
36+
},
37+
bcc: {
38+
type: "string",
39+
label: "BCC",
40+
description: "An array of email address to blind carbon copy the email to",
41+
optional: true,
42+
},
43+
consentToTrack: {
44+
propDefinition: [
45+
campaignMonitor,
46+
"consentToTrack",
47+
],
48+
},
49+
},
50+
async run({ $ }) {
51+
const response = await this.campaignMonitor.sendSmartEmail({
52+
$,
53+
smartEmailId: this.smartEmailId,
54+
data: {
55+
To: this.to,
56+
CC: this.cc,
57+
BCC: this.bcc,
58+
ConsentToTrack: this.consentToTrack,
59+
},
60+
});
61+
$.export("$summary", "Successfully sent smart transactional email");
62+
return response;
63+
},
64+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import campaignMonitor from "../../campaign_monitor.app.mjs";
2+
3+
export default {
4+
key: "campaign_monitor-unsubscribe",
5+
name: "Unsubscribe",
6+
description: "Removes a subscriber from a mailing list given their email address. [See the documentation](https://www.campaignmonitor.com/api/v3-3/subscribers/#unsubscribing-a-subscriber)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
campaignMonitor,
11+
clientId: {
12+
propDefinition: [
13+
campaignMonitor,
14+
"clientId",
15+
],
16+
},
17+
listId: {
18+
propDefinition: [
19+
campaignMonitor,
20+
"listId",
21+
(c) => ({
22+
clientId: c.clientId,
23+
}),
24+
],
25+
},
26+
subscriber: {
27+
propDefinition: [
28+
campaignMonitor,
29+
"subscriber",
30+
(c) => ({
31+
listId: c.listId,
32+
}),
33+
],
34+
},
35+
},
36+
async run({ $ }) {
37+
const response = await this.campaignMonitor.unsubscribeSubscriber({
38+
$,
39+
listId: this.listId,
40+
data: {
41+
EmailAddress: this.subscriber,
42+
},
43+
});
44+
$.export("$summary", `Successfully unsubscribed ${this.subscriber}`);
45+
return response;
46+
},
47+
};

0 commit comments

Comments
 (0)