Skip to content

Commit 6a3b772

Browse files
committed
[Components] mailosaur #16655
Sources - New Message - New Message Macthing Criteira Actions - Create Email - Search Message - Delete Message
1 parent ea73453 commit 6a3b772

File tree

11 files changed

+307
-375
lines changed

11 files changed

+307
-375
lines changed

components/mailosaur/actions/create-email/create-email.mjs

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ConfigurationError } from "@pipedream/platform";
12
import mailosaur from "../../mailosaur.app.mjs";
23

34
export default {
@@ -15,65 +16,56 @@ export default {
1516
],
1617
},
1718
to: {
18-
propDefinition: [
19-
mailosaur,
20-
"to",
21-
],
22-
},
23-
subject: {
24-
propDefinition: [
25-
mailosaur,
26-
"subject",
27-
],
19+
type: "string",
20+
label: "To",
21+
description: "The verified external email address to which the email should be sent.",
2822
},
2923
from: {
30-
propDefinition: [
31-
mailosaur,
32-
"from",
33-
],
24+
type: "string",
25+
label: "From",
26+
description: "Optionally overrides of the message's `from` address. This **must** be an address ending with `YOUR_SERVER.mailosaur.net`, such as `my-emails @a1bcdef2.mailosaur.net`.",
3427
optional: true,
3528
},
29+
subject: {
30+
type: "string",
31+
label: "Subject",
32+
description: "The subject line for an email.",
33+
},
3634
html: {
37-
propDefinition: [
38-
mailosaur,
39-
"html",
40-
],
35+
type: "object",
36+
label: "HTML",
37+
description: "An object with HTML properties. Please [see the documentation](https://mailosaur.com/docs/api#send-an-email) for more details.",
4138
optional: true,
4239
},
4340
text: {
44-
propDefinition: [
45-
mailosaur,
46-
"text",
47-
],
41+
type: "object",
42+
label: "Text",
43+
description: "An object with Plain text properties. Please [see the documentation](https://mailosaur.com/docs/api#send-an-email) for more details.",
4844
optional: true,
4945
},
5046
send: {
51-
propDefinition: [
52-
mailosaur,
53-
"send",
54-
],
55-
optional: true,
56-
},
57-
attachments: {
58-
propDefinition: [
59-
mailosaur,
60-
"attachments",
61-
],
62-
optional: true,
47+
type: "boolean",
48+
label: "Send",
49+
description: "If `false`, the email will be created in your server, but will not be sent.",
6350
},
6451
},
6552
async run({ $ }) {
66-
const response = await this.mailosaur.sendEmail({
67-
serverId: this.serverId,
68-
to: this.to,
69-
subject: this.subject,
70-
from: this.from,
71-
html: this.html,
72-
text: this.text,
73-
send: this.send,
74-
attachments: this.attachments
75-
? this.attachments.map(JSON.parse)
76-
: undefined,
53+
if ((!!this.send) && (!this.html && !this.text)) {
54+
throw new ConfigurationError("Please provide either HTML or plain text content.");
55+
}
56+
57+
const {
58+
mailosaur,
59+
serverId,
60+
...data
61+
} = this;
62+
63+
const response = await mailosaur.sendEmail({
64+
$,
65+
params: {
66+
server: serverId,
67+
},
68+
data,
7769
});
7870

7971
$.export("$summary", `Email sent successfully to ${this.to}`);

components/mailosaur/actions/delete-email/delete-email.mjs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import mailosaur from "../../mailosaur.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "mailosaur-delete-email",
@@ -9,20 +8,29 @@ export default {
98
type: "action",
109
props: {
1110
mailosaur,
11+
serverId: {
12+
propDefinition: [
13+
mailosaur,
14+
"serverId",
15+
],
16+
},
1217
emailId: {
1318
propDefinition: [
1419
mailosaur,
1520
"emailId",
21+
({ serverId }) => ({
22+
serverId,
23+
}),
1624
],
1725
},
1826
},
1927
async run({ $ }) {
20-
const response = await this.mailosaur.deleteEmail({
28+
await this.mailosaur.deleteEmail({
29+
$,
2130
emailId: this.emailId,
2231
});
2332
$.export("$summary", `Successfully deleted email with ID ${this.emailId}`);
2433
return {
25-
success: true,
2634
emailId: this.emailId,
2735
};
2836
},

components/mailosaur/actions/search-email/search-email.mjs

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import mailosaur from "../../mailosaur.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "mailosaur-search-email",
65
name: "Search Email",
76
description: "Search for received emails in a server matching specified criteria. [See the documentation](https://mailosaur.com/docs/api/#search-for-messages)",
8-
version: "0.0.{{ts}}",
7+
version: "0.0.1",
98
type: "action",
109
props: {
1110
mailosaur,
@@ -16,31 +15,29 @@ export default {
1615
],
1716
},
1817
receiveAfter: {
19-
propDefinition: [
20-
mailosaur,
21-
"receiveAfter",
22-
],
18+
type: "string",
19+
label: "Receive After",
20+
description:
21+
"Limits results to only messages received after this date/time.",
2322
optional: true,
2423
},
2524
page: {
26-
propDefinition: [
27-
mailosaur,
28-
"page",
29-
],
25+
type: "integer",
26+
label: "Page",
27+
description: "Used in conjunction with `itemsPerPage` to support pagination.",
3028
optional: true,
3129
},
3230
itemsPerPage: {
33-
propDefinition: [
34-
mailosaur,
35-
"itemsPerPage",
36-
],
31+
type: "integer",
32+
label: "Items Per Page",
33+
description:
34+
"A limit on the number of results to be returned per page. Can be set between 1 and 1000 items, default is 50.",
3735
optional: true,
3836
},
3937
dir: {
40-
propDefinition: [
41-
mailosaur,
42-
"dir",
43-
],
38+
type: "string",
39+
label: "Direction",
40+
description: "Optionally limits results based on the direction (`Sent` or `Received`).",
4441
optional: true,
4542
},
4643
sentFrom: {
@@ -81,16 +78,21 @@ export default {
8178
},
8279
async run({ $ }) {
8380
const response = await this.mailosaur.searchMessages({
84-
serverId: this.serverId,
85-
receiveAfter: this.receiveAfter,
86-
page: this.page,
87-
itemsPerPage: this.itemsPerPage,
88-
dir: this.dir,
89-
sentFrom: this.sentFrom,
90-
sentTo: this.sentTo,
91-
subject: this.subject,
92-
body: this.body,
93-
match: this.match,
81+
$,
82+
params: {
83+
server: this.serverId,
84+
receiveAfter: this.receiveAfter,
85+
page: this.page,
86+
itemsPerPage: this.itemsPerPage,
87+
dir: this.dir,
88+
},
89+
data: {
90+
sentFrom: this.sentFrom,
91+
sentTo: this.sentTo,
92+
subject: this.subject,
93+
body: this.body,
94+
match: this.match,
95+
},
9496
});
9597

9698
$.export("$summary", `Successfully retrieved ${response.items.length} email(s) from server.`);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const LIMIT = 1000;
2+
3+
export const MATCH_OPTIONS = [
4+
{
5+
label: "All",
6+
value: "ALL",
7+
},
8+
{
9+
label: "Any",
10+
value: "ANY",
11+
},
12+
];

0 commit comments

Comments
 (0)