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 @@ -5,7 +5,7 @@ export default {
key: "sendgrid-add-email-to-global-suppression",
name: "Add Email to Global Suppression",
description: "Allows you to add one or more email addresses to the global suppressions group. [See the docs here](https://sendgrid.api-docs.io/v3.0/suppressions-global-suppressions/add-recipient-addresses-to-the-global-suppression-group)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "sendgrid-add-or-update-contact",
name: "Add or Update Contact",
description: "Adds or updates a contact. [See the docs here](https://docs.sendgrid.com/api-reference/contacts/add-or-update-a-contact)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "sendgrid-create-contact-list",
name: "Create Contact List",
description: "Allows you to create a new contact list. [See the docs here](https://docs.sendgrid.com/api-reference/lists/create-list)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
172 changes: 172 additions & 0 deletions components/sendgrid/actions/create-send/create-send.mjs
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);
}
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "sendgrid-delete-blocks",
name: "Delete Blocks",
description: "Allows you to delete all email addresses on your blocks list. [See the docs here](https://docs.sendgrid.com/api-reference/blocks-api/delete-blocks)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "sendgrid-delete-bounces",
name: "Delete Bounces",
description: "Allows you to delete all emails on your bounces list. [See the docs here](https://docs.sendgrid.com/api-reference/bounces-api/delete-bounces)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "sendgrid-delete-contacts",
name: "Delete Contacts",
description: "Allows you to delete one or more contacts. [See the docs here](https://docs.sendgrid.com/api-reference/contacts/delete-contacts)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "sendgrid-delete-global-suppression",
name: "Delete Global Suppression",
description: "Allows you to remove an email address from the global suppressions group. [See the docs here](https://docs.sendgrid.com/api-reference/suppressions-global-suppressions/delete-a-global-suppression)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
2 changes: 1 addition & 1 deletion components/sendgrid/actions/delete-list/delete-list.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "sendgrid-delete-list",
name: "Delete List",
description: "Allows you to delete a specific contact list. [See the docs here](https://docs.sendgrid.com/api-reference/lists/delete-a-list)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
2 changes: 1 addition & 1 deletion components/sendgrid/actions/get-a-block/get-a-block.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "sendgrid-get-a-block",
name: "Get a Block",
description: "Gets a specific block. [See the docs here](https://docs.sendgrid.com/api-reference/blocks-api/retrieve-a-specific-block)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "sendgrid-get-a-global-suppression",
name: "Get A Global Suppression",
description: "Gets a global suppression. [See the docs here](https://docs.sendgrid.com/api-reference/suppressions-global-suppressions/retrieve-a-global-suppression)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "sendgrid-get-all-bounces",
name: "Get All Bounces",
description: "Allows you to get all of your bounces. [See the docs here](https://docs.sendgrid.com/api-reference/bounces-api/retrieve-all-bounces)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "sendgrid-get-contact-lists",
name: "Get Contact Lists",
description: "Allows you to get details of your contact lists. [See the docs here](https://docs.sendgrid.com/api-reference/lists/get-all-lists)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
2 changes: 1 addition & 1 deletion components/sendgrid/actions/list-blocks/list-blocks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "sendgrid-list-blocks",
name: "List Blocks",
description: "Allows you to list all email addresses that are currently on your blocks list. [See the docs here](https://docs.sendgrid.com/api-reference/blocks-api/retrieve-all-blocks)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "sendgrid-list-global-suppressions",
name: "List Global Suppressions",
description: "Allows you to get a list of all email address that are globally suppressed. [See the docs here](https://docs.sendgrid.com/api-reference/suppressions-global-suppressions/retrieve-all-global-suppressions)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "sendgrid-remove-contact-from-list",
name: "Remove Contact From List",
description: "Allows you to remove contacts from a given list. [See the docs here](https://docs.sendgrid.com/api-reference/lists/remove-contacts-from-a-list)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ConfigurationError } from "@pipedream/platform";
import common from "../common/common.mjs";
import constants from "../common/constants.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
...common,
key: "sendgrid-search-contacts",
name: "Search Contacts",
description: "Searches contacts with a SGQL query. [See the docs here](https://docs.sendgrid.com/api-reference/contacts/search-contacts)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "sendgrid-send-email-multiple-recipients",
name: "Send Email Multiple Recipients",
description: "This action sends a personalized e-mail to multiple specified recipients. [See the docs here](https://docs.sendgrid.com/api-reference/mail-send/mail-send)",
version: "0.0.4",
version: "0.0.5",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "sendgrid-send-email-single-recipient",
name: "Send Email Single Recipient",
description: "This action sends a personalized e-mail to the specified recipient. [See the docs here](https://docs.sendgrid.com/api-reference/mail-send/mail-send)",
version: "0.0.6",
version: "0.0.7",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "sendgrid-validate-email",
name: "Validate Email",
description: "Validates an email address. This action requires a Sendgrid's Pro or Premier plan. [See the docs here](https://docs.sendgrid.com/api-reference/e-mail-address-validation/validate-an-email)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
1 change: 1 addition & 0 deletions components/sendgrid/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const LIMIT = 100;
24 changes: 24 additions & 0 deletions components/sendgrid/common/utils.mjs
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;
});
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch (e) {
return obj;
}
}
return obj;
};
4 changes: 2 additions & 2 deletions components/sendgrid/package.json
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": [
Expand All @@ -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",
Expand Down
Loading
Loading