mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(HubSpot Node): Assign owner ID (#18753)
This commit is contained in:
@@ -13,13 +13,14 @@ export class Hubspot extends VersionedNodeType {
|
|||||||
group: ['output'],
|
group: ['output'],
|
||||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||||
description: 'Consume HubSpot API',
|
description: 'Consume HubSpot API',
|
||||||
defaultVersion: 2.1,
|
defaultVersion: 2.2,
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
||||||
1: new HubspotV1(baseDescription),
|
1: new HubspotV1(baseDescription),
|
||||||
2: new HubspotV2(baseDescription),
|
2: new HubspotV2(baseDescription),
|
||||||
2.1: new HubspotV2(baseDescription),
|
2.1: new HubspotV2(baseDescription),
|
||||||
|
2.2: new HubspotV2(baseDescription),
|
||||||
};
|
};
|
||||||
|
|
||||||
super(nodeVersions, baseDescription);
|
super(nodeVersions, baseDescription);
|
||||||
|
|||||||
@@ -411,6 +411,22 @@ export const engagementFields: INodeProperties[] = [
|
|||||||
name: 'ownerIds',
|
name: 'ownerIds',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'@version': [{ _cnd: { lt: 2.2 } }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Owner ID',
|
||||||
|
name: 'ownerId',
|
||||||
|
type: 'number',
|
||||||
|
default: 0,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'@version': [{ _cnd: { gte: 2.2 } }],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Ticket IDs',
|
displayName: 'Ticket IDs',
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export class HubspotV2 implements INodeType {
|
|||||||
this.description = {
|
this.description = {
|
||||||
...baseDescription,
|
...baseDescription,
|
||||||
group: ['output'],
|
group: ['output'],
|
||||||
version: [2, 2.1],
|
version: [2, 2.1, 2.2],
|
||||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||||
defaults: {
|
defaults: {
|
||||||
name: 'HubSpot',
|
name: 'HubSpot',
|
||||||
@@ -2736,13 +2736,19 @@ export class HubspotV2 implements INodeType {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ownerId =
|
||||||
|
associations.ownerId && typeof associations.ownerId === 'number'
|
||||||
|
? associations.ownerId
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const body: {
|
const body: {
|
||||||
engagement: { type: string };
|
engagement: { type: string; ownerId?: number };
|
||||||
metadata: IDataObject;
|
metadata: IDataObject;
|
||||||
associations: IDataObject;
|
associations: IDataObject;
|
||||||
} = {
|
} = {
|
||||||
engagement: {
|
engagement: {
|
||||||
type: type.toUpperCase(),
|
type: type.toUpperCase(),
|
||||||
|
ownerId,
|
||||||
},
|
},
|
||||||
metadata: {},
|
metadata: {},
|
||||||
associations: {},
|
associations: {},
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import contacts from './fixtures/contacts.json';
|
|||||||
import contactsSearchResult from './fixtures/contacts_search_result.json';
|
import contactsSearchResult from './fixtures/contacts_search_result.json';
|
||||||
import deals from './fixtures/deals.json';
|
import deals from './fixtures/deals.json';
|
||||||
import dealsSearchResult from './fixtures/deals_search_result.json';
|
import dealsSearchResult from './fixtures/deals_search_result.json';
|
||||||
|
import engagements from './fixtures/engagements.json';
|
||||||
|
|
||||||
describe('Hubspot Node', () => {
|
describe('Hubspot Node', () => {
|
||||||
nock.disableNetConnect();
|
nock.disableNetConnect();
|
||||||
@@ -351,4 +352,24 @@ describe('Hubspot Node', () => {
|
|||||||
workflowFiles: ['deals.workflow.json'],
|
workflowFiles: ['deals.workflow.json'],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('engagements', () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
hubspotNock
|
||||||
|
.post('/engagements/v1/engagements', function checkOwnerIdIsDefined(body) {
|
||||||
|
return body.engagement.ownerId === engagements.request[0].engagement.ownerId;
|
||||||
|
})
|
||||||
|
.reply(200, engagements.response[0])
|
||||||
|
.post('/engagements/v1/engagements', function checkOwnerIdIsNotDefined(body) {
|
||||||
|
return body.engagement.ownerId === undefined;
|
||||||
|
})
|
||||||
|
.reply(200, engagements.response[1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => hubspotNock.done());
|
||||||
|
|
||||||
|
new NodeTestHarness().setupTests({
|
||||||
|
workflowFiles: ['engagements.workflow.json'],
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,189 @@
|
|||||||
|
{
|
||||||
|
"name": "Hubspot - Engagements",
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"parameters": {
|
||||||
|
"authentication": "appToken",
|
||||||
|
"resource": "engagement",
|
||||||
|
"type": "task",
|
||||||
|
"metadata": {
|
||||||
|
"body": "Hello world",
|
||||||
|
"subject": "Title"
|
||||||
|
},
|
||||||
|
"additionalFields": {
|
||||||
|
"associations": {
|
||||||
|
"ownerId": 123456789
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "n8n-nodes-base.hubspot",
|
||||||
|
"typeVersion": 2.2,
|
||||||
|
"position": [0, 0],
|
||||||
|
"id": "942a05ef-f3ed-4511-a00f-0b1e5e1b8a49",
|
||||||
|
"name": "HubSpot - Engagement - Create with ownerId",
|
||||||
|
"credentials": {
|
||||||
|
"hubspotAppToken": {
|
||||||
|
"id": "vWZfuQawMAWdxKms",
|
||||||
|
"name": "HubSpot account"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parameters": {
|
||||||
|
"authentication": "appToken",
|
||||||
|
"resource": "engagement",
|
||||||
|
"type": "task",
|
||||||
|
"metadata": {
|
||||||
|
"body": "Hello world",
|
||||||
|
"subject": "Title"
|
||||||
|
},
|
||||||
|
"additionalFields": {}
|
||||||
|
},
|
||||||
|
"type": "n8n-nodes-base.hubspot",
|
||||||
|
"typeVersion": 2.2,
|
||||||
|
"position": [0, 200],
|
||||||
|
"id": "7fb51d0d-28b5-450d-b910-f6d91e69e934",
|
||||||
|
"name": "HubSpot - Engagement - Create",
|
||||||
|
"credentials": {
|
||||||
|
"hubspotAppToken": {
|
||||||
|
"id": "vWZfuQawMAWdxKms",
|
||||||
|
"name": "HubSpot account"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parameters": {},
|
||||||
|
"type": "n8n-nodes-base.manualTrigger",
|
||||||
|
"typeVersion": 1,
|
||||||
|
"position": [-220, 600],
|
||||||
|
"id": "ec9e619e-c75a-41ea-8f54-16827bcd664b",
|
||||||
|
"name": "When clicking ‘Execute workflow’"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pinData": {
|
||||||
|
"HubSpot - Engagement - Create with ownerId": [
|
||||||
|
{
|
||||||
|
"json": {
|
||||||
|
"associationCreateFailures": [],
|
||||||
|
"engagement": {
|
||||||
|
"id": 274361144556,
|
||||||
|
"portalId": 146787276,
|
||||||
|
"active": true,
|
||||||
|
"createdAt": 1756127696406,
|
||||||
|
"lastUpdated": 1756127696406,
|
||||||
|
"ownerId": 123456789,
|
||||||
|
"type": "TASK",
|
||||||
|
"timestamp": 1756127696406,
|
||||||
|
"allAccessibleTeamIds": [],
|
||||||
|
"bodyPreview": "Hello world",
|
||||||
|
"queueMembershipIds": [],
|
||||||
|
"bodyPreviewIsTruncated": false,
|
||||||
|
"bodyPreviewHtml": "<html>\n <head></head>\n <body>\n Hello world\n </body>\n</html>"
|
||||||
|
},
|
||||||
|
"associations": {
|
||||||
|
"contactIds": [],
|
||||||
|
"companyIds": [],
|
||||||
|
"dealIds": [],
|
||||||
|
"ownerIds": [],
|
||||||
|
"workflowIds": [],
|
||||||
|
"ticketIds": [],
|
||||||
|
"contentIds": [],
|
||||||
|
"quoteIds": [],
|
||||||
|
"marketingEventIds": [],
|
||||||
|
"partnerClientIds": [],
|
||||||
|
"orderIds": [],
|
||||||
|
"cartIds": []
|
||||||
|
},
|
||||||
|
"attachments": [],
|
||||||
|
"scheduledTasks": [],
|
||||||
|
"metadata": {
|
||||||
|
"body": "Hello world",
|
||||||
|
"status": "NOT_STARTED",
|
||||||
|
"forObjectType": "OWNER",
|
||||||
|
"subject": "Title",
|
||||||
|
"taskType": "TODO",
|
||||||
|
"reminders": [],
|
||||||
|
"priority": "NONE",
|
||||||
|
"isAllDay": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"HubSpot - Engagement - Create": [
|
||||||
|
{
|
||||||
|
"json": {
|
||||||
|
"associationCreateFailures": [],
|
||||||
|
"engagement": {
|
||||||
|
"id": 274123775164,
|
||||||
|
"portalId": 146787276,
|
||||||
|
"active": true,
|
||||||
|
"createdAt": 1756127766844,
|
||||||
|
"lastUpdated": 1756127766844,
|
||||||
|
"type": "TASK",
|
||||||
|
"timestamp": 1756127766844,
|
||||||
|
"allAccessibleTeamIds": [],
|
||||||
|
"bodyPreview": "Hello world",
|
||||||
|
"queueMembershipIds": [],
|
||||||
|
"bodyPreviewIsTruncated": false,
|
||||||
|
"bodyPreviewHtml": "<html>\n <head></head>\n <body>\n Hello world\n </body>\n</html>"
|
||||||
|
},
|
||||||
|
"associations": {
|
||||||
|
"contactIds": [],
|
||||||
|
"companyIds": [],
|
||||||
|
"dealIds": [],
|
||||||
|
"ownerIds": [],
|
||||||
|
"workflowIds": [],
|
||||||
|
"ticketIds": [],
|
||||||
|
"contentIds": [],
|
||||||
|
"quoteIds": [],
|
||||||
|
"marketingEventIds": [],
|
||||||
|
"partnerClientIds": [],
|
||||||
|
"orderIds": [],
|
||||||
|
"cartIds": []
|
||||||
|
},
|
||||||
|
"attachments": [],
|
||||||
|
"scheduledTasks": [],
|
||||||
|
"metadata": {
|
||||||
|
"body": "Hello world",
|
||||||
|
"status": "NOT_STARTED",
|
||||||
|
"forObjectType": "OWNER",
|
||||||
|
"subject": "Title",
|
||||||
|
"taskType": "TODO",
|
||||||
|
"reminders": [],
|
||||||
|
"priority": "NONE",
|
||||||
|
"isAllDay": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"connections": {
|
||||||
|
"When clicking ‘Execute workflow’": {
|
||||||
|
"main": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"node": "HubSpot - Engagement - Create with ownerId",
|
||||||
|
"type": "main",
|
||||||
|
"index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": "HubSpot - Engagement - Create",
|
||||||
|
"type": "main",
|
||||||
|
"index": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"active": false,
|
||||||
|
"settings": {
|
||||||
|
"executionOrder": "v1"
|
||||||
|
},
|
||||||
|
"versionId": "7b4c4c50-0d21-4857-b36d-6392ee84ab18",
|
||||||
|
"meta": {
|
||||||
|
"templateCredsSetupCompleted": true,
|
||||||
|
"instanceId": "653b28422b2af80d4de68237267b34fdf127ab92f8fb0887c6b0a2be7e7f27c7"
|
||||||
|
},
|
||||||
|
"id": "4TOsSL2vMvJQ86E2",
|
||||||
|
"tags": []
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"request": [
|
||||||
|
{
|
||||||
|
"engagement": { "type": "TASK", "ownerId": 123456789 },
|
||||||
|
"metadata": { "body": "Hello world", "subject": "Title" },
|
||||||
|
"associations": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"engagement": { "type": "TASK" },
|
||||||
|
"metadata": { "body": "Hello world", "subject": "Title" },
|
||||||
|
"associations": {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"response": [
|
||||||
|
{
|
||||||
|
"associationCreateFailures": [],
|
||||||
|
"engagement": {
|
||||||
|
"id": 274361144556,
|
||||||
|
"portalId": 146787276,
|
||||||
|
"active": true,
|
||||||
|
"createdAt": 1756127696406,
|
||||||
|
"lastUpdated": 1756127696406,
|
||||||
|
"ownerId": 123456789,
|
||||||
|
"type": "TASK",
|
||||||
|
"timestamp": 1756127696406,
|
||||||
|
"allAccessibleTeamIds": [],
|
||||||
|
"bodyPreview": "Hello world",
|
||||||
|
"queueMembershipIds": [],
|
||||||
|
"bodyPreviewIsTruncated": false,
|
||||||
|
"bodyPreviewHtml": "<html>\n <head></head>\n <body>\n Hello world\n </body>\n</html>"
|
||||||
|
},
|
||||||
|
"associations": {
|
||||||
|
"contactIds": [],
|
||||||
|
"companyIds": [],
|
||||||
|
"dealIds": [],
|
||||||
|
"ownerIds": [],
|
||||||
|
"workflowIds": [],
|
||||||
|
"ticketIds": [],
|
||||||
|
"contentIds": [],
|
||||||
|
"quoteIds": [],
|
||||||
|
"marketingEventIds": [],
|
||||||
|
"partnerClientIds": [],
|
||||||
|
"orderIds": [],
|
||||||
|
"cartIds": []
|
||||||
|
},
|
||||||
|
"attachments": [],
|
||||||
|
"scheduledTasks": [],
|
||||||
|
"metadata": {
|
||||||
|
"body": "Hello world",
|
||||||
|
"status": "NOT_STARTED",
|
||||||
|
"forObjectType": "OWNER",
|
||||||
|
"subject": "Title",
|
||||||
|
"taskType": "TODO",
|
||||||
|
"reminders": [],
|
||||||
|
"priority": "NONE",
|
||||||
|
"isAllDay": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"associationCreateFailures": [],
|
||||||
|
"engagement": {
|
||||||
|
"id": 274123775164,
|
||||||
|
"portalId": 146787276,
|
||||||
|
"active": true,
|
||||||
|
"createdAt": 1756127766844,
|
||||||
|
"lastUpdated": 1756127766844,
|
||||||
|
"type": "TASK",
|
||||||
|
"timestamp": 1756127766844,
|
||||||
|
"allAccessibleTeamIds": [],
|
||||||
|
"bodyPreview": "Hello world",
|
||||||
|
"queueMembershipIds": [],
|
||||||
|
"bodyPreviewIsTruncated": false,
|
||||||
|
"bodyPreviewHtml": "<html>\n <head></head>\n <body>\n Hello world\n </body>\n</html>"
|
||||||
|
},
|
||||||
|
"associations": {
|
||||||
|
"contactIds": [],
|
||||||
|
"companyIds": [],
|
||||||
|
"dealIds": [],
|
||||||
|
"ownerIds": [],
|
||||||
|
"workflowIds": [],
|
||||||
|
"ticketIds": [],
|
||||||
|
"contentIds": [],
|
||||||
|
"quoteIds": [],
|
||||||
|
"marketingEventIds": [],
|
||||||
|
"partnerClientIds": [],
|
||||||
|
"orderIds": [],
|
||||||
|
"cartIds": []
|
||||||
|
},
|
||||||
|
"attachments": [],
|
||||||
|
"scheduledTasks": [],
|
||||||
|
"metadata": {
|
||||||
|
"body": "Hello world",
|
||||||
|
"status": "NOT_STARTED",
|
||||||
|
"forObjectType": "OWNER",
|
||||||
|
"subject": "Title",
|
||||||
|
"taskType": "TODO",
|
||||||
|
"reminders": [],
|
||||||
|
"priority": "NONE",
|
||||||
|
"isAllDay": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user