From 3ec6a9afb45c6f029d34703b77e7a26191493464 Mon Sep 17 00:00:00 2001 From: Bradley Greathead Date: Fri, 16 Aug 2024 15:43:03 +0200 Subject: [PATCH 1/2] Make Hubspot CRM URL to be consistent as currently getting 404 errors from Hubspot --- packages/api/src/crm/company/services/hubspot/index.ts | 2 +- packages/api/src/crm/contact/services/hubspot/index.ts | 2 +- packages/api/src/crm/deal/services/hubspot/index.ts | 2 +- packages/api/src/crm/note/services/hubspot/index.ts | 6 +++--- packages/api/src/crm/task/services/hubspot/index.ts | 6 +++--- packages/api/src/crm/user/services/hubspot/index.ts | 2 +- packages/shared/src/connectors/metadata.ts | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/api/src/crm/company/services/hubspot/index.ts b/packages/api/src/crm/company/services/hubspot/index.ts index 4ff80ba66..8363f922c 100644 --- a/packages/api/src/crm/company/services/hubspot/index.ts +++ b/packages/api/src/crm/company/services/hubspot/index.ts @@ -78,7 +78,7 @@ export class HubspotService implements ICompanyService { const commonPropertyNames = Object.keys(commonCompanyHubspotProperties); const allProperties = [...commonPropertyNames, ...custom_properties]; - const baseURL = `${connection.account_url}/v3/objects/companies`; + const baseURL = `${connection.account_url}/crm/v3/objects/companies`; const queryString = allProperties .map((prop) => `properties=${encodeURIComponent(prop)}`) .join('&'); diff --git a/packages/api/src/crm/contact/services/hubspot/index.ts b/packages/api/src/crm/contact/services/hubspot/index.ts index a0c32a178..590315bc6 100644 --- a/packages/api/src/crm/contact/services/hubspot/index.ts +++ b/packages/api/src/crm/contact/services/hubspot/index.ts @@ -80,7 +80,7 @@ export class HubspotService implements IContactService { const commonPropertyNames = Object.keys(commonHubspotProperties); const allProperties = [...commonPropertyNames, ...custom_properties]; - const baseURL = `${connection.account_url}/v3/objects/contacts`; + const baseURL = `${connection.account_url}/crm/v3/objects/contacts`; const queryString = allProperties .map((prop) => `properties=${encodeURIComponent(prop)}`) diff --git a/packages/api/src/crm/deal/services/hubspot/index.ts b/packages/api/src/crm/deal/services/hubspot/index.ts index 5f2ba38ee..2543ad8f3 100644 --- a/packages/api/src/crm/deal/services/hubspot/index.ts +++ b/packages/api/src/crm/deal/services/hubspot/index.ts @@ -43,7 +43,7 @@ export class HubspotService implements IDealService { properties: dealData, }; const resp = await axios.post( - `${connection.account_url}/v3/objects/deals`, + `${connection.account_url}/crm/v3/objects/deals`, JSON.stringify(dataBody), { headers: { diff --git a/packages/api/src/crm/note/services/hubspot/index.ts b/packages/api/src/crm/note/services/hubspot/index.ts index 71e3e332a..641589e16 100644 --- a/packages/api/src/crm/note/services/hubspot/index.ts +++ b/packages/api/src/crm/note/services/hubspot/index.ts @@ -40,7 +40,7 @@ export class HubspotService implements INoteService { }, }); const resp = await axios.post( - `${connection.account_url}/v3/objects/notes`, + `${connection.account_url}/crm/v3/objects/notes`, JSON.stringify(noteData), { headers: { @@ -53,7 +53,7 @@ export class HubspotService implements INoteService { ); const final_resp = await axios.get( - `${connection.account_url}/objects/notes/${resp.data.id}?properties=hs_note_body&associations=deal,contact,company`, + `${connection.account_url}/crm/v3/objects/notes/${resp.data.id}?properties=hs_note_body&associations=deal,contact,company`, { headers: { 'Content-Type': 'application/json', @@ -87,7 +87,7 @@ export class HubspotService implements INoteService { const commonPropertyNames = Object.keys(commonNoteHubspotProperties); const allProperties = [...commonPropertyNames, ...custom_properties]; - const baseURL = `${connection.account_url}/objects/notes`; + const baseURL = `${connection.account_url}/crm/v3/objects/notes`; const queryString = allProperties .map((prop) => `properties=${encodeURIComponent(prop)}`) diff --git a/packages/api/src/crm/task/services/hubspot/index.ts b/packages/api/src/crm/task/services/hubspot/index.ts index 4b8cad070..215543886 100644 --- a/packages/api/src/crm/task/services/hubspot/index.ts +++ b/packages/api/src/crm/task/services/hubspot/index.ts @@ -41,7 +41,7 @@ export class HubspotService implements ITaskService { }, }); const resp = await axios.post( - `${connection.account_url}/v3/objects/tasks`, + `${connection.account_url}/crm/v3/objects/tasks`, JSON.stringify(taskData), { headers: { @@ -53,7 +53,7 @@ export class HubspotService implements ITaskService { }, ); const final_resp = await axios.get( - `${connection.account_url}/v3/objects/tasks/${resp.data.id}?properties=hs_task_body&associations=deal,company`, + `${connection.account_url}/crm/v3/objects/tasks/${resp.data.id}?properties=hs_task_body&associations=deal,company`, { headers: { 'Content-Type': 'application/json', @@ -87,7 +87,7 @@ export class HubspotService implements ITaskService { const commonPropertyNames = Object.keys(commonTaskHubspotProperties); const allProperties = [...commonPropertyNames, ...custom_properties]; - const baseURL = `${connection.account_url}/v3/objects/tasks`; + const baseURL = `${connection.account_url}/crm/v3/objects/tasks`; const queryString = allProperties .map((prop) => `properties=${encodeURIComponent(prop)}`) diff --git a/packages/api/src/crm/user/services/hubspot/index.ts b/packages/api/src/crm/user/services/hubspot/index.ts index a86a7ec20..160b45d1a 100644 --- a/packages/api/src/crm/user/services/hubspot/index.ts +++ b/packages/api/src/crm/user/services/hubspot/index.ts @@ -39,7 +39,7 @@ export class HubspotService implements IUserService { const commonPropertyNames = Object.keys(commonUserHubspotProperties); const allProperties = [...commonPropertyNames, ...custom_properties]; - const baseURL = `${connection.account_url}/v3/owners`; + const baseURL = `${connection.account_url}/crm/v3/owners`; /*const queryString = allProperties .map((prop) => `properties=${encodeURIComponent(prop)}`) diff --git a/packages/shared/src/connectors/metadata.ts b/packages/shared/src/connectors/metadata.ts index 3bc4e8fb3..5fced89c0 100644 --- a/packages/shared/src/connectors/metadata.ts +++ b/packages/shared/src/connectors/metadata.ts @@ -10,7 +10,7 @@ export const CONNECTORS_METADATA: ProvidersConfig = { urls: { docsUrl: 'https://developers.hubspot.com/docs/api/crm/understanding-the-crm', authBaseUrl: 'https://app-eu1.hubspot.com/oauth/authorize', - apiUrl: 'https://api.hubapi.com/crm', + apiUrl: 'https://api.hubapi.com', customPropertiesUrl: 'https://api.hubapi.com/properties/v1/contacts/properties', }, logoPath: 'https://assets-global.website-files.com/6421a177cdeeaf3c6791b745/64d61202dd99e63d40d446f6_hubspot%20logo.png', From 8004d8fa9f74e78a8bcb512a746b70843919fb8e Mon Sep 17 00:00:00 2001 From: Bradley Greathead Date: Fri, 16 Aug 2024 15:45:06 +0200 Subject: [PATCH 2/2] Remove deprecated crypto npm package. Use native NodeJS module --- packages/api/package.json | 1 - pnpm-lock.yaml | 8 -------- 2 files changed, 9 deletions(-) diff --git a/packages/api/package.json b/packages/api/package.json index f9952ae87..a0caaa0e5 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -52,7 +52,6 @@ "class-validator": "^0.14.0", "cookie-parser": "^1.4.6", "cors": "^2.8.5", - "crypto": "^1.0.1", "dotenv": "^16.3.1", "exponential-backoff": "^3.1.1", "form-data": "^4.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 630e6c431..1e50aeae8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -508,9 +508,6 @@ importers: cors: specifier: ^2.8.5 version: 2.8.5 - crypto: - specifier: ^1.0.1 - version: 1.0.1 dotenv: specifier: ^16.3.1 version: 16.4.5 @@ -8175,11 +8172,6 @@ packages: type-fest: 1.4.0 dev: false - /crypto@1.0.1: - resolution: {integrity: sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==} - deprecated: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in. - dev: false - /css-color-keywords@1.0.0: resolution: {integrity: sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==} engines: {node: '>=4'}