Skip to content

Commit 75f7d61

Browse files
committed
[ACTION] Sendgrid "Campaign sends" #14026
Actions - Create Send
1 parent 15cbf13 commit 75f7d61

File tree

26 files changed

+319
-28
lines changed

26 files changed

+319
-28
lines changed

components/sendgrid/actions/add-email-to-global-suppression/add-email-to-global-suppression.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "sendgrid-add-email-to-global-suppression",
66
name: "Add Email to Global Suppression",
77
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)",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "action",
1010
props: {
1111
...common.props,

components/sendgrid/actions/add-or-update-contact/add-or-update-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "sendgrid-add-or-update-contact",
77
name: "Add or Update Contact",
88
description: "Adds or updates a contact. [See the docs here](https://docs.sendgrid.com/api-reference/contacts/add-or-update-a-contact)",
9-
version: "0.0.3",
9+
version: "0.0.4",
1010
type: "action",
1111
props: {
1212
...common.props,

components/sendgrid/actions/create-contact-list/create-contact-list.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "sendgrid-create-contact-list",
66
name: "Create Contact List",
77
description: "Allows you to create a new contact list. [See the docs here](https://docs.sendgrid.com/api-reference/lists/create-list)",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "action",
1010
props: {
1111
...common.props,
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import { parseObject } from "../../common/utils.mjs";
3+
import common from "../common/common.mjs";
4+
5+
export default {
6+
...common,
7+
key: "sendgrid-create-send",
8+
name: "Create Send",
9+
description: "Create a single send. [See the docs here](https://www.twilio.com/docs/sendgrid/api-reference/single-sends/create-single-send)",
10+
version: "0.0.1",
11+
type: "action",
12+
props: {
13+
...common.props,
14+
name: {
15+
type: "string",
16+
label: "Name",
17+
description: "The name of the Single Send.",
18+
},
19+
categoryIds: {
20+
propDefinition: [
21+
common.props.sendgrid,
22+
"categoryIds",
23+
],
24+
optional: true,
25+
},
26+
sendAt: {
27+
type: "string",
28+
label: "Send At",
29+
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.",
30+
optional: true,
31+
},
32+
listIds: {
33+
propDefinition: [
34+
common.props.sendgrid,
35+
"listIds",
36+
],
37+
description: "The recipient List IDs that will receive the Single Send.",
38+
optional: true,
39+
},
40+
segmentIds: {
41+
propDefinition: [
42+
common.props.sendgrid,
43+
"segmentIds",
44+
],
45+
optional: true,
46+
},
47+
all: {
48+
type: "boolean",
49+
label: "All",
50+
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.",
51+
optional: true,
52+
},
53+
subject: {
54+
type: "string",
55+
label: "Subject",
56+
description: "The subject line of the Single Send. Do not include this field when using a `Design Id`.",
57+
optional: true,
58+
},
59+
htmlContent: {
60+
type: "string",
61+
label: "HTML Content",
62+
description: "The HTML content of the Single Send. Do not include this field when using a `Design Id`.",
63+
optional: true,
64+
},
65+
plainContent: {
66+
type: "string",
67+
label: "Plain Content",
68+
description: "The plain text content of the Single Send. Do not include this field when using a `Design Id`.",
69+
optional: true,
70+
},
71+
generatePlainContent: {
72+
type: "boolean",
73+
label: "Generate Plain Content",
74+
description: "If set to `true`, `Plain Content` is always generated from `HTML Content`. If set to false, `Plain Content` is not altered.",
75+
optional: true,
76+
},
77+
designId: {
78+
propDefinition: [
79+
common.props.sendgrid,
80+
"designId",
81+
],
82+
optional: true,
83+
},
84+
editor: {
85+
type: "string",
86+
label: "Editor",
87+
description: "The editor is used to modify the Single Send's design in the Marketing Campaigns App.",
88+
options: [
89+
"design",
90+
"code",
91+
],
92+
optional: true,
93+
},
94+
suppressionGroupId: {
95+
type: "integer",
96+
label: "Suppression Group Id",
97+
description: "The ID of the Suppression Group to allow recipients to unsubscribe — you must provide this or the `Custom Unsubscribe URL`.",
98+
optional: true,
99+
},
100+
customUnsubscribeUrl: {
101+
type: "string",
102+
label: "Custom Unsubscribe URL",
103+
description: "The URL allowing recipients to unsubscribe — you must provide this or the `Suppression Group Id`.",
104+
optional: true,
105+
},
106+
senderId: {
107+
propDefinition: [
108+
common.props.sendgrid,
109+
"senderId",
110+
],
111+
optional: true,
112+
},
113+
ipPool: {
114+
type: "string",
115+
label: "IP Pool",
116+
description: "The name of the IP Pool from which the Single Send emails are sent.",
117+
optional: true,
118+
},
119+
},
120+
async run({ $ }) {
121+
if (!this.suppressionGroupId && !this.customUnsubscribeUrl) {
122+
throw new ConfigurationError("You must provide either `Suppression Goup Id` or the `Custom Unsubscribe URL`.");
123+
}
124+
try {
125+
const resp = await this.sendgrid.createSingleSend({
126+
$,
127+
data: {
128+
name: this.name,
129+
categories: parseObject(this.categories),
130+
send_at: this.sendAt,
131+
send_to: {
132+
list_ids: parseObject(this.listIds),
133+
segment_ids: parseObject(this.segmentIds),
134+
all: this.all,
135+
},
136+
email_config: {
137+
subject: this.subject,
138+
html_content: this.htmlContent,
139+
plain_content: this.plainContent,
140+
generate_plain_content: this.generatePlainContent,
141+
design_id: this.designId,
142+
editor: this.editor,
143+
suppression_group_id: this.suppressionGroupId,
144+
custom_unsubscribe_url: this.customUnsubscribeUrl,
145+
sender_id: this.senderId,
146+
ip_pool: this.ipPool,
147+
},
148+
},
149+
});
150+
$.export("$summary", `Successfully created contact ${this.name}`);
151+
return resp;
152+
} catch (e) {
153+
const errors = e.split("Unexpected error (status code: ERR_BAD_REQUEST):")[1];
154+
const errorJson = JSON.parse(errors);
155+
156+
throw new ConfigurationError(errorJson.data.errors[0].message);
157+
}
158+
},
159+
};

components/sendgrid/actions/delete-blocks/delete-blocks.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "sendgrid-delete-blocks",
66
name: "Delete Blocks",
77
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)",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "action",
1010
props: {
1111
...common.props,

components/sendgrid/actions/delete-bounces/delete-bounces.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "sendgrid-delete-bounces",
66
name: "Delete Bounces",
77
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)",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "action",
1010
props: {
1111
...common.props,

components/sendgrid/actions/delete-contacts/delete-contacts.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "sendgrid-delete-contacts",
66
name: "Delete Contacts",
77
description: "Allows you to delete one or more contacts. [See the docs here](https://docs.sendgrid.com/api-reference/contacts/delete-contacts)",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "action",
1010
props: {
1111
...common.props,

components/sendgrid/actions/delete-global-suppression/delete-global-suppression.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "sendgrid-delete-global-suppression",
77
name: "Delete Global Suppression",
88
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)",
9-
version: "0.0.3",
9+
version: "0.0.4",
1010
type: "action",
1111
props: {
1212
...common.props,

components/sendgrid/actions/delete-list/delete-list.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "sendgrid-delete-list",
66
name: "Delete List",
77
description: "Allows you to delete a specific contact list. [See the docs here](https://docs.sendgrid.com/api-reference/lists/delete-a-list)",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "action",
1010
props: {
1111
...common.props,

components/sendgrid/actions/get-a-block/get-a-block.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "sendgrid-get-a-block",
77
name: "Get a Block",
88
description: "Gets a specific block. [See the docs here](https://docs.sendgrid.com/api-reference/blocks-api/retrieve-a-specific-block)",
9-
version: "0.0.3",
9+
version: "0.0.4",
1010
type: "action",
1111
props: {
1212
...common.props,

0 commit comments

Comments
 (0)