Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {
key: "elastic_email-add-contact",
name: "Add Contact to Mailing List",
description: "Adds a new contact to a mailing list. [See the documentation](https://elasticemail.com/developers/api-documentation/rest-api#operation/contactsPost)",
version: "0.0.2",
version: "0.0.3",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
127 changes: 127 additions & 0 deletions components/elastic_email/actions/create-campaign/create-campaign.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import app from "../../elastic_email.app.mjs";
import { ConfigurationError } from "@pipedream/platform";
import { isValidEmailFormat } from "../../common/utils.mjs";

export default {
key: "elastic_email-create-campaign",
name: "Create Campaign",
description: "Create a campaign in an Elastic Email account. [See the documentation](https://elasticemail.com/developers/api-documentation/rest-api#operation/campaignsPost)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
app,
name: {
type: "string",
label: "Campaign Name",
description: "The name of the campaign",
},
from: {
type: "string",
label: "From",
description: "Your e-mail with an optional name (e.g.: `email@domain.com` or `John Doe <email@domain.com>`)",
},
recipientListNames: {
propDefinition: [
app,
"listNames",
],
label: "Recipient List Names",
description: "Names of lists from your Account to read recipients from",
},
recipientSegmentNames: {
propDefinition: [
app,
"segmentNames",
],
label: "Recipient Segment Names",
description: "Names of segments from your Account to read recipients from",
optional: true,
},
replyTo: {
type: "string",
label: "Reply To",
description: "To what address should the recipients reply to (e.g. `email@domain.com` or `John Doe <email@domain.com>`)",
},
status: {
propDefinition: [
app,
"campaignStatus",
],
},
subject: {
type: "string",
label: "Subject",
description: "Default subject of email",
optional: true,
},
templateName: {
propDefinition: [
app,
"templateName",
],
optional: true,
},
excludeRecipientListNames: {
propDefinition: [
app,
"listNames",
],
label: "Exclude Recipient List Names",
description: "Names of lists from your Account to exclude from the campaign",
},
excludeRecipientSegmentNames: {
propDefinition: [
app,
"segmentNames",
],
label: "Exclude Recipient Segment Names",
description: "Names of segments from your Account to exclude from the campaign",
optional: true,
},
},
async run({ $ }) {
if (this.from && !isValidEmailFormat(this.from)) {
throw new ConfigurationError("Invalid email format for 'From'");
}
if (this.replyTo && !isValidEmailFormat(this.replyTo)) {
throw new ConfigurationError("Invalid email format for 'Reply To'");
}

if (!this.recipientListNames && !this.recipientSegmentNames) {
throw new ConfigurationError("You must provide at least one list or segment to read recipients from");
}

const response = await this.app.createCampaign({
$,
data: {
Name: this.name,
Recipients: {
ListNames: this.recipientListNames,
SegmentNames: this.recipientSegmentNames,
},
Content: [
{
From: this.from,
ReplyTo: this.replyTo,
Subject: this.subject,
TemplateName: this.templateName,
},
],
Status: this.status,
ExcludeRecipients: this.excludeRecipientListNames || this.excludeRecipientSegmentNames
? {
ListNames: this.excludeRecipientListNames,
SegmentNames: this.excludeRecipientSegmentNames,
}
: undefined,
},
});
$.export("$summary", "Campaign created successfully");
return response;
},
};
63 changes: 63 additions & 0 deletions components/elastic_email/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import app from "../../elastic_email.app.mjs";
import { parseObject } from "../../common/utils.mjs";

export default {
key: "elastic_email-create-contact",
name: "Create Contact",
description: "Create a contact in an Elastic Email account. [See the documentation](https://elasticemail.com/developers/api-documentation/rest-api#operation/contactsPost)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
app,
email: {
type: "string",
label: "Email",
description: "The email of the contact",
},
status: {
propDefinition: [
app,
"contactStatus",
],
},
firstName: {
type: "string",
label: "First Name",
description: "The first name of the contact",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "The last name of the contact",
optional: true,
},
customFields: {
type: "object",
label: "Custom Fields",
description: "A key-value collection of custom contact fields which can be used in the system. Only already existing custom fields will be saved.",
optional: true,
},
},
async run({ $ }) {
const response = await this.app.createContact({
$,
data: [
{
Email: this.email,
Status: this.status,
FirstName: this.firstName,
LastName: this.lastName,
CustomFields: parseObject(this.customFields),
},
],
});
$.export("$summary", "Contact created successfully");
return response;
},
};
38 changes: 38 additions & 0 deletions components/elastic_email/actions/create-segment/create-segment.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import app from "../../elastic_email.app.mjs";

