Skip to content

Commit 232295a

Browse files
committed
Added actions
1 parent a7d0f19 commit 232295a

File tree

6 files changed

+247
-25
lines changed

6 files changed

+247
-25
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import app from "../../parsio_io.app.mjs";
2+
3+
export default {
4+
key: "parsio_io-create-mailbox",
5+
name: "Create Mailbox",
6+
description: "Create a new mailbox in Parsio. [See the documentation](https://help.parsio.io/public-api/parsio-public-api#create-a-mailbox)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
name: {
17+
propDefinition: [
18+
app,
19+
"name",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.app.createMailbox({
25+
$,
26+
data: {
27+
name: this.name,
28+
},
29+
});
30+
$.export("$summary", "Successfully created mailbox");
31+
return response;
32+
},
33+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import app from "../../parsio_io.app.mjs";
2+
3+
export default {
4+
key: "parsio_io-delete-mailbox",
5+
name: "Delete Mailbox",
6+
description: "Delete the specified mailbox. [See the documentation](https://help.parsio.io/public-api/parsio-public-api#delete-a-mailbox)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: true,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
mailboxId: {
17+
propDefinition: [
18+
app,
19+
"mailboxId",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.app.deleteMailbox({
25+
$,
26+
mailboxId: this.mailboxId,
27+
});
28+
$.export("$summary", "Successfully deleted mailbox");
29+
return response;
30+
},
31+
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import app from "../../parsio_io.app.mjs";
2+
3+
export default {
4+
key: "parsio_io-update-mailbox",
5+
name: "Update Mailbox",
6+
description: "Update the specified mailbox. [See the documentation](https://help.parsio.io/public-api/parsio-public-api#update-a-mailbox)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: true,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
mailboxId: {
17+
propDefinition: [
18+
app,
19+
"mailboxId",
20+
],
21+
},
22+
name: {
23+
propDefinition: [
24+
app,
25+
"name",
26+
],
27+
description: "The new name of the mailbox",
28+
},
29+
emailPrefix: {
30+
propDefinition: [
31+
app,
32+
"emailPrefix",
33+
],
34+
},
35+
processAttachments: {
36+
propDefinition: [
37+
app,
38+
"processAttachments",
39+
],
40+
},
41+
collectEmails: {
42+
propDefinition: [
43+
app,
44+
"collectEmails",
45+
],
46+
},
47+
alertEmailH: {
48+
propDefinition: [
49+
app,
50+
"alertEmailH",
51+
],
52+
},
53+
},
54+
async run({ $ }) {
55+
const response = await this.app.updateMailbox({
56+
$,
57+
mailboxId: this.mailboxId,
58+
data: {
59+
name: this.name,
60+
email_prefix: this.emailPrefix,
61+
process_attachments: this.processAttachments,
62+
collect_emails: this.collectEmails,
63+
alert_email_h: this.alertEmailH,
64+
},
65+
});
66+
$.export("$summary", "Successfully updated mailbox");
67+
return response;
68+
},
69+
};

components/parsio_io/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/parsio_io",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Parsio.io Components",
55
"main": "parsio_io.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
1518
}
Lines changed: 96 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,102 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "parsio_io",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
name: {
8+
type: "string",
9+
label: "Name",
10+
description: "Name of the mailbox to create",
11+
},
12+
emailPrefix: {
13+
type: "string",
14+
label: "Email Prefix",
15+
description: "Custom prefix for the mailbox email address",
16+
},
17+
processAttachments: {
18+
type: "boolean",
19+
label: "Process Attachments",
20+
description: "Specifies whether to process attachments automatically",
21+
optional: true,
22+
},
23+
collectEmails: {
24+
type: "boolean",
25+
label: "Collect Emails",
26+
description: "Defines if emails should be collected automatically from the mailbox",
27+
optional: true,
28+
},
29+
alertEmailH: {
30+
type: "string",
31+
label: "Alert Email H",
32+
description: "Optional email address to receive alert notifications",
33+
optional: true,
34+
},
35+
mailboxId: {
36+
type: "string",
37+
label: "Mailbox ID",
38+
description: "Unique identifier of the mailbox",
39+
async options() {
40+
const response = await this.getMailboxes();
41+
return response.map(({
42+
name, _id,
43+
}) => ({
44+
label: name,
45+
value: _id,
46+
}));
47+
},
48+
},
49+
},
550
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
51+
_baseUrl() {
52+
return "https://api.parsio.io";
53+
},
54+
async _makeRequest(opts = {}) {
55+
const {
56+
$ = this,
57+
path,
58+
headers,
59+
...otherOpts
60+
} = opts;
61+
return axios($, {
62+
...otherOpts,
63+
url: this._baseUrl() + path,
64+
headers: {
65+
"X-API-Key": `${this.$auth.api_key}`,
66+
...headers,
67+
},
68+
});
69+
},
70+
async createMailbox(args = {}) {
71+
return this._makeRequest({
72+
path: "/mailboxes/create",
73+
method: "post",
74+
...args,
75+
});
76+
},
77+
async updateMailbox({
78+
mailboxId, ...args
79+
}) {
80+
return this._makeRequest({
81+
path: `/mailboxes/${mailboxId}`,
82+
method: "post",
83+
...args,
84+
});
85+
},
86+
async deleteMailbox({
87+
mailboxId, ...args
88+
}) {
89+
return this._makeRequest({
90+
path: `/mailboxes/${mailboxId}`,
91+
method: "delete",
92+
...args,
93+
});
94+
},
95+
async getMailboxes(args = {}) {
96+
return this._makeRequest({
97+
path: "/mailboxes",
98+
...args,
99+
});
9100
},
10101
},
11-
};
102+
};

pnpm-lock.yaml

Lines changed: 14 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)