Skip to content

New Components - doppler_marketing_automation #14243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {
COUNTRY_OPTIONS, GENDER_OPTIONS,
} from "../../common/constants.mjs";
import app from "../../doppler_marketing_automation.app.mjs";

export default {
key: "doppler_marketing_automation-add-update-subscriber",
name: "Add or Update Subscriber",
description: "Adds a new subscriber or updates an existing one. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameListsByListIdSubscribersPost)",
version: "0.0.1",
type: "action",
props: {
app,
listId: {
propDefinition: [
app,
"listId",
],
},
subscriberEmail: {
type: "string",
label: "Subscriber Email",
description: "The email of the subscriber to add or update.",
},
firstName: {
type: "string",
label: "First Name",
description: "Subscriber first name",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "Subscriber last name",
optional: true,
},
birthDate: {
type: "string",
label: "Birth Date",
description: "The birth date of the subscriber",
optional: true,
},
country: {
type: "string",
label: "Country",
description: "Optional country of the subscriber",
options: COUNTRY_OPTIONS,
optional: true,
},
gender: {
type: "string",
label: "Gender",
description: "The gender of the subscriber",
options: GENDER_OPTIONS,
optional: true,
},
},
async run({ $ }) {
const fields = [];
if (this.firstName) fields.push({
name: "FIRSTNAME",
value: this.firstName,
});
if (this.lastName) fields.push({
name: "LASTNAME",
value: this.lastName,
});
if (this.birthDate) fields.push({
name: "BIRTHDAY",
value: this.birthDate,
});
if (this.country) fields.push({
name: "COUNTRY",
value: this.country,
});
if (this.gender) fields.push({
name: "GENDER",
value: this.gender,
});

const response = await this.app.addOrUpdateSubscriber({
$,
listId: this.listId,
data: {
email: this.subscriberEmail,
fields,
},
});

$.export("$summary", `Successfully added or updated subscriber with email: ${this.subscriberEmail}`);
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import app from "../../doppler_marketing_automation.app.mjs";

export default {
name: "Get Subscriber",
version: "0.0.1",
version: "0.0.2",
key: "doppler_marketing_automation-get-subscriber",
description: "Get a subscriber. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameSubscribersByEmailGet)",
type: "action",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import app from "../../doppler_marketing_automation.app.mjs";

export default {
name: "Remove Subscriber",
version: "0.0.1",
key: "doppler_marketing_automation-remove-subscriber",
description: "Remove a subscriber. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameListsByListIdSubscribersByEmailDelete)",
name: "Remove Subscriber",
description: "Removes a subscriber from a list completely. [See the documentation](https://restapi.fromdoppler.com/docs/resources#!/Subscribers/AccountsByAccountNameListsByListIdSubscribersByEmailDelete)",
version: "0.0.2",
type: "action",
props: {
app,
Expand All @@ -18,8 +18,8 @@ export default {
propDefinition: [
app,
"subscriberEmail",
(c) => ({
listId: c.listId,
({ listId }) => ({
listId,
}),
],
},
Expand All @@ -30,11 +30,7 @@ export default {
email: this.email,
listId: this.listId,
});

if (response) {
$.export("$summary", `Successfully removed subscriber with email ${this.email}`);
}

$.export("$summary", `Successfully removed subscriber: ${this.email} from list: ${this.listId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import app from "../../doppler_marketing_automation.app.mjs";

export default {
key: "doppler_marketing_automation-unsubscribe-email",
name: "Unsubscribe Email",
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)",
version: "0.0.1",
type: "action",
props: {
app,
email: {
propDefinition: [
app,
"subscriberEmail",
() => ({
filter: ({ status }) => status != "unsubscribed",
}),
],
},
},
async run({ $ }) {
const response = await this.app.unsubscribeSubscriber({
$,
data: {
email: this.email,
},
});
$.export("$summary", `Successfully unsubscribed email: ${this.email}`);
return response;
},
};
Loading
Loading