Skip to content

Commit 24bd15a

Browse files
authored
New Components - doppler_marketing_automation (#14243)
* doppler_marketing_automation init * [Components] doppler #13202 Actions - Add Update Subscriber - Unsubscribe Email - Remove Subscriber * pnpm update * some adjusts * some adjusts
1 parent c4ba5f7 commit 24bd15a

File tree

9 files changed

+1260
-167
lines changed

9 files changed

+1260
-167
lines changed

components/doppler_marketing_automation/actions/add-subscriber/add-subscriber.mjs

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import {
2+
COUNTRY_OPTIONS, GENDER_OPTIONS,
3+
} from "../../common/constants.mjs";
4+
import app from "../../doppler_marketing_automation.app.mjs";
5+
6+
export default {
7+
key: "doppler_marketing_automation-add-update-subscriber",
8+
name: "Add or Update Subscriber",
9+
description: "Adds a new subscriber or updates an existing one. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameListsByListIdSubscribersPost)",
10+
version: "0.0.1",
11+
type: "action",
12+
props: {
13+
app,
14+
listId: {
15+
propDefinition: [
16+
app,
17+
"listId",
18+
],
19+
},
20+
subscriberEmail: {
21+
type: "string",
22+
label: "Subscriber Email",
23+
description: "The email of the subscriber to add or update.",
24+
},
25+
firstName: {
26+
type: "string",
27+
label: "First Name",
28+
description: "Subscriber first name",
29+
optional: true,
30+
},
31+
lastName: {
32+
type: "string",
33+
label: "Last Name",
34+
description: "Subscriber last name",
35+
optional: true,
36+
},
37+
birthDate: {
38+
type: "string",
39+
label: "Birth Date",
40+
description: "The birth date of the subscriber",
41+
optional: true,
42+
},
43+
country: {
44+
type: "string",
45+
label: "Country",
46+
description: "Optional country of the subscriber",
47+
options: COUNTRY_OPTIONS,
48+
optional: true,
49+
},
50+
gender: {
51+
type: "string",
52+
label: "Gender",
53+
description: "The gender of the subscriber",
54+
options: GENDER_OPTIONS,
55+
optional: true,
56+
},
57+
},
58+
async run({ $ }) {
59+
const fields = [];
60+
if (this.firstName) fields.push({
61+
name: "FIRSTNAME",
62+
value: this.firstName,
63+
});
64+
if (this.lastName) fields.push({
65+
name: "LASTNAME",
66+
value: this.lastName,
67+
});
68+
if (this.birthDate) fields.push({
69+
name: "BIRTHDAY",
70+
value: this.birthDate,
71+
});
72+
if (this.country) fields.push({
73+
name: "COUNTRY",
74+
value: this.country,
75+
});
76+
if (this.gender) fields.push({
77+
name: "GENDER",
78+
value: this.gender,
79+
});
80+
81+
const response = await this.app.addOrUpdateSubscriber({
82+
$,
83+
listId: this.listId,
84+
data: {
85+
email: this.subscriberEmail,
86+
fields,
87+
},
88+
});
89+
90+
$.export("$summary", `Successfully added or updated subscriber with email: ${this.subscriberEmail}`);
91+
return response;
92+
},
93+
};

components/doppler_marketing_automation/actions/get-subscriber/get-subscriber.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import app from "../../doppler_marketing_automation.app.mjs";
22

33
export default {
44
name: "Get Subscriber",
5-
version: "0.0.1",
5+
version: "0.0.2",
66
key: "doppler_marketing_automation-get-subscriber",
77
description: "Get a subscriber. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameSubscribersByEmailGet)",
88
type: "action",
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import app from "../../doppler_marketing_automation.app.mjs";
22

33
export default {
4-
name: "Remove Subscriber",
5-
version: "0.0.1",
64
key: "doppler_marketing_automation-remove-subscriber",
7-
description: "Remove a subscriber. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameListsByListIdSubscribersByEmailDelete)",
5+
name: "Remove Subscriber",
6+
description: "Removes a subscriber from a list completely. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameListsByListIdSubscribersByEmailDelete)",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
app,
@@ -18,8 +18,8 @@ export default {
1818
propDefinition: [
1919
app,
2020
"subscriberEmail",
21-
(c) => ({
22-
listId: c.listId,
21+
({ listId }) => ({
22+
listId,
2323
}),
2424
],
2525
},
@@ -30,11 +30,7 @@ export default {
3030
email: this.email,
3131
listId: this.listId,
3232
});
33-
34-
if (response) {
35-
$.export("$summary", `Successfully removed subscriber with email ${this.email}`);
36-
}
37-
33+
$.export("$summary", `Successfully removed subscriber: ${this.email} from list: ${this.listId}`);
3834
return response;
3935
},
4036
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import app from "../../doppler_marketing_automation.app.mjs";
2+
3+
export default {
4+
key: "doppler_marketing_automation-unsubscribe-email",
5+
name: "Unsubscribe Email",
6+
description: "Unsubscribe an email address from the account. Once unsubscribed, the user will not receive any more communication. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameUnsubscribedPost)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
email: {
12+
propDefinition: [
13+
app,
14+
"subscriberEmail",
15+
() => ({
16+
filter: ({ status }) => status != "unsubscribed",
17+
}),
18+
],
19+
},
20+
},
21+
async run({ $ }) {
22+
const response = await this.app.unsubscribeSubscriber({
23+
$,
24+
data: {
25+
email: this.email,
26+
},
27+
});
28+
$.export("$summary", `Successfully unsubscribed email: ${this.email}`);
29+
return response;
30+
},
31+
};

0 commit comments

Comments
 (0)