fix(HubSpot Node): Migrate from v2 owners api (#10013)

This commit is contained in:
Jon 2024-07-12 08:29:05 +01:00 committed by GitHub
parent 47882161c8
commit 56dd491bca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 12 deletions

View file

@ -862,11 +862,11 @@ export class HubspotV1 implements INodeType {
// select them easily
async getOwners(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
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,

View file

@ -939,11 +939,11 @@ export class HubspotV2 implements INodeType {
// select them easily
async getOwners(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
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<INodeListSearchResult> {
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),
})),
};
},