export default {
key: "elastic_email-create-segment",
name: "Create Segment",
description: "Create a segment in an Elastic Email account. [See the documentation](https://elasticemail.com/developers/api-documentation/rest-api#tag/Segments)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
app,
name: {
type: "string",
label: "Segment Name",
description: "The name of the segment",
},
rule: {
type: "string",
label: "Rule",
description: "SQL-like rule to determine which Contacts belong to this Segment. Help for building a segment rule can be found [here](https://help.elasticemail.com/en/articles/5162182-segment-rules)",
},
},
async run({ $ }) {
const response = await this.app.createSegment({
$,
data: {
Name: this.name,
Rule: this.rule,
},
});
$.export("$summary", "Segment created successfully");
return response;
},
};
49 changes: 49 additions & 0 deletions components/elastic_email/actions/list-campaigns/list-campaigns.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import app from "../../elastic_email.app.mjs";

export default {
key: "elastic_email-list-campaigns",
name: "List Campaigns",
description: "List campaigns in an Elastic Email account. [See the documentation](https://elasticemail.com/developers/api-documentation/rest-api#operation/campaignsGet)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
app,
search: {
type: "string",
label: "Search",
description: "The search query to filter campaigns",
optional: true,
},
limit: {
type: "integer",
label: "Limit",
description: "The maximum number of campaigns to return",
default: 100,
optional: true,
},
offset: {
type: "integer",
label: "Offset",
description: "The offset to start from",
default: 0,
optional: true,
},
},
async run({ $ }) {
const response = await this.app.listCampaigns({
$,
params: {
search: this.search,
limit: this.limit,
offset: this.offset,
},
});
$.export("$summary", `Successfully listed ${response?.length} campaigns.`);
return response;
},
};
42 changes: 42 additions & 0 deletions components/elastic_email/actions/list-contacts/list-contacts.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import app from "../../elastic_email.app.mjs";

export default {
key: "elastic_email-list-contacts",
name: "List Contacts",
description: "List contacts in an Elastic Email account. [See the documentation](https://elasticemail.com/developers/api-documentation/rest-api#operation/contactsGet)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
app,
limit: {
type: "integer",
label: "Limit",
description: "The maximum number of contacts to return",
default: 100,
optional: true,
},
offset: {
type: "integer",
label: "Offset",
description: "The offset to start from",
default: 0,
optional: true,
},
},
async run({ $ }) {
const response = await this.app.listContacts({
$,
params: {
limit: this.limit,
offset: this.offset,
},
});
$.export("$summary", `Successfully listed ${response?.length} contacts.`);
return response;
},
};
18 changes: 14 additions & 4 deletions components/elastic_email/actions/send-email/send-email.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import {
BODY_CONTENT_TYPE_OPTIONS,
ENCODING_OPTIONS,
} from "../../common/constants.mjs";
import { parseObject } from "../../common/utils.mjs";
import {
parseObject, isValidEmailFormat,
} from "../../common/utils.mjs";
import { ConfigurationError } from "@pipedream/platform";
import app from "../../elastic_email.app.mjs";

export default {
key: "elastic_email-send-email",
name: "Send Email",
description: "Sends an email to one or more recipients. [See the documentation](https://elasticemail.com/developers/api-documentation/rest-api#operation/emailsPost)",
version: "0.0.2",
version: "0.0.3",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand All @@ -26,7 +29,7 @@ export default {
from: {
type: "string",
label: "From",
description: "Your e-mail with an optional name (e.g.: email@domain.com)",
description: "Your e-mail with an optional name (e.g.: `email@domain.com` or `John Doe <email@domain.com>`)",
},
bodyContentType: {
type: "string",
Expand All @@ -50,7 +53,7 @@ export default {
replyTo: {
type: "string",
label: "Reply To",
description: "To what address should the recipients reply to (e.g. email@domain.com)",
description: "To what address should the recipients reply to (e.g. `email@domain.com` or `John Doe <email@domain.com>`)",
optional: true,
},
subject: {
Expand Down Expand Up @@ -105,6 +108,13 @@ export default {
},
},
async run({ $ }) {
if (this.from && !isValidEmailFormat(this.from)) {
throw new ConfigurationError("Invalid email format for 'From'");
}
if (this.replyTo && !isValidEmailFormat(this.replyTo)) {
throw new ConfigurationError("Invalid email format for 'Reply To'");
}

const response = await this.app.sendBulkEmails({
$,
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "elastic_email-unsubscribe-contact",
name: "Unsubscribe Contact",
description: "Unsubscribes a contact from future emails. [See the documentation](https://elasticemail.com/developers/api-documentation/rest-api#operation/suppressionsUnsubscribesPost)",
version: "0.0.2",
version: "0.0.3",
annotations: {
destructiveHint: true,
openWorldHint: true,
Expand Down
Loading
Loading