From d0c0ff63f49931e8fb9f74ff7647d82ef33627a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Falc=C3=A3o?= <48412907+GTFalcao@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:24:57 -0300 Subject: [PATCH] Loops.so new components (#14226) * Delete Contact * List Mailing Lists * List Custom Fields * Version bumps * pnpm * syntax adjustment * Update components/loops_so/actions/send-transactional-email/send-transactional-email.mjs Co-authored-by: michelle0927 --------- Co-authored-by: michelle0927 --- .../actions/create-contact/create-contact.mjs | 2 +- .../actions/delete-contact/delete-contact.mjs | 54 +++++++++++++++++++ .../actions/find-contact/find-contact.mjs | 2 +- .../list-custom-fields/list-custom-fields.mjs | 21 ++++++++ .../list-mailing-lists/list-mailing-lists.mjs | 21 ++++++++ .../actions/send-event/send-event.mjs | 2 +- .../send-transactional-email.mjs | 2 +- .../actions/update-contact/update-contact.mjs | 2 +- components/loops_so/loops_so.app.mjs | 13 +++++ components/loops_so/package.json | 4 +- pnpm-lock.yaml | 4 +- 11 files changed, 118 insertions(+), 9 deletions(-) create mode 100644 components/loops_so/actions/delete-contact/delete-contact.mjs create mode 100644 components/loops_so/actions/list-custom-fields/list-custom-fields.mjs create mode 100644 components/loops_so/actions/list-mailing-lists/list-mailing-lists.mjs diff --git a/components/loops_so/actions/create-contact/create-contact.mjs b/components/loops_so/actions/create-contact/create-contact.mjs index b9a009d4ba4f3..aa1af0b007fdf 100644 --- a/components/loops_so/actions/create-contact/create-contact.mjs +++ b/components/loops_so/actions/create-contact/create-contact.mjs @@ -5,7 +5,7 @@ export default { key: "loops_so-create-contact", name: "Create Contact", description: "Creates a new contact. [See the Documentation](https://loops.so/docs/add-users/api-reference#add)", - version: "0.1.0", + version: "0.1.1", type: "action", async run({ $ }) { const { // eslint-disable-next-line no-unused-vars diff --git a/components/loops_so/actions/delete-contact/delete-contact.mjs b/components/loops_so/actions/delete-contact/delete-contact.mjs new file mode 100644 index 0000000000000..1d5e9a111f664 --- /dev/null +++ b/components/loops_so/actions/delete-contact/delete-contact.mjs @@ -0,0 +1,54 @@ +import { ConfigurationError } from "@pipedream/platform"; +import loops from "../../loops_so.app.mjs"; + +export default { + key: "loops_so-delete-contact", + name: "Delete Contact", + description: "Delete an existing contact. [See the documentation](https://loops.so/docs/api-reference/delete-contact)", + version: "0.0.1", + type: "action", + props: { + loops, + infoAlert: { + type: "alert", + alertType: "info", + content: "You can provide either the contact's email address or user ID.", + }, + email: { + propDefinition: [ + loops, + "email", + ], + optional: true, + }, + userId: { + type: "string", + label: "User ID", + description: "User ID of the contact", + optional: true, + }, + }, + async run({ $ }) { + const { + loops, email, userId, + } = this; + if (!email && !userId) { + throw new ConfigurationError("You must provide either the contact's email address or user ID."); + } + const response = await loops.deleteContact({ + $, + data: { + email, + userId, + }, + }); + + const summary = response?.success + ? "Successfully deleted contact" + : "Failed to delete contact"; + + $.export("$summary", summary); + + return response; + }, +}; diff --git a/components/loops_so/actions/find-contact/find-contact.mjs b/components/loops_so/actions/find-contact/find-contact.mjs index 1bad05b2ddf59..2ef773e7bf0db 100644 --- a/components/loops_so/actions/find-contact/find-contact.mjs +++ b/components/loops_so/actions/find-contact/find-contact.mjs @@ -4,7 +4,7 @@ export default { key: "loops_so-find-contact", name: "Find Contact", description: "Search for a contact by email address. [See the Documentation](https://loops.so/docs/add-users/api-reference#find)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { loops, diff --git a/components/loops_so/actions/list-custom-fields/list-custom-fields.mjs b/components/loops_so/actions/list-custom-fields/list-custom-fields.mjs new file mode 100644 index 0000000000000..6f09402dd9de2 --- /dev/null +++ b/components/loops_so/actions/list-custom-fields/list-custom-fields.mjs @@ -0,0 +1,21 @@ +import loops from "../../loops_so.app.mjs"; + +export default { + key: "loops_so-list-custom-fields", + name: "List Custom Fields", + description: "List your account's custom contact properties. [See the documentation](https://loops.so/docs/api-reference/list-custom-fields)", + version: "0.0.1", + type: "action", + props: { + loops, + }, + async run({ $ }) { + const response = await this.loops.listCustomFields({ + $, + }); + + $.export("$summary", `Successfully retrieved ${response.length} custom fields`); + + return response; + }, +}; diff --git a/components/loops_so/actions/list-mailing-lists/list-mailing-lists.mjs b/components/loops_so/actions/list-mailing-lists/list-mailing-lists.mjs new file mode 100644 index 0000000000000..331f0d415ebb0 --- /dev/null +++ b/components/loops_so/actions/list-mailing-lists/list-mailing-lists.mjs @@ -0,0 +1,21 @@ +import loops from "../../loops_so.app.mjs"; + +export default { + key: "loops_so-list-mailing-lists", + name: "List Mailing Lists", + description: "List your account's mailing lists. [See the documentation](https://loops.so/docs/api-reference/list-mailing-lists)", + version: "0.0.1", + type: "action", + props: { + loops, + }, + async run({ $ }) { + const response = await this.loops.listMailingLists({ + $, + }); + + $.export("$summary", `Successfully retrieved ${response.length} mailing lists`); + + return response; + }, +}; diff --git a/components/loops_so/actions/send-event/send-event.mjs b/components/loops_so/actions/send-event/send-event.mjs index ccd8d2e947527..bd05174c56e99 100644 --- a/components/loops_so/actions/send-event/send-event.mjs +++ b/components/loops_so/actions/send-event/send-event.mjs @@ -4,7 +4,7 @@ export default { key: "loops_so-send-event", name: "Send Event", description: "Send an event to an email address. [See the Documentation](https://loops.so/docs/add-users/api-reference#send)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { loops, diff --git a/components/loops_so/actions/send-transactional-email/send-transactional-email.mjs b/components/loops_so/actions/send-transactional-email/send-transactional-email.mjs index a2776e17ba440..73c4a65cfd9d3 100644 --- a/components/loops_so/actions/send-transactional-email/send-transactional-email.mjs +++ b/components/loops_so/actions/send-transactional-email/send-transactional-email.mjs @@ -4,7 +4,7 @@ export default { key: "loops_so-send-transactional-email", name: "Send Transactional Email", description: "Send a transactional email. [See the Documentation](https://loops.so/docs/transactional/guide#send-your-email)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { loops, diff --git a/components/loops_so/actions/update-contact/update-contact.mjs b/components/loops_so/actions/update-contact/update-contact.mjs index e4c6187d246ed..1de02233ac884 100644 --- a/components/loops_so/actions/update-contact/update-contact.mjs +++ b/components/loops_so/actions/update-contact/update-contact.mjs @@ -6,7 +6,7 @@ export default { key: "loops_so-update-contact", name: "Update Contact", description: "Updates an existing contact by email. If email not found, a new contact will be created. [See the Documentation](https://loops.so/docs/add-users/api-reference#update)", - version: "0.1.0", + version: "0.1.1", type: "action", async run({ $ }) { const { // eslint-disable-next-line no-unused-vars diff --git a/components/loops_so/loops_so.app.mjs b/components/loops_so/loops_so.app.mjs index 844bb80ecc58f..10d7ef3c3da17 100644 --- a/components/loops_so/loops_so.app.mjs +++ b/components/loops_so/loops_so.app.mjs @@ -85,6 +85,13 @@ export default { ...args, }); }, + deleteContact(args = {}) { + return this._makeRequest({ + path: "/contacts/delete", + method: "POST", + ...args, + }); + }, sendEvent(args = {}) { return this._makeRequest({ path: "/events/send", @@ -105,5 +112,11 @@ export default { ...args, }); }, + listMailingLists(args = {}) { + return this._makeRequest({ + path: "/lists", + ...args, + }); + }, }, }; diff --git a/components/loops_so/package.json b/components/loops_so/package.json index e979764dbc906..ada57b44b3e17 100644 --- a/components/loops_so/package.json +++ b/components/loops_so/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/loops_so", - "version": "0.2.0", + "version": "0.3.0", "description": "Pipedream Loops.so Components", "main": "loops_so.app.mjs", "keywords": [ @@ -13,7 +13,7 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^1.5.1", + "@pipedream/platform": "^3.0.3", "lodash.pickby": "^4.6.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2bcbd7c6f91c0..5178a24692786 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5630,10 +5630,10 @@ importers: components/loops_so: specifiers: - '@pipedream/platform': ^1.5.1 + '@pipedream/platform': ^3.0.3 lodash.pickby: ^4.6.0 dependencies: - '@pipedream/platform': 1.5.1 + '@pipedream/platform': 3.0.3 lodash.pickby: 4.6.0 components/loqate: