From 2d6227d83d78649ea251e8cca3775444b97455b5 Mon Sep 17 00:00:00 2001 From: Michael Lim Date: Mon, 23 Oct 2023 16:49:59 -0700 Subject: [PATCH 1/3] Updating beehiiv actions from v1 to v2 --- .../create-subscriber/create-subscriber.ts | 4 ++-- .../list-all-publications.ts | 2 +- components/beehiiv/app/beehiiv.app.ts | 19 ++++++++++++------- pnpm-lock.yaml | 18 ++++++++++++++++++ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/components/beehiiv/actions/create-subscriber/create-subscriber.ts b/components/beehiiv/actions/create-subscriber/create-subscriber.ts index 390b57d81665a..892d5171b1510 100644 --- a/components/beehiiv/actions/create-subscriber/create-subscriber.ts +++ b/components/beehiiv/actions/create-subscriber/create-subscriber.ts @@ -5,7 +5,7 @@ export default defineAction({ name: "Create Subscriber", description: "Create a new subscriber. [See docs](https://www.beehiiv.com/developers/docs)", key: "beehiiv-create-subscriber", - version: "0.0.1", + version: "0.0.2", type: "action", props: { app, @@ -49,7 +49,7 @@ export default defineAction({ utm_source: this.utmSource, }; const response = await this.app.createSubscriber($, param); - $.export("$summary", `Successfully created a new subscriber with id: ${response.id}`); + $.export("$summary", `Successfully created a new subscriber with id: ${response.data.id}`); return response; }, }); diff --git a/components/beehiiv/actions/list-all-publications/list-all-publications.ts b/components/beehiiv/actions/list-all-publications/list-all-publications.ts index 4a3d02542b099..77328ac8cdafb 100644 --- a/components/beehiiv/actions/list-all-publications/list-all-publications.ts +++ b/components/beehiiv/actions/list-all-publications/list-all-publications.ts @@ -5,7 +5,7 @@ export default defineAction({ name: "List All Publications", description: "Get a list of all your publications. [See docs](https://www.beehiiv.com/developers/docs)", key: "beehiiv-list-all-publications", - version: "0.0.1", + version: "0.0.2", type: "action", props: { app, diff --git a/components/beehiiv/app/beehiiv.app.ts b/components/beehiiv/app/beehiiv.app.ts index 04c50693da738..7cc3b576c57d6 100644 --- a/components/beehiiv/app/beehiiv.app.ts +++ b/components/beehiiv/app/beehiiv.app.ts @@ -21,7 +21,7 @@ export default defineApp({ reactivateExisting: { type: "boolean", label: "Reactivate Existing", - description: "Whether or not to reactivate the subscriber if they have already unsubscribed. **This option should be used only if the subscriber is knowingly resubscribing**. default: `false`.", + description: "Whether or not to reactivate the subscriber if they have already unsubscribed. default: `false`.", optional: true, }, sendWelcomeEmail: { @@ -38,12 +38,16 @@ export default defineApp({ }, }, methods: { - _getUrl(path) { - return `https://api.beehiiv.com/v1${path}`; + _getUrl(path, params = {}) { + let formattedPath = path; + for (const [key, value] of Object.entries(params)) { + formattedPath = formattedPath.replace(`{${key}}`, value); + } + return `https://api.beehiiv.com/v2${formattedPath}`; }, _getHeaders(headers = {}) { return { - "X-ApiKey": this.$auth.api_key, + "Authorization": `Bearer ${this.$auth.api_key}`, "Content-Type": "application/json", ...headers, }; @@ -51,14 +55,15 @@ export default defineApp({ _getRequestParams(opts: any) { return { ...opts, - url: this._getUrl(opts.path), + url: this._getUrl(opts.path, opts.params), headers: this._getHeaders(), }; }, async createSubscriber($ = this, param) { const response = await axios($, this._getRequestParams({ method: "POST", - path: "/subscribers", + path: "/publications/{publicationId}/subscriptions", + params: { publicationId: param.publication_id }, data: param, })); return response; @@ -68,7 +73,7 @@ export default defineApp({ method: "GET", path: "/publications", })); - return response; + return { publications: response.data }; }, async getPublicationOpts() { const { publications } = await this.listPublications(this); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4d6e5c54ef0b9..197f8d92af03f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -240,6 +240,9 @@ importers: dependencies: algoliasearch: 4.20.0 + components/algomo: + specifiers: {} + components/alpaca: specifiers: '@pipedream/platform': ^1.1.1 @@ -797,6 +800,9 @@ importers: components/census_bureau: specifiers: {} + components/centralstationcrm: + specifiers: {} + components/cflow: specifiers: {} @@ -896,6 +902,9 @@ importers: dependencies: '@pipedream/platform': 1.5.1 + components/click2mail2: + specifiers: {} + components/clickfunnels: specifiers: {} @@ -1039,6 +1048,9 @@ importers: components/college_football_data: specifiers: {} + components/cometly: + specifiers: {} + components/commcare: specifiers: {} @@ -4805,6 +4817,9 @@ importers: dependencies: '@pipedream/platform': 1.5.1 + components/riskadvisor: + specifiers: {} + components/rkvst: specifiers: {} @@ -6463,6 +6478,9 @@ importers: components/webscraping_ai: specifiers: {} + components/webvizio: + specifiers: {} + components/weglot: specifiers: '@pipedream/platform': ^1.5.1 From 50e77da3a02e4660a4f925029e2cecf1a6cdac72 Mon Sep 17 00:00:00 2001 From: Michael Lim Date: Mon, 23 Oct 2023 16:51:43 -0700 Subject: [PATCH 2/3] updating language. --- components/beehiiv/app/beehiiv.app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/beehiiv/app/beehiiv.app.ts b/components/beehiiv/app/beehiiv.app.ts index 7cc3b576c57d6..09f1f273eea43 100644 --- a/components/beehiiv/app/beehiiv.app.ts +++ b/components/beehiiv/app/beehiiv.app.ts @@ -21,7 +21,7 @@ export default defineApp({ reactivateExisting: { type: "boolean", label: "Reactivate Existing", - description: "Whether or not to reactivate the subscriber if they have already unsubscribed. default: `false`.", + description: "Whether or not to reactivate the subscriber if they have already unsubscribed. **This option should be used only if the subscriber is knowingly resubscribing**. default: `false`.", optional: true, }, sendWelcomeEmail: { From 6f1a9490624ade37595e222234c3289f8e4d1ee4 Mon Sep 17 00:00:00 2001 From: Michael Lim Date: Mon, 23 Oct 2023 16:53:42 -0700 Subject: [PATCH 3/3] Updating package.json version. --- components/beehiiv/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/beehiiv/package.json b/components/beehiiv/package.json index 50949c519a8eb..310e2b32a1417 100644 --- a/components/beehiiv/package.json +++ b/components/beehiiv/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/beehiiv", - "version": "0.0.4", + "version": "0.0.5", "description": "Pipedream Beehiiv Components", "main": "dist/app/beehiiv.app.mjs", "keywords": [