-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Elastic Email - new components #18943
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
components/elastic_email/actions/create-campaign/create-campaign.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); | ||
| } | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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
63
components/elastic_email/actions/create-contact/create-contact.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
38
components/elastic_email/actions/create-segment/create-segment.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
49
components/elastic_email/actions/list-campaigns/list-campaigns.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
42
components/elastic_email/actions/list-contacts/list-contacts.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.