From ff6588c0b446fdef16373fcb5825e47a27771fd0 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 1 May 2025 22:43:58 -0300 Subject: [PATCH 1/5] Package version --- components/ditlead/package.json | 5 ++++- pnpm-lock.yaml | 15 ++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/components/ditlead/package.json b/components/ditlead/package.json index f0c802e4069d8..b11a6945ca953 100644 --- a/components/ditlead/package.json +++ b/components/ditlead/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/ditlead", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream DitLead Components", "main": "ditlead.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "3.0.3" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5ffdac2a9eb91..9f1c4d27b1a3b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3567,7 +3567,11 @@ importers: components/dispatch: {} - components/ditlead: {} + components/ditlead: + dependencies: + '@pipedream/platform': + specifier: 3.0.3 + version: 3.0.3 components/dixa: dependencies: @@ -7870,8 +7874,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/meetstream_ai: - specifiers: {} + components/meetstream_ai: {} components/meetup: {} @@ -9895,8 +9898,7 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/plainly: - specifiers: {} + components/plainly: {} components/planday: {} @@ -14336,8 +14338,7 @@ importers: components/wicked_reports: {} - components/widgetform: - specifiers: {} + components/widgetform: {} components/wildapricot: dependencies: From 2a12adc278c1f26d2c66e2ac8c516e4deca46d49 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Sun, 4 May 2025 20:03:52 -0300 Subject: [PATCH 2/5] Base and generic webhook source --- components/ditlead/common/constants.mjs | 18 +++++++ components/ditlead/ditlead.app.mjs | 32 ++++++++++-- components/ditlead/sources/common/base.mjs | 49 +++++++++++++++++++ .../new-webhook-event/new-webhook-event.mjs | 27 ++++++++++ 4 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 components/ditlead/common/constants.mjs create mode 100644 components/ditlead/sources/common/base.mjs create mode 100644 components/ditlead/sources/new-webhook-event/new-webhook-event.mjs diff --git a/components/ditlead/common/constants.mjs b/components/ditlead/common/constants.mjs new file mode 100644 index 0000000000000..02202e049eed4 --- /dev/null +++ b/components/ditlead/common/constants.mjs @@ -0,0 +1,18 @@ +export const WEBHOOK_EVENT_TYPES = [ + "email.bounced", + "email.opened", + "contact.replied", + "contact.created", + "contact.contacted", + "contact.started_campaign", + "contact.restarted_campaign", + "contact.completed_campaign", + "contact.unsubscribed", + "campaign.scheduled", + "campaign.started", + "campaign.paused", + "campaign.restarted", + "campaign.completed", + "campaign.limit", + "campaign.errored", +]; diff --git a/components/ditlead/ditlead.app.mjs b/components/ditlead/ditlead.app.mjs index 57c6ae77c00b7..7bee3be6b08a5 100644 --- a/components/ditlead/ditlead.app.mjs +++ b/components/ditlead/ditlead.app.mjs @@ -1,11 +1,35 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "ditlead", propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _makeRequest({ + $, headers, ...args + }) { + return axios($, { + baseURL: "https://api.ditlead.com/v1", + headers: { + ...headers, + Authorization: `Bearer ${this.$auth.api_key}`, + }, + ...args, + }); + }, + createWebhook(args) { + return this._makeRequest({ + method: "POST", + url: "/webhook", + ...args, + }); + }, + deleteWebhook(args) { + return this._makeRequest({ + method: "DELETE", + url: "/webhook", + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/ditlead/sources/common/base.mjs b/components/ditlead/sources/common/base.mjs new file mode 100644 index 0000000000000..35d4e12bb87ba --- /dev/null +++ b/components/ditlead/sources/common/base.mjs @@ -0,0 +1,49 @@ +import ditlead from "../../ditlead.app.mjs"; + +export default { + props: { + ditlead, + db: "$.service.db", + http: "$.interface.http", + }, + hooks: { + async activate() { + const { id } = await this.ditlead.createWebhook({ + data: { + url: this.http.endpoint, + name: "Pipedream Source", + eventId: this.getEventTypes(), + }, + }); + this._setWebhookId(id); + }, + async deactivate() { + await this.ditlead.deleteWebhook({ + data: { + subscriptionId: this._getWebhookId(), + }, + }); + }, + }, + methods: { + getEventTypes() { + throw new Error("Event types not specified for this component"); + }, + _setWebhookId(value) { + this.db.set("webhookId", value); + }, + _getWebhookId() { + return this.db.get("webhookId"); + }, + + }, + async run(event) { + const { body } = event; + const ts = Date.now(); + this.$emit(body, { + id: ts, + summary: "New event", + ts, + }); + }, +}; diff --git a/components/ditlead/sources/new-webhook-event/new-webhook-event.mjs b/components/ditlead/sources/new-webhook-event/new-webhook-event.mjs new file mode 100644 index 0000000000000..a7299c4cdbd0f --- /dev/null +++ b/components/ditlead/sources/new-webhook-event/new-webhook-event.mjs @@ -0,0 +1,27 @@ +import common from "../common/base.mjs"; +import { WEBHOOK_EVENT_TYPES } from "../../common/constants.mjs"; + +export default { + ...common, + key: "ditlead-new-webhook-event", + name: "New Webhook Event", + description: "Emit new events according to the selected event types. [See the documentation](https://ditlead.com/developer/api#tag/Webhook/paths/~1v1~1webhook/post)", + version: "0.0.1", + type: "source", + dedupe: "unique", + props: { + ...common.props, + eventTypes: { + type: "string[]", + label: "Event Types", + description: "Select one or more event types to listen for.", + options: WEBHOOK_EVENT_TYPES, + }, + }, + methods: { + ...common.methods, + getEventTypes() { + return this.eventTypes; + }, + }, +}; From 58887830484de9b4f7495d5d70f572a43a4bd16f Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 6 May 2025 01:41:28 -0300 Subject: [PATCH 3/5] List Campaigns action --- .../actions/list-campaigns/list-campaigns.mjs | 20 +++++++++++++++++++ components/ditlead/ditlead.app.mjs | 6 ++++++ 2 files changed, 26 insertions(+) create mode 100644 components/ditlead/actions/list-campaigns/list-campaigns.mjs diff --git a/components/ditlead/actions/list-campaigns/list-campaigns.mjs b/components/ditlead/actions/list-campaigns/list-campaigns.mjs new file mode 100644 index 0000000000000..859efd4687a29 --- /dev/null +++ b/components/ditlead/actions/list-campaigns/list-campaigns.mjs @@ -0,0 +1,20 @@ +import ditlead from "../../ditlead.app.mjs"; + +export default { + key: "ditlead-list-campaigns", + name: "List Campaigns", + description: "List campaigns in Ditlead. [See the documentation](https://ditlead.com/developer/api#tag/Campaign/paths/~1v1~1campaign/get)", + version: "0.0.1", + type: "action", + props: { + ditlead, + }, + async run({ $ }) { + const { data } = await this.ditlead.listCampaigns({ + $, + }); + + $.export("$summary", `Successfully listed ${data.length} campaigns`); + return data; + }, +}; diff --git a/components/ditlead/ditlead.app.mjs b/components/ditlead/ditlead.app.mjs index 7bee3be6b08a5..8ae0c581c2516 100644 --- a/components/ditlead/ditlead.app.mjs +++ b/components/ditlead/ditlead.app.mjs @@ -31,5 +31,11 @@ export default { ...args, }); }, + listCampaigns(args) { + return this._makeRequest({ + url: "/campaign", + ...args, + }); + }, }, }; From de079a80c9cb386757230a951ce13dbb2ea0a6d2 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 6 May 2025 16:11:15 -0300 Subject: [PATCH 4/5] add newline --- components/ditlead/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ditlead/package.json b/components/ditlead/package.json index b11a6945ca953..42834691f72bb 100644 --- a/components/ditlead/package.json +++ b/components/ditlead/package.json @@ -15,4 +15,4 @@ "dependencies": { "@pipedream/platform": "3.0.3" } -} \ No newline at end of file +} From 725c806a2c048faf8fa422c7d5cc26a45a3c0e0b Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 12 May 2025 21:44:34 -0300 Subject: [PATCH 5/5] pnpm --- pnpm-lock.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e5d3dbb3b3fd7..a84004a1b2201 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12890,8 +12890,7 @@ importers: components/systeme_io: {} - components/szybkisms: - specifiers: {} + components/szybkisms: {} components/t2m_url_shortener: {}