From 56dd491bcaeab1d11d7874f190eaf20d2e315ca1 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 12 Jul 2024 08:29:05 +0100 Subject: [PATCH] fix(HubSpot Node): Migrate from v2 owners api (#10013) --- .../nodes/Hubspot/V1/HubspotV1.node.ts | 8 ++++---- .../nodes/Hubspot/V2/HubspotV2.node.ts | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/nodes-base/nodes/Hubspot/V1/HubspotV1.node.ts b/packages/nodes-base/nodes/Hubspot/V1/HubspotV1.node.ts index 983461de8d..d8ab8f039e 100644 --- a/packages/nodes-base/nodes/Hubspot/V1/HubspotV1.node.ts +++ b/packages/nodes-base/nodes/Hubspot/V1/HubspotV1.node.ts @@ -862,11 +862,11 @@ export class HubspotV1 implements INodeType { // select them easily async getOwners(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const endpoint = '/owners/v2/owners'; - const owners = await hubspotApiRequest.call(this, 'GET', endpoint); - for (const owner of owners) { + const endpoint = '/crm/v3/owners'; + const { results } = await hubspotApiRequest.call(this, 'GET', endpoint); + for (const owner of results) { const ownerName = owner.email; - const ownerId = owner.ownerId; + const ownerId = isNaN(parseInt(owner.id)) ? owner.id : parseInt(owner.id); returnData.push({ name: ownerName, value: ownerId, diff --git a/packages/nodes-base/nodes/Hubspot/V2/HubspotV2.node.ts b/packages/nodes-base/nodes/Hubspot/V2/HubspotV2.node.ts index 3bd8d4ab8d..e15170bb94 100644 --- a/packages/nodes-base/nodes/Hubspot/V2/HubspotV2.node.ts +++ b/packages/nodes-base/nodes/Hubspot/V2/HubspotV2.node.ts @@ -939,11 +939,11 @@ export class HubspotV2 implements INodeType { // select them easily async getOwners(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const endpoint = '/owners/v2/owners'; - const owners = await hubspotApiRequest.call(this, 'GET', endpoint); - for (const owner of owners) { + const endpoint = '/crm/v3/owners'; + const { results } = await hubspotApiRequest.call(this, 'GET', endpoint); + for (const owner of results) { const ownerName = owner.email; - const ownerId = owner.ownerId; + const ownerId = isNaN(parseInt(owner.id)) ? owner.id : parseInt(owner.id); returnData.push({ name: ownerName, value: ownerId, @@ -1130,13 +1130,13 @@ export class HubspotV2 implements INodeType { }; }, async searchOwners(this: ILoadOptionsFunctions): Promise { - const endpoint = '/owners/v2/owners'; - const owners = await hubspotApiRequest.call(this, 'GET', endpoint, {}); + const endpoint = '/crm/v3/owners'; + const { results } = await hubspotApiRequest.call(this, 'GET', endpoint, {}); return { // tslint:disable-next-line: no-any - results: owners.map((b: any) => ({ + results: results.map((b: any) => ({ name: b.email, - value: b.ownerId, + value: isNaN(parseInt(b.id)) ? b.id : parseInt(b.id), })), }; },