diff --git a/components/gmail/actions/archive-email/archive-email.mjs b/components/gmail/actions/archive-email/archive-email.mjs new file mode 100644 index 0000000000000..a1bca2ae6aa00 --- /dev/null +++ b/components/gmail/actions/archive-email/archive-email.mjs @@ -0,0 +1,35 @@ +import gmail from "../../gmail.app.mjs"; +import constants from "../../common/constants.mjs"; + +export default { + key: "gmail-archive-email", + name: "Archive Email", + description: "Archive an email message. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)", + version: "0.0.1", + type: "action", + props: { + gmail, + message: { + propDefinition: [ + gmail, + "message", + ], + }, + }, + async run({ $ }) { + const { + gmail, + message, + } = this; + + const response = await gmail.updateLabels({ + message, + removeLabelIds: [ + constants.INBOX_LABEL_ID, + ], + }); + + $.export("$summary", `Successfully archived email (ID: ${message})`); + return response; + }, +}; diff --git a/components/gmail/common/constants.mjs b/components/gmail/common/constants.mjs index 1d4ff4a9c2f8f..deb65852ee483 100644 --- a/components/gmail/common/constants.mjs +++ b/components/gmail/common/constants.mjs @@ -5,10 +5,12 @@ const BODY_TYPES = { }; const HISTORICAL_EVENTS = 10; const DEFAULT_LIMIT = 100; +const INBOX_LABEL_ID = "INBOX"; export default { USER_ID, BODY_TYPES, HISTORICAL_EVENTS, DEFAULT_LIMIT, + INBOX_LABEL_ID, }; diff --git a/components/gmail/package.json b/components/gmail/package.json index 41868414a4024..5db6e3f772f94 100644 --- a/components/gmail/package.json +++ b/components/gmail/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/gmail", - "version": "0.2.10", + "version": "0.3.0", "description": "Pipedream Gmail Components", "main": "gmail.app.mjs", "keywords": [