-
Couldn't load subscription status.
- Fork 5.5k
14026 action sendgrid campaign sends #14811
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
8 commits
Select commit
Hold shift + click to select a range
75f7d61
[ACTION] Sendgrid "Campaign sends" #14026
luancazarine 952f5ea
pnpm update
luancazarine 94be3a9
Update components/sendgrid/actions/create-send/create-send.mjs
luancazarine 3f86cda
Update components/sendgrid/actions/create-send/create-send.mjs
luancazarine 841f337
Update components/sendgrid/actions/create-send/create-send.mjs
luancazarine ded7bb8
Update components/sendgrid/actions/create-send/create-send.mjs
luancazarine aa0e4ce
fix coderabbitai commit
luancazarine 871cd64
soem adjusts
luancazarine 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
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
172 changes: 172 additions & 0 deletions
172
components/sendgrid/actions/create-send/create-send.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,172 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import common from "../common/common.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "sendgrid-create-send", | ||
| name: "Create Send", | ||
| description: "Create a single send. [See the docs here](https://www.twilio.com/docs/sendgrid/api-reference/single-sends/create-single-send)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| ...common.props, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "The name of the Single Send.", | ||
| }, | ||
| categoryIds: { | ||
| propDefinition: [ | ||
| common.props.sendgrid, | ||
| "categoryIds", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| sendAt: { | ||
| type: "string", | ||
| label: "Send At", | ||
| description: "Set this property to an ISO 8601 formatted date-time (YYYY-MM-DDTHH:MM:SSZ) when you would like to send the Single Send. Please note that any `send_at` property value set with this endpoint will prepopulate the send date in the SendGrid user interface (UI). However, the Single Send will remain an unscheduled draft until it's updated with the [Schedule Single Send](https://www.twilio.com/docs/sendgrid/api-reference/single-sends/schedule-single-send) endpoint or SendGrid application UI. Setting this property to `now` with this endpoint will cause an error.", | ||
| optional: true, | ||
| }, | ||
| listIds: { | ||
| propDefinition: [ | ||
| common.props.sendgrid, | ||
| "listIds", | ||
| ], | ||
| description: "The recipient List IDs that will receive the Single Send.", | ||
| optional: true, | ||
| hidden: true, | ||
| }, | ||
| segmentIds: { | ||
| propDefinition: [ | ||
| common.props.sendgrid, | ||
| "segmentIds", | ||
| ], | ||
| optional: true, | ||
| hidden: true, | ||
| }, | ||
| all: { | ||
| type: "boolean", | ||
| label: "All", | ||
| description: "Set to `true` to send to All Contacts. If set to `false`, at least one `List Ids` or `Segment Ids` value must be provided before the Single Send is scheduled to be sent to recipients.", | ||
| default: true, | ||
| reloadProps: true, | ||
| }, | ||
| subject: { | ||
| type: "string", | ||
| label: "Subject", | ||
| description: "The subject line of the Single Send. Do not include this field when using a `Design Id`.", | ||
| optional: true, | ||
| }, | ||
| htmlContent: { | ||
| type: "string", | ||
| label: "HTML Content", | ||
| description: "The HTML content of the Single Send. Do not include this field when using a `Design Id`.", | ||
| optional: true, | ||
| }, | ||
| plainContent: { | ||
| type: "string", | ||
| label: "Plain Content", | ||
| description: "The plain text content of the Single Send. Do not include this field when using a `Design Id`.", | ||
| optional: true, | ||
| }, | ||
| generatePlainContent: { | ||
| type: "boolean", | ||
| label: "Generate Plain Content", | ||
| description: "If set to `true`, `Plain Content` is always generated from `HTML Content`. If set to false, `Plain Content` is not altered.", | ||
| optional: true, | ||
| }, | ||
| designId: { | ||
| propDefinition: [ | ||
| common.props.sendgrid, | ||
| "designId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| editor: { | ||
| type: "string", | ||
| label: "Editor", | ||
| description: "The editor is used to modify the Single Send's design in the Marketing Campaigns App.", | ||
| options: [ | ||
| "design", | ||
| "code", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| suppressionGroupId: { | ||
| propDefinition: [ | ||
| common.props.sendgrid, | ||
| "asmGroupId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| customUnsubscribeUrl: { | ||
| type: "string", | ||
| label: "Custom Unsubscribe URL", | ||
| description: "The URL allowing recipients to unsubscribe — you must provide this or the `Suppression Group Id`.", | ||
| optional: true, | ||
| }, | ||
| senderId: { | ||
| propDefinition: [ | ||
| common.props.sendgrid, | ||
| "senderId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| ipPool: { | ||
| type: "string", | ||
| label: "IP Pool", | ||
| description: "The name of the IP Pool from which the Single Send emails are sent.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async additionalProps(props) { | ||
| props.listIds.hidden = this.all; | ||
| props.segmentIds.hidden = this.all; | ||
| return {}; | ||
| }, | ||
| async run({ $ }) { | ||
| if (!this.suppressionGroupId && !this.customUnsubscribeUrl) { | ||
| throw new ConfigurationError("You must provide either `ASM Group ID` or the `Custom Unsubscribe URL`."); | ||
| } | ||
| try { | ||
| const resp = await this.sendgrid.createSingleSend({ | ||
| $, | ||
| data: { | ||
| name: this.name, | ||
| categories: parseObject(this.categoryIds), | ||
| send_at: this.sendAt, | ||
| send_to: { | ||
| list_ids: !this.all | ||
| ? parseObject(this.listIds) | ||
| : null, | ||
| segment_ids: !this.all | ||
| ? parseObject(this.segmentIds) | ||
| : null, | ||
| all: this.all, | ||
| }, | ||
| email_config: { | ||
| subject: this.subject, | ||
| html_content: this.htmlContent, | ||
| plain_content: this.plainContent, | ||
| generate_plain_content: this.generatePlainContent, | ||
| design_id: this.designId, | ||
| editor: this.editor, | ||
| suppression_group_id: this.suppressionGroupId, | ||
| custom_unsubscribe_url: this.customUnsubscribeUrl, | ||
| sender_id: this.senderId, | ||
| ip_pool: this.ipPool, | ||
| }, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully created single send ${this.name}`); | ||
| return resp; | ||
| } catch (e) { | ||
| const errors = e.split("Unexpected error (status code: ERR_BAD_REQUEST):")[1]; | ||
| const errorJson = JSON.parse(errors); | ||
|
|
||
| throw new ConfigurationError(errorJson.data.errors[0].message); | ||
| } | ||
| }, | ||
| }; | ||
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
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
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
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
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
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
4 changes: 2 additions & 2 deletions
4
components/sendgrid/actions/search-contacts/search-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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const LIMIT = 100; |
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,24 @@ | ||
| export const parseObject = (obj) => { | ||
| if (!obj) return undefined; | ||
|
|
||
| if (Array.isArray(obj)) { | ||
| return obj.map((item) => { | ||
| if (typeof item === "string") { | ||
| try { | ||
| return JSON.parse(item); | ||
| } catch (e) { | ||
| return item; | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return obj; | ||
| }; | ||
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/sendgrid", | ||
| "version": "0.3.10", | ||
| "version": "0.4.0", | ||
| "description": "Pipedream Sendgrid Components", | ||
| "main": "sendgrid.app.js", | ||
| "keywords": [ | ||
|
|
@@ -10,7 +10,7 @@ | |
| "homepage": "https://pipedream.com/apps/sendgrid", | ||
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "dependencies": { | ||
| "@pipedream/platform": "^1.2.0", | ||
| "@pipedream/platform": "^3.0.3", | ||
| "@sendgrid/client": "^7.6.2", | ||
| "@sendgrid/eventwebhook": "^7.4.5", | ||
| "async-retry": "^1.3.1", | ||
|
|
||
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.