diff --git a/components/parsio_io/actions/create-mailbox/create-mailbox.mjs b/components/parsio_io/actions/create-mailbox/create-mailbox.mjs new file mode 100644 index 0000000000000..2afa99e664258 --- /dev/null +++ b/components/parsio_io/actions/create-mailbox/create-mailbox.mjs @@ -0,0 +1,33 @@ +import app from "../../parsio_io.app.mjs"; + +export default { + key: "parsio_io-create-mailbox", + name: "Create Mailbox", + description: "Create a new mailbox in Parsio. [See the documentation](https://help.parsio.io/public-api/parsio-public-api#create-a-mailbox)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + app, + name: { + propDefinition: [ + app, + "name", + ], + }, + }, + async run({ $ }) { + const response = await this.app.createMailbox({ + $, + data: { + name: this.name, + }, + }); + $.export("$summary", "Successfully created mailbox"); + return response; + }, +}; diff --git a/components/parsio_io/actions/delete-mailbox/delete-mailbox.mjs b/components/parsio_io/actions/delete-mailbox/delete-mailbox.mjs new file mode 100644 index 0000000000000..5f095b4916910 --- /dev/null +++ b/components/parsio_io/actions/delete-mailbox/delete-mailbox.mjs @@ -0,0 +1,31 @@ +import app from "../../parsio_io.app.mjs"; + +export default { + key: "parsio_io-delete-mailbox", + name: "Delete Mailbox", + description: "Delete the specified mailbox. [See the documentation](https://help.parsio.io/public-api/parsio-public-api#delete-a-mailbox)", + version: "0.0.1", + annotations: { + destructiveHint: true, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + app, + mailboxId: { + propDefinition: [ + app, + "mailboxId", + ], + }, + }, + async run({ $ }) { + const response = await this.app.deleteMailbox({ + $, + mailboxId: this.mailboxId, + }); + $.export("$summary", "Successfully deleted mailbox"); + return response; + }, +}; diff --git a/components/parsio_io/actions/update-mailbox/update-mailbox.mjs b/components/parsio_io/actions/update-mailbox/update-mailbox.mjs new file mode 100644 index 0000000000000..b072eed622ac5 --- /dev/null +++ b/components/parsio_io/actions/update-mailbox/update-mailbox.mjs @@ -0,0 +1,69 @@ +import app from "../../parsio_io.app.mjs"; + +export default { + key: "parsio_io-update-mailbox", + name: "Update Mailbox", + description: "Update the specified mailbox. [See the documentation](https://help.parsio.io/public-api/parsio-public-api#update-a-mailbox)", + version: "0.0.1", + annotations: { + destructiveHint: true, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + app, + mailboxId: { + propDefinition: [ + app, + "mailboxId", + ], + }, + name: { + propDefinition: [ + app, + "name", + ], + description: "The new name of the mailbox", + }, + emailPrefix: { + propDefinition: [ + app, + "emailPrefix", + ], + }, + processAttachments: { + propDefinition: [ + app, + "processAttachments", + ], + }, + collectEmails: { + propDefinition: [ + app, + "collectEmails", + ], + }, + alertEmailH: { + propDefinition: [ + app, + "alertEmailH", + ], + }, + }, + async run({ $ }) { + const response = await this.app.updateMailbox({ + $, + mailboxId: this.mailboxId, + data: { + name: this.name, + email_prefix: this.emailPrefix, + process_attachments: this.processAttachments, + collect_emails: this.collectEmails, + alert_email_h: this.alertEmailH, + }, + }); + $.export("$summary", "Successfully updated mailbox"); + return response; + }, +}; diff --git a/components/parsio_io/package.json b/components/parsio_io/package.json index b18326c78ada9..0b1207472b782 100644 --- a/components/parsio_io/package.json +++ b/components/parsio_io/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/parsio_io", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Parsio.io Components", "main": "parsio_io.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } } diff --git a/components/parsio_io/parsio_io.app.mjs b/components/parsio_io/parsio_io.app.mjs index d6e5a8b4ab3ed..77e81688409f4 100644 --- a/components/parsio_io/parsio_io.app.mjs +++ b/components/parsio_io/parsio_io.app.mjs @@ -1,11 +1,102 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "parsio_io", - propDefinitions: {}, + propDefinitions: { + name: { + type: "string", + label: "Name", + description: "Name of the mailbox to create", + }, + emailPrefix: { + type: "string", + label: "Email Prefix", + description: "Custom prefix for the mailbox email address", + }, + processAttachments: { + type: "boolean", + label: "Process Attachments", + description: "Specifies whether to process attachments automatically", + optional: true, + }, + collectEmails: { + type: "boolean", + label: "Collect Emails", + description: "Defines if emails should be collected automatically from the mailbox", + optional: true, + }, + alertEmailH: { + type: "string", + label: "Alert Email H", + description: "Optional email address to receive alert notifications", + optional: true, + }, + mailboxId: { + type: "string", + label: "Mailbox ID", + description: "Unique identifier of the mailbox", + async options() { + const response = await this.getMailboxes(); + return response.map(({ + name, _id, + }) => ({ + label: name, + value: _id, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.parsio.io"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + "X-API-Key": `${this.$auth.api_key}`, + ...headers, + }, + }); + }, + async createMailbox(args = {}) { + return this._makeRequest({ + path: "/mailboxes/create", + method: "post", + ...args, + }); + }, + async updateMailbox({ + mailboxId, ...args + }) { + return this._makeRequest({ + path: `/mailboxes/${mailboxId}`, + method: "post", + ...args, + }); + }, + async deleteMailbox({ + mailboxId, ...args + }) { + return this._makeRequest({ + path: `/mailboxes/${mailboxId}`, + method: "delete", + ...args, + }); + }, + async getMailboxes(args = {}) { + return this._makeRequest({ + path: "/mailboxes", + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 64258dc0b26cd..28431e7ea3c3c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1015,8 +1015,7 @@ importers: specifier: ^2.3.0 version: 2.3.0 - components/apollo_io_oauth: - specifiers: {} + components/apollo_io_oauth: {} components/appcircle: {} @@ -1791,8 +1790,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/blotato: - specifiers: {} + components/blotato: {} components/blue: {} @@ -3403,8 +3401,7 @@ importers: specifier: ^1.2.0 version: 1.6.6 - components/curated_letters: - specifiers: {} + components/curated_letters: {} components/currencyapi: {} @@ -7968,8 +7965,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/lightspeed_x: - specifiers: {} + components/lightspeed_x: {} components/lime_go: dependencies: @@ -9115,8 +9111,7 @@ importers: specifier: ^4.6.0 version: 4.17.2(@aws-sdk/client-sso-oidc@3.696.0(@aws-sdk/client-sts@3.696.0(aws-crt@1.25.0))(aws-crt@1.25.0))(aws-crt@1.25.0) - components/monica_crm: - specifiers: {} + components/monica_crm: {} components/monkeylearn: dependencies: @@ -10321,7 +10316,11 @@ importers: specifier: ^1.3.0 version: 1.6.6 - components/parsio_io: {} + components/parsio_io: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/partnerize: {} @@ -12598,8 +12597,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/screenshotbase: - specifiers: {} + components/screenshotbase: {} components/screenshotone: dependencies: @@ -12871,8 +12869,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/serpnode: - specifiers: {} + components/serpnode: {} components/serveravatar: dependencies: @@ -14913,8 +14910,7 @@ importers: specifier: ^2.1.2 version: 2.1.2 - components/twake: - specifiers: {} + components/twake: {} components/twelve_data: {} @@ -15121,8 +15117,7 @@ importers: specifier: ^3.0.3 version: 3.1.0 - components/unleashed_software: - specifiers: {} + components/unleashed_software: {} components/unsplash: dependencies: