mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-24 04:59:13 +00:00
fix(HubSpot Node): Include properties for contact and deal in getAll operation (#8772)
This commit is contained in:
@@ -54,7 +54,7 @@ export class HubspotV2 implements INodeType {
|
||||
this.description = {
|
||||
...baseDescription,
|
||||
group: ['output'],
|
||||
version: 2,
|
||||
version: [2, 2.1],
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
defaults: {
|
||||
name: 'HubSpot',
|
||||
@@ -339,7 +339,18 @@ export class HubspotV2 implements INodeType {
|
||||
async getContactProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const endpoint = '/properties/v2/contacts/properties';
|
||||
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
|
||||
|
||||
let properties = (await hubspotApiRequest.call(this, 'GET', endpoint, {})) as Array<{
|
||||
label: string;
|
||||
name: string;
|
||||
}>;
|
||||
|
||||
properties = properties.sort((a, b) => {
|
||||
if (a.label < b.label) return -1;
|
||||
if (a.label > b.label) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
for (const property of properties) {
|
||||
const propertyName = property.label;
|
||||
const propertyId = property.name;
|
||||
@@ -348,6 +359,7 @@ export class HubspotV2 implements INodeType {
|
||||
value: propertyId,
|
||||
});
|
||||
}
|
||||
|
||||
return returnData;
|
||||
},
|
||||
// Get all the contact properties to display them to user so that they can
|
||||
@@ -670,7 +682,16 @@ export class HubspotV2 implements INodeType {
|
||||
async getDealProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const endpoint = '/properties/v2/deals/properties';
|
||||
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
|
||||
let properties = (await hubspotApiRequest.call(this, 'GET', endpoint, {})) as Array<{
|
||||
label: string;
|
||||
name: string;
|
||||
}>;
|
||||
|
||||
properties = properties.sort((a, b) => {
|
||||
if (a.label < b.label) return -1;
|
||||
if (a.label > b.label) return 1;
|
||||
return 0;
|
||||
});
|
||||
for (const property of properties) {
|
||||
const propertyName = property.label;
|
||||
const propertyId = property.name;
|
||||
@@ -696,6 +717,7 @@ export class HubspotV2 implements INodeType {
|
||||
returnData.push({
|
||||
name: propertyName,
|
||||
// Hacky way to get the property type need to be parsed to be use in the api
|
||||
// this is no longer working, properties does not returned in the response
|
||||
value: `${propertyId}|${propertyType}`,
|
||||
});
|
||||
}
|
||||
@@ -1553,7 +1575,7 @@ export class HubspotV2 implements INodeType {
|
||||
const propertiesValues = additionalFields.propertiesCollection // @ts-ignore
|
||||
.propertiesValues as IDataObject;
|
||||
const properties = propertiesValues.properties as string | string[];
|
||||
qs.properties = !Array.isArray(propertiesValues.properties)
|
||||
qs.property = !Array.isArray(propertiesValues.properties)
|
||||
? (properties as string).split(',')
|
||||
: properties;
|
||||
qs.propertyMode = snakeCase(propertiesValues.propertyMode as string);
|
||||
@@ -2441,6 +2463,7 @@ export class HubspotV2 implements INodeType {
|
||||
qs.includeAssociations = filters.includeAssociations as boolean;
|
||||
}
|
||||
|
||||
//for version 2
|
||||
if (filters.propertiesCollection) {
|
||||
const propertiesValues = filters.propertiesCollection // @ts-ignore
|
||||
.propertiesValues as IDataObject;
|
||||
@@ -2451,6 +2474,18 @@ export class HubspotV2 implements INodeType {
|
||||
qs.propertyMode = snakeCase(propertiesValues.propertyMode as string);
|
||||
}
|
||||
|
||||
//for version > 2
|
||||
if (filters.properties) {
|
||||
const properties = filters.properties as string | string[];
|
||||
qs.properties = !Array.isArray(properties) ? properties.split(',') : properties;
|
||||
}
|
||||
if (filters.propertiesWithHistory) {
|
||||
const properties = filters.propertiesWithHistory as string | string[];
|
||||
qs.propertiesWithHistory = !Array.isArray(properties)
|
||||
? properties.split(',')
|
||||
: properties;
|
||||
}
|
||||
|
||||
const endpoint = '/deals/v1/deal/paged';
|
||||
if (returnAll) {
|
||||
responseData = await hubspotApiRequestAllItems.call(
|
||||
|
||||
Reference in New Issue
Block a user