From 820f342f43a44a383620aac372da6fd886c95b0e Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 16 Apr 2024 23:34:10 -0300 Subject: [PATCH 01/13] Package updates --- components/gohighlevel/package.json | 18 ++++++++++++++++++ components/highlevel_oauth/.gitignore | 3 --- ...el_oauth.app.ts => highlevel_oauth.app.mjs} | 2 +- components/highlevel_oauth/package.json | 8 +++++--- 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 components/gohighlevel/package.json delete mode 100644 components/highlevel_oauth/.gitignore rename components/highlevel_oauth/{app/highlevel_oauth.app.ts => highlevel_oauth.app.mjs} (98%) diff --git a/components/gohighlevel/package.json b/components/gohighlevel/package.json new file mode 100644 index 0000000000000..f1472e97609cd --- /dev/null +++ b/components/gohighlevel/package.json @@ -0,0 +1,18 @@ +{ + "name": "@pipedream/gohighlevel", + "version": "0.1.0", + "description": "Pipedream HighLevel Components", + "main": "gohighlevel.app.mjs", + "keywords": [ + "pipedream", + "gohighlevel" + ], + "homepage": "https://pipedream.com/apps/gohighlevel", + "author": "Pipedream (https://pipedream.com/)", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^1.6.2" + } +} \ No newline at end of file diff --git a/components/highlevel_oauth/.gitignore b/components/highlevel_oauth/.gitignore deleted file mode 100644 index ec761ccab7595..0000000000000 --- a/components/highlevel_oauth/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.mjs -dist \ No newline at end of file diff --git a/components/highlevel_oauth/app/highlevel_oauth.app.ts b/components/highlevel_oauth/highlevel_oauth.app.mjs similarity index 98% rename from components/highlevel_oauth/app/highlevel_oauth.app.ts rename to components/highlevel_oauth/highlevel_oauth.app.mjs index 4649c3187d4e5..0116b360957f4 100644 --- a/components/highlevel_oauth/app/highlevel_oauth.app.ts +++ b/components/highlevel_oauth/highlevel_oauth.app.mjs @@ -10,4 +10,4 @@ export default defineApp({ console.log(Object.keys(this.$auth)); }, }, -}); \ No newline at end of file +}); diff --git a/components/highlevel_oauth/package.json b/components/highlevel_oauth/package.json index 41edf1aabf156..3fa2c6429caeb 100644 --- a/components/highlevel_oauth/package.json +++ b/components/highlevel_oauth/package.json @@ -1,16 +1,18 @@ { "name": "@pipedream/highlevel_oauth", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream HighLevel (OAuth) Components", - "main": "dist/app/highlevel_oauth.app.mjs", + "main": "highlevel_oauth.app.mjs", "keywords": [ "pipedream", "highlevel_oauth" ], - "files": ["dist"], "homepage": "https://pipedream.com/apps/highlevel_oauth", "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^1.6.2" } } \ No newline at end of file From b742e3d9783aa5071de2e3c451c21fd43109f150 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 16 Apr 2024 23:35:55 -0300 Subject: [PATCH 02/13] pnpm --- pnpm-lock.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b5e33c79c89f1..859cdf14c6bee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3215,6 +3215,12 @@ importers: components/godial: specifiers: {} + components/gohighlevel: + specifiers: + '@pipedream/platform': ^1.6.2 + dependencies: + '@pipedream/platform': 1.6.2 + components/gong: specifiers: '@pipedream/platform': ^1.5.1 @@ -3704,7 +3710,10 @@ importers: '@pipedream/platform': 1.5.1 components/highlevel_oauth: - specifiers: {} + specifiers: + '@pipedream/platform': ^1.6.2 + dependencies: + '@pipedream/platform': 1.6.2 components/hippo_video: specifiers: {} From 37e26e2fa262d90b534f0a19b3c8eb2502761da8 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 16 Apr 2024 23:54:13 -0300 Subject: [PATCH 03/13] app base request --- components/gohighlevel/package.json | 18 ------------- .../highlevel_oauth/highlevel_oauth.app.mjs | 25 ++++++++++++++----- 2 files changed, 19 insertions(+), 24 deletions(-) delete mode 100644 components/gohighlevel/package.json diff --git a/components/gohighlevel/package.json b/components/gohighlevel/package.json deleted file mode 100644 index f1472e97609cd..0000000000000 --- a/components/gohighlevel/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "@pipedream/gohighlevel", - "version": "0.1.0", - "description": "Pipedream HighLevel Components", - "main": "gohighlevel.app.mjs", - "keywords": [ - "pipedream", - "gohighlevel" - ], - "homepage": "https://pipedream.com/apps/gohighlevel", - "author": "Pipedream (https://pipedream.com/)", - "publishConfig": { - "access": "public" - }, - "dependencies": { - "@pipedream/platform": "^1.6.2" - } -} \ No newline at end of file diff --git a/components/highlevel_oauth/highlevel_oauth.app.mjs b/components/highlevel_oauth/highlevel_oauth.app.mjs index 0116b360957f4..e5357006bdc82 100644 --- a/components/highlevel_oauth/highlevel_oauth.app.mjs +++ b/components/highlevel_oauth/highlevel_oauth.app.mjs @@ -1,13 +1,26 @@ -import { defineApp } from "@pipedream/types"; +import { axios } from "@pipedream/platform"; -export default defineApp({ +export default { type: "app", app: "highlevel_oauth", propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://services.leadconnectorhq.com"; + }, + async _makeRequest({ + $ = this, + headers, + ...otherOpts + }) { + return axios($, { + baseURL: this._baseUrl(), + headers: { + ...headers, + Authorization: `Bearer ${this.$auth.oauth_access_token}`, + }, + ...otherOpts, + }); }, }, -}); +}; From 386b4ddac93abff598b7cd8a398a1a15f8d81da4 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 16 Apr 2024 23:54:42 -0300 Subject: [PATCH 04/13] pnpm --- pnpm-lock.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 859cdf14c6bee..81b902af23877 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3215,12 +3215,6 @@ importers: components/godial: specifiers: {} - components/gohighlevel: - specifiers: - '@pipedream/platform': ^1.6.2 - dependencies: - '@pipedream/platform': 1.6.2 - components/gong: specifiers: '@pipedream/platform': ^1.5.1 From c3a03bbfb92b3afe1b7795bd0fc1f8918c2003e5 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 17 Apr 2024 00:03:26 -0300 Subject: [PATCH 05/13] Adding request methods --- .../highlevel_oauth/highlevel_oauth.app.mjs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/components/highlevel_oauth/highlevel_oauth.app.mjs b/components/highlevel_oauth/highlevel_oauth.app.mjs index e5357006bdc82..49609d3b7296a 100644 --- a/components/highlevel_oauth/highlevel_oauth.app.mjs +++ b/components/highlevel_oauth/highlevel_oauth.app.mjs @@ -22,5 +22,28 @@ export default { ...otherOpts, }); }, + async createContact(args) { + return this._makeRequest({ + method: "POST", + url: "/contacts", + ...args, + }); + }, + async updateContact({ + contactId, ...args + }) { + return this._makeRequest({ + method: "PUT", + url: `/contacts/${contactId}`, + ...args, + }); + }, + async upsertContact(args) { + return this._makeRequest({ + method: "POST", + url: "/contacts/upsert", + ...args, + }); + }, }, }; From d8ee241feea7769de0410d1be1041a32c2644f0a Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 17 Apr 2024 00:29:38 -0300 Subject: [PATCH 06/13] Create Contact action --- .../actions/create-contact/create-contact.mjs | 64 +++++++++++++++++++ components/highlevel_oauth/common/utils.mjs | 22 +++++++ .../highlevel_oauth/highlevel_oauth.app.mjs | 27 +++++++- 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 components/highlevel_oauth/actions/create-contact/create-contact.mjs create mode 100644 components/highlevel_oauth/common/utils.mjs diff --git a/components/highlevel_oauth/actions/create-contact/create-contact.mjs b/components/highlevel_oauth/actions/create-contact/create-contact.mjs new file mode 100644 index 0000000000000..3971fd15ae5a2 --- /dev/null +++ b/components/highlevel_oauth/actions/create-contact/create-contact.mjs @@ -0,0 +1,64 @@ +import { parseObjectEntries } from "../../common/utils.mjs"; +import app from "../../highlevel_oauth.app.mjs"; + +export default { + key: "highlevel_oauth-create-contact", + name: "Create Contact", + description: "Creates a new contact on HighLevel. [See the documentation](https://highlevel.stoplight.io/docs/integrations/4c8362223c17b-create-contact)", + version: "0.0.1", + type: "action", + props: { + app, + locationId: { + propDefinition: [ + app, + "locationId", + ], + }, + name: { + type: "string", + label: "First Name", + description: "Full name of the contact, e.g. `Rosan Deo`", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "Email of the contact, e.g. `rosan@deos.com`", + optional: true, + }, + phone: { + type: "string", + label: "Phone Number", + description: "Phone number of the contact, e.g. `+1 888-888-8888`", + optional: true, + }, + gender: { + type: "string", + label: "Gender", + description: "Gender of the contact, e.g. `male`", + optional: true, + }, + additionalOptions: { + type: "object", + label: "Additional Options", + description: "Additional parameters to send in the request. [See the documentation](https://highlevel.stoplight.io/docs/integrations/4c8362223c17b-create-contact) for available parameters. Values will be parsed as JSON where applicable.", + optional: true, + }, + }, + async run({ $ }) { + const { + app, additionalOptions, ...data + } = this; + const response = await app.createContact({ + $, + data: { + ...data, + ...(additionalOptions && parseObjectEntries(additionalOptions)), + }, + }); + + $.export("$summary", `Successfully created contact (ID: ${response?.contact?.id})`); + return response; + }, +}; diff --git a/components/highlevel_oauth/common/utils.mjs b/components/highlevel_oauth/common/utils.mjs new file mode 100644 index 0000000000000..9c3cdbf569744 --- /dev/null +++ b/components/highlevel_oauth/common/utils.mjs @@ -0,0 +1,22 @@ +function optionalParseAsJSON(value) { + try { + return JSON.parse(value); + } catch (e) { + return value; + } +} + +export function parseObjectEntries(value) { + const obj = typeof value === "string" + ? JSON.parse(value) + : value; + return Object.fromEntries( + Object.entries(obj).map(([ + key, + value, + ]) => [ + key, + optionalParseAsJSON(value), + ]), + ); +} diff --git a/components/highlevel_oauth/highlevel_oauth.app.mjs b/components/highlevel_oauth/highlevel_oauth.app.mjs index 49609d3b7296a..82de2bc1dba34 100644 --- a/components/highlevel_oauth/highlevel_oauth.app.mjs +++ b/components/highlevel_oauth/highlevel_oauth.app.mjs @@ -3,7 +3,26 @@ import { axios } from "@pipedream/platform"; export default { type: "app", app: "highlevel_oauth", - propDefinitions: {}, + propDefinitions: { + locationId: { + type: "string", + label: "Location ID", + description: "Select a location or provide a custom location ID", + async options({ page }) { + const { locations } = await this.searchLocations({ + params: { + limit: page, + }, + }); + return locations?.map(({ + id, name, + }) => ({ + label: name, + value: id, + })); + }, + }, + }, methods: { _baseUrl() { return "https://services.leadconnectorhq.com"; @@ -45,5 +64,11 @@ export default { ...args, }); }, + async searchLocations(args) { + return this._makeRequest({ + url: "/locations/search", + ...args, + }); + }, }, }; From ee79727275dcfa87164c1c5c2961ab0a3517b2c5 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 17 Apr 2024 00:46:09 -0300 Subject: [PATCH 07/13] Reusing common props for contacts --- .../highlevel_oauth/actions/common/common.mjs | 51 +++++++++++++++++++ .../actions/create-contact/create-contact.mjs | 50 +++++------------- components/highlevel_oauth/package.json | 2 +- 3 files changed, 64 insertions(+), 39 deletions(-) create mode 100644 components/highlevel_oauth/actions/common/common.mjs diff --git a/components/highlevel_oauth/actions/common/common.mjs b/components/highlevel_oauth/actions/common/common.mjs new file mode 100644 index 0000000000000..9a35a4f85d86a --- /dev/null +++ b/components/highlevel_oauth/actions/common/common.mjs @@ -0,0 +1,51 @@ +import { parseObjectEntries } from "../../common/utils.mjs"; +import app from "../../highlevel_oauth.app.mjs"; + +export default { + props: { + app, + name: { + type: "string", + label: "First Name", + description: "Full name of the contact, e.g. `Rosan Deo`", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "Email of the contact, e.g. `rosan@deos.com`", + optional: true, + }, + phone: { + type: "string", + label: "Phone Number", + description: "Phone number of the contact, e.g. `+1 888-888-8888`", + optional: true, + }, + gender: { + type: "string", + label: "Gender", + description: "Gender of the contact, e.g. `male`", + optional: true, + }, + additionalOptions: { + type: "object", + label: "Additional Options", + description: + "Additional parameters to send in the request. [See the documentation](https://highlevel.stoplight.io/docs/integrations/4c8362223c17b-create-contact) for available parameters. Values will be parsed as JSON where applicable.", + optional: true, + }, + }, + methods: { + getData() { + const { + app, additionalOptions, ...data + } = this; + return { + app, + ...data, + ...(additionalOptions && parseObjectEntries(additionalOptions)), + }; + }, + }, +}; diff --git a/components/highlevel_oauth/actions/create-contact/create-contact.mjs b/components/highlevel_oauth/actions/create-contact/create-contact.mjs index 3971fd15ae5a2..288d0bf1a2a9e 100644 --- a/components/highlevel_oauth/actions/create-contact/create-contact.mjs +++ b/components/highlevel_oauth/actions/create-contact/create-contact.mjs @@ -1,7 +1,13 @@ -import { parseObjectEntries } from "../../common/utils.mjs"; -import app from "../../highlevel_oauth.app.mjs"; +import common from "../common/common.mjs"; + +const { + props: { + app, ...props + }, +} = common; export default { + ...common, key: "highlevel_oauth-create-contact", name: "Create Contact", description: "Creates a new contact on HighLevel. [See the documentation](https://highlevel.stoplight.io/docs/integrations/4c8362223c17b-create-contact)", @@ -15,47 +21,15 @@ export default { "locationId", ], }, - name: { - type: "string", - label: "First Name", - description: "Full name of the contact, e.g. `Rosan Deo`", - optional: true, - }, - email: { - type: "string", - label: "Email", - description: "Email of the contact, e.g. `rosan@deos.com`", - optional: true, - }, - phone: { - type: "string", - label: "Phone Number", - description: "Phone number of the contact, e.g. `+1 888-888-8888`", - optional: true, - }, - gender: { - type: "string", - label: "Gender", - description: "Gender of the contact, e.g. `male`", - optional: true, - }, - additionalOptions: { - type: "object", - label: "Additional Options", - description: "Additional parameters to send in the request. [See the documentation](https://highlevel.stoplight.io/docs/integrations/4c8362223c17b-create-contact) for available parameters. Values will be parsed as JSON where applicable.", - optional: true, - }, + ...props, }, async run({ $ }) { const { - app, additionalOptions, ...data - } = this; + app, ...data + } = this.getData(); const response = await app.createContact({ $, - data: { - ...data, - ...(additionalOptions && parseObjectEntries(additionalOptions)), - }, + data, }); $.export("$summary", `Successfully created contact (ID: ${response?.contact?.id})`); diff --git a/components/highlevel_oauth/package.json b/components/highlevel_oauth/package.json index 3fa2c6429caeb..e3a641a3c9d26 100644 --- a/components/highlevel_oauth/package.json +++ b/components/highlevel_oauth/package.json @@ -15,4 +15,4 @@ "dependencies": { "@pipedream/platform": "^1.6.2" } -} \ No newline at end of file +} From b4b5c08cfcf687c0fe3dc3b0d7e4b9ddc99804f9 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 17 Apr 2024 00:47:43 -0300 Subject: [PATCH 08/13] Upsert Contact prop --- .../actions/upsert-contact/upsert-contact.mjs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs diff --git a/components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs b/components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs new file mode 100644 index 0000000000000..524125f93b504 --- /dev/null +++ b/components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs @@ -0,0 +1,38 @@ +import common from "../common/common.mjs"; + +const { + props: { + app, ...props + }, +} = common; + +export default { + ...common, + key: "highlevel_oauth-upsert-contact", + name: "Upsert Contact", + description: "Creates or updates a contact on HighLevel. [See the documentation](https://highlevel.stoplight.io/docs/integrations/f71bbdd88f028-upsert-contact)", + version: "0.0.1", + type: "action", + props: { + app, + locationId: { + propDefinition: [ + app, + "locationId", + ], + }, + ...props, + }, + async run({ $ }) { + const { + app, ...data + } = this.getData(); + const response = await app.upsertContact({ + $, + data, + }); + + $.export("$summary", `Successfully upserted contact (ID: ${response?.contact?.id})`); + return response; + }, +}; From 206ddc9361aa1935a5e1a4b082e8b9a3a2bd8af3 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 17 Apr 2024 00:52:52 -0300 Subject: [PATCH 09/13] Update Contact + contact id query --- .../actions/update-contact/update-contact.mjs | 41 +++++++++++++++++++ .../highlevel_oauth/highlevel_oauth.app.mjs | 26 ++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 components/highlevel_oauth/actions/update-contact/update-contact.mjs diff --git a/components/highlevel_oauth/actions/update-contact/update-contact.mjs b/components/highlevel_oauth/actions/update-contact/update-contact.mjs new file mode 100644 index 0000000000000..79a653ce48885 --- /dev/null +++ b/components/highlevel_oauth/actions/update-contact/update-contact.mjs @@ -0,0 +1,41 @@ +import common from "../common/common.mjs"; + +const { + props: { + app, ...props + }, +} = common; + +export default { + ...common, + key: "highlevel_oauth-update-contact", + name: "Update Contact", + description: "Updates a selected contact on HighLevel. [See the documentation](https://highlevel.stoplight.io/docs/integrations/9ce5a739d4fb9-update-contact)", + version: "0.0.1", + type: "action", + props: { + app, + contactId: { + propDefinition: [ + app, + "contactId", + ], + }, + ...props, + }, + async run({ $ }) { + const { + app, data: { + contactId, ...data + }, + } = this.getData(); + const response = await app.updateContact({ + $, + contactId, + data, + }); + + $.export("$summary", `Successfully updated contact (ID: ${contactId})`); + return response; + }, +}; diff --git a/components/highlevel_oauth/highlevel_oauth.app.mjs b/components/highlevel_oauth/highlevel_oauth.app.mjs index 82de2bc1dba34..35bc953462ddc 100644 --- a/components/highlevel_oauth/highlevel_oauth.app.mjs +++ b/components/highlevel_oauth/highlevel_oauth.app.mjs @@ -22,6 +22,26 @@ export default { })); }, }, + contactId: { + type: "string", + label: "Contact ID", + description: "Search for a contact or provide a custom contact ID", + useQuery: true, + async options({ query }) { + const { contacts } = await this.searchContacts({ + params: { + query, + limit: 100, + }, + }); + return contacts?.map(({ + id, name, email, + }) => ({ + label: name ?? email ?? id, + value: id, + })); + }, + }, }, methods: { _baseUrl() { @@ -64,6 +84,12 @@ export default { ...args, }); }, + async searchContacts(args) { + return this._makeRequest({ + url: "/contacts", + ...args, + }); + }, async searchLocations(args) { return this._makeRequest({ url: "/locations/search", From c6ceb5fe3e14d42ce75b712487dcb53698d6a32c Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Fri, 19 Apr 2024 21:34:20 -0300 Subject: [PATCH 10/13] Adding missing 'version' header --- components/highlevel_oauth/highlevel_oauth.app.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/highlevel_oauth/highlevel_oauth.app.mjs b/components/highlevel_oauth/highlevel_oauth.app.mjs index 35bc953462ddc..7cceb0f3f622a 100644 --- a/components/highlevel_oauth/highlevel_oauth.app.mjs +++ b/components/highlevel_oauth/highlevel_oauth.app.mjs @@ -56,7 +56,8 @@ export default { baseURL: this._baseUrl(), headers: { ...headers, - Authorization: `Bearer ${this.$auth.oauth_access_token}`, + "Authorization": `Bearer ${this.$auth.oauth_access_token}`, + "Version": "2021-07-28", }, ...otherOpts, }); From 66901016bab26a41b2168c9b5f866c9c3c5ef54f Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 23 Apr 2024 16:19:55 -0300 Subject: [PATCH 11/13] Adjustments --- .../highlevel_oauth/actions/common/common.mjs | 9 ++++-- .../actions/update-contact/update-contact.mjs | 10 +++---- .../actions/upsert-contact/upsert-contact.mjs | 2 +- .../highlevel_oauth/highlevel_oauth.app.mjs | 30 +++++-------------- 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/components/highlevel_oauth/actions/common/common.mjs b/components/highlevel_oauth/actions/common/common.mjs index 9a35a4f85d86a..449b51137b8c9 100644 --- a/components/highlevel_oauth/actions/common/common.mjs +++ b/components/highlevel_oauth/actions/common/common.mjs @@ -6,7 +6,7 @@ export default { app, name: { type: "string", - label: "First Name", + label: "Name", description: "Full name of the contact, e.g. `Rosan Deo`", optional: true, }, @@ -37,12 +37,15 @@ export default { }, }, methods: { - getData() { + getData(useLocation = true) { const { - app, additionalOptions, ...data + app, additionalOptions, locationId, ...data } = this; return { app, + ...(useLocation && { + locationId: locationId ?? app.getLocationId(), + }), ...data, ...(additionalOptions && parseObjectEntries(additionalOptions)), }; diff --git a/components/highlevel_oauth/actions/update-contact/update-contact.mjs b/components/highlevel_oauth/actions/update-contact/update-contact.mjs index 79a653ce48885..503a75c9376a7 100644 --- a/components/highlevel_oauth/actions/update-contact/update-contact.mjs +++ b/components/highlevel_oauth/actions/update-contact/update-contact.mjs @@ -11,7 +11,7 @@ export default { key: "highlevel_oauth-update-contact", name: "Update Contact", description: "Updates a selected contact on HighLevel. [See the documentation](https://highlevel.stoplight.io/docs/integrations/9ce5a739d4fb9-update-contact)", - version: "0.0.1", + version: "0.0.{{ts}}", type: "action", props: { app, @@ -25,10 +25,10 @@ export default { }, async run({ $ }) { const { - app, data: { - contactId, ...data - }, - } = this.getData(); + app, + contactId, ...data + + } = this.getData(false); const response = await app.updateContact({ $, contactId, diff --git a/components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs b/components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs index 524125f93b504..a0b642f838893 100644 --- a/components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs +++ b/components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs @@ -11,7 +11,7 @@ export default { key: "highlevel_oauth-upsert-contact", name: "Upsert Contact", description: "Creates or updates a contact on HighLevel. [See the documentation](https://highlevel.stoplight.io/docs/integrations/f71bbdd88f028-upsert-contact)", - version: "0.0.1", + version: "0.0.{{ts}}", type: "action", props: { app, diff --git a/components/highlevel_oauth/highlevel_oauth.app.mjs b/components/highlevel_oauth/highlevel_oauth.app.mjs index 7cceb0f3f622a..f960606db53e5 100644 --- a/components/highlevel_oauth/highlevel_oauth.app.mjs +++ b/components/highlevel_oauth/highlevel_oauth.app.mjs @@ -7,20 +7,8 @@ export default { locationId: { type: "string", label: "Location ID", - description: "Select a location or provide a custom location ID", - async options({ page }) { - const { locations } = await this.searchLocations({ - params: { - limit: page, - }, - }); - return locations?.map(({ - id, name, - }) => ({ - label: name, - value: id, - })); - }, + description: "If not specified, defaults to the authenticated location.", + optional: true, }, contactId: { type: "string", @@ -32,6 +20,7 @@ export default { params: { query, limit: 100, + locationId: this.getLocationId(), }, }); return contacts?.map(({ @@ -44,6 +33,9 @@ export default { }, }, methods: { + getLocationId() { + return this.$auth.locationId; + }, _baseUrl() { return "https://services.leadconnectorhq.com"; }, @@ -65,7 +57,7 @@ export default { async createContact(args) { return this._makeRequest({ method: "POST", - url: "/contacts", + url: "/contacts/", ...args, }); }, @@ -87,13 +79,7 @@ export default { }, async searchContacts(args) { return this._makeRequest({ - url: "/contacts", - ...args, - }); - }, - async searchLocations(args) { - return this._makeRequest({ - url: "/locations/search", + url: "/contacts/", ...args, }); }, From f06d1b01690ee5bed38a02848f1b4ea603fd6587 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 23 Apr 2024 16:30:31 -0300 Subject: [PATCH 12/13] Adding reloadProps to check for correct auth --- .../highlevel_oauth/actions/common/common.mjs | 14 +++++++++++++- .../actions/update-contact/update-contact.mjs | 2 +- .../actions/upsert-contact/upsert-contact.mjs | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/components/highlevel_oauth/actions/common/common.mjs b/components/highlevel_oauth/actions/common/common.mjs index 449b51137b8c9..f73552cb68d56 100644 --- a/components/highlevel_oauth/actions/common/common.mjs +++ b/components/highlevel_oauth/actions/common/common.mjs @@ -1,9 +1,13 @@ +import { ConfigurationError } from "@pipedream/platform"; import { parseObjectEntries } from "../../common/utils.mjs"; import app from "../../highlevel_oauth.app.mjs"; export default { props: { - app, + app: { + ...app, + reloadProps: true, + }, name: { type: "string", label: "Name", @@ -36,6 +40,14 @@ export default { optional: true, }, }, + async additionalProps() { + const locationId = this.app.getLocationId(); + if (!locationId) { + throw new ConfigurationError("This component requires you to authenticate as a **location**, not as an agency/company. *(`locationId` field is missing from `$auth`)*"); + } + + return {}; + }, methods: { getData(useLocation = true) { const { diff --git a/components/highlevel_oauth/actions/update-contact/update-contact.mjs b/components/highlevel_oauth/actions/update-contact/update-contact.mjs index 503a75c9376a7..6637abe890535 100644 --- a/components/highlevel_oauth/actions/update-contact/update-contact.mjs +++ b/components/highlevel_oauth/actions/update-contact/update-contact.mjs @@ -11,7 +11,7 @@ export default { key: "highlevel_oauth-update-contact", name: "Update Contact", description: "Updates a selected contact on HighLevel. [See the documentation](https://highlevel.stoplight.io/docs/integrations/9ce5a739d4fb9-update-contact)", - version: "0.0.{{ts}}", + version: "0.0.1", type: "action", props: { app, diff --git a/components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs b/components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs index a0b642f838893..524125f93b504 100644 --- a/components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs +++ b/components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs @@ -11,7 +11,7 @@ export default { key: "highlevel_oauth-upsert-contact", name: "Upsert Contact", description: "Creates or updates a contact on HighLevel. [See the documentation](https://highlevel.stoplight.io/docs/integrations/f71bbdd88f028-upsert-contact)", - version: "0.0.{{ts}}", + version: "0.0.1", type: "action", props: { app, From ab95f75b094e09f9027f7d4edbf8b2b68e0a3352 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 24 Apr 2024 01:27:37 -0300 Subject: [PATCH 13/13] Removing gender prop --- components/highlevel_oauth/actions/common/common.mjs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/components/highlevel_oauth/actions/common/common.mjs b/components/highlevel_oauth/actions/common/common.mjs index f73552cb68d56..3d4308d2478b0 100644 --- a/components/highlevel_oauth/actions/common/common.mjs +++ b/components/highlevel_oauth/actions/common/common.mjs @@ -26,12 +26,6 @@ export default { description: "Phone number of the contact, e.g. `+1 888-888-8888`", optional: true, }, - gender: { - type: "string", - label: "Gender", - description: "Gender of the contact, e.g. `male`", - optional: true, - }, additionalOptions: { type: "object", label: "Additional Options",