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