mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
fix(HubSpot Node): Migrate from v2 owners api (#10013)
This commit is contained in:
parent
47882161c8
commit
56dd491bca
|
@ -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,
|
||||
|
|
|
@ -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),
|
||||
})),
|
||||
};
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue