n8n-nodes-base 0.225.0 → 0.226.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.tsbuildinfo +1 -1
- package/dist/credentials/AirtableApi.credentials.js +6 -0
- package/dist/credentials/AirtableApi.credentials.js.map +1 -1
- package/dist/credentials/AirtableTokenApi.credentials.d.ts +9 -0
- package/dist/credentials/AirtableTokenApi.credentials.js +34 -0
- package/dist/credentials/AirtableTokenApi.credentials.js.map +1 -0
- package/dist/credentials/JotFormApi.credentials.js +4 -0
- package/dist/credentials/JotFormApi.credentials.js.map +1 -1
- package/dist/credentials/NpmApi.credentials.d.ts +9 -0
- package/dist/credentials/NpmApi.credentials.js +41 -0
- package/dist/credentials/NpmApi.credentials.js.map +1 -0
- package/dist/credentials/SshPrivateKey.credentials.js +1 -1
- package/dist/credentials/SshPrivateKey.credentials.js.map +1 -1
- package/dist/known/credentials.json +21 -3
- package/dist/known/nodes.json +4 -0
- package/dist/methods/defined.json +4 -1
- package/dist/methods/referenced.json +4 -1
- package/dist/nodes/Airtable/Airtable.node.js +36 -3
- package/dist/nodes/Airtable/Airtable.node.js.map +1 -1
- package/dist/nodes/Airtable/AirtableTrigger.node.js +31 -1
- package/dist/nodes/Airtable/AirtableTrigger.node.js.map +1 -1
- package/dist/nodes/Airtable/GenericFunctions.js +2 -1
- package/dist/nodes/Airtable/GenericFunctions.js.map +1 -1
- package/dist/nodes/Aws/Rekognition/AwsRekognition.node.js +35 -35
- package/dist/nodes/Aws/Rekognition/AwsRekognition.node.js.map +1 -1
- package/dist/nodes/Aws/Rekognition/test/AwsRekognitionTestWorkflow.json +344 -0
- package/dist/nodes/Code/Code.node.js +59 -35
- package/dist/nodes/Code/Code.node.js.map +1 -1
- package/dist/nodes/Code/Code.node.json +1 -1
- package/dist/nodes/Code/JavaScriptSandbox.d.ts +11 -0
- package/dist/nodes/Code/JavaScriptSandbox.js +81 -0
- package/dist/nodes/Code/JavaScriptSandbox.js.map +1 -0
- package/dist/nodes/Code/Pyodide.d.ts +2 -0
- package/dist/nodes/Code/Pyodide.js +47 -0
- package/dist/nodes/Code/Pyodide.js.map +1 -0
- package/dist/nodes/Code/PythonSandbox.d.ts +13 -0
- package/dist/nodes/Code/PythonSandbox.js +86 -0
- package/dist/nodes/Code/PythonSandbox.js.map +1 -0
- package/dist/nodes/Code/Sandbox.d.ts +20 -11
- package/dist/nodes/Code/Sandbox.js +61 -103
- package/dist/nodes/Code/Sandbox.js.map +1 -1
- package/dist/nodes/Code/descriptions/JavascriptCodeDescription.d.ts +2 -0
- package/dist/nodes/Code/descriptions/JavascriptCodeDescription.js +73 -0
- package/dist/nodes/Code/descriptions/JavascriptCodeDescription.js.map +1 -0
- package/dist/nodes/Code/descriptions/PythonCodeDescription.d.ts +2 -0
- package/dist/nodes/Code/descriptions/PythonCodeDescription.js +61 -0
- package/dist/nodes/Code/descriptions/PythonCodeDescription.js.map +1 -0
- package/dist/nodes/Code/utils.d.ts +0 -2
- package/dist/nodes/Code/utils.js +1 -2
- package/dist/nodes/Code/utils.js.map +1 -1
- package/dist/nodes/DateTime/DateTime.node.d.ts +3 -9
- package/dist/nodes/DateTime/DateTime.node.js +9 -502
- package/dist/nodes/DateTime/DateTime.node.js.map +1 -1
- package/dist/nodes/DateTime/V1/DateTimeV1.node.d.ts +11 -0
- package/dist/nodes/DateTime/V1/DateTimeV1.node.js +523 -0
- package/dist/nodes/DateTime/V1/DateTimeV1.node.js.map +1 -0
- package/dist/nodes/DateTime/V2/AddToDateDescription.d.ts +2 -0
- package/dist/nodes/DateTime/V2/AddToDateDescription.js +105 -0
- package/dist/nodes/DateTime/V2/AddToDateDescription.js.map +1 -0
- package/dist/nodes/DateTime/V2/CurrentDateDescription.d.ts +2 -0
- package/dist/nodes/DateTime/V2/CurrentDateDescription.js +63 -0
- package/dist/nodes/DateTime/V2/CurrentDateDescription.js.map +1 -0
- package/dist/nodes/DateTime/V2/DateTimeV2.node.d.ts +6 -0
- package/dist/nodes/DateTime/V2/DateTimeV2.node.js +187 -0
- package/dist/nodes/DateTime/V2/DateTimeV2.node.js.map +1 -0
- package/dist/nodes/DateTime/V2/ExtractDateDescription.d.ts +2 -0
- package/dist/nodes/DateTime/V2/ExtractDateDescription.js +82 -0
- package/dist/nodes/DateTime/V2/ExtractDateDescription.js.map +1 -0
- package/dist/nodes/DateTime/V2/FormatDateDescription.d.ts +2 -0
- package/dist/nodes/DateTime/V2/FormatDateDescription.js +129 -0
- package/dist/nodes/DateTime/V2/FormatDateDescription.js.map +1 -0
- package/dist/nodes/DateTime/V2/GenericFunctions.d.ts +3 -0
- package/dist/nodes/DateTime/V2/GenericFunctions.js +46 -0
- package/dist/nodes/DateTime/V2/GenericFunctions.js.map +1 -0
- package/dist/nodes/DateTime/V2/GetTimeBetweenDates.d.ts +2 -0
- package/dist/nodes/DateTime/V2/GetTimeBetweenDates.js +106 -0
- package/dist/nodes/DateTime/V2/GetTimeBetweenDates.js.map +1 -0
- package/dist/nodes/DateTime/V2/RoundDateDescription.d.ts +2 -0
- package/dist/nodes/DateTime/V2/RoundDateDescription.js +122 -0
- package/dist/nodes/DateTime/V2/RoundDateDescription.js.map +1 -0
- package/dist/nodes/DateTime/V2/SubtractFromDateDescription.d.ts +2 -0
- package/dist/nodes/DateTime/V2/SubtractFromDateDescription.js +105 -0
- package/dist/nodes/DateTime/V2/SubtractFromDateDescription.js.map +1 -0
- package/dist/nodes/DateTime/test/node/DateTimeWorkflowV2.json +260 -0
- package/dist/nodes/DateTime/test/node/workflow.timestamp_v2.json +352 -0
- package/dist/nodes/Ftp/Ftp.node.js +4 -4
- package/dist/nodes/Ftp/Ftp.node.js.map +1 -1
- package/dist/nodes/HttpRequest/HttpRequest.node.js +2 -1
- package/dist/nodes/HttpRequest/HttpRequest.node.js.map +1 -1
- package/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js +4 -1
- package/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js.map +1 -1
- package/dist/nodes/Hubspot/Hubspot.node.d.ts +3 -45
- package/dist/nodes/Hubspot/Hubspot.node.js +9 -2321
- package/dist/nodes/Hubspot/Hubspot.node.js.map +1 -1
- package/dist/nodes/Hubspot/HubspotTrigger.node.js +1 -1
- package/dist/nodes/Hubspot/HubspotTrigger.node.js.map +1 -1
- package/dist/nodes/Hubspot/{CompanyDescription.js → V1/CompanyDescription.js} +1 -0
- package/dist/nodes/Hubspot/V1/CompanyDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V1/ContactDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V1/ContactListDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V1/DealDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V1/DealInterface.js.map +1 -0
- package/dist/nodes/Hubspot/V1/EngagementDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V1/FormDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V1/FormInterface.js.map +1 -0
- package/dist/nodes/Hubspot/V1/GenericFunctions.d.ts +70 -0
- package/dist/nodes/Hubspot/V1/GenericFunctions.js +1964 -0
- package/dist/nodes/Hubspot/V1/GenericFunctions.js.map +1 -0
- package/dist/nodes/Hubspot/V1/HubspotV1.node.d.ts +48 -0
- package/dist/nodes/Hubspot/V1/HubspotV1.node.js +2334 -0
- package/dist/nodes/Hubspot/V1/HubspotV1.node.js.map +1 -0
- package/dist/nodes/Hubspot/V1/TicketDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V2/CompanyDescription.d.ts +3 -0
- package/dist/nodes/Hubspot/V2/CompanyDescription.js +1134 -0
- package/dist/nodes/Hubspot/V2/CompanyDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V2/ContactDescription.d.ts +3 -0
- package/dist/nodes/Hubspot/V2/ContactDescription.js +1158 -0
- package/dist/nodes/Hubspot/V2/ContactDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V2/ContactListDescription.d.ts +3 -0
- package/dist/nodes/Hubspot/V2/ContactListDescription.js +125 -0
- package/dist/nodes/Hubspot/V2/ContactListDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V2/DealDescription.d.ts +3 -0
- package/dist/nodes/Hubspot/V2/DealDescription.js +949 -0
- package/dist/nodes/Hubspot/V2/DealDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V2/DealInterface.d.ts +9 -0
- package/dist/nodes/Hubspot/V2/DealInterface.js +3 -0
- package/dist/nodes/Hubspot/V2/DealInterface.js.map +1 -0
- package/dist/nodes/Hubspot/V2/EngagementDescription.d.ts +3 -0
- package/dist/nodes/Hubspot/V2/EngagementDescription.js +530 -0
- package/dist/nodes/Hubspot/V2/EngagementDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V2/FormDescription.d.ts +3 -0
- package/dist/nodes/Hubspot/V2/FormDescription.js +297 -0
- package/dist/nodes/Hubspot/V2/FormDescription.js.map +1 -0
- package/dist/nodes/Hubspot/V2/FormInterface.d.ts +19 -0
- package/dist/nodes/Hubspot/V2/FormInterface.js +3 -0
- package/dist/nodes/Hubspot/V2/FormInterface.js.map +1 -0
- package/dist/nodes/Hubspot/V2/GenericFunctions.js.map +1 -0
- package/dist/nodes/Hubspot/V2/HubspotV2.node.d.ts +59 -0
- package/dist/nodes/Hubspot/V2/HubspotV2.node.js +2554 -0
- package/dist/nodes/Hubspot/V2/HubspotV2.node.js.map +1 -0
- package/dist/nodes/Hubspot/V2/TicketDescription.d.ts +3 -0
- package/dist/nodes/Hubspot/V2/TicketDescription.js +563 -0
- package/dist/nodes/Hubspot/V2/TicketDescription.js.map +1 -0
- package/dist/nodes/Kafka/KafkaTrigger.node.js +28 -4
- package/dist/nodes/Kafka/KafkaTrigger.node.js.map +1 -1
- package/dist/nodes/MySql/MySql.node.js +2 -1
- package/dist/nodes/MySql/MySql.node.js.map +1 -1
- package/dist/nodes/MySql/v2/actions/router.js +1 -0
- package/dist/nodes/MySql/v2/actions/router.js.map +1 -1
- package/dist/nodes/MySql/v2/actions/versionDescription.js +1 -1
- package/dist/nodes/MySql/v2/actions/versionDescription.js.map +1 -1
- package/dist/nodes/MySql/v2/transport/index.js +3 -0
- package/dist/nodes/MySql/v2/transport/index.js.map +1 -1
- package/dist/nodes/Npm/DistTagDescription.d.ts +3 -0
- package/dist/nodes/Npm/DistTagDescription.js +94 -0
- package/dist/nodes/Npm/DistTagDescription.js.map +1 -0
- package/dist/nodes/Npm/Npm.node.d.ts +4 -0
- package/dist/nodes/Npm/Npm.node.js +57 -0
- package/dist/nodes/Npm/Npm.node.js.map +1 -0
- package/dist/nodes/Npm/Npm.node.json +19 -0
- package/dist/nodes/Npm/PackageDescription.d.ts +3 -0
- package/dist/nodes/Npm/PackageDescription.js +168 -0
- package/dist/nodes/Npm/PackageDescription.js.map +1 -0
- package/dist/nodes/Npm/npm.svg +4 -0
- package/dist/nodes/Npm/test/Npm.workflow.test.json +117 -0
- package/dist/nodes/Postgres/Postgres.node.js +2 -1
- package/dist/nodes/Postgres/Postgres.node.js.map +1 -1
- package/dist/nodes/Postgres/v2/actions/router.js +1 -0
- package/dist/nodes/Postgres/v2/actions/router.js.map +1 -1
- package/dist/nodes/Postgres/v2/actions/versionDescription.js +1 -1
- package/dist/nodes/Postgres/v2/actions/versionDescription.js.map +1 -1
- package/dist/nodes/Postgres/v2/methods/listSearch.js +4 -2
- package/dist/nodes/Postgres/v2/methods/listSearch.js.map +1 -1
- package/dist/nodes/Postgres/v2/methods/loadOptions.js +2 -1
- package/dist/nodes/Postgres/v2/methods/loadOptions.js.map +1 -1
- package/dist/nodes/Postgres/v2/transport/index.js +7 -0
- package/dist/nodes/Postgres/v2/transport/index.js.map +1 -1
- package/dist/nodes/ReadBinaryFiles/test/ReadBinaryFiles.workflow.json +45 -0
- package/dist/nodes/ReadBinaryFiles/test/data/sample.json +3 -0
- package/dist/nodes/ReadBinaryFiles/test/data/sample2.json +3 -0
- package/dist/package.json +912 -0
- package/dist/types/credentials.json +5 -3
- package/dist/types/nodes.json +21 -15
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +7 -0
- package/dist/utils/constants.js.map +1 -0
- package/package.json +9 -4
- package/dist/nodes/Hubspot/CompanyDescription.js.map +0 -1
- package/dist/nodes/Hubspot/ContactDescription.js.map +0 -1
- package/dist/nodes/Hubspot/ContactListDescription.js.map +0 -1
- package/dist/nodes/Hubspot/DealDescription.js.map +0 -1
- package/dist/nodes/Hubspot/DealInterface.js.map +0 -1
- package/dist/nodes/Hubspot/EngagementDescription.js.map +0 -1
- package/dist/nodes/Hubspot/FormDescription.js.map +0 -1
- package/dist/nodes/Hubspot/FormInterface.js.map +0 -1
- package/dist/nodes/Hubspot/GenericFunctions.js.map +0 -1
- package/dist/nodes/Hubspot/TicketDescription.js.map +0 -1
- /package/dist/nodes/Hubspot/{CompanyDescription.d.ts → V1/CompanyDescription.d.ts} +0 -0
- /package/dist/nodes/Hubspot/{ContactDescription.d.ts → V1/ContactDescription.d.ts} +0 -0
- /package/dist/nodes/Hubspot/{ContactDescription.js → V1/ContactDescription.js} +0 -0
- /package/dist/nodes/Hubspot/{ContactListDescription.d.ts → V1/ContactListDescription.d.ts} +0 -0
- /package/dist/nodes/Hubspot/{ContactListDescription.js → V1/ContactListDescription.js} +0 -0
- /package/dist/nodes/Hubspot/{DealDescription.d.ts → V1/DealDescription.d.ts} +0 -0
- /package/dist/nodes/Hubspot/{DealDescription.js → V1/DealDescription.js} +0 -0
- /package/dist/nodes/Hubspot/{DealInterface.d.ts → V1/DealInterface.d.ts} +0 -0
- /package/dist/nodes/Hubspot/{DealInterface.js → V1/DealInterface.js} +0 -0
- /package/dist/nodes/Hubspot/{EngagementDescription.d.ts → V1/EngagementDescription.d.ts} +0 -0
- /package/dist/nodes/Hubspot/{EngagementDescription.js → V1/EngagementDescription.js} +0 -0
- /package/dist/nodes/Hubspot/{FormDescription.d.ts → V1/FormDescription.d.ts} +0 -0
- /package/dist/nodes/Hubspot/{FormDescription.js → V1/FormDescription.js} +0 -0
- /package/dist/nodes/Hubspot/{FormInterface.d.ts → V1/FormInterface.d.ts} +0 -0
- /package/dist/nodes/Hubspot/{FormInterface.js → V1/FormInterface.js} +0 -0
- /package/dist/nodes/Hubspot/{TicketDescription.d.ts → V1/TicketDescription.d.ts} +0 -0
- /package/dist/nodes/Hubspot/{TicketDescription.js → V1/TicketDescription.js} +0 -0
- /package/dist/nodes/Hubspot/{GenericFunctions.d.ts → V2/GenericFunctions.d.ts} +0 -0
- /package/dist/nodes/Hubspot/{GenericFunctions.js → V2/GenericFunctions.js} +0 -0
|
@@ -0,0 +1,2554 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HubspotV2 = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
6
|
+
const ContactDescription_1 = require("./ContactDescription");
|
|
7
|
+
const ContactListDescription_1 = require("./ContactListDescription");
|
|
8
|
+
const CompanyDescription_1 = require("./CompanyDescription");
|
|
9
|
+
const DealDescription_1 = require("./DealDescription");
|
|
10
|
+
const EngagementDescription_1 = require("./EngagementDescription");
|
|
11
|
+
const TicketDescription_1 = require("./TicketDescription");
|
|
12
|
+
const change_case_1 = require("change-case");
|
|
13
|
+
class HubspotV2 {
|
|
14
|
+
constructor(baseDescription) {
|
|
15
|
+
this.methods = {
|
|
16
|
+
credentialTest: {
|
|
17
|
+
async hubspotApiTest(credential) {
|
|
18
|
+
try {
|
|
19
|
+
await GenericFunctions_1.validateCredentials.call(this, credential.data);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
const err = error;
|
|
23
|
+
if (err.statusCode === 401) {
|
|
24
|
+
return {
|
|
25
|
+
status: 'Error',
|
|
26
|
+
message: 'Invalid credentials',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
status: 'OK',
|
|
32
|
+
message: 'Authentication successful',
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
loadOptions: {
|
|
37
|
+
async getContactLeadStatuses() {
|
|
38
|
+
const returnData = [];
|
|
39
|
+
const endpoint = '/properties/v2/contacts/properties';
|
|
40
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
41
|
+
for (const property of properties) {
|
|
42
|
+
if (property.name === 'hs_lead_status') {
|
|
43
|
+
for (const option of property.options) {
|
|
44
|
+
const statusName = option.label;
|
|
45
|
+
const statusId = option.value;
|
|
46
|
+
returnData.push({
|
|
47
|
+
name: statusName,
|
|
48
|
+
value: statusId,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return returnData;
|
|
54
|
+
},
|
|
55
|
+
async getContactLealBasics() {
|
|
56
|
+
const returnData = [];
|
|
57
|
+
const endpoint = '/properties/v2/contacts/properties';
|
|
58
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
59
|
+
for (const property of properties) {
|
|
60
|
+
if (property.name === 'hs_legal_basis') {
|
|
61
|
+
for (const option of property.options) {
|
|
62
|
+
const statusName = option.label;
|
|
63
|
+
const statusId = option.value;
|
|
64
|
+
returnData.push({
|
|
65
|
+
name: statusName,
|
|
66
|
+
value: statusId,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return returnData;
|
|
72
|
+
},
|
|
73
|
+
async getContactLifeCycleStages() {
|
|
74
|
+
const returnData = [];
|
|
75
|
+
const endpoint = '/properties/v2/contacts/properties';
|
|
76
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
77
|
+
for (const property of properties) {
|
|
78
|
+
if (property.name === 'lifecyclestage') {
|
|
79
|
+
for (const option of property.options) {
|
|
80
|
+
const stageName = option.label;
|
|
81
|
+
const stageId = option.value;
|
|
82
|
+
returnData.push({
|
|
83
|
+
name: stageName,
|
|
84
|
+
value: stageId,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return returnData;
|
|
90
|
+
},
|
|
91
|
+
async getContactOriginalSources() {
|
|
92
|
+
const returnData = [];
|
|
93
|
+
const endpoint = '/properties/v2/contacts/properties';
|
|
94
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
95
|
+
for (const property of properties) {
|
|
96
|
+
if (property.name === 'hs_analytics_source') {
|
|
97
|
+
for (const option of property.options) {
|
|
98
|
+
const sourceName = option.label;
|
|
99
|
+
const sourceId = option.value;
|
|
100
|
+
returnData.push({
|
|
101
|
+
name: sourceName,
|
|
102
|
+
value: sourceId,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return returnData;
|
|
108
|
+
},
|
|
109
|
+
async getContactPrefferedLanguages() {
|
|
110
|
+
const returnData = [];
|
|
111
|
+
const endpoint = '/properties/v2/contacts/properties';
|
|
112
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
113
|
+
for (const property of properties) {
|
|
114
|
+
if (property.name === 'hs_language') {
|
|
115
|
+
for (const option of property.options) {
|
|
116
|
+
const languageName = option.label;
|
|
117
|
+
const languageId = option.value;
|
|
118
|
+
returnData.push({
|
|
119
|
+
name: languageName,
|
|
120
|
+
value: languageId,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return returnData;
|
|
126
|
+
},
|
|
127
|
+
async getContactStatuses() {
|
|
128
|
+
const returnData = [];
|
|
129
|
+
const endpoint = '/properties/v2/contacts/properties';
|
|
130
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
131
|
+
for (const property of properties) {
|
|
132
|
+
if (property.name === 'hs_content_membership_status') {
|
|
133
|
+
for (const option of property.options) {
|
|
134
|
+
const languageName = option.label;
|
|
135
|
+
const languageId = option.value;
|
|
136
|
+
returnData.push({
|
|
137
|
+
name: languageName,
|
|
138
|
+
value: languageId,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return returnData;
|
|
144
|
+
},
|
|
145
|
+
async getContactProperties() {
|
|
146
|
+
const returnData = [];
|
|
147
|
+
const endpoint = '/properties/v2/contacts/properties';
|
|
148
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
149
|
+
for (const property of properties) {
|
|
150
|
+
const propertyName = property.label;
|
|
151
|
+
const propertyId = property.name;
|
|
152
|
+
returnData.push({
|
|
153
|
+
name: propertyName,
|
|
154
|
+
value: propertyId,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return returnData;
|
|
158
|
+
},
|
|
159
|
+
async getContactPropertiesWithType() {
|
|
160
|
+
const returnData = [];
|
|
161
|
+
const endpoint = '/properties/v2/contacts/properties';
|
|
162
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
163
|
+
for (const property of properties) {
|
|
164
|
+
const propertyName = property.label;
|
|
165
|
+
const propertyId = property.name;
|
|
166
|
+
const propertyType = property.type;
|
|
167
|
+
returnData.push({
|
|
168
|
+
name: propertyName,
|
|
169
|
+
value: `${propertyId}|${propertyType}`,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return returnData;
|
|
173
|
+
},
|
|
174
|
+
async getContactCustomProperties() {
|
|
175
|
+
const returnData = [];
|
|
176
|
+
const endpoint = '/properties/v2/contacts/properties';
|
|
177
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
178
|
+
for (const property of properties) {
|
|
179
|
+
if (property.hubspotDefined === null) {
|
|
180
|
+
const propertyName = property.label;
|
|
181
|
+
const propertyId = property.name;
|
|
182
|
+
returnData.push({
|
|
183
|
+
name: propertyName,
|
|
184
|
+
value: propertyId,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return returnData;
|
|
189
|
+
},
|
|
190
|
+
async getContactNumberOfEmployees() {
|
|
191
|
+
const returnData = [];
|
|
192
|
+
const endpoint = '/properties/v2/contacts/properties';
|
|
193
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
194
|
+
for (const property of properties) {
|
|
195
|
+
if (property.name === 'numemployees') {
|
|
196
|
+
for (const option of property.options) {
|
|
197
|
+
const optionName = option.label;
|
|
198
|
+
const optionId = option.value;
|
|
199
|
+
returnData.push({
|
|
200
|
+
name: optionName,
|
|
201
|
+
value: optionId,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return returnData;
|
|
207
|
+
},
|
|
208
|
+
async getCompanyIndustries() {
|
|
209
|
+
const returnData = [];
|
|
210
|
+
const endpoint = '/properties/v2/companies/properties';
|
|
211
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
212
|
+
for (const property of properties) {
|
|
213
|
+
if (property.name === 'industry') {
|
|
214
|
+
for (const option of property.options) {
|
|
215
|
+
const industryName = option.label;
|
|
216
|
+
const industryId = option.value;
|
|
217
|
+
returnData.push({
|
|
218
|
+
name: industryName,
|
|
219
|
+
value: industryId,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return returnData;
|
|
225
|
+
},
|
|
226
|
+
async getCompanyleadStatuses() {
|
|
227
|
+
const returnData = [];
|
|
228
|
+
const endpoint = '/properties/v2/companies/properties';
|
|
229
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
230
|
+
for (const property of properties) {
|
|
231
|
+
if (property.name === 'hs_lead_status') {
|
|
232
|
+
for (const option of property.options) {
|
|
233
|
+
const statusName = option.label;
|
|
234
|
+
const statusId = option.value;
|
|
235
|
+
returnData.push({
|
|
236
|
+
name: statusName,
|
|
237
|
+
value: statusId,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return returnData;
|
|
243
|
+
},
|
|
244
|
+
async getCompanylifecycleStages() {
|
|
245
|
+
const returnData = [];
|
|
246
|
+
const endpoint = '/properties/v2/companies/properties';
|
|
247
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
248
|
+
for (const property of properties) {
|
|
249
|
+
if (property.name === 'lifecyclestage') {
|
|
250
|
+
for (const option of property.options) {
|
|
251
|
+
const stageName = option.label;
|
|
252
|
+
const stageId = option.value;
|
|
253
|
+
returnData.push({
|
|
254
|
+
name: stageName,
|
|
255
|
+
value: stageId,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return returnData;
|
|
261
|
+
},
|
|
262
|
+
async getCompanyTypes() {
|
|
263
|
+
const returnData = [];
|
|
264
|
+
const endpoint = '/properties/v2/companies/properties';
|
|
265
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
266
|
+
for (const property of properties) {
|
|
267
|
+
if (property.name === 'type') {
|
|
268
|
+
for (const option of property.options) {
|
|
269
|
+
const typeName = option.label;
|
|
270
|
+
const typeId = option.value;
|
|
271
|
+
returnData.push({
|
|
272
|
+
name: typeName,
|
|
273
|
+
value: typeId,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return returnData;
|
|
279
|
+
},
|
|
280
|
+
async getCompanyTargetAccounts() {
|
|
281
|
+
const returnData = [];
|
|
282
|
+
const endpoint = '/properties/v2/companies/properties';
|
|
283
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
284
|
+
for (const property of properties) {
|
|
285
|
+
if (property.name === 'hs_target_account') {
|
|
286
|
+
for (const option of property.options) {
|
|
287
|
+
const targetName = option.label;
|
|
288
|
+
const targetId = option.value;
|
|
289
|
+
returnData.push({
|
|
290
|
+
name: targetName,
|
|
291
|
+
value: targetId,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return returnData;
|
|
297
|
+
},
|
|
298
|
+
async getCompanySourceTypes() {
|
|
299
|
+
const returnData = [];
|
|
300
|
+
const endpoint = '/properties/v2/companies/properties';
|
|
301
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
302
|
+
for (const property of properties) {
|
|
303
|
+
if (property.name === 'hs_analytics_source') {
|
|
304
|
+
for (const option of property.options) {
|
|
305
|
+
const typeName = option.label;
|
|
306
|
+
const typeId = option.value;
|
|
307
|
+
returnData.push({
|
|
308
|
+
name: typeName,
|
|
309
|
+
value: typeId,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return returnData;
|
|
315
|
+
},
|
|
316
|
+
async getCompanyWebTechnologies() {
|
|
317
|
+
const returnData = [];
|
|
318
|
+
const endpoint = '/properties/v2/companies/properties';
|
|
319
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
320
|
+
for (const property of properties) {
|
|
321
|
+
if (property.name === 'web_technologies') {
|
|
322
|
+
for (const option of property.options) {
|
|
323
|
+
const technologyName = option.label;
|
|
324
|
+
const technologyId = option.value;
|
|
325
|
+
returnData.push({
|
|
326
|
+
name: technologyName,
|
|
327
|
+
value: technologyId,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return returnData;
|
|
333
|
+
},
|
|
334
|
+
async getCompanyProperties() {
|
|
335
|
+
const returnData = [];
|
|
336
|
+
const endpoint = '/properties/v2/companies/properties';
|
|
337
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
338
|
+
for (const property of properties) {
|
|
339
|
+
const propertyName = property.label;
|
|
340
|
+
const propertyId = property.name;
|
|
341
|
+
returnData.push({
|
|
342
|
+
name: propertyName,
|
|
343
|
+
value: propertyId,
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
return returnData;
|
|
347
|
+
},
|
|
348
|
+
async getCompanyCustomProperties() {
|
|
349
|
+
const returnData = [];
|
|
350
|
+
const endpoint = '/properties/v2/companies/properties';
|
|
351
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
352
|
+
for (const property of properties) {
|
|
353
|
+
if (property.hubspotDefined === null) {
|
|
354
|
+
const propertyName = property.label;
|
|
355
|
+
const propertyId = property.name;
|
|
356
|
+
returnData.push({
|
|
357
|
+
name: propertyName,
|
|
358
|
+
value: propertyId,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return returnData;
|
|
363
|
+
},
|
|
364
|
+
async getDealStages() {
|
|
365
|
+
const returnData = [];
|
|
366
|
+
const endpoint = '/crm-pipelines/v1/pipelines/deals';
|
|
367
|
+
let stages = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
368
|
+
stages = stages.results[0].stages;
|
|
369
|
+
for (const stage of stages) {
|
|
370
|
+
const stageName = stage.label;
|
|
371
|
+
const stageId = stage.stageId;
|
|
372
|
+
returnData.push({
|
|
373
|
+
name: stageName,
|
|
374
|
+
value: stageId,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
return returnData;
|
|
378
|
+
},
|
|
379
|
+
async getDealTypes() {
|
|
380
|
+
const returnData = [];
|
|
381
|
+
const endpoint = '/properties/v1/deals/properties/named/dealtype';
|
|
382
|
+
const dealTypes = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint);
|
|
383
|
+
for (const dealType of dealTypes.options) {
|
|
384
|
+
const dealTypeName = dealType.label;
|
|
385
|
+
const dealTypeId = dealType.value;
|
|
386
|
+
returnData.push({
|
|
387
|
+
name: dealTypeName,
|
|
388
|
+
value: dealTypeId,
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
return returnData;
|
|
392
|
+
},
|
|
393
|
+
async getDealCustomProperties() {
|
|
394
|
+
const returnData = [];
|
|
395
|
+
const endpoint = '/properties/v2/deals/properties';
|
|
396
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
397
|
+
for (const property of properties) {
|
|
398
|
+
if (property.hubspotDefined === null) {
|
|
399
|
+
const propertyName = property.label;
|
|
400
|
+
const propertyId = property.name;
|
|
401
|
+
returnData.push({
|
|
402
|
+
name: propertyName,
|
|
403
|
+
value: propertyId,
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return returnData;
|
|
408
|
+
},
|
|
409
|
+
async getDealProperties() {
|
|
410
|
+
const returnData = [];
|
|
411
|
+
const endpoint = '/properties/v2/deals/properties';
|
|
412
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
413
|
+
for (const property of properties) {
|
|
414
|
+
const propertyName = property.label;
|
|
415
|
+
const propertyId = property.name;
|
|
416
|
+
returnData.push({
|
|
417
|
+
name: propertyName,
|
|
418
|
+
value: propertyId,
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
return returnData;
|
|
422
|
+
},
|
|
423
|
+
async getDealPropertiesWithType() {
|
|
424
|
+
const returnData = [];
|
|
425
|
+
const endpoint = '/properties/v2/deals/properties';
|
|
426
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
427
|
+
for (const property of properties) {
|
|
428
|
+
const propertyName = property.label;
|
|
429
|
+
const propertyId = property.name;
|
|
430
|
+
const propertyType = property.type;
|
|
431
|
+
returnData.push({
|
|
432
|
+
name: propertyName,
|
|
433
|
+
value: `${propertyId}|${propertyType}`,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
return returnData;
|
|
437
|
+
},
|
|
438
|
+
async getDealPipelines() {
|
|
439
|
+
const returnData = [];
|
|
440
|
+
const endpoint = '/crm/v3/pipelines/deals';
|
|
441
|
+
const data = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
442
|
+
for (const pipeline of data.results) {
|
|
443
|
+
returnData.push({
|
|
444
|
+
name: pipeline.label,
|
|
445
|
+
value: pipeline.id,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
return returnData;
|
|
449
|
+
},
|
|
450
|
+
async getForms() {
|
|
451
|
+
const returnData = [];
|
|
452
|
+
const endpoint = '/forms/v2/forms';
|
|
453
|
+
const forms = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, { formTypes: 'ALL' });
|
|
454
|
+
for (const form of forms) {
|
|
455
|
+
const formName = form.name;
|
|
456
|
+
const formId = form.guid;
|
|
457
|
+
returnData.push({
|
|
458
|
+
name: formName,
|
|
459
|
+
value: formId,
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
return returnData;
|
|
463
|
+
},
|
|
464
|
+
async getSubscriptionTypes() {
|
|
465
|
+
const returnData = [];
|
|
466
|
+
const endpoint = '/email/public/v1/subscriptions';
|
|
467
|
+
const subscriptions = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'subscriptionDefinitions', 'GET', endpoint, {});
|
|
468
|
+
for (const subscription of subscriptions) {
|
|
469
|
+
const subscriptionName = subscription.name;
|
|
470
|
+
const subscriptionId = subscription.id;
|
|
471
|
+
returnData.push({
|
|
472
|
+
name: subscriptionName,
|
|
473
|
+
value: subscriptionId,
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
return returnData;
|
|
477
|
+
},
|
|
478
|
+
async getTicketCategories() {
|
|
479
|
+
const returnData = [];
|
|
480
|
+
const endpoint = '/properties/v2/tickets/properties';
|
|
481
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
482
|
+
for (const property of properties) {
|
|
483
|
+
if (property.name === 'hs_ticket_category') {
|
|
484
|
+
for (const option of property.options) {
|
|
485
|
+
const categoryName = option.label;
|
|
486
|
+
const categoryId = option.value;
|
|
487
|
+
returnData.push({
|
|
488
|
+
name: categoryName,
|
|
489
|
+
value: categoryId,
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return returnData.sort((a, b) => (a.name < b.name ? 0 : 1));
|
|
495
|
+
},
|
|
496
|
+
async getTicketPipelines() {
|
|
497
|
+
const returnData = [];
|
|
498
|
+
const endpoint = '/crm-pipelines/v1/pipelines/tickets';
|
|
499
|
+
const { results } = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
500
|
+
for (const pipeline of results) {
|
|
501
|
+
const pipelineName = pipeline.label;
|
|
502
|
+
const pipelineId = pipeline.pipelineId;
|
|
503
|
+
returnData.push({
|
|
504
|
+
name: pipelineName,
|
|
505
|
+
value: pipelineId,
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
return returnData;
|
|
509
|
+
},
|
|
510
|
+
async getTicketPriorities() {
|
|
511
|
+
const returnData = [];
|
|
512
|
+
const endpoint = '/properties/v2/tickets/properties';
|
|
513
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
514
|
+
for (const property of properties) {
|
|
515
|
+
if (property.name === 'hs_ticket_priority') {
|
|
516
|
+
for (const option of property.options) {
|
|
517
|
+
const priorityName = option.label;
|
|
518
|
+
const priorityId = option.value;
|
|
519
|
+
returnData.push({
|
|
520
|
+
name: priorityName,
|
|
521
|
+
value: priorityId,
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return returnData;
|
|
527
|
+
},
|
|
528
|
+
async getTicketProperties() {
|
|
529
|
+
const returnData = [];
|
|
530
|
+
const endpoint = '/properties/v2/tickets/properties';
|
|
531
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
532
|
+
for (const property of properties) {
|
|
533
|
+
const propertyName = property.label;
|
|
534
|
+
const propertyId = property.name;
|
|
535
|
+
returnData.push({
|
|
536
|
+
name: propertyName,
|
|
537
|
+
value: propertyId,
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
return returnData;
|
|
541
|
+
},
|
|
542
|
+
async getTicketResolutions() {
|
|
543
|
+
const returnData = [];
|
|
544
|
+
const endpoint = '/properties/v2/tickets/properties';
|
|
545
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
546
|
+
for (const property of properties) {
|
|
547
|
+
if (property.name === 'hs_resolution') {
|
|
548
|
+
for (const option of property.options) {
|
|
549
|
+
const resolutionName = option.label;
|
|
550
|
+
const resolutionId = option.value;
|
|
551
|
+
returnData.push({
|
|
552
|
+
name: resolutionName,
|
|
553
|
+
value: resolutionId,
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return returnData.sort((a, b) => (a.name < b.name ? 0 : 1));
|
|
559
|
+
},
|
|
560
|
+
async getTicketSources() {
|
|
561
|
+
const returnData = [];
|
|
562
|
+
const endpoint = '/properties/v2/tickets/properties';
|
|
563
|
+
const properties = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
564
|
+
for (const property of properties) {
|
|
565
|
+
if (property.name === 'source_type') {
|
|
566
|
+
for (const option of property.options) {
|
|
567
|
+
const sourceName = option.label;
|
|
568
|
+
const sourceId = option.value;
|
|
569
|
+
returnData.push({
|
|
570
|
+
name: sourceName,
|
|
571
|
+
value: sourceId,
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return returnData.sort((a, b) => (a.name < b.name ? 0 : 1));
|
|
577
|
+
},
|
|
578
|
+
async getTicketStages() {
|
|
579
|
+
let currentPipelineId = this.getCurrentNodeParameter('pipelineId');
|
|
580
|
+
if (currentPipelineId === undefined) {
|
|
581
|
+
currentPipelineId = this.getNodeParameter('updateFields.pipelineId', '');
|
|
582
|
+
}
|
|
583
|
+
const returnData = [];
|
|
584
|
+
const endpoint = '/crm-pipelines/v1/pipelines/tickets';
|
|
585
|
+
const { results } = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
586
|
+
for (const pipeline of results) {
|
|
587
|
+
if (currentPipelineId === pipeline.pipelineId) {
|
|
588
|
+
for (const stage of pipeline.stages) {
|
|
589
|
+
const stageName = stage.label;
|
|
590
|
+
const stageId = stage.stageId;
|
|
591
|
+
returnData.push({
|
|
592
|
+
name: stageName,
|
|
593
|
+
value: stageId,
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return returnData;
|
|
599
|
+
},
|
|
600
|
+
async getOwners() {
|
|
601
|
+
const returnData = [];
|
|
602
|
+
const endpoint = '/owners/v2/owners';
|
|
603
|
+
const owners = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint);
|
|
604
|
+
for (const owner of owners) {
|
|
605
|
+
const ownerName = owner.email;
|
|
606
|
+
const ownerId = owner.ownerId;
|
|
607
|
+
returnData.push({
|
|
608
|
+
name: ownerName,
|
|
609
|
+
value: ownerId,
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
return returnData;
|
|
613
|
+
},
|
|
614
|
+
async getCompanies() {
|
|
615
|
+
const returnData = [];
|
|
616
|
+
const qs = {
|
|
617
|
+
properties: ['name'],
|
|
618
|
+
};
|
|
619
|
+
const endpoint = '/companies/v2/companies/paged';
|
|
620
|
+
const companies = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'companies', 'GET', endpoint, {}, qs);
|
|
621
|
+
for (const company of companies) {
|
|
622
|
+
const companyName = company.properties.name
|
|
623
|
+
? company.properties.name.value
|
|
624
|
+
: company.companyId;
|
|
625
|
+
const companyId = company.companyId;
|
|
626
|
+
returnData.push({
|
|
627
|
+
name: companyName,
|
|
628
|
+
value: companyId,
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
return returnData.sort((a, b) => (a.name < b.name ? 0 : 1));
|
|
632
|
+
},
|
|
633
|
+
async getContacts() {
|
|
634
|
+
var _a, _b, _c, _d;
|
|
635
|
+
const returnData = [];
|
|
636
|
+
const endpoint = '/contacts/v1/lists/all/contacts/all';
|
|
637
|
+
const contacts = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint);
|
|
638
|
+
for (const contact of contacts) {
|
|
639
|
+
const firstName = ((_b = (_a = contact.properties) === null || _a === void 0 ? void 0 : _a.firstname) === null || _b === void 0 ? void 0 : _b.value) || '';
|
|
640
|
+
const lastName = ((_d = (_c = contact.properties) === null || _c === void 0 ? void 0 : _c.lastname) === null || _d === void 0 ? void 0 : _d.value) || '';
|
|
641
|
+
const contactName = `${firstName} ${lastName}`;
|
|
642
|
+
const contactId = contact.vid;
|
|
643
|
+
returnData.push({
|
|
644
|
+
name: contactName,
|
|
645
|
+
value: contactId,
|
|
646
|
+
description: `Contact VID: ${contactId}`,
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
return returnData.sort((a, b) => (a.name < b.name ? 0 : 1));
|
|
650
|
+
},
|
|
651
|
+
},
|
|
652
|
+
listSearch: {
|
|
653
|
+
async searchCompanies() {
|
|
654
|
+
const qs = {
|
|
655
|
+
properties: ['name'],
|
|
656
|
+
};
|
|
657
|
+
const endpoint = '/companies/v2/companies/paged';
|
|
658
|
+
const searchResults = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'companies', 'GET', endpoint, {}, qs);
|
|
659
|
+
return {
|
|
660
|
+
results: searchResults.map((b) => {
|
|
661
|
+
var _a, _b;
|
|
662
|
+
return ({
|
|
663
|
+
name: ((_b = (_a = b.properties) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.value) || b.companyId,
|
|
664
|
+
value: b.companyId,
|
|
665
|
+
});
|
|
666
|
+
}),
|
|
667
|
+
};
|
|
668
|
+
},
|
|
669
|
+
async searchContacts(filter) {
|
|
670
|
+
const endpoint = '/contacts/v1/lists/all/contacts/all';
|
|
671
|
+
const qs = {
|
|
672
|
+
property: ['email'],
|
|
673
|
+
};
|
|
674
|
+
const contacts = (await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint, {}, qs));
|
|
675
|
+
const results = contacts
|
|
676
|
+
.map((c) => ({
|
|
677
|
+
name: c.properties.email.value || c.vid,
|
|
678
|
+
value: c.vid,
|
|
679
|
+
}))
|
|
680
|
+
.filter((c) => {
|
|
681
|
+
var _a;
|
|
682
|
+
return !filter ||
|
|
683
|
+
c.name.toLowerCase().includes(filter.toLowerCase()) ||
|
|
684
|
+
((_a = c.value) === null || _a === void 0 ? void 0 : _a.toString()) === filter;
|
|
685
|
+
})
|
|
686
|
+
.sort((a, b) => {
|
|
687
|
+
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
|
|
688
|
+
});
|
|
689
|
+
return { results };
|
|
690
|
+
},
|
|
691
|
+
async searchDeals(filter) {
|
|
692
|
+
const endpoint = '/deals/v1/deal/paged';
|
|
693
|
+
const qs = {
|
|
694
|
+
properties: ['dealname'],
|
|
695
|
+
};
|
|
696
|
+
const deals = (await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'deals', 'GET', endpoint, {}, qs));
|
|
697
|
+
const results = deals
|
|
698
|
+
.map((c) => {
|
|
699
|
+
var _a, _b;
|
|
700
|
+
return ({
|
|
701
|
+
name: ((_b = (_a = c.properties) === null || _a === void 0 ? void 0 : _a.dealname) === null || _b === void 0 ? void 0 : _b.value) || c.dealId,
|
|
702
|
+
value: c.dealId,
|
|
703
|
+
});
|
|
704
|
+
})
|
|
705
|
+
.filter((c) => {
|
|
706
|
+
var _a;
|
|
707
|
+
return !filter ||
|
|
708
|
+
c.name.toString().toLowerCase().includes(filter.toString().toLowerCase()) ||
|
|
709
|
+
((_a = c.value) === null || _a === void 0 ? void 0 : _a.toString()) === filter;
|
|
710
|
+
})
|
|
711
|
+
.sort((a, b) => {
|
|
712
|
+
return a.name.toString().toLowerCase() < b.name.toString().toLowerCase() ? -1 : 1;
|
|
713
|
+
});
|
|
714
|
+
return {
|
|
715
|
+
results,
|
|
716
|
+
};
|
|
717
|
+
},
|
|
718
|
+
async searchEngagements() {
|
|
719
|
+
const endpoint = '/engagements/v1/engagements/paged';
|
|
720
|
+
const qs = {
|
|
721
|
+
properties: ['name'],
|
|
722
|
+
};
|
|
723
|
+
const engagements = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
724
|
+
return {
|
|
725
|
+
results: engagements.results.map((b) => {
|
|
726
|
+
var _a, _b, _c, _d;
|
|
727
|
+
return ({
|
|
728
|
+
name: ((_b = (_a = b.properties) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.value) || ((_c = b.engagement) === null || _c === void 0 ? void 0 : _c.type)
|
|
729
|
+
? `${(_d = b.engagement) === null || _d === void 0 ? void 0 : _d.type}: ${b.engagement.id}`
|
|
730
|
+
: b.engagement.id,
|
|
731
|
+
value: b.engagement.id,
|
|
732
|
+
});
|
|
733
|
+
}),
|
|
734
|
+
};
|
|
735
|
+
},
|
|
736
|
+
async searchTickets() {
|
|
737
|
+
const endpoint = '/crm-objects/v1/objects/tickets/paged';
|
|
738
|
+
const qs = {
|
|
739
|
+
properties: ['ticket_name'],
|
|
740
|
+
};
|
|
741
|
+
const tickets = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'objects', 'GET', endpoint, {}, qs);
|
|
742
|
+
return {
|
|
743
|
+
results: tickets.map((b) => ({
|
|
744
|
+
name: b.objectId,
|
|
745
|
+
value: b.objectId,
|
|
746
|
+
})),
|
|
747
|
+
};
|
|
748
|
+
},
|
|
749
|
+
async searchOwners() {
|
|
750
|
+
const endpoint = '/owners/v2/owners';
|
|
751
|
+
const owners = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {});
|
|
752
|
+
return {
|
|
753
|
+
results: owners.map((b) => ({
|
|
754
|
+
name: b.email,
|
|
755
|
+
value: b.ownerId,
|
|
756
|
+
})),
|
|
757
|
+
};
|
|
758
|
+
},
|
|
759
|
+
},
|
|
760
|
+
};
|
|
761
|
+
this.description = {
|
|
762
|
+
...baseDescription,
|
|
763
|
+
group: ['output'],
|
|
764
|
+
version: 2,
|
|
765
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
766
|
+
defaults: {
|
|
767
|
+
name: 'HubSpot',
|
|
768
|
+
},
|
|
769
|
+
inputs: ['main'],
|
|
770
|
+
outputs: ['main'],
|
|
771
|
+
credentials: [
|
|
772
|
+
{
|
|
773
|
+
name: 'hubspotApi',
|
|
774
|
+
required: true,
|
|
775
|
+
testedBy: 'hubspotApiTest',
|
|
776
|
+
displayOptions: {
|
|
777
|
+
show: {
|
|
778
|
+
authentication: ['apiKey'],
|
|
779
|
+
},
|
|
780
|
+
},
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
name: 'hubspotAppToken',
|
|
784
|
+
required: true,
|
|
785
|
+
testedBy: 'hubspotApiTest',
|
|
786
|
+
displayOptions: {
|
|
787
|
+
show: {
|
|
788
|
+
authentication: ['appToken'],
|
|
789
|
+
},
|
|
790
|
+
},
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
name: 'hubspotOAuth2Api',
|
|
794
|
+
required: true,
|
|
795
|
+
displayOptions: {
|
|
796
|
+
show: {
|
|
797
|
+
authentication: ['oAuth2'],
|
|
798
|
+
},
|
|
799
|
+
},
|
|
800
|
+
},
|
|
801
|
+
],
|
|
802
|
+
properties: [
|
|
803
|
+
{
|
|
804
|
+
displayName: 'Authentication',
|
|
805
|
+
name: 'authentication',
|
|
806
|
+
type: 'options',
|
|
807
|
+
options: [
|
|
808
|
+
{
|
|
809
|
+
name: 'API Key',
|
|
810
|
+
value: 'apiKey',
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
name: 'APP Token',
|
|
814
|
+
value: 'appToken',
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
name: 'OAuth2',
|
|
818
|
+
value: 'oAuth2',
|
|
819
|
+
},
|
|
820
|
+
],
|
|
821
|
+
default: 'apiKey',
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
displayName: 'Resource',
|
|
825
|
+
name: 'resource',
|
|
826
|
+
type: 'options',
|
|
827
|
+
noDataExpression: true,
|
|
828
|
+
options: [
|
|
829
|
+
{
|
|
830
|
+
name: 'Company',
|
|
831
|
+
value: 'company',
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
name: 'Contact',
|
|
835
|
+
value: 'contact',
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
name: 'Contact List',
|
|
839
|
+
value: 'contactList',
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
name: 'Deal',
|
|
843
|
+
value: 'deal',
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
name: 'Engagement',
|
|
847
|
+
value: 'engagement',
|
|
848
|
+
},
|
|
849
|
+
{
|
|
850
|
+
name: 'Ticket',
|
|
851
|
+
value: 'ticket',
|
|
852
|
+
},
|
|
853
|
+
],
|
|
854
|
+
default: 'contact',
|
|
855
|
+
},
|
|
856
|
+
...ContactDescription_1.contactOperations,
|
|
857
|
+
...ContactDescription_1.contactFields,
|
|
858
|
+
...ContactListDescription_1.contactListOperations,
|
|
859
|
+
...ContactListDescription_1.contactListFields,
|
|
860
|
+
...CompanyDescription_1.companyOperations,
|
|
861
|
+
...CompanyDescription_1.companyFields,
|
|
862
|
+
...DealDescription_1.dealOperations,
|
|
863
|
+
...DealDescription_1.dealFields,
|
|
864
|
+
...EngagementDescription_1.engagementOperations,
|
|
865
|
+
...EngagementDescription_1.engagementFields,
|
|
866
|
+
...TicketDescription_1.ticketOperations,
|
|
867
|
+
...TicketDescription_1.ticketFields,
|
|
868
|
+
],
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
async execute() {
|
|
872
|
+
var _a, _b, _c, _d, _e;
|
|
873
|
+
const items = this.getInputData();
|
|
874
|
+
const returnData = [];
|
|
875
|
+
const length = items.length;
|
|
876
|
+
let responseData;
|
|
877
|
+
const qs = {};
|
|
878
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
879
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
880
|
+
if (resource === 'contactList') {
|
|
881
|
+
try {
|
|
882
|
+
if (operation === 'add') {
|
|
883
|
+
const listId = this.getNodeParameter('listId', 0);
|
|
884
|
+
const by = this.getNodeParameter('by', 0);
|
|
885
|
+
const body = { emails: [], vids: [] };
|
|
886
|
+
for (let i = 0; i < length; i++) {
|
|
887
|
+
if (by === 'id') {
|
|
888
|
+
const id = this.getNodeParameter('id', i);
|
|
889
|
+
body.vids.push(parseInt(id, 10));
|
|
890
|
+
}
|
|
891
|
+
else {
|
|
892
|
+
const email = this.getNodeParameter('email', i);
|
|
893
|
+
body.emails.push(email);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', `/contacts/v1/lists/${listId}/add`, body);
|
|
897
|
+
returnData.push.apply(returnData, responseData);
|
|
898
|
+
}
|
|
899
|
+
if (operation === 'remove') {
|
|
900
|
+
const listId = this.getNodeParameter('listId', 0);
|
|
901
|
+
const body = { vids: [] };
|
|
902
|
+
for (let i = 0; i < length; i++) {
|
|
903
|
+
const id = this.getNodeParameter('id', i);
|
|
904
|
+
body.vids.push(parseInt(id, 10));
|
|
905
|
+
}
|
|
906
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', `/contacts/v1/lists/${listId}/remove`, body);
|
|
907
|
+
returnData.push.apply(returnData, responseData);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
catch (error) {
|
|
911
|
+
if (this.continueOnFail()) {
|
|
912
|
+
returnData.push({ json: { error: error.message } });
|
|
913
|
+
}
|
|
914
|
+
else {
|
|
915
|
+
throw error;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
else {
|
|
920
|
+
for (let i = 0; i < length; i++) {
|
|
921
|
+
try {
|
|
922
|
+
if (resource === 'contact') {
|
|
923
|
+
if (operation === 'upsert') {
|
|
924
|
+
const email = this.getNodeParameter('email', i);
|
|
925
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
926
|
+
const options = this.getNodeParameter('options', i);
|
|
927
|
+
const body = [];
|
|
928
|
+
if (additionalFields.annualRevenue) {
|
|
929
|
+
body.push({
|
|
930
|
+
property: 'annualrevenue',
|
|
931
|
+
value: additionalFields.annualRevenue.toString(),
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
if (additionalFields.city) {
|
|
935
|
+
body.push({
|
|
936
|
+
property: 'city',
|
|
937
|
+
value: additionalFields.city,
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
if (additionalFields.clickedFacebookAd) {
|
|
941
|
+
body.push({
|
|
942
|
+
property: 'hs_facebook_ad_clicked',
|
|
943
|
+
value: additionalFields.clickedFacebookAd,
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
if (additionalFields.closeDate) {
|
|
947
|
+
body.push({
|
|
948
|
+
property: 'closedate',
|
|
949
|
+
value: new Date(additionalFields.closeDate).getTime(),
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
if (additionalFields.companyName) {
|
|
953
|
+
body.push({
|
|
954
|
+
property: 'company',
|
|
955
|
+
value: additionalFields.companyName,
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
if (additionalFields.companySize) {
|
|
959
|
+
body.push({
|
|
960
|
+
property: 'company_size',
|
|
961
|
+
value: additionalFields.companySize,
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
if (additionalFields.description) {
|
|
965
|
+
body.push({
|
|
966
|
+
property: 'description',
|
|
967
|
+
value: additionalFields.description,
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
if (additionalFields.contactOwner) {
|
|
971
|
+
body.push({
|
|
972
|
+
property: 'hubspot_owner_id',
|
|
973
|
+
value: additionalFields.contactOwner,
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
if (additionalFields.country) {
|
|
977
|
+
body.push({
|
|
978
|
+
property: 'country',
|
|
979
|
+
value: additionalFields.country,
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
if (additionalFields.dateOfBirth) {
|
|
983
|
+
body.push({
|
|
984
|
+
property: 'date_of_birth',
|
|
985
|
+
value: additionalFields.dateOfBirth,
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
if (additionalFields.degree) {
|
|
989
|
+
body.push({
|
|
990
|
+
property: 'degree',
|
|
991
|
+
value: additionalFields.degree,
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
if (additionalFields.facebookClickId) {
|
|
995
|
+
body.push({
|
|
996
|
+
property: 'hs_facebook_click_id',
|
|
997
|
+
value: additionalFields.facebookClickId,
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
if (additionalFields.faxNumber) {
|
|
1001
|
+
body.push({
|
|
1002
|
+
property: 'fax',
|
|
1003
|
+
value: additionalFields.faxNumber,
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
if (additionalFields.fieldOfStudy) {
|
|
1007
|
+
body.push({
|
|
1008
|
+
property: 'field_of_study',
|
|
1009
|
+
value: additionalFields.fieldOfStudy,
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
if (additionalFields.firstName) {
|
|
1013
|
+
body.push({
|
|
1014
|
+
property: 'firstname',
|
|
1015
|
+
value: additionalFields.firstName,
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
if (additionalFields.gender) {
|
|
1019
|
+
body.push({
|
|
1020
|
+
property: 'gender',
|
|
1021
|
+
value: additionalFields.gender,
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
if (additionalFields.googleAdClickId) {
|
|
1025
|
+
body.push({
|
|
1026
|
+
property: 'hs_google_click_id',
|
|
1027
|
+
value: additionalFields.googleAdClickId,
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
if (additionalFields.graduationDate) {
|
|
1031
|
+
body.push({
|
|
1032
|
+
property: 'graduation_date',
|
|
1033
|
+
value: additionalFields.graduationDate,
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
if (additionalFields.industry) {
|
|
1037
|
+
body.push({
|
|
1038
|
+
property: 'industry',
|
|
1039
|
+
value: additionalFields.industry,
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
if (additionalFields.jobFunction) {
|
|
1043
|
+
body.push({
|
|
1044
|
+
property: 'job_function',
|
|
1045
|
+
value: additionalFields.jobFunction,
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
if (additionalFields.jobTitle) {
|
|
1049
|
+
body.push({
|
|
1050
|
+
property: 'jobtitle',
|
|
1051
|
+
value: additionalFields.jobTitle,
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
if (additionalFields.lastName) {
|
|
1055
|
+
body.push({
|
|
1056
|
+
property: 'lastname',
|
|
1057
|
+
value: additionalFields.lastName,
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
if (additionalFields.leadStatus) {
|
|
1061
|
+
body.push({
|
|
1062
|
+
property: 'hs_lead_status',
|
|
1063
|
+
value: additionalFields.leadStatus,
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
if (additionalFields.processingContactData) {
|
|
1067
|
+
body.push({
|
|
1068
|
+
property: 'hs_legal_basis',
|
|
1069
|
+
value: additionalFields.processingContactData,
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
if (additionalFields.lifeCycleStage) {
|
|
1073
|
+
body.push({
|
|
1074
|
+
property: 'lifecyclestage',
|
|
1075
|
+
value: additionalFields.lifeCycleStage,
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
if (additionalFields.maritalStatus) {
|
|
1079
|
+
body.push({
|
|
1080
|
+
property: 'marital_status',
|
|
1081
|
+
value: additionalFields.maritalStatus,
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
if (additionalFields.membershipNote) {
|
|
1085
|
+
body.push({
|
|
1086
|
+
property: 'hs_content_membership_notes',
|
|
1087
|
+
value: additionalFields.membershipNote,
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
if (additionalFields.message) {
|
|
1091
|
+
body.push({
|
|
1092
|
+
property: 'message',
|
|
1093
|
+
value: additionalFields.message,
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
if (additionalFields.mobilePhoneNumber) {
|
|
1097
|
+
body.push({
|
|
1098
|
+
property: 'mobilephone',
|
|
1099
|
+
value: additionalFields.mobilePhoneNumber,
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
if (additionalFields.numberOfEmployees) {
|
|
1103
|
+
body.push({
|
|
1104
|
+
property: 'numemployees',
|
|
1105
|
+
value: additionalFields.numberOfEmployees,
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
if (additionalFields.originalSource) {
|
|
1109
|
+
body.push({
|
|
1110
|
+
property: 'hs_analytics_source',
|
|
1111
|
+
value: additionalFields.originalSource,
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
if (additionalFields.phoneNumber) {
|
|
1115
|
+
body.push({
|
|
1116
|
+
property: 'phone',
|
|
1117
|
+
value: additionalFields.phoneNumber,
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
if (additionalFields.postalCode) {
|
|
1121
|
+
body.push({
|
|
1122
|
+
property: 'zip',
|
|
1123
|
+
value: additionalFields.postalCode,
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
if (additionalFields.prefferedLanguage) {
|
|
1127
|
+
body.push({
|
|
1128
|
+
property: 'hs_language',
|
|
1129
|
+
value: additionalFields.prefferedLanguage,
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
if (additionalFields.relationshipStatus) {
|
|
1133
|
+
body.push({
|
|
1134
|
+
property: 'relationship_status',
|
|
1135
|
+
value: additionalFields.relationshipStatus,
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
if (additionalFields.salutation) {
|
|
1139
|
+
body.push({
|
|
1140
|
+
property: 'salutation',
|
|
1141
|
+
value: additionalFields.salutation,
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
if (additionalFields.school) {
|
|
1145
|
+
body.push({
|
|
1146
|
+
property: 'school',
|
|
1147
|
+
value: additionalFields.school,
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
if (additionalFields.seniority) {
|
|
1151
|
+
body.push({
|
|
1152
|
+
property: 'seniority',
|
|
1153
|
+
value: additionalFields.seniority,
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
if (additionalFields.startDate) {
|
|
1157
|
+
body.push({
|
|
1158
|
+
property: 'start_date',
|
|
1159
|
+
value: additionalFields.startDate,
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
if (additionalFields.stateRegion) {
|
|
1163
|
+
body.push({
|
|
1164
|
+
property: 'state',
|
|
1165
|
+
value: additionalFields.stateRegion,
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
if (additionalFields.status) {
|
|
1169
|
+
body.push({
|
|
1170
|
+
property: 'hs_content_membership_status',
|
|
1171
|
+
value: additionalFields.status,
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
if (additionalFields.streetAddress) {
|
|
1175
|
+
body.push({
|
|
1176
|
+
property: 'address',
|
|
1177
|
+
value: additionalFields.streetAddress,
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
if (additionalFields.twitterUsername) {
|
|
1181
|
+
body.push({
|
|
1182
|
+
property: 'twitterhandle',
|
|
1183
|
+
value: additionalFields.twitterUsername,
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
if (additionalFields.websiteUrl) {
|
|
1187
|
+
body.push({
|
|
1188
|
+
property: 'website',
|
|
1189
|
+
value: additionalFields.websiteUrl,
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
if (additionalFields.workEmail) {
|
|
1193
|
+
body.push({
|
|
1194
|
+
property: 'work_email',
|
|
1195
|
+
value: additionalFields.workEmail,
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
if (additionalFields.customPropertiesUi) {
|
|
1199
|
+
const customProperties = additionalFields.customPropertiesUi
|
|
1200
|
+
.customPropertiesValues;
|
|
1201
|
+
if (customProperties) {
|
|
1202
|
+
for (const customProperty of customProperties) {
|
|
1203
|
+
body.push({
|
|
1204
|
+
property: customProperty.property,
|
|
1205
|
+
value: customProperty.value,
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
const endpoint = `/contacts/v1/contact/createOrUpdate/email/${email}`;
|
|
1211
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', endpoint, {
|
|
1212
|
+
properties: body,
|
|
1213
|
+
});
|
|
1214
|
+
if (additionalFields.associatedCompanyId) {
|
|
1215
|
+
const companyAssociations = [];
|
|
1216
|
+
companyAssociations.push({
|
|
1217
|
+
fromObjectId: responseData.vid,
|
|
1218
|
+
toObjectId: additionalFields.associatedCompanyId,
|
|
1219
|
+
category: 'HUBSPOT_DEFINED',
|
|
1220
|
+
definitionId: 1,
|
|
1221
|
+
});
|
|
1222
|
+
await GenericFunctions_1.hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', companyAssociations);
|
|
1223
|
+
}
|
|
1224
|
+
if (!options.resolveData) {
|
|
1225
|
+
const isNew = responseData.isNew;
|
|
1226
|
+
if (additionalFields.properties) {
|
|
1227
|
+
qs.property = additionalFields.properties;
|
|
1228
|
+
}
|
|
1229
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', `/contacts/v1/contact/vid/${responseData.vid}/profile`, {}, qs);
|
|
1230
|
+
responseData.isNew = isNew;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
if (operation === 'get') {
|
|
1234
|
+
const contactId = this.getNodeParameter('contactId', i, undefined, {
|
|
1235
|
+
extractValue: true,
|
|
1236
|
+
});
|
|
1237
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
1238
|
+
if (additionalFields.formSubmissionMode) {
|
|
1239
|
+
qs.formSubmissionMode = additionalFields.formSubmissionMode;
|
|
1240
|
+
}
|
|
1241
|
+
if (additionalFields.listMemberships) {
|
|
1242
|
+
qs.showListMemberships = additionalFields.listMemberships;
|
|
1243
|
+
}
|
|
1244
|
+
if (additionalFields.propertiesCollection) {
|
|
1245
|
+
const propertiesValues = additionalFields.propertiesCollection
|
|
1246
|
+
.propertiesValues;
|
|
1247
|
+
const properties = propertiesValues.properties;
|
|
1248
|
+
qs.properties = !Array.isArray(propertiesValues.properties)
|
|
1249
|
+
? properties.split(',')
|
|
1250
|
+
: properties;
|
|
1251
|
+
qs.propertyMode = (0, change_case_1.snakeCase)(propertiesValues.propertyMode);
|
|
1252
|
+
}
|
|
1253
|
+
const endpoint = `/contacts/v1/contact/vid/${contactId}/profile`;
|
|
1254
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
1255
|
+
}
|
|
1256
|
+
if (operation === 'getAll') {
|
|
1257
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
1258
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
1259
|
+
if (additionalFields.formSubmissionMode) {
|
|
1260
|
+
qs.formSubmissionMode = additionalFields.formSubmissionMode;
|
|
1261
|
+
}
|
|
1262
|
+
if (additionalFields.listMemberships) {
|
|
1263
|
+
qs.showListMemberships = additionalFields.listMemberships;
|
|
1264
|
+
}
|
|
1265
|
+
if (additionalFields.propertiesCollection) {
|
|
1266
|
+
const propertiesValues = additionalFields.propertiesCollection
|
|
1267
|
+
.propertiesValues;
|
|
1268
|
+
const properties = propertiesValues.properties;
|
|
1269
|
+
qs.properties = !Array.isArray(propertiesValues.properties)
|
|
1270
|
+
? properties.split(',')
|
|
1271
|
+
: properties;
|
|
1272
|
+
qs.propertyMode = (0, change_case_1.snakeCase)(propertiesValues.propertyMode);
|
|
1273
|
+
}
|
|
1274
|
+
const endpoint = '/contacts/v1/lists/all/contacts/all';
|
|
1275
|
+
if (returnAll) {
|
|
1276
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint, {}, qs);
|
|
1277
|
+
}
|
|
1278
|
+
else {
|
|
1279
|
+
qs.count = this.getNodeParameter('limit', 0);
|
|
1280
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
1281
|
+
responseData = responseData.contacts;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
if (operation === 'getRecentlyCreatedUpdated') {
|
|
1285
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
1286
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
1287
|
+
if (additionalFields.formSubmissionMode) {
|
|
1288
|
+
qs.formSubmissionMode = additionalFields.formSubmissionMode;
|
|
1289
|
+
}
|
|
1290
|
+
if (additionalFields.listMemberships) {
|
|
1291
|
+
qs.showListMemberships = additionalFields.listMemberships;
|
|
1292
|
+
}
|
|
1293
|
+
if (additionalFields.propertiesCollection) {
|
|
1294
|
+
const propertiesValues = additionalFields.propertiesCollection
|
|
1295
|
+
.propertiesValues;
|
|
1296
|
+
const properties = propertiesValues.properties;
|
|
1297
|
+
qs.properties = !Array.isArray(propertiesValues.properties)
|
|
1298
|
+
? properties.split(',')
|
|
1299
|
+
: properties;
|
|
1300
|
+
qs.propertyMode = (0, change_case_1.snakeCase)(propertiesValues.propertyMode);
|
|
1301
|
+
}
|
|
1302
|
+
const endpoint = '/contacts/v1/lists/recently_updated/contacts/recent';
|
|
1303
|
+
if (returnAll) {
|
|
1304
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint, {}, qs);
|
|
1305
|
+
}
|
|
1306
|
+
else {
|
|
1307
|
+
qs.count = this.getNodeParameter('limit', 0);
|
|
1308
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
1309
|
+
responseData = responseData.contacts;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
if (operation === 'delete') {
|
|
1313
|
+
const contactId = this.getNodeParameter('contactId', i, undefined, {
|
|
1314
|
+
extractValue: true,
|
|
1315
|
+
});
|
|
1316
|
+
const endpoint = `/contacts/v1/contact/vid/${contactId}`;
|
|
1317
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'DELETE', endpoint);
|
|
1318
|
+
responseData =
|
|
1319
|
+
responseData === undefined ? { vid: contactId, deleted: true } : responseData;
|
|
1320
|
+
}
|
|
1321
|
+
if (operation === 'search') {
|
|
1322
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
1323
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
1324
|
+
const filtersGroupsUi = this.getNodeParameter('filterGroupsUi', i);
|
|
1325
|
+
const sortBy = additionalFields.sortBy || 'createdate';
|
|
1326
|
+
const direction = additionalFields.direction || 'DESCENDING';
|
|
1327
|
+
const body = {
|
|
1328
|
+
sorts: [
|
|
1329
|
+
{
|
|
1330
|
+
propertyName: sortBy,
|
|
1331
|
+
direction,
|
|
1332
|
+
},
|
|
1333
|
+
],
|
|
1334
|
+
};
|
|
1335
|
+
if (filtersGroupsUi === null || filtersGroupsUi === void 0 ? void 0 : filtersGroupsUi.filterGroupsValues) {
|
|
1336
|
+
const filterGroupValues = filtersGroupsUi.filterGroupsValues;
|
|
1337
|
+
body.filterGroups = [];
|
|
1338
|
+
for (const filterGroupValue of filterGroupValues) {
|
|
1339
|
+
if (filterGroupValue.filtersUi) {
|
|
1340
|
+
const filterValues = filterGroupValue.filtersUi
|
|
1341
|
+
.filterValues;
|
|
1342
|
+
for (const filter of filterValues) {
|
|
1343
|
+
delete filter.type;
|
|
1344
|
+
filter.propertyName = (_a = filter.propertyName) === null || _a === void 0 ? void 0 : _a.toString().split('|')[0];
|
|
1345
|
+
}
|
|
1346
|
+
body.filterGroups.push({ filters: filterValues });
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
if (body.filterGroups.length > 3) {
|
|
1350
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'You can only have 3 filter groups');
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
Object.assign(body, additionalFields);
|
|
1354
|
+
const endpoint = '/crm/v3/objects/contacts/search';
|
|
1355
|
+
if (returnAll) {
|
|
1356
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'results', 'POST', endpoint, body, qs);
|
|
1357
|
+
}
|
|
1358
|
+
else {
|
|
1359
|
+
body.limit = this.getNodeParameter('limit', 0);
|
|
1360
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', endpoint, body, qs);
|
|
1361
|
+
responseData = responseData.results;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
if (resource === 'company') {
|
|
1366
|
+
if (operation === 'create') {
|
|
1367
|
+
const name = this.getNodeParameter('name', i);
|
|
1368
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
1369
|
+
const body = [];
|
|
1370
|
+
body.push({
|
|
1371
|
+
name: 'name',
|
|
1372
|
+
value: name,
|
|
1373
|
+
});
|
|
1374
|
+
if (additionalFields.aboutUs) {
|
|
1375
|
+
body.push({
|
|
1376
|
+
name: 'about_us',
|
|
1377
|
+
value: additionalFields.aboutUs,
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
if (additionalFields.annualRevenue) {
|
|
1381
|
+
body.push({
|
|
1382
|
+
name: 'annualrevenue',
|
|
1383
|
+
value: additionalFields.annualRevenue.toString(),
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
if (additionalFields.city) {
|
|
1387
|
+
body.push({
|
|
1388
|
+
name: 'city',
|
|
1389
|
+
value: additionalFields.city,
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
if (additionalFields.closeDate) {
|
|
1393
|
+
body.push({
|
|
1394
|
+
name: 'closedate',
|
|
1395
|
+
value: new Date(additionalFields.closeDate).getTime(),
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
if (additionalFields.companyDomainName) {
|
|
1399
|
+
body.push({
|
|
1400
|
+
name: 'domain',
|
|
1401
|
+
value: additionalFields.companyDomainName,
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
if (additionalFields.companyOwner) {
|
|
1405
|
+
body.push({
|
|
1406
|
+
name: 'hubspot_owner_id',
|
|
1407
|
+
value: additionalFields.companyOwner,
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
if (additionalFields.countryRegion) {
|
|
1411
|
+
body.push({
|
|
1412
|
+
name: 'country',
|
|
1413
|
+
value: additionalFields.countryRegion,
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
if (additionalFields.description) {
|
|
1417
|
+
body.push({
|
|
1418
|
+
name: 'description',
|
|
1419
|
+
value: additionalFields.description,
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
if (additionalFields.facebookFans) {
|
|
1423
|
+
body.push({
|
|
1424
|
+
name: 'facebookfans',
|
|
1425
|
+
value: additionalFields.facebookFans,
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
if (additionalFields.googlePlusPage) {
|
|
1429
|
+
body.push({
|
|
1430
|
+
name: 'googleplus_page',
|
|
1431
|
+
value: additionalFields.googlePlusPage,
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
if (additionalFields.industry) {
|
|
1435
|
+
body.push({
|
|
1436
|
+
name: 'industry',
|
|
1437
|
+
value: additionalFields.industry,
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
if (additionalFields.isPublic) {
|
|
1441
|
+
body.push({
|
|
1442
|
+
name: 'is_public',
|
|
1443
|
+
value: additionalFields.isPublic,
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
if (additionalFields.leadStatus) {
|
|
1447
|
+
body.push({
|
|
1448
|
+
name: 'hs_lead_status',
|
|
1449
|
+
value: additionalFields.leadStatus,
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
if (additionalFields.lifecycleStatus) {
|
|
1453
|
+
body.push({
|
|
1454
|
+
name: 'lifecyclestage',
|
|
1455
|
+
value: additionalFields.lifecycleStatus,
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
if (additionalFields.linkedinBio) {
|
|
1459
|
+
body.push({
|
|
1460
|
+
name: 'linkedinbio',
|
|
1461
|
+
value: additionalFields.linkedinBio,
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
if (additionalFields.linkedInCompanyPage) {
|
|
1465
|
+
body.push({
|
|
1466
|
+
name: 'linkedin_company_page',
|
|
1467
|
+
value: additionalFields.linkedInCompanyPage,
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
if (additionalFields.numberOfEmployees) {
|
|
1471
|
+
body.push({
|
|
1472
|
+
name: 'numberofemployees',
|
|
1473
|
+
value: additionalFields.numberOfEmployees,
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
if (additionalFields.originalSourceType) {
|
|
1477
|
+
body.push({
|
|
1478
|
+
name: 'hs_analytics_source',
|
|
1479
|
+
value: additionalFields.originalSourceType,
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1482
|
+
if (additionalFields.phoneNumber) {
|
|
1483
|
+
body.push({
|
|
1484
|
+
name: 'phone',
|
|
1485
|
+
value: additionalFields.phoneNumber,
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
if (additionalFields.postalCode) {
|
|
1489
|
+
body.push({
|
|
1490
|
+
name: 'zip',
|
|
1491
|
+
value: additionalFields.postalCode,
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
if (additionalFields.stateRegion) {
|
|
1495
|
+
body.push({
|
|
1496
|
+
name: 'state',
|
|
1497
|
+
value: additionalFields.stateRegion,
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
if (additionalFields.streetAddress) {
|
|
1501
|
+
body.push({
|
|
1502
|
+
name: 'address',
|
|
1503
|
+
value: additionalFields.streetAddress,
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
if (additionalFields.streetAddress2) {
|
|
1507
|
+
body.push({
|
|
1508
|
+
name: 'address2',
|
|
1509
|
+
value: additionalFields.streetAddress2,
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
if (additionalFields.targetAccount) {
|
|
1513
|
+
body.push({
|
|
1514
|
+
name: 'hs_target_account',
|
|
1515
|
+
value: additionalFields.targetAccount,
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
if (additionalFields.timezone) {
|
|
1519
|
+
body.push({
|
|
1520
|
+
name: 'timezone',
|
|
1521
|
+
value: additionalFields.timezone,
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
if (additionalFields.totalMoneyRaised) {
|
|
1525
|
+
body.push({
|
|
1526
|
+
name: 'total_money_raised',
|
|
1527
|
+
value: additionalFields.totalMoneyRaised,
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
if (additionalFields.twitterBio) {
|
|
1531
|
+
body.push({
|
|
1532
|
+
name: 'twitterbio',
|
|
1533
|
+
value: additionalFields.twitterBio,
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
if (additionalFields.twitterFollowers) {
|
|
1537
|
+
body.push({
|
|
1538
|
+
name: 'twitterfollowers',
|
|
1539
|
+
value: additionalFields.twitterFollowers,
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
if (additionalFields.twitterHandle) {
|
|
1543
|
+
body.push({
|
|
1544
|
+
name: 'twitterhandle',
|
|
1545
|
+
value: additionalFields.twitterHandle,
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1548
|
+
if (additionalFields.type) {
|
|
1549
|
+
body.push({
|
|
1550
|
+
name: 'type',
|
|
1551
|
+
value: additionalFields.type,
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
if (additionalFields.websiteUrl) {
|
|
1555
|
+
body.push({
|
|
1556
|
+
name: 'website',
|
|
1557
|
+
value: additionalFields.websiteUrl,
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
if (additionalFields.webTechnologies) {
|
|
1561
|
+
body.push({
|
|
1562
|
+
name: 'web_technologies',
|
|
1563
|
+
value: additionalFields.webTechnologies,
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
if (additionalFields.yearFounded) {
|
|
1567
|
+
body.push({
|
|
1568
|
+
name: 'founded_year',
|
|
1569
|
+
value: additionalFields.yearFounded,
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
if (additionalFields.customPropertiesUi) {
|
|
1573
|
+
const customProperties = additionalFields.customPropertiesUi
|
|
1574
|
+
.customPropertiesValues;
|
|
1575
|
+
if (customProperties) {
|
|
1576
|
+
for (const customProperty of customProperties) {
|
|
1577
|
+
body.push({
|
|
1578
|
+
name: customProperty.property,
|
|
1579
|
+
value: customProperty.value,
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
const endpoint = '/companies/v2/companies';
|
|
1585
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', endpoint, {
|
|
1586
|
+
properties: body,
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
if (operation === 'update') {
|
|
1590
|
+
const companyId = this.getNodeParameter('companyId', i, undefined, {
|
|
1591
|
+
extractValue: true,
|
|
1592
|
+
});
|
|
1593
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
1594
|
+
const body = [];
|
|
1595
|
+
if (updateFields.name) {
|
|
1596
|
+
body.push({
|
|
1597
|
+
name: 'name',
|
|
1598
|
+
value: updateFields.name,
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
if (updateFields.aboutUs) {
|
|
1602
|
+
body.push({
|
|
1603
|
+
name: 'about_us',
|
|
1604
|
+
value: updateFields.aboutUs,
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
if (updateFields.annualRevenue) {
|
|
1608
|
+
body.push({
|
|
1609
|
+
name: 'annualrevenue',
|
|
1610
|
+
value: updateFields.annualRevenue.toString(),
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
if (updateFields.city) {
|
|
1614
|
+
body.push({
|
|
1615
|
+
name: 'city',
|
|
1616
|
+
value: updateFields.city,
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
if (updateFields.closeDate) {
|
|
1620
|
+
body.push({
|
|
1621
|
+
name: 'closedate',
|
|
1622
|
+
value: new Date(updateFields.closeDate).getTime(),
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
if (updateFields.companyDomainName) {
|
|
1626
|
+
body.push({
|
|
1627
|
+
name: 'domain',
|
|
1628
|
+
value: updateFields.companyDomainName,
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
if (updateFields.companyOwner) {
|
|
1632
|
+
body.push({
|
|
1633
|
+
name: 'hubspot_owner_id',
|
|
1634
|
+
value: updateFields.companyOwner,
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
if (updateFields.countryRegion) {
|
|
1638
|
+
body.push({
|
|
1639
|
+
name: 'country',
|
|
1640
|
+
value: updateFields.countryRegion,
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
if (updateFields.description) {
|
|
1644
|
+
body.push({
|
|
1645
|
+
name: 'description',
|
|
1646
|
+
value: updateFields.description,
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
if (updateFields.facebookFans) {
|
|
1650
|
+
body.push({
|
|
1651
|
+
name: 'facebookfans',
|
|
1652
|
+
value: updateFields.facebookFans,
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
if (updateFields.googlePlusPage) {
|
|
1656
|
+
body.push({
|
|
1657
|
+
name: 'googleplus_page',
|
|
1658
|
+
value: updateFields.googlePlusPage,
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
if (updateFields.industry) {
|
|
1662
|
+
body.push({
|
|
1663
|
+
name: 'industry',
|
|
1664
|
+
value: updateFields.industry,
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
if (updateFields.isPublic) {
|
|
1668
|
+
body.push({
|
|
1669
|
+
name: 'is_public',
|
|
1670
|
+
value: updateFields.isPublic,
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
if (updateFields.leadStatus) {
|
|
1674
|
+
body.push({
|
|
1675
|
+
name: 'hs_lead_status',
|
|
1676
|
+
value: updateFields.leadStatus,
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
if (updateFields.lifecycleStatus) {
|
|
1680
|
+
body.push({
|
|
1681
|
+
name: 'lifecyclestage',
|
|
1682
|
+
value: updateFields.lifecycleStatus,
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
if (updateFields.linkedinBio) {
|
|
1686
|
+
body.push({
|
|
1687
|
+
name: 'linkedinbio',
|
|
1688
|
+
value: updateFields.linkedinBio,
|
|
1689
|
+
});
|
|
1690
|
+
}
|
|
1691
|
+
if (updateFields.linkedInCompanyPage) {
|
|
1692
|
+
body.push({
|
|
1693
|
+
name: 'linkedin_company_page',
|
|
1694
|
+
value: updateFields.linkedInCompanyPage,
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
if (updateFields.numberOfEmployees) {
|
|
1698
|
+
body.push({
|
|
1699
|
+
name: 'numberofemployees',
|
|
1700
|
+
value: updateFields.numberOfEmployees,
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
if (updateFields.originalSourceType) {
|
|
1704
|
+
body.push({
|
|
1705
|
+
name: 'hs_analytics_source',
|
|
1706
|
+
value: updateFields.originalSourceType,
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
if (updateFields.phoneNumber) {
|
|
1710
|
+
body.push({
|
|
1711
|
+
name: 'phone',
|
|
1712
|
+
value: updateFields.phoneNumber,
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1715
|
+
if (updateFields.postalCode) {
|
|
1716
|
+
body.push({
|
|
1717
|
+
name: 'zip',
|
|
1718
|
+
value: updateFields.postalCode,
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
if (updateFields.stateRegion) {
|
|
1722
|
+
body.push({
|
|
1723
|
+
name: 'state',
|
|
1724
|
+
value: updateFields.stateRegion,
|
|
1725
|
+
});
|
|
1726
|
+
}
|
|
1727
|
+
if (updateFields.streetAddress) {
|
|
1728
|
+
body.push({
|
|
1729
|
+
name: 'address',
|
|
1730
|
+
value: updateFields.streetAddress,
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
if (updateFields.streetAddress2) {
|
|
1734
|
+
body.push({
|
|
1735
|
+
name: 'address2',
|
|
1736
|
+
value: updateFields.streetAddress2,
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
if (updateFields.targetAccount) {
|
|
1740
|
+
body.push({
|
|
1741
|
+
name: 'hs_target_account',
|
|
1742
|
+
value: updateFields.targetAccount,
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
if (updateFields.timezone) {
|
|
1746
|
+
body.push({
|
|
1747
|
+
name: 'timezone',
|
|
1748
|
+
value: updateFields.timezone,
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
if (updateFields.totalMoneyRaised) {
|
|
1752
|
+
body.push({
|
|
1753
|
+
name: 'total_money_raised',
|
|
1754
|
+
value: updateFields.totalMoneyRaised,
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
if (updateFields.twitterBio) {
|
|
1758
|
+
body.push({
|
|
1759
|
+
name: 'twitterbio',
|
|
1760
|
+
value: updateFields.twitterBio,
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
if (updateFields.twitterFollowers) {
|
|
1764
|
+
body.push({
|
|
1765
|
+
name: 'twitterfollowers',
|
|
1766
|
+
value: updateFields.twitterFollowers,
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
if (updateFields.twitterHandle) {
|
|
1770
|
+
body.push({
|
|
1771
|
+
name: 'twitterhandle',
|
|
1772
|
+
value: updateFields.twitterHandle,
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
if (updateFields.type) {
|
|
1776
|
+
body.push({
|
|
1777
|
+
name: 'type',
|
|
1778
|
+
value: updateFields.type,
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
if (updateFields.websiteUrl) {
|
|
1782
|
+
body.push({
|
|
1783
|
+
name: 'website',
|
|
1784
|
+
value: updateFields.websiteUrl,
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
if (updateFields.webTechnologies) {
|
|
1788
|
+
body.push({
|
|
1789
|
+
name: 'web_technologies',
|
|
1790
|
+
value: updateFields.webTechnologies,
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1793
|
+
if (updateFields.yearFounded) {
|
|
1794
|
+
body.push({
|
|
1795
|
+
name: 'founded_year',
|
|
1796
|
+
value: updateFields.yearFounded,
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
if (updateFields.customPropertiesUi) {
|
|
1800
|
+
const customProperties = updateFields.customPropertiesUi
|
|
1801
|
+
.customPropertiesValues;
|
|
1802
|
+
if (customProperties) {
|
|
1803
|
+
for (const customProperty of customProperties) {
|
|
1804
|
+
body.push({
|
|
1805
|
+
name: customProperty.property,
|
|
1806
|
+
value: customProperty.value,
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
const endpoint = `/companies/v2/companies/${companyId}`;
|
|
1812
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'PUT', endpoint, {
|
|
1813
|
+
properties: body,
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
if (operation === 'get') {
|
|
1817
|
+
const companyId = this.getNodeParameter('companyId', i, undefined, {
|
|
1818
|
+
extractValue: true,
|
|
1819
|
+
});
|
|
1820
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
1821
|
+
if (additionalFields.includeMergeAudits) {
|
|
1822
|
+
qs.includeMergeAudits = additionalFields.includeMergeAudits;
|
|
1823
|
+
}
|
|
1824
|
+
const endpoint = `/companies/v2/companies/${companyId}`;
|
|
1825
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
1826
|
+
}
|
|
1827
|
+
if (operation === 'getAll') {
|
|
1828
|
+
const additionalFields = this.getNodeParameter('options', i);
|
|
1829
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
1830
|
+
if (additionalFields.formSubmissionMode) {
|
|
1831
|
+
qs.formSubmissionMode = additionalFields.formSubmissionMode;
|
|
1832
|
+
}
|
|
1833
|
+
if (additionalFields.listMerberships) {
|
|
1834
|
+
qs.showListMemberships = additionalFields.listMerberships;
|
|
1835
|
+
}
|
|
1836
|
+
if (additionalFields.propertiesCollection) {
|
|
1837
|
+
const propertiesValues = additionalFields.propertiesCollection
|
|
1838
|
+
.propertiesValues;
|
|
1839
|
+
const properties = propertiesValues.properties;
|
|
1840
|
+
qs.properties = !Array.isArray(propertiesValues.properties)
|
|
1841
|
+
? properties.split(',')
|
|
1842
|
+
: properties;
|
|
1843
|
+
qs.propertyMode = (0, change_case_1.snakeCase)(propertiesValues.propertyMode);
|
|
1844
|
+
}
|
|
1845
|
+
const endpoint = '/companies/v2/companies/paged';
|
|
1846
|
+
if (returnAll) {
|
|
1847
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'companies', 'GET', endpoint, {}, qs);
|
|
1848
|
+
}
|
|
1849
|
+
else {
|
|
1850
|
+
qs.limit = this.getNodeParameter('limit', 0);
|
|
1851
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
1852
|
+
responseData = responseData.companies;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
if (operation === 'getRecentlyCreatedUpdated') {
|
|
1856
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
1857
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
1858
|
+
if (additionalFields.since) {
|
|
1859
|
+
qs.since = new Date(additionalFields.since).getTime();
|
|
1860
|
+
}
|
|
1861
|
+
if (additionalFields.propertiesCollection) {
|
|
1862
|
+
const propertiesValues = additionalFields.propertiesCollection
|
|
1863
|
+
.propertiesValues;
|
|
1864
|
+
const properties = propertiesValues.properties;
|
|
1865
|
+
qs.properties = !Array.isArray(propertiesValues.properties)
|
|
1866
|
+
? properties.split(',')
|
|
1867
|
+
: properties;
|
|
1868
|
+
qs.propertyMode = (0, change_case_1.snakeCase)(propertiesValues.propertyMode);
|
|
1869
|
+
}
|
|
1870
|
+
const endpoint = '/companies/v2/companies/recent/modified';
|
|
1871
|
+
if (returnAll) {
|
|
1872
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'results', 'GET', endpoint, {}, qs);
|
|
1873
|
+
}
|
|
1874
|
+
else {
|
|
1875
|
+
qs.count = this.getNodeParameter('limit', 0);
|
|
1876
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
1877
|
+
responseData = responseData.results;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
if (operation === 'searchByDomain') {
|
|
1881
|
+
let domain = this.getNodeParameter('domain', i);
|
|
1882
|
+
const options = this.getNodeParameter('options', i);
|
|
1883
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
1884
|
+
if (domain.includes('https://')) {
|
|
1885
|
+
domain = domain.replace('https://', '');
|
|
1886
|
+
}
|
|
1887
|
+
else if (domain.includes('http://')) {
|
|
1888
|
+
domain = domain.replace('http://', '');
|
|
1889
|
+
}
|
|
1890
|
+
const body = {
|
|
1891
|
+
requestOptions: {},
|
|
1892
|
+
};
|
|
1893
|
+
if (options.properties) {
|
|
1894
|
+
body.requestOptions = { properties: options.properties };
|
|
1895
|
+
}
|
|
1896
|
+
const endpoint = `/companies/v2/domains/${domain}/companies`;
|
|
1897
|
+
if (returnAll) {
|
|
1898
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'results', 'POST', endpoint, body);
|
|
1899
|
+
}
|
|
1900
|
+
else {
|
|
1901
|
+
body.limit = this.getNodeParameter('limit', 0);
|
|
1902
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', endpoint, body);
|
|
1903
|
+
responseData = responseData.results;
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
if (operation === 'delete') {
|
|
1907
|
+
const companyId = this.getNodeParameter('companyId', i, undefined, {
|
|
1908
|
+
extractValue: true,
|
|
1909
|
+
});
|
|
1910
|
+
const endpoint = `/crm/v3/objects/companies/${companyId}`;
|
|
1911
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'DELETE', endpoint);
|
|
1912
|
+
responseData =
|
|
1913
|
+
responseData === undefined ? { vid: companyId, deleted: true } : responseData;
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
if (resource === 'deal') {
|
|
1917
|
+
if (operation === 'create') {
|
|
1918
|
+
const body = {};
|
|
1919
|
+
body.properties = [];
|
|
1920
|
+
const association = {};
|
|
1921
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
1922
|
+
const stage = this.getNodeParameter('stage', i);
|
|
1923
|
+
if (stage) {
|
|
1924
|
+
body.properties.push({
|
|
1925
|
+
name: 'dealstage',
|
|
1926
|
+
value: stage,
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
if (additionalFields.associatedCompany) {
|
|
1930
|
+
association.associatedCompanyIds = additionalFields.associatedCompany;
|
|
1931
|
+
}
|
|
1932
|
+
if (additionalFields.associatedVids) {
|
|
1933
|
+
association.associatedVids = additionalFields.associatedVids;
|
|
1934
|
+
}
|
|
1935
|
+
if (additionalFields.dealName) {
|
|
1936
|
+
body.properties.push({
|
|
1937
|
+
name: 'dealname',
|
|
1938
|
+
value: additionalFields.dealName,
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
if (additionalFields.dealOwner) {
|
|
1942
|
+
const dealOwner = additionalFields.dealOwner;
|
|
1943
|
+
body.properties.push({
|
|
1944
|
+
name: 'hubspot_owner_id',
|
|
1945
|
+
value: dealOwner.value,
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
if (additionalFields.closeDate) {
|
|
1949
|
+
body.properties.push({
|
|
1950
|
+
name: 'closedate',
|
|
1951
|
+
value: new Date(additionalFields.closeDate).getTime(),
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
if (additionalFields.amount) {
|
|
1955
|
+
body.properties.push({
|
|
1956
|
+
name: 'amount',
|
|
1957
|
+
value: additionalFields.amount,
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
if (additionalFields.dealType) {
|
|
1961
|
+
body.properties.push({
|
|
1962
|
+
name: 'dealtype',
|
|
1963
|
+
value: additionalFields.dealType,
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1966
|
+
if (additionalFields.pipeline) {
|
|
1967
|
+
body.properties.push({
|
|
1968
|
+
name: 'pipeline',
|
|
1969
|
+
value: additionalFields.pipeline,
|
|
1970
|
+
});
|
|
1971
|
+
}
|
|
1972
|
+
if (additionalFields.description) {
|
|
1973
|
+
body.properties.push({
|
|
1974
|
+
name: 'description',
|
|
1975
|
+
value: additionalFields.description,
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1978
|
+
if (additionalFields.customPropertiesUi) {
|
|
1979
|
+
const customProperties = additionalFields.customPropertiesUi
|
|
1980
|
+
.customPropertiesValues;
|
|
1981
|
+
if (customProperties) {
|
|
1982
|
+
for (const customProperty of customProperties) {
|
|
1983
|
+
body.properties.push({
|
|
1984
|
+
name: customProperty.property,
|
|
1985
|
+
value: customProperty.value,
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
body.associations = association;
|
|
1991
|
+
const endpoint = '/deals/v1/deal';
|
|
1992
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', endpoint, body);
|
|
1993
|
+
}
|
|
1994
|
+
if (operation === 'update') {
|
|
1995
|
+
const body = {};
|
|
1996
|
+
body.properties = [];
|
|
1997
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
1998
|
+
const dealId = this.getNodeParameter('dealId', i, {}, { extractValue: true });
|
|
1999
|
+
if (updateFields.stage) {
|
|
2000
|
+
body.properties.push({
|
|
2001
|
+
name: 'dealstage',
|
|
2002
|
+
value: updateFields.stage,
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
if (updateFields.dealName) {
|
|
2006
|
+
body.properties.push({
|
|
2007
|
+
name: 'dealname',
|
|
2008
|
+
value: updateFields.dealName,
|
|
2009
|
+
});
|
|
2010
|
+
}
|
|
2011
|
+
if (updateFields.closeDate) {
|
|
2012
|
+
body.properties.push({
|
|
2013
|
+
name: 'closedate',
|
|
2014
|
+
value: new Date(updateFields.closeDate).getTime(),
|
|
2015
|
+
});
|
|
2016
|
+
}
|
|
2017
|
+
if (updateFields.amount) {
|
|
2018
|
+
body.properties.push({
|
|
2019
|
+
name: 'amount',
|
|
2020
|
+
value: updateFields.amount,
|
|
2021
|
+
});
|
|
2022
|
+
}
|
|
2023
|
+
if (updateFields.dealType) {
|
|
2024
|
+
body.properties.push({
|
|
2025
|
+
name: 'dealtype',
|
|
2026
|
+
value: updateFields.dealType,
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
if (updateFields.pipeline) {
|
|
2030
|
+
body.properties.push({
|
|
2031
|
+
name: 'pipeline',
|
|
2032
|
+
value: updateFields.pipeline,
|
|
2033
|
+
});
|
|
2034
|
+
}
|
|
2035
|
+
if (updateFields.description) {
|
|
2036
|
+
body.properties.push({
|
|
2037
|
+
name: 'description',
|
|
2038
|
+
value: updateFields.description,
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
if (updateFields.customPropertiesUi) {
|
|
2042
|
+
const customProperties = updateFields.customPropertiesUi
|
|
2043
|
+
.customPropertiesValues;
|
|
2044
|
+
if (customProperties) {
|
|
2045
|
+
for (const customProperty of customProperties) {
|
|
2046
|
+
body.properties.push({
|
|
2047
|
+
name: customProperty.property,
|
|
2048
|
+
value: customProperty.value,
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
const endpoint = `/deals/v1/deal/${dealId}`;
|
|
2054
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'PUT', endpoint, body);
|
|
2055
|
+
}
|
|
2056
|
+
if (operation === 'get') {
|
|
2057
|
+
const dealId = this.getNodeParameter('dealId', i, {}, { extractValue: true });
|
|
2058
|
+
const filters = this.getNodeParameter('filters', i);
|
|
2059
|
+
if (filters.includePropertyVersions) {
|
|
2060
|
+
qs.includePropertyVersions = filters.includePropertyVersions;
|
|
2061
|
+
}
|
|
2062
|
+
if (filters.propertiesCollection) {
|
|
2063
|
+
const propertiesValues = filters.propertiesCollection
|
|
2064
|
+
.propertiesValues;
|
|
2065
|
+
const properties = propertiesValues.properties;
|
|
2066
|
+
qs.properties = !Array.isArray(propertiesValues.properties)
|
|
2067
|
+
? properties.split(',')
|
|
2068
|
+
: properties;
|
|
2069
|
+
qs.propertyMode = (0, change_case_1.snakeCase)(propertiesValues.propertyMode);
|
|
2070
|
+
}
|
|
2071
|
+
const endpoint = `/deals/v1/deal/${dealId}`;
|
|
2072
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint);
|
|
2073
|
+
}
|
|
2074
|
+
if (operation === 'getAll') {
|
|
2075
|
+
const filters = this.getNodeParameter('filters', i);
|
|
2076
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
2077
|
+
if (filters.includeAssociations) {
|
|
2078
|
+
qs.includeAssociations = filters.includeAssociations;
|
|
2079
|
+
}
|
|
2080
|
+
if (filters.propertiesCollection) {
|
|
2081
|
+
const propertiesValues = filters.propertiesCollection
|
|
2082
|
+
.propertiesValues;
|
|
2083
|
+
const properties = propertiesValues.properties;
|
|
2084
|
+
qs.properties = !Array.isArray(propertiesValues.properties)
|
|
2085
|
+
? properties.split(',')
|
|
2086
|
+
: properties;
|
|
2087
|
+
qs.propertyMode = (0, change_case_1.snakeCase)(propertiesValues.propertyMode);
|
|
2088
|
+
}
|
|
2089
|
+
const endpoint = '/deals/v1/deal/paged';
|
|
2090
|
+
if (returnAll) {
|
|
2091
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'deals', 'GET', endpoint, {}, qs);
|
|
2092
|
+
}
|
|
2093
|
+
else {
|
|
2094
|
+
qs.limit = this.getNodeParameter('limit', 0);
|
|
2095
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
2096
|
+
responseData = responseData.deals;
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
if (operation === 'getRecentlyCreatedUpdated') {
|
|
2100
|
+
const endpoint = '/deals/v1/deal/recent/created';
|
|
2101
|
+
const filters = this.getNodeParameter('filters', i);
|
|
2102
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
2103
|
+
if (filters.since) {
|
|
2104
|
+
qs.since = new Date(filters.since).getTime();
|
|
2105
|
+
}
|
|
2106
|
+
if (filters.includePropertyVersions) {
|
|
2107
|
+
qs.includePropertyVersions = filters.includePropertyVersions;
|
|
2108
|
+
}
|
|
2109
|
+
if (returnAll) {
|
|
2110
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'results', 'GET', endpoint, {}, qs);
|
|
2111
|
+
}
|
|
2112
|
+
else {
|
|
2113
|
+
qs.count = this.getNodeParameter('limit', 0);
|
|
2114
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
2115
|
+
responseData = responseData.results;
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
if (operation === 'delete') {
|
|
2119
|
+
const dealId = this.getNodeParameter('dealId', i, {}, { extractValue: true });
|
|
2120
|
+
const endpoint = `/deals/v1/deal/${dealId}`;
|
|
2121
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'DELETE', endpoint);
|
|
2122
|
+
responseData =
|
|
2123
|
+
responseData === undefined ? { vid: dealId, deleted: true } : responseData;
|
|
2124
|
+
}
|
|
2125
|
+
if (operation === 'search') {
|
|
2126
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
2127
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
2128
|
+
const filtersGroupsUi = this.getNodeParameter('filterGroupsUi', i);
|
|
2129
|
+
const sortBy = additionalFields.sortBy || 'createdate';
|
|
2130
|
+
const direction = additionalFields.direction || 'DESCENDING';
|
|
2131
|
+
const body = {
|
|
2132
|
+
sorts: [
|
|
2133
|
+
{
|
|
2134
|
+
propertyName: sortBy,
|
|
2135
|
+
direction,
|
|
2136
|
+
},
|
|
2137
|
+
],
|
|
2138
|
+
};
|
|
2139
|
+
if (filtersGroupsUi === null || filtersGroupsUi === void 0 ? void 0 : filtersGroupsUi.filterGroupsValues) {
|
|
2140
|
+
const filterGroupValues = filtersGroupsUi.filterGroupsValues;
|
|
2141
|
+
body.filterGroups = [];
|
|
2142
|
+
for (const filterGroupValue of filterGroupValues) {
|
|
2143
|
+
if (filterGroupValue.filtersUi) {
|
|
2144
|
+
const filterValues = filterGroupValue.filtersUi
|
|
2145
|
+
.filterValues;
|
|
2146
|
+
for (const filter of filterValues) {
|
|
2147
|
+
delete filter.type;
|
|
2148
|
+
filter.propertyName = (_b = filter.propertyName) === null || _b === void 0 ? void 0 : _b.toString().split('|')[0];
|
|
2149
|
+
}
|
|
2150
|
+
body.filterGroups.push({ filters: filterValues });
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
if (body.filterGroups.length > 3) {
|
|
2154
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'You can only have 3 filter groups');
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
Object.assign(body, additionalFields);
|
|
2158
|
+
const endpoint = '/crm/v3/objects/deals/search';
|
|
2159
|
+
if (returnAll) {
|
|
2160
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'results', 'POST', endpoint, body, qs);
|
|
2161
|
+
}
|
|
2162
|
+
else {
|
|
2163
|
+
body.limit = this.getNodeParameter('limit', 0);
|
|
2164
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', endpoint, body, qs);
|
|
2165
|
+
responseData = responseData.results;
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
if (resource === 'engagement') {
|
|
2170
|
+
if (operation === 'create') {
|
|
2171
|
+
const type = this.getNodeParameter('type', i);
|
|
2172
|
+
const metadata = this.getNodeParameter('metadata', i);
|
|
2173
|
+
const associations = this.getNodeParameter('additionalFields.associations', i, {});
|
|
2174
|
+
if (!Object.keys(metadata).length) {
|
|
2175
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least one metadata field needs to set', { itemIndex: i });
|
|
2176
|
+
}
|
|
2177
|
+
const body = {
|
|
2178
|
+
engagement: {
|
|
2179
|
+
type: type.toUpperCase(),
|
|
2180
|
+
},
|
|
2181
|
+
metadata: {},
|
|
2182
|
+
associations: {},
|
|
2183
|
+
};
|
|
2184
|
+
if (type === 'email') {
|
|
2185
|
+
body.metadata = (0, GenericFunctions_1.getEmailMetadata)(metadata);
|
|
2186
|
+
}
|
|
2187
|
+
if (type === 'task') {
|
|
2188
|
+
body.metadata = (0, GenericFunctions_1.getTaskMetadata)(metadata);
|
|
2189
|
+
}
|
|
2190
|
+
if (type === 'meeting') {
|
|
2191
|
+
body.metadata = (0, GenericFunctions_1.getMeetingMetadata)(metadata);
|
|
2192
|
+
}
|
|
2193
|
+
if (type === 'call') {
|
|
2194
|
+
body.metadata = (0, GenericFunctions_1.getCallMetadata)(metadata);
|
|
2195
|
+
}
|
|
2196
|
+
body.associations = (0, GenericFunctions_1.getAssociations)(associations);
|
|
2197
|
+
const endpoint = '/engagements/v1/engagements';
|
|
2198
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', endpoint, body);
|
|
2199
|
+
}
|
|
2200
|
+
if (operation === 'delete') {
|
|
2201
|
+
const engagementId = this.getNodeParameter('engagementId', i, undefined, {
|
|
2202
|
+
extractValue: true,
|
|
2203
|
+
});
|
|
2204
|
+
const endpoint = `/engagements/v1/engagements/${engagementId}`;
|
|
2205
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'DELETE', endpoint, {}, qs);
|
|
2206
|
+
responseData =
|
|
2207
|
+
responseData === undefined ? { vid: engagementId, deleted: true } : responseData;
|
|
2208
|
+
}
|
|
2209
|
+
if (operation === 'get') {
|
|
2210
|
+
const engagementId = this.getNodeParameter('engagementId', i, undefined, {
|
|
2211
|
+
extractValue: true,
|
|
2212
|
+
});
|
|
2213
|
+
const endpoint = `/engagements/v1/engagements/${engagementId}`;
|
|
2214
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
2215
|
+
}
|
|
2216
|
+
if (operation === 'getAll') {
|
|
2217
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
2218
|
+
const endpoint = '/engagements/v1/engagements/paged';
|
|
2219
|
+
if (returnAll) {
|
|
2220
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'results', 'GET', endpoint, {}, qs);
|
|
2221
|
+
}
|
|
2222
|
+
else {
|
|
2223
|
+
qs.limit = this.getNodeParameter('limit', 0);
|
|
2224
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
2225
|
+
responseData = responseData.results;
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
if (resource === 'form') {
|
|
2230
|
+
if (operation === 'getFields') {
|
|
2231
|
+
const formId = this.getNodeParameter('formId', i);
|
|
2232
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', `/forms/v2/fields/${formId}`);
|
|
2233
|
+
}
|
|
2234
|
+
if (operation === 'submit') {
|
|
2235
|
+
const formId = this.getNodeParameter('formId', i);
|
|
2236
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
2237
|
+
const context = this.getNodeParameter('contextUi', i)
|
|
2238
|
+
.contextValue;
|
|
2239
|
+
const legalConsent = this.getNodeParameter('lengalConsentUi', i)
|
|
2240
|
+
.lengalConsentValues;
|
|
2241
|
+
const legitimateInteres = this.getNodeParameter('lengalConsentUi', i)
|
|
2242
|
+
.legitimateInterestValues;
|
|
2243
|
+
const { portalId } = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', `/forms/v2/forms/${formId}`);
|
|
2244
|
+
const body = {
|
|
2245
|
+
formId,
|
|
2246
|
+
portalId,
|
|
2247
|
+
legalConsentOptions: {},
|
|
2248
|
+
fields: [],
|
|
2249
|
+
};
|
|
2250
|
+
if (additionalFields.submittedAt) {
|
|
2251
|
+
body.submittedAt = new Date(additionalFields.submittedAt).getTime();
|
|
2252
|
+
}
|
|
2253
|
+
if (additionalFields.skipValidation) {
|
|
2254
|
+
body.skipValidation = additionalFields.skipValidation;
|
|
2255
|
+
}
|
|
2256
|
+
const consent = {};
|
|
2257
|
+
if (legalConsent) {
|
|
2258
|
+
if (legalConsent.consentToProcess) {
|
|
2259
|
+
consent.consentToProcess = legalConsent.consentToProcess;
|
|
2260
|
+
}
|
|
2261
|
+
if (legalConsent.text) {
|
|
2262
|
+
consent.text = legalConsent.text;
|
|
2263
|
+
}
|
|
2264
|
+
if (legalConsent.communicationsUi) {
|
|
2265
|
+
consent.communications = legalConsent.communicationsUi
|
|
2266
|
+
.communicationValues;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
body.legalConsentOptions.consent = consent;
|
|
2270
|
+
const fields = items[i].json;
|
|
2271
|
+
for (const key of Object.keys(fields)) {
|
|
2272
|
+
(_c = body.fields) === null || _c === void 0 ? void 0 : _c.push({ name: key, value: fields[key] });
|
|
2273
|
+
}
|
|
2274
|
+
if (body.legalConsentOptions.legitimateInterest) {
|
|
2275
|
+
Object.assign(body, {
|
|
2276
|
+
legalConsentOptions: { legitimateInterest: legitimateInteres },
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
if (context) {
|
|
2280
|
+
(0, GenericFunctions_1.clean)(context);
|
|
2281
|
+
Object.assign(body, { context });
|
|
2282
|
+
}
|
|
2283
|
+
const uri = `https://api.hsforms.com/submissions/v3/integration/submit/${portalId}/${formId}`;
|
|
2284
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', '', body, {}, uri);
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
if (resource === 'ticket') {
|
|
2288
|
+
if (operation === 'create') {
|
|
2289
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
2290
|
+
const pipelineId = this.getNodeParameter('pipelineId', i);
|
|
2291
|
+
const stageId = this.getNodeParameter('stageId', i);
|
|
2292
|
+
const ticketName = this.getNodeParameter('ticketName', i);
|
|
2293
|
+
const body = [
|
|
2294
|
+
{
|
|
2295
|
+
name: 'hs_pipeline',
|
|
2296
|
+
value: pipelineId,
|
|
2297
|
+
},
|
|
2298
|
+
{
|
|
2299
|
+
name: 'hs_pipeline_stage',
|
|
2300
|
+
value: stageId,
|
|
2301
|
+
},
|
|
2302
|
+
{
|
|
2303
|
+
name: 'subject',
|
|
2304
|
+
value: ticketName,
|
|
2305
|
+
},
|
|
2306
|
+
];
|
|
2307
|
+
if (additionalFields.category) {
|
|
2308
|
+
body.push({
|
|
2309
|
+
name: 'hs_ticket_category',
|
|
2310
|
+
value: additionalFields.category,
|
|
2311
|
+
});
|
|
2312
|
+
}
|
|
2313
|
+
if (additionalFields.closeDate) {
|
|
2314
|
+
body.push({
|
|
2315
|
+
name: 'closed_date',
|
|
2316
|
+
value: new Date(additionalFields.closeDate).getTime(),
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
if (additionalFields.createDate) {
|
|
2320
|
+
body.push({
|
|
2321
|
+
name: 'createdate',
|
|
2322
|
+
value: new Date(additionalFields.createDate).getTime(),
|
|
2323
|
+
});
|
|
2324
|
+
}
|
|
2325
|
+
if (additionalFields.description) {
|
|
2326
|
+
body.push({
|
|
2327
|
+
name: 'content',
|
|
2328
|
+
value: additionalFields.description,
|
|
2329
|
+
});
|
|
2330
|
+
}
|
|
2331
|
+
if (additionalFields.priority) {
|
|
2332
|
+
body.push({
|
|
2333
|
+
name: 'hs_ticket_priority',
|
|
2334
|
+
value: additionalFields.priority,
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2337
|
+
if (additionalFields.resolution) {
|
|
2338
|
+
body.push({
|
|
2339
|
+
name: 'hs_resolution',
|
|
2340
|
+
value: additionalFields.resolution,
|
|
2341
|
+
});
|
|
2342
|
+
}
|
|
2343
|
+
if (additionalFields.source) {
|
|
2344
|
+
body.push({
|
|
2345
|
+
name: 'source_type',
|
|
2346
|
+
value: additionalFields.source,
|
|
2347
|
+
});
|
|
2348
|
+
}
|
|
2349
|
+
if (additionalFields.ticketOwnerId) {
|
|
2350
|
+
body.push({
|
|
2351
|
+
name: 'hubspot_owner_id',
|
|
2352
|
+
value: additionalFields.ticketOwnerId,
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
const endpoint = '/crm-objects/v1/objects/tickets';
|
|
2356
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'POST', endpoint, body);
|
|
2357
|
+
if (additionalFields.associatedCompanyIds) {
|
|
2358
|
+
const companyAssociations = [];
|
|
2359
|
+
for (const companyId of additionalFields.associatedCompanyIds) {
|
|
2360
|
+
companyAssociations.push({
|
|
2361
|
+
fromObjectId: responseData.objectId,
|
|
2362
|
+
toObjectId: companyId,
|
|
2363
|
+
category: 'HUBSPOT_DEFINED',
|
|
2364
|
+
definitionId: 26,
|
|
2365
|
+
});
|
|
2366
|
+
}
|
|
2367
|
+
await GenericFunctions_1.hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', companyAssociations);
|
|
2368
|
+
}
|
|
2369
|
+
if (additionalFields.associatedContactIds) {
|
|
2370
|
+
const contactAssociations = [];
|
|
2371
|
+
for (const contactId of additionalFields.associatedContactIds) {
|
|
2372
|
+
contactAssociations.push({
|
|
2373
|
+
fromObjectId: responseData.objectId,
|
|
2374
|
+
toObjectId: contactId,
|
|
2375
|
+
category: 'HUBSPOT_DEFINED',
|
|
2376
|
+
definitionId: 16,
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
await GenericFunctions_1.hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', contactAssociations);
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
if (operation === 'get') {
|
|
2383
|
+
const ticketId = this.getNodeParameter('ticketId', i, undefined, {
|
|
2384
|
+
extractValue: true,
|
|
2385
|
+
});
|
|
2386
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
2387
|
+
if (additionalFields.properties) {
|
|
2388
|
+
qs.properties = additionalFields.properties;
|
|
2389
|
+
}
|
|
2390
|
+
if (additionalFields.propertiesWithHistory) {
|
|
2391
|
+
qs.propertiesWithHistory = additionalFields.propertiesWithHistory.split(',');
|
|
2392
|
+
}
|
|
2393
|
+
if (additionalFields.includeDeleted) {
|
|
2394
|
+
qs.includeDeleted = additionalFields.includeDeleted;
|
|
2395
|
+
}
|
|
2396
|
+
const endpoint = `/crm-objects/v1/objects/tickets/${ticketId}`;
|
|
2397
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
2398
|
+
}
|
|
2399
|
+
if (operation === 'getAll') {
|
|
2400
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
2401
|
+
const returnAll = this.getNodeParameter('returnAll', 0);
|
|
2402
|
+
if (additionalFields.properties) {
|
|
2403
|
+
qs.properties = additionalFields.properties;
|
|
2404
|
+
}
|
|
2405
|
+
if (additionalFields.propertiesWithHistory) {
|
|
2406
|
+
qs.propertiesWithHistory = additionalFields.propertiesWithHistory.split(',');
|
|
2407
|
+
}
|
|
2408
|
+
const endpoint = '/crm-objects/v1/objects/tickets/paged';
|
|
2409
|
+
if (returnAll) {
|
|
2410
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'objects', 'GET', endpoint, {}, qs);
|
|
2411
|
+
}
|
|
2412
|
+
else {
|
|
2413
|
+
qs.limit = this.getNodeParameter('limit', 0);
|
|
2414
|
+
responseData = await GenericFunctions_1.hubspotApiRequestAllItems.call(this, 'objects', 'GET', endpoint, {}, qs);
|
|
2415
|
+
responseData = responseData.splice(0, qs.limit);
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
if (operation === 'delete') {
|
|
2419
|
+
const ticketId = this.getNodeParameter('ticketId', i, undefined, {
|
|
2420
|
+
extractValue: true,
|
|
2421
|
+
});
|
|
2422
|
+
const endpoint = `/crm-objects/v1/objects/tickets/${ticketId}`;
|
|
2423
|
+
await GenericFunctions_1.hubspotApiRequest.call(this, 'DELETE', endpoint);
|
|
2424
|
+
responseData =
|
|
2425
|
+
responseData === undefined ? { vid: ticketId, deleted: true } : responseData;
|
|
2426
|
+
}
|
|
2427
|
+
if (operation === 'update') {
|
|
2428
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
2429
|
+
const ticketId = this.getNodeParameter('ticketId', i, undefined, {
|
|
2430
|
+
extractValue: true,
|
|
2431
|
+
});
|
|
2432
|
+
const body = [];
|
|
2433
|
+
if (updateFields.pipelineId) {
|
|
2434
|
+
body.push({
|
|
2435
|
+
name: 'hs_pipeline',
|
|
2436
|
+
value: updateFields.pipelineId,
|
|
2437
|
+
});
|
|
2438
|
+
}
|
|
2439
|
+
if (updateFields.stageId) {
|
|
2440
|
+
body.push({
|
|
2441
|
+
name: 'hs_pipeline_stage',
|
|
2442
|
+
value: updateFields.stageId,
|
|
2443
|
+
});
|
|
2444
|
+
}
|
|
2445
|
+
if (updateFields.ticketName) {
|
|
2446
|
+
body.push({
|
|
2447
|
+
name: 'subject',
|
|
2448
|
+
value: updateFields.ticketName,
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
if (updateFields.category) {
|
|
2452
|
+
body.push({
|
|
2453
|
+
name: 'hs_ticket_category',
|
|
2454
|
+
value: updateFields.category,
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2457
|
+
if (updateFields.closeDate) {
|
|
2458
|
+
body.push({
|
|
2459
|
+
name: 'closed_date',
|
|
2460
|
+
value: new Date(updateFields.createDate).getTime(),
|
|
2461
|
+
});
|
|
2462
|
+
}
|
|
2463
|
+
if (updateFields.createDate) {
|
|
2464
|
+
body.push({
|
|
2465
|
+
name: 'createdate',
|
|
2466
|
+
value: new Date(updateFields.createDate).getTime(),
|
|
2467
|
+
});
|
|
2468
|
+
}
|
|
2469
|
+
if (updateFields.description) {
|
|
2470
|
+
body.push({
|
|
2471
|
+
name: 'content',
|
|
2472
|
+
value: updateFields.description,
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
if (updateFields.priority) {
|
|
2476
|
+
body.push({
|
|
2477
|
+
name: 'hs_ticket_priority',
|
|
2478
|
+
value: updateFields.priority,
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
2481
|
+
if (updateFields.resolution) {
|
|
2482
|
+
body.push({
|
|
2483
|
+
name: 'hs_resolution',
|
|
2484
|
+
value: updateFields.resolution,
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
if (updateFields.source) {
|
|
2488
|
+
body.push({
|
|
2489
|
+
name: 'source_type',
|
|
2490
|
+
value: updateFields.source,
|
|
2491
|
+
});
|
|
2492
|
+
}
|
|
2493
|
+
if (updateFields.ticketOwnerId) {
|
|
2494
|
+
body.push({
|
|
2495
|
+
name: 'hubspot_owner_id',
|
|
2496
|
+
value: updateFields.ticketOwnerId,
|
|
2497
|
+
});
|
|
2498
|
+
}
|
|
2499
|
+
const endpoint = `/crm-objects/v1/objects/tickets/${ticketId}`;
|
|
2500
|
+
responseData = await GenericFunctions_1.hubspotApiRequest.call(this, 'PUT', endpoint, body);
|
|
2501
|
+
if (updateFields.associatedCompanyIds) {
|
|
2502
|
+
const companyAssociations = [];
|
|
2503
|
+
for (const companyId of updateFields.associatedCompanyIds) {
|
|
2504
|
+
companyAssociations.push({
|
|
2505
|
+
fromObjectId: responseData.objectId,
|
|
2506
|
+
toObjectId: companyId,
|
|
2507
|
+
category: 'HUBSPOT_DEFINED',
|
|
2508
|
+
definitionId: 26,
|
|
2509
|
+
});
|
|
2510
|
+
}
|
|
2511
|
+
await GenericFunctions_1.hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', companyAssociations);
|
|
2512
|
+
}
|
|
2513
|
+
if (updateFields.associatedContactIds) {
|
|
2514
|
+
const contactAssociations = [];
|
|
2515
|
+
for (const contactId of updateFields.associatedContactIds) {
|
|
2516
|
+
contactAssociations.push({
|
|
2517
|
+
fromObjectId: responseData.objectId,
|
|
2518
|
+
toObjectId: contactId,
|
|
2519
|
+
category: 'HUBSPOT_DEFINED',
|
|
2520
|
+
definitionId: 16,
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
await GenericFunctions_1.hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', contactAssociations);
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
|
|
2528
|
+
returnData.push(...executionData);
|
|
2529
|
+
}
|
|
2530
|
+
catch (errorObject) {
|
|
2531
|
+
const error = errorObject.cause.cause ? errorObject.cause : errorObject;
|
|
2532
|
+
if (((_d = error.cause.error) === null || _d === void 0 ? void 0 : _d.validationResults) &&
|
|
2533
|
+
error.cause.error.validationResults[0].error === 'INVALID_EMAIL') {
|
|
2534
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error.cause.error.validationResults[0].message);
|
|
2535
|
+
}
|
|
2536
|
+
if (((_e = error.cause.error) === null || _e === void 0 ? void 0 : _e.message) !== 'The resource you are requesting could not be found') {
|
|
2537
|
+
if (error.httpCode === '404' && error.description === 'resource not found') {
|
|
2538
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${error.node.parameters.resource} #${error.node.parameters[`${error.node.parameters.resource}Id`].value} could not be found. Check your ${error.node.parameters.resource} ID is correct`);
|
|
2539
|
+
}
|
|
2540
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
|
|
2541
|
+
}
|
|
2542
|
+
if (this.continueOnFail()) {
|
|
2543
|
+
returnData.push({ json: { error: error.message } });
|
|
2544
|
+
continue;
|
|
2545
|
+
}
|
|
2546
|
+
throw error;
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
return this.prepareOutputData(returnData);
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
exports.HubspotV2 = HubspotV2;
|
|
2554
|
+
//# sourceMappingURL=HubspotV2.node.js.map
|