Skip to content

Commit 03c56bb

Browse files
committed
[Components] doppler #13202
Actions - Add Update Subscriber - Unsubscribe Email - Remove Subscriber
1 parent 1e0cef1 commit 03c56bb

File tree

9 files changed

+1158
-187
lines changed

9 files changed

+1158
-187
lines changed

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

Lines changed: 0 additions & 60 deletions
This file was deleted.

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

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import dopplerMarketingAutomation from "../../doppler_marketing_automation.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import {
2+
COUNTRY_OPTIONS, GENDER_OPTIONS,
3+
} from "../../common/constants.mjs";
4+
import app from "../../doppler_marketing_automation.app.mjs";
35

46
export default {
57
key: "doppler_marketing_automation-add-update-subscriber",
68
name: "Add or Update Subscriber",
7-
description: "Adds a new subscriber or updates an existing one. [See the documentation](https://restapi.fromdoppler.com/docs/resources)",
8-
version: "0.0.{{ts}}",
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",
911
type: "action",
1012
props: {
11-
dopplerMarketingAutomation,
13+
app,
1214
listId: {
1315
propDefinition: [
14-
dopplerMarketingAutomation,
16+
app,
1517
"listId",
1618
],
1719
},
@@ -20,38 +22,69 @@ export default {
2022
label: "Subscriber Email",
2123
description: "The email of the subscriber to add or update.",
2224
},
23-
fields: {
24-
propDefinition: [
25-
dopplerMarketingAutomation,
26-
"fields",
27-
],
25+
firstName: {
26+
type: "string",
27+
label: "First Name",
28+
description: "Subscriber first name",
29+
optional: true,
2830
},
29-
origin: {
30-
propDefinition: [
31-
dopplerMarketingAutomation,
32-
"origin",
33-
],
31+
lastName: {
32+
type: "string",
33+
label: "Last Name",
34+
description: "Subscriber last name",
35+
optional: true,
3436
},
35-
name: {
36-
propDefinition: [
37-
dopplerMarketingAutomation,
38-
"name",
39-
],
37+
birthDate: {
38+
type: "string",
39+
label: "Birth Date",
40+
description: "The birth date of the subscriber",
41+
optional: true,
4042
},
4143
country: {
42-
propDefinition: [
43-
dopplerMarketingAutomation,
44-
"country",
45-
],
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,
4656
},
4757
},
4858
async run({ $ }) {
49-
const response = await this.dopplerMarketingAutomation.addOrUpdateSubscriber({
50-
email: this.subscriberEmail,
51-
fields: this.fields,
52-
name: this.name,
53-
country: this.country,
54-
origin: this.origin,
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+
},
5588
});
5689

5790
$.export("$summary", `Successfully added or updated subscriber with email: ${this.subscriberEmail}`);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ export default {
88
type: "action",
99
props: {
1010
app,
11+
listId: {
12+
propDefinition: [
13+
app,
14+
"listId",
15+
],
16+
},
1117
email: {
1218
propDefinition: [
1319
app,
1420
"subscriberEmail",
21+
({ listId }) => ({
22+
listId,
23+
}),
1524
],
1625
},
1726
},
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
import dopplerMarketingAutomation from "../../doppler_marketing_automation.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import app from "../../doppler_marketing_automation.app.mjs";
32

43
export default {
54
key: "doppler_marketing_automation-remove-subscriber",
65
name: "Remove Subscriber",
7-
description: "Removes a subscriber from a list completely. [See the documentation](https://restapi.fromdoppler.com/docs/resources)",
6+
description: "Removes a subscriber from a list completely. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameListsByListIdSubscribersByEmailDelete)",
87
version: "0.0.1",
98
type: "action",
109
props: {
11-
dopplerMarketingAutomation,
10+
app,
1211
listId: {
1312
propDefinition: [
14-
dopplerMarketingAutomation,
13+
app,
1514
"listId",
1615
],
1716
},
18-
subscriberEmail: {
17+
email: {
1918
propDefinition: [
20-
dopplerMarketingAutomation,
19+
app,
2120
"subscriberEmail",
2221
({ listId }) => ({
2322
listId,
@@ -26,11 +25,12 @@ export default {
2625
},
2726
},
2827
async run({ $ }) {
29-
const response = await this.dopplerMarketingAutomation.removeSubscriber({
30-
email: this.subscriberEmail,
28+
const response = await this.app.removeSubscriber({
29+
$,
30+
email: this.email,
3131
listId: this.listId,
3232
});
33-
$.export("$summary", `Successfully removed subscriber: ${this.subscriberEmail} from list: ${this.listId}`);
33+
$.export("$summary", `Successfully removed subscriber: ${this.email} from list: ${this.listId}`);
3434
return response;
3535
},
3636
};
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
import dopplerMarketingAutomation from "../../doppler_marketing_automation.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import app from "../../doppler_marketing_automation.app.mjs";
32

43
export default {
54
key: "doppler_marketing_automation-unsubscribe-email",
65
name: "Unsubscribe Email",
7-
description: "Unsubscribe an email address from the mailing list. Once unsubscribed, the user will not receive any more communication. [See the documentation](https://restapi.fromdoppler.com/docs/)",
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)",
87
version: "0.0.1",
98
type: "action",
109
props: {
11-
dopplerMarketingAutomation,
12-
subscriberEmail: {
10+
app,
11+
email: {
1312
propDefinition: [
14-
dopplerMarketingAutomation,
13+
app,
1514
"subscriberEmail",
15+
() => ({
16+
filter: ({ status }) => status != "unsubscribed",
17+
}),
1618
],
1719
},
1820
},
1921
async run({ $ }) {
20-
const response = await this.dopplerMarketingAutomation.unsubscribeSubscriber({
21-
email: this.subscriberEmail,
22+
const response = await this.app.unsubscribeSubscriber({
23+
$,
24+
data: {
25+
email: this.email,
26+
},
2227
});
23-
$.export("$summary", `Successfully unsubscribed email: ${this.subscriberEmail}`);
28+
$.export("$summary", `Successfully unsubscribed email: ${this.email}`);
2429
return response;
2530
},
2631
};

0 commit comments

Comments
 (0)