Skip to content

Commit 0b6b989

Browse files
committed
new components
1 parent 6997b04 commit 0b6b989

File tree

5 files changed

+143
-5
lines changed

5 files changed

+143
-5
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import stripo from "../../stripo.app.mjs";
2+
3+
export default {
4+
key: "stripo-get-raw-html",
5+
name: "Get Raw HTML & CSS",
6+
description: "Retrieves the HTML and CSS code of the selected email message in Stripo. [See the documentation](https://api.stripo.email/reference/getrawemail)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
stripo,
11+
emailId: {
12+
propDefinition: [
13+
stripo,
14+
"emailId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.stripo.getRawHtml({
20+
$,
21+
emailId: this.emailId,
22+
});
23+
$.export("$summary", `Successfully retrieved HTML & CSS from email with ID: ${this.emailId}`);
24+
return response;
25+
},
26+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import stripo from "../../stripo.app.mjs";
2+
3+
export default {
4+
key: "stripo-remove-email",
5+
name: "Remove Email",
6+
description: "Removes an existing message from the user's project in Stripo. [See the documentation](https://api.stripo.email/reference/deleteemail)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
stripo,
11+
emailId: {
12+
propDefinition: [
13+
stripo,
14+
"emailId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.stripo.removeEmail({
20+
$,
21+
emailId: this.emailId,
22+
});
23+
$.export("$summary", `Successfully removed email with ID: ${this.emailId}`);
24+
return response;
25+
},
26+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import stripo from "../../stripo.app.mjs";
2+
3+
export default {
4+
key: "stripo-search-emails",
5+
name: "Search Emails",
6+
description: "Searches existing emails by search query in Stripo. [See the documentation](https://api.stripo.email/reference/findemails)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
stripo,
11+
query: {
12+
propDefinition: [
13+
stripo,
14+
"query",
15+
],
16+
},
17+
maxResults: {
18+
type: "integer",
19+
label: "Max Results",
20+
description: "The maximum number of results to return",
21+
default: 100,
22+
optional: true,
23+
},
24+
},
25+
async run({ $ }) {
26+
const results = this.stripo.paginate({
27+
fn: this.stripo.listEmails,
28+
params: {
29+
queryStr: this.query,
30+
},
31+
max: this.maxResults,
32+
});
33+
34+
const emails = [];
35+
for await (const item of results) {
36+
emails.push(item);
37+
}
38+
39+
$.export("$summary", `Successfully retrieved ${emails.length} email${emails.length === 1
40+
? ""
41+
: "s"}`);
42+
return emails;
43+
},
44+
};

components/stripo/sources/new-email-created/new-email-created.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export default {
1919
},
2020
},
2121
query: {
22-
type: "string",
23-
label: "Query",
24-
description: "A query to search for",
25-
optional: true,
22+
propDefinition: [
23+
stripo,
24+
"query",
25+
],
2626
},
2727
},
2828
methods: {

components/stripo/stripo.app.mjs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,32 @@ import { axios } from "@pipedream/platform";
33
export default {
44
type: "app",
55
app: "stripo",
6-
propDefinitions: {},
6+
propDefinitions: {
7+
emailId: {
8+
type: "string",
9+
label: "Email ID",
10+
description: "The identifier of an email",
11+
async options({ page }) {
12+
const { data } = await this.listEmails({
13+
params: {
14+
page,
15+
},
16+
});
17+
return data?.map(({
18+
emailId: value, name: label,
19+
}) => ({
20+
value,
21+
label,
22+
})) || [];
23+
},
24+
},
25+
query: {
26+
type: "string",
27+
label: "Query",
28+
description: "The query to search for",
29+
optional: true,
30+
},
31+
},
732
methods: {
833
_baseUrl() {
934
return "https://my.stripo.email/emailgeneration/v1";
@@ -28,6 +53,23 @@ export default {
2853
...opts,
2954
});
3055
},
56+
getRawHtml({
57+
emailId, ...opts
58+
}) {
59+
return this._makeRequest({
60+
path: `/raw-email/${emailId}`,
61+
...opts,
62+
});
63+
},
64+
removeEmail({
65+
emailId, ...opts
66+
}) {
67+
return this._makeRequest({
68+
method: "DELETE",
69+
path: `/emails/${emailId}`,
70+
...opts,
71+
});
72+
},
3173
async *paginate({
3274
fn, params, max,
3375
}) {

0 commit comments

Comments
 (0)