@crm-kraft/n8n-nodes-close 2.0.5
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/credentials/CloseApi.credentials.d.ts +23 -0
- package/dist/credentials/CloseApi.credentials.d.ts.map +1 -0
- package/dist/credentials/CloseApi.credentials.js +38 -0
- package/dist/credentials/CloseApi.credentials.js.map +1 -0
- package/dist/nodes/Close/Close.node.d.ts +14 -0
- package/dist/nodes/Close/Close.node.d.ts.map +1 -0
- package/dist/nodes/Close/Close.node.js +893 -0
- package/dist/nodes/Close/Close.node.js.map +1 -0
- package/dist/nodes/Close/GenericFunctions.d.ts +4 -0
- package/dist/nodes/Close/GenericFunctions.d.ts.map +1 -0
- package/dist/nodes/Close/GenericFunctions.js +46 -0
- package/dist/nodes/Close/GenericFunctions.js.map +1 -0
- package/dist/nodes/Close/close.svg +16 -0
- package/dist/nodes/CloseTrigger/CloseTrigger.node.d.ts +18 -0
- package/dist/nodes/CloseTrigger/CloseTrigger.node.d.ts.map +1 -0
- package/dist/nodes/CloseTrigger/CloseTrigger.node.js +361 -0
- package/dist/nodes/CloseTrigger/CloseTrigger.node.js.map +1 -0
- package/dist/nodes/CloseTrigger/close.svg +16 -0
- package/dist/nodes/close.svg +16 -0
- package/package.json +60 -0
|
@@ -0,0 +1,893 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Close = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
6
|
+
class Close {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.description = {
|
|
9
|
+
displayName: 'Close',
|
|
10
|
+
name: 'close',
|
|
11
|
+
icon: 'file:close.svg',
|
|
12
|
+
group: ['transform'],
|
|
13
|
+
version: 1,
|
|
14
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
15
|
+
description: 'Interact with Close CRM',
|
|
16
|
+
defaults: {
|
|
17
|
+
name: 'Close',
|
|
18
|
+
},
|
|
19
|
+
inputs: ['main'],
|
|
20
|
+
outputs: ['main'],
|
|
21
|
+
credentials: [
|
|
22
|
+
{
|
|
23
|
+
name: 'closeApi',
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
properties: [
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Resource',
|
|
30
|
+
name: 'resource',
|
|
31
|
+
type: 'options',
|
|
32
|
+
noDataExpression: true,
|
|
33
|
+
options: [
|
|
34
|
+
{ name: 'Activity', value: 'activity' },
|
|
35
|
+
{ name: 'Comment', value: 'comment' },
|
|
36
|
+
{ name: 'Contact', value: 'contact' },
|
|
37
|
+
{ name: 'Custom Activity', value: 'customActivity' },
|
|
38
|
+
{ name: 'Custom Field', value: 'customField' },
|
|
39
|
+
{ name: 'Email Template', value: 'emailTemplate' },
|
|
40
|
+
{ name: 'Lead', value: 'lead' },
|
|
41
|
+
{ name: 'Lead Status', value: 'leadStatus' },
|
|
42
|
+
{ name: 'Opportunity', value: 'opportunity' },
|
|
43
|
+
{ name: 'Opportunity Status', value: 'opportunityStatus' },
|
|
44
|
+
{ name: 'Pipeline', value: 'pipeline' },
|
|
45
|
+
{ name: 'Smart View', value: 'smartView' },
|
|
46
|
+
{ name: 'Task', value: 'task' },
|
|
47
|
+
{ name: 'User', value: 'user' },
|
|
48
|
+
],
|
|
49
|
+
default: 'lead',
|
|
50
|
+
},
|
|
51
|
+
// ─── LEAD ───────────────────────────────────────────────────────────────
|
|
52
|
+
{
|
|
53
|
+
displayName: 'Operation',
|
|
54
|
+
name: 'operation',
|
|
55
|
+
type: 'options',
|
|
56
|
+
noDataExpression: true,
|
|
57
|
+
displayOptions: { show: { resource: ['lead'] } },
|
|
58
|
+
options: [
|
|
59
|
+
{ name: 'Create', value: 'create', action: 'Create a lead' },
|
|
60
|
+
{ name: 'Delete', value: 'delete', action: 'Delete a lead' },
|
|
61
|
+
{ name: 'Get', value: 'get', action: 'Get a lead' },
|
|
62
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all leads' },
|
|
63
|
+
{ name: 'Update', value: 'update', action: 'Update a lead' },
|
|
64
|
+
{ name: 'Search', value: 'search', action: 'Search leads' },
|
|
65
|
+
],
|
|
66
|
+
default: 'get',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
displayName: 'Lead ID',
|
|
70
|
+
name: 'leadId',
|
|
71
|
+
type: 'string',
|
|
72
|
+
default: '',
|
|
73
|
+
required: true,
|
|
74
|
+
displayOptions: { show: { resource: ['lead'], operation: ['get', 'update', 'delete'] } },
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
displayName: 'Company Name',
|
|
78
|
+
name: 'companyName',
|
|
79
|
+
type: 'string',
|
|
80
|
+
default: '',
|
|
81
|
+
required: true,
|
|
82
|
+
displayOptions: { show: { resource: ['lead'], operation: ['create'] } },
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
displayName: 'Additional Fields',
|
|
86
|
+
name: 'additionalFields',
|
|
87
|
+
type: 'collection',
|
|
88
|
+
placeholder: 'Add Field',
|
|
89
|
+
default: {},
|
|
90
|
+
displayOptions: { show: { resource: ['lead'], operation: ['create', 'update'] } },
|
|
91
|
+
options: [
|
|
92
|
+
{ displayName: 'Description', name: 'description', type: 'string', default: '' },
|
|
93
|
+
{ displayName: 'Status', name: 'status_id', type: 'options', typeOptions: { loadOptionsMethod: 'getLeadStatuses' }, default: '' },
|
|
94
|
+
{ displayName: 'URL', name: 'url', type: 'string', default: '' },
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
displayName: 'Query',
|
|
99
|
+
name: 'query',
|
|
100
|
+
type: 'string',
|
|
101
|
+
default: '',
|
|
102
|
+
required: true,
|
|
103
|
+
displayOptions: { show: { resource: ['lead'], operation: ['search'] } },
|
|
104
|
+
description: 'Search query string',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
displayName: 'Return All',
|
|
108
|
+
name: 'returnAll',
|
|
109
|
+
type: 'boolean',
|
|
110
|
+
default: false,
|
|
111
|
+
displayOptions: { show: { resource: ['lead'], operation: ['getAll', 'search'] } },
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
displayName: 'Limit',
|
|
115
|
+
name: 'limit',
|
|
116
|
+
type: 'number',
|
|
117
|
+
default: 50,
|
|
118
|
+
typeOptions: { minValue: 1, maxValue: 200 },
|
|
119
|
+
displayOptions: { show: { resource: ['lead'], operation: ['getAll', 'search'], returnAll: [false] } },
|
|
120
|
+
},
|
|
121
|
+
// ─── CONTACT ────────────────────────────────────────────────────────────
|
|
122
|
+
{
|
|
123
|
+
displayName: 'Operation',
|
|
124
|
+
name: 'operation',
|
|
125
|
+
type: 'options',
|
|
126
|
+
noDataExpression: true,
|
|
127
|
+
displayOptions: { show: { resource: ['contact'] } },
|
|
128
|
+
options: [
|
|
129
|
+
{ name: 'Create', value: 'create', action: 'Create a contact' },
|
|
130
|
+
{ name: 'Delete', value: 'delete', action: 'Delete a contact' },
|
|
131
|
+
{ name: 'Get', value: 'get', action: 'Get a contact' },
|
|
132
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all contacts' },
|
|
133
|
+
{ name: 'Update', value: 'update', action: 'Update a contact' },
|
|
134
|
+
],
|
|
135
|
+
default: 'get',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
displayName: 'Contact ID',
|
|
139
|
+
name: 'contactId',
|
|
140
|
+
type: 'string',
|
|
141
|
+
default: '',
|
|
142
|
+
required: true,
|
|
143
|
+
displayOptions: { show: { resource: ['contact'], operation: ['get', 'update', 'delete'] } },
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
displayName: 'Lead ID',
|
|
147
|
+
name: 'leadId',
|
|
148
|
+
type: 'string',
|
|
149
|
+
default: '',
|
|
150
|
+
required: true,
|
|
151
|
+
displayOptions: { show: { resource: ['contact'], operation: ['create'] } },
|
|
152
|
+
description: 'ID of the lead to create the contact under',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
displayName: 'Name',
|
|
156
|
+
name: 'name',
|
|
157
|
+
type: 'string',
|
|
158
|
+
default: '',
|
|
159
|
+
displayOptions: { show: { resource: ['contact'], operation: ['create'] } },
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
displayName: 'Additional Fields',
|
|
163
|
+
name: 'additionalFields',
|
|
164
|
+
type: 'collection',
|
|
165
|
+
placeholder: 'Add Field',
|
|
166
|
+
default: {},
|
|
167
|
+
displayOptions: { show: { resource: ['contact'], operation: ['create', 'update'] } },
|
|
168
|
+
options: [
|
|
169
|
+
{ displayName: 'Title', name: 'title', type: 'string', default: '' },
|
|
170
|
+
{ displayName: 'Name', name: 'name', type: 'string', default: '' },
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
displayName: 'Return All',
|
|
175
|
+
name: 'returnAll',
|
|
176
|
+
type: 'boolean',
|
|
177
|
+
default: false,
|
|
178
|
+
displayOptions: { show: { resource: ['contact'], operation: ['getAll'] } },
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
displayName: 'Limit',
|
|
182
|
+
name: 'limit',
|
|
183
|
+
type: 'number',
|
|
184
|
+
default: 50,
|
|
185
|
+
typeOptions: { minValue: 1, maxValue: 200 },
|
|
186
|
+
displayOptions: { show: { resource: ['contact'], operation: ['getAll'], returnAll: [false] } },
|
|
187
|
+
},
|
|
188
|
+
// ─── OPPORTUNITY ─────────────────────────────────────────────────────────
|
|
189
|
+
{
|
|
190
|
+
displayName: 'Operation',
|
|
191
|
+
name: 'operation',
|
|
192
|
+
type: 'options',
|
|
193
|
+
noDataExpression: true,
|
|
194
|
+
displayOptions: { show: { resource: ['opportunity'] } },
|
|
195
|
+
options: [
|
|
196
|
+
{ name: 'Create', value: 'create', action: 'Create an opportunity' },
|
|
197
|
+
{ name: 'Delete', value: 'delete', action: 'Delete an opportunity' },
|
|
198
|
+
{ name: 'Get', value: 'get', action: 'Get an opportunity' },
|
|
199
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all opportunities' },
|
|
200
|
+
{ name: 'Update', value: 'update', action: 'Update an opportunity' },
|
|
201
|
+
],
|
|
202
|
+
default: 'get',
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
displayName: 'Opportunity ID',
|
|
206
|
+
name: 'opportunityId',
|
|
207
|
+
type: 'string',
|
|
208
|
+
default: '',
|
|
209
|
+
required: true,
|
|
210
|
+
displayOptions: { show: { resource: ['opportunity'], operation: ['get', 'update', 'delete'] } },
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
displayName: 'Lead ID',
|
|
214
|
+
name: 'leadId',
|
|
215
|
+
type: 'string',
|
|
216
|
+
default: '',
|
|
217
|
+
required: true,
|
|
218
|
+
displayOptions: { show: { resource: ['opportunity'], operation: ['create'] } },
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
displayName: 'Additional Fields',
|
|
222
|
+
name: 'additionalFields',
|
|
223
|
+
type: 'collection',
|
|
224
|
+
placeholder: 'Add Field',
|
|
225
|
+
default: {},
|
|
226
|
+
displayOptions: { show: { resource: ['opportunity'], operation: ['create', 'update'] } },
|
|
227
|
+
options: [
|
|
228
|
+
{ displayName: 'Note', name: 'note', type: 'string', default: '' },
|
|
229
|
+
{ displayName: 'Status', name: 'status_id', type: 'options', typeOptions: { loadOptionsMethod: 'getOpportunityStatuses' }, default: '' },
|
|
230
|
+
{ displayName: 'Value (in cents)', name: 'value', type: 'number', default: 0 },
|
|
231
|
+
{ displayName: 'Value Currency', name: 'value_currency', type: 'string', default: 'USD' },
|
|
232
|
+
{ displayName: 'Value Period', name: 'value_period', type: 'options', options: [{ name: 'One Time', value: 'one_time' }, { name: 'Monthly', value: 'monthly' }, { name: 'Annual', value: 'annual' }], default: 'one_time' },
|
|
233
|
+
{ displayName: 'Close Date', name: 'date_won', type: 'string', default: '' },
|
|
234
|
+
],
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
displayName: 'Return All',
|
|
238
|
+
name: 'returnAll',
|
|
239
|
+
type: 'boolean',
|
|
240
|
+
default: false,
|
|
241
|
+
displayOptions: { show: { resource: ['opportunity'], operation: ['getAll'] } },
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
displayName: 'Limit',
|
|
245
|
+
name: 'limit',
|
|
246
|
+
type: 'number',
|
|
247
|
+
default: 50,
|
|
248
|
+
typeOptions: { minValue: 1, maxValue: 200 },
|
|
249
|
+
displayOptions: { show: { resource: ['opportunity'], operation: ['getAll'], returnAll: [false] } },
|
|
250
|
+
},
|
|
251
|
+
// ─── TASK ────────────────────────────────────────────────────────────────
|
|
252
|
+
{
|
|
253
|
+
displayName: 'Operation',
|
|
254
|
+
name: 'operation',
|
|
255
|
+
type: 'options',
|
|
256
|
+
noDataExpression: true,
|
|
257
|
+
displayOptions: { show: { resource: ['task'] } },
|
|
258
|
+
options: [
|
|
259
|
+
{ name: 'Create', value: 'create', action: 'Create a task' },
|
|
260
|
+
{ name: 'Delete', value: 'delete', action: 'Delete a task' },
|
|
261
|
+
{ name: 'Get', value: 'get', action: 'Get a task' },
|
|
262
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all tasks' },
|
|
263
|
+
{ name: 'Update', value: 'update', action: 'Update a task' },
|
|
264
|
+
],
|
|
265
|
+
default: 'get',
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
displayName: 'Task ID',
|
|
269
|
+
name: 'taskId',
|
|
270
|
+
type: 'string',
|
|
271
|
+
default: '',
|
|
272
|
+
required: true,
|
|
273
|
+
displayOptions: { show: { resource: ['task'], operation: ['get', 'update', 'delete'] } },
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
displayName: 'Text',
|
|
277
|
+
name: 'text',
|
|
278
|
+
type: 'string',
|
|
279
|
+
default: '',
|
|
280
|
+
required: true,
|
|
281
|
+
displayOptions: { show: { resource: ['task'], operation: ['create'] } },
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
displayName: 'Additional Fields',
|
|
285
|
+
name: 'additionalFields',
|
|
286
|
+
type: 'collection',
|
|
287
|
+
placeholder: 'Add Field',
|
|
288
|
+
default: {},
|
|
289
|
+
displayOptions: { show: { resource: ['task'], operation: ['create', 'update'] } },
|
|
290
|
+
options: [
|
|
291
|
+
{ displayName: 'Lead ID', name: 'lead_id', type: 'string', default: '' },
|
|
292
|
+
{ displayName: 'Assigned To (User ID)', name: 'assigned_to', type: 'string', default: '' },
|
|
293
|
+
{ displayName: 'Due Date', name: 'due_date', type: 'string', default: '', description: 'ISO 8601 date string' },
|
|
294
|
+
{ displayName: 'Is Complete', name: 'is_complete', type: 'boolean', default: false },
|
|
295
|
+
],
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
displayName: 'Return All',
|
|
299
|
+
name: 'returnAll',
|
|
300
|
+
type: 'boolean',
|
|
301
|
+
default: false,
|
|
302
|
+
displayOptions: { show: { resource: ['task'], operation: ['getAll'] } },
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
displayName: 'Limit',
|
|
306
|
+
name: 'limit',
|
|
307
|
+
type: 'number',
|
|
308
|
+
default: 50,
|
|
309
|
+
typeOptions: { minValue: 1, maxValue: 200 },
|
|
310
|
+
displayOptions: { show: { resource: ['task'], operation: ['getAll'], returnAll: [false] } },
|
|
311
|
+
},
|
|
312
|
+
// ─── ACTIVITY ────────────────────────────────────────────────────────────
|
|
313
|
+
{
|
|
314
|
+
displayName: 'Operation',
|
|
315
|
+
name: 'operation',
|
|
316
|
+
type: 'options',
|
|
317
|
+
noDataExpression: true,
|
|
318
|
+
displayOptions: { show: { resource: ['activity'] } },
|
|
319
|
+
options: [
|
|
320
|
+
{ name: 'Create Note', value: 'createNote', action: 'Create a note activity' },
|
|
321
|
+
{ name: 'Get', value: 'get', action: 'Get an activity' },
|
|
322
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all activities for a lead' },
|
|
323
|
+
{ name: 'Delete', value: 'delete', action: 'Delete an activity' },
|
|
324
|
+
],
|
|
325
|
+
default: 'getAll',
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
displayName: 'Activity ID',
|
|
329
|
+
name: 'activityId',
|
|
330
|
+
type: 'string',
|
|
331
|
+
default: '',
|
|
332
|
+
required: true,
|
|
333
|
+
displayOptions: { show: { resource: ['activity'], operation: ['get', 'delete'] } },
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
displayName: 'Lead ID',
|
|
337
|
+
name: 'leadId',
|
|
338
|
+
type: 'string',
|
|
339
|
+
default: '',
|
|
340
|
+
required: true,
|
|
341
|
+
displayOptions: { show: { resource: ['activity'], operation: ['createNote', 'getAll'] } },
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
displayName: 'Note',
|
|
345
|
+
name: 'note',
|
|
346
|
+
type: 'string',
|
|
347
|
+
default: '',
|
|
348
|
+
required: true,
|
|
349
|
+
displayOptions: { show: { resource: ['activity'], operation: ['createNote'] } },
|
|
350
|
+
},
|
|
351
|
+
// ─── CUSTOM ACTIVITY ─────────────────────────────────────────────────────
|
|
352
|
+
{
|
|
353
|
+
displayName: 'Operation',
|
|
354
|
+
name: 'operation',
|
|
355
|
+
type: 'options',
|
|
356
|
+
noDataExpression: true,
|
|
357
|
+
displayOptions: { show: { resource: ['customActivity'] } },
|
|
358
|
+
options: [
|
|
359
|
+
{ name: 'Create', value: 'create', action: 'Create a custom activity' },
|
|
360
|
+
{ name: 'Delete', value: 'delete', action: 'Delete a custom activity' },
|
|
361
|
+
{ name: 'Get', value: 'get', action: 'Get a custom activity' },
|
|
362
|
+
{ name: 'Update', value: 'update', action: 'Update a custom activity' },
|
|
363
|
+
],
|
|
364
|
+
default: 'create',
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
displayName: 'Custom Activity ID',
|
|
368
|
+
name: 'customActivityId',
|
|
369
|
+
type: 'string',
|
|
370
|
+
default: '',
|
|
371
|
+
required: true,
|
|
372
|
+
displayOptions: { show: { resource: ['customActivity'], operation: ['get', 'update', 'delete'] } },
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
displayName: 'Activity Type',
|
|
376
|
+
name: 'activityTypeId',
|
|
377
|
+
type: 'options',
|
|
378
|
+
typeOptions: { loadOptionsMethod: 'getCustomActivityTypes' },
|
|
379
|
+
default: '',
|
|
380
|
+
required: true,
|
|
381
|
+
displayOptions: { show: { resource: ['customActivity'], operation: ['create'] } },
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
displayName: 'Lead ID',
|
|
385
|
+
name: 'leadId',
|
|
386
|
+
type: 'string',
|
|
387
|
+
default: '',
|
|
388
|
+
required: true,
|
|
389
|
+
displayOptions: { show: { resource: ['customActivity'], operation: ['create'] } },
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
displayName: 'Additional Fields',
|
|
393
|
+
name: 'additionalFields',
|
|
394
|
+
type: 'collection',
|
|
395
|
+
placeholder: 'Add Field',
|
|
396
|
+
default: {},
|
|
397
|
+
displayOptions: { show: { resource: ['customActivity'], operation: ['create', 'update'] } },
|
|
398
|
+
options: [
|
|
399
|
+
{ displayName: 'Status', name: 'status', type: 'options', options: [{ name: 'Draft', value: 'draft' }, { name: 'Published', value: 'published' }], default: 'draft' },
|
|
400
|
+
{ displayName: 'Custom Fields (JSON)', name: 'custom_fields_json', type: 'string', default: '', description: 'JSON object of custom field ID to value pairs' },
|
|
401
|
+
],
|
|
402
|
+
},
|
|
403
|
+
// ─── COMMENT ─────────────────────────────────────────────────────────────
|
|
404
|
+
{
|
|
405
|
+
displayName: 'Operation',
|
|
406
|
+
name: 'operation',
|
|
407
|
+
type: 'options',
|
|
408
|
+
noDataExpression: true,
|
|
409
|
+
displayOptions: { show: { resource: ['comment'] } },
|
|
410
|
+
options: [
|
|
411
|
+
{ name: 'Create', value: 'create', action: 'Create a comment' },
|
|
412
|
+
{ name: 'Delete', value: 'delete', action: 'Delete a comment' },
|
|
413
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all comments for a lead' },
|
|
414
|
+
],
|
|
415
|
+
default: 'getAll',
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
displayName: 'Lead ID',
|
|
419
|
+
name: 'leadId',
|
|
420
|
+
type: 'string',
|
|
421
|
+
default: '',
|
|
422
|
+
required: true,
|
|
423
|
+
displayOptions: { show: { resource: ['comment'], operation: ['create', 'getAll'] } },
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
displayName: 'Comment ID',
|
|
427
|
+
name: 'commentId',
|
|
428
|
+
type: 'string',
|
|
429
|
+
default: '',
|
|
430
|
+
required: true,
|
|
431
|
+
displayOptions: { show: { resource: ['comment'], operation: ['delete'] } },
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
displayName: 'Note',
|
|
435
|
+
name: 'note',
|
|
436
|
+
type: 'string',
|
|
437
|
+
default: '',
|
|
438
|
+
required: true,
|
|
439
|
+
displayOptions: { show: { resource: ['comment'], operation: ['create'] } },
|
|
440
|
+
},
|
|
441
|
+
// ─── EMAIL TEMPLATE ───────────────────────────────────────────────────────
|
|
442
|
+
{
|
|
443
|
+
displayName: 'Operation',
|
|
444
|
+
name: 'operation',
|
|
445
|
+
type: 'options',
|
|
446
|
+
noDataExpression: true,
|
|
447
|
+
displayOptions: { show: { resource: ['emailTemplate'] } },
|
|
448
|
+
options: [
|
|
449
|
+
{ name: 'Get', value: 'get', action: 'Get an email template' },
|
|
450
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all email templates' },
|
|
451
|
+
],
|
|
452
|
+
default: 'getAll',
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
displayName: 'Template ID',
|
|
456
|
+
name: 'templateId',
|
|
457
|
+
type: 'string',
|
|
458
|
+
default: '',
|
|
459
|
+
required: true,
|
|
460
|
+
displayOptions: { show: { resource: ['emailTemplate'], operation: ['get'] } },
|
|
461
|
+
},
|
|
462
|
+
// ─── LEAD STATUS ──────────────────────────────────────────────────────────
|
|
463
|
+
{
|
|
464
|
+
displayName: 'Operation',
|
|
465
|
+
name: 'operation',
|
|
466
|
+
type: 'options',
|
|
467
|
+
noDataExpression: true,
|
|
468
|
+
displayOptions: { show: { resource: ['leadStatus'] } },
|
|
469
|
+
options: [
|
|
470
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all lead statuses' },
|
|
471
|
+
],
|
|
472
|
+
default: 'getAll',
|
|
473
|
+
},
|
|
474
|
+
// ─── OPPORTUNITY STATUS ───────────────────────────────────────────────────
|
|
475
|
+
{
|
|
476
|
+
displayName: 'Operation',
|
|
477
|
+
name: 'operation',
|
|
478
|
+
type: 'options',
|
|
479
|
+
noDataExpression: true,
|
|
480
|
+
displayOptions: { show: { resource: ['opportunityStatus'] } },
|
|
481
|
+
options: [
|
|
482
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all opportunity statuses' },
|
|
483
|
+
],
|
|
484
|
+
default: 'getAll',
|
|
485
|
+
},
|
|
486
|
+
// ─── PIPELINE ─────────────────────────────────────────────────────────────
|
|
487
|
+
{
|
|
488
|
+
displayName: 'Operation',
|
|
489
|
+
name: 'operation',
|
|
490
|
+
type: 'options',
|
|
491
|
+
noDataExpression: true,
|
|
492
|
+
displayOptions: { show: { resource: ['pipeline'] } },
|
|
493
|
+
options: [
|
|
494
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all pipelines' },
|
|
495
|
+
],
|
|
496
|
+
default: 'getAll',
|
|
497
|
+
},
|
|
498
|
+
// ─── SMART VIEW ───────────────────────────────────────────────────────────
|
|
499
|
+
{
|
|
500
|
+
displayName: 'Operation',
|
|
501
|
+
name: 'operation',
|
|
502
|
+
type: 'options',
|
|
503
|
+
noDataExpression: true,
|
|
504
|
+
displayOptions: { show: { resource: ['smartView'] } },
|
|
505
|
+
options: [
|
|
506
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all smart views' },
|
|
507
|
+
{ name: 'Get Leads', value: 'getLeads', action: 'Get leads from a smart view' },
|
|
508
|
+
],
|
|
509
|
+
default: 'getAll',
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
displayName: 'Smart View ID',
|
|
513
|
+
name: 'smartViewId',
|
|
514
|
+
type: 'string',
|
|
515
|
+
default: '',
|
|
516
|
+
required: true,
|
|
517
|
+
displayOptions: { show: { resource: ['smartView'], operation: ['getLeads'] } },
|
|
518
|
+
},
|
|
519
|
+
// ─── USER ─────────────────────────────────────────────────────────────────
|
|
520
|
+
{
|
|
521
|
+
displayName: 'Operation',
|
|
522
|
+
name: 'operation',
|
|
523
|
+
type: 'options',
|
|
524
|
+
noDataExpression: true,
|
|
525
|
+
displayOptions: { show: { resource: ['user'] } },
|
|
526
|
+
options: [
|
|
527
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all users' },
|
|
528
|
+
{ name: 'Get Me', value: 'getMe', action: 'Get current user' },
|
|
529
|
+
],
|
|
530
|
+
default: 'getAll',
|
|
531
|
+
},
|
|
532
|
+
// ─── CUSTOM FIELD ─────────────────────────────────────────────────────────
|
|
533
|
+
{
|
|
534
|
+
displayName: 'Operation',
|
|
535
|
+
name: 'operation',
|
|
536
|
+
type: 'options',
|
|
537
|
+
noDataExpression: true,
|
|
538
|
+
displayOptions: { show: { resource: ['customField'] } },
|
|
539
|
+
options: [
|
|
540
|
+
{ name: 'Get All', value: 'getAll', action: 'Get all custom fields' },
|
|
541
|
+
],
|
|
542
|
+
default: 'getAll',
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
displayName: 'Object Type',
|
|
546
|
+
name: 'objectType',
|
|
547
|
+
type: 'options',
|
|
548
|
+
options: [
|
|
549
|
+
{ name: 'Contact', value: 'contact' },
|
|
550
|
+
{ name: 'Lead', value: 'lead' },
|
|
551
|
+
{ name: 'Opportunity', value: 'opportunity' },
|
|
552
|
+
{ name: 'Shared', value: 'shared' },
|
|
553
|
+
],
|
|
554
|
+
default: 'lead',
|
|
555
|
+
displayOptions: { show: { resource: ['customField'], operation: ['getAll'] } },
|
|
556
|
+
},
|
|
557
|
+
],
|
|
558
|
+
};
|
|
559
|
+
this.methods = {
|
|
560
|
+
loadOptions: {
|
|
561
|
+
async getLeadStatuses() {
|
|
562
|
+
const response = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/status/lead/');
|
|
563
|
+
return (response.data || []).map((s) => ({ name: s.label, value: s.id }));
|
|
564
|
+
},
|
|
565
|
+
async getOpportunityStatuses() {
|
|
566
|
+
const response = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/status/opportunity/');
|
|
567
|
+
return (response.data || []).map((s) => ({ name: s.label, value: s.id }));
|
|
568
|
+
},
|
|
569
|
+
async getCustomActivityTypes() {
|
|
570
|
+
const response = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/custom_activity/');
|
|
571
|
+
return (response.data || []).map((t) => ({ name: t.name, value: t.id }));
|
|
572
|
+
},
|
|
573
|
+
async getUsers() {
|
|
574
|
+
const response = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/user/');
|
|
575
|
+
return (response.data || []).map((u) => ({
|
|
576
|
+
name: `${u.first_name} ${u.last_name}`.trim() || u.email,
|
|
577
|
+
value: u.id,
|
|
578
|
+
}));
|
|
579
|
+
},
|
|
580
|
+
},
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
async execute() {
|
|
584
|
+
const items = this.getInputData();
|
|
585
|
+
const returnData = [];
|
|
586
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
587
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
588
|
+
for (let i = 0; i < items.length; i++) {
|
|
589
|
+
try {
|
|
590
|
+
let responseData;
|
|
591
|
+
// ── LEAD ──────────────────────────────────────────────────────────────
|
|
592
|
+
if (resource === 'lead') {
|
|
593
|
+
if (operation === 'get') {
|
|
594
|
+
const leadId = this.getNodeParameter('leadId', i);
|
|
595
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'GET', `/lead/${leadId}/`);
|
|
596
|
+
}
|
|
597
|
+
else if (operation === 'getAll') {
|
|
598
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
599
|
+
if (returnAll) {
|
|
600
|
+
responseData = await GenericFunctions_1.closeApiRequestAllItems.call(this, 'GET', '/lead/');
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
const limit = this.getNodeParameter('limit', i);
|
|
604
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/lead/', {}, { _limit: limit });
|
|
605
|
+
responseData = res.data || [];
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
else if (operation === 'search') {
|
|
609
|
+
const query = this.getNodeParameter('query', i);
|
|
610
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
611
|
+
if (returnAll) {
|
|
612
|
+
responseData = await GenericFunctions_1.closeApiRequestAllItems.call(this, 'GET', '/lead/', {}, { query });
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
const limit = this.getNodeParameter('limit', i);
|
|
616
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/lead/', {}, { query, _limit: limit });
|
|
617
|
+
responseData = res.data || [];
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
else if (operation === 'create') {
|
|
621
|
+
const companyName = this.getNodeParameter('companyName', i);
|
|
622
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
623
|
+
const body = { name: companyName, ...additionalFields };
|
|
624
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'POST', '/lead/', body);
|
|
625
|
+
}
|
|
626
|
+
else if (operation === 'update') {
|
|
627
|
+
const leadId = this.getNodeParameter('leadId', i);
|
|
628
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
629
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'PUT', `/lead/${leadId}/`, additionalFields);
|
|
630
|
+
}
|
|
631
|
+
else if (operation === 'delete') {
|
|
632
|
+
const leadId = this.getNodeParameter('leadId', i);
|
|
633
|
+
await GenericFunctions_1.closeApiRequest.call(this, 'DELETE', `/lead/${leadId}/`);
|
|
634
|
+
responseData = { success: true };
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
// ── CONTACT ───────────────────────────────────────────────────────────
|
|
638
|
+
else if (resource === 'contact') {
|
|
639
|
+
if (operation === 'get') {
|
|
640
|
+
const contactId = this.getNodeParameter('contactId', i);
|
|
641
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'GET', `/contact/${contactId}/`);
|
|
642
|
+
}
|
|
643
|
+
else if (operation === 'getAll') {
|
|
644
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
645
|
+
if (returnAll) {
|
|
646
|
+
responseData = await GenericFunctions_1.closeApiRequestAllItems.call(this, 'GET', '/contact/');
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
const limit = this.getNodeParameter('limit', i);
|
|
650
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/contact/', {}, { _limit: limit });
|
|
651
|
+
responseData = res.data || [];
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
else if (operation === 'create') {
|
|
655
|
+
const leadId = this.getNodeParameter('leadId', i);
|
|
656
|
+
const name = this.getNodeParameter('name', i);
|
|
657
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
658
|
+
const body = { lead_id: leadId, name, ...additionalFields };
|
|
659
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'POST', '/contact/', body);
|
|
660
|
+
}
|
|
661
|
+
else if (operation === 'update') {
|
|
662
|
+
const contactId = this.getNodeParameter('contactId', i);
|
|
663
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
664
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'PUT', `/contact/${contactId}/`, additionalFields);
|
|
665
|
+
}
|
|
666
|
+
else if (operation === 'delete') {
|
|
667
|
+
const contactId = this.getNodeParameter('contactId', i);
|
|
668
|
+
await GenericFunctions_1.closeApiRequest.call(this, 'DELETE', `/contact/${contactId}/`);
|
|
669
|
+
responseData = { success: true };
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
// ── OPPORTUNITY ───────────────────────────────────────────────────────
|
|
673
|
+
else if (resource === 'opportunity') {
|
|
674
|
+
if (operation === 'get') {
|
|
675
|
+
const opportunityId = this.getNodeParameter('opportunityId', i);
|
|
676
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'GET', `/opportunity/${opportunityId}/`);
|
|
677
|
+
}
|
|
678
|
+
else if (operation === 'getAll') {
|
|
679
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
680
|
+
if (returnAll) {
|
|
681
|
+
responseData = await GenericFunctions_1.closeApiRequestAllItems.call(this, 'GET', '/opportunity/');
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
const limit = this.getNodeParameter('limit', i);
|
|
685
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/opportunity/', {}, { _limit: limit });
|
|
686
|
+
responseData = res.data || [];
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
else if (operation === 'create') {
|
|
690
|
+
const leadId = this.getNodeParameter('leadId', i);
|
|
691
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
692
|
+
const body = { lead_id: leadId, ...additionalFields };
|
|
693
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'POST', '/opportunity/', body);
|
|
694
|
+
}
|
|
695
|
+
else if (operation === 'update') {
|
|
696
|
+
const opportunityId = this.getNodeParameter('opportunityId', i);
|
|
697
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
698
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'PUT', `/opportunity/${opportunityId}/`, additionalFields);
|
|
699
|
+
}
|
|
700
|
+
else if (operation === 'delete') {
|
|
701
|
+
const opportunityId = this.getNodeParameter('opportunityId', i);
|
|
702
|
+
await GenericFunctions_1.closeApiRequest.call(this, 'DELETE', `/opportunity/${opportunityId}/`);
|
|
703
|
+
responseData = { success: true };
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
// ── TASK ──────────────────────────────────────────────────────────────
|
|
707
|
+
else if (resource === 'task') {
|
|
708
|
+
if (operation === 'get') {
|
|
709
|
+
const taskId = this.getNodeParameter('taskId', i);
|
|
710
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'GET', `/task/${taskId}/`);
|
|
711
|
+
}
|
|
712
|
+
else if (operation === 'getAll') {
|
|
713
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
714
|
+
if (returnAll) {
|
|
715
|
+
responseData = await GenericFunctions_1.closeApiRequestAllItems.call(this, 'GET', '/task/');
|
|
716
|
+
}
|
|
717
|
+
else {
|
|
718
|
+
const limit = this.getNodeParameter('limit', i);
|
|
719
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/task/', {}, { _limit: limit });
|
|
720
|
+
responseData = res.data || [];
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
else if (operation === 'create') {
|
|
724
|
+
const text = this.getNodeParameter('text', i);
|
|
725
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
726
|
+
const body = { text, ...additionalFields };
|
|
727
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'POST', '/task/', body);
|
|
728
|
+
}
|
|
729
|
+
else if (operation === 'update') {
|
|
730
|
+
const taskId = this.getNodeParameter('taskId', i);
|
|
731
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
732
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'PUT', `/task/${taskId}/`, additionalFields);
|
|
733
|
+
}
|
|
734
|
+
else if (operation === 'delete') {
|
|
735
|
+
const taskId = this.getNodeParameter('taskId', i);
|
|
736
|
+
await GenericFunctions_1.closeApiRequest.call(this, 'DELETE', `/task/${taskId}/`);
|
|
737
|
+
responseData = { success: true };
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
// ── ACTIVITY ──────────────────────────────────────────────────────────
|
|
741
|
+
else if (resource === 'activity') {
|
|
742
|
+
if (operation === 'createNote') {
|
|
743
|
+
const leadId = this.getNodeParameter('leadId', i);
|
|
744
|
+
const note = this.getNodeParameter('note', i);
|
|
745
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'POST', '/activity/note/', { lead_id: leadId, note });
|
|
746
|
+
}
|
|
747
|
+
else if (operation === 'get') {
|
|
748
|
+
const activityId = this.getNodeParameter('activityId', i);
|
|
749
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'GET', `/activity/${activityId}/`);
|
|
750
|
+
}
|
|
751
|
+
else if (operation === 'getAll') {
|
|
752
|
+
const leadId = this.getNodeParameter('leadId', i);
|
|
753
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/activity/', {}, { lead_id: leadId });
|
|
754
|
+
responseData = res.data || [];
|
|
755
|
+
}
|
|
756
|
+
else if (operation === 'delete') {
|
|
757
|
+
const activityId = this.getNodeParameter('activityId', i);
|
|
758
|
+
await GenericFunctions_1.closeApiRequest.call(this, 'DELETE', `/activity/${activityId}/`);
|
|
759
|
+
responseData = { success: true };
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
// ── CUSTOM ACTIVITY ───────────────────────────────────────────────────
|
|
763
|
+
else if (resource === 'customActivity') {
|
|
764
|
+
if (operation === 'get') {
|
|
765
|
+
const id = this.getNodeParameter('customActivityId', i);
|
|
766
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'GET', `/activity/custom/${id}/`);
|
|
767
|
+
}
|
|
768
|
+
else if (operation === 'create') {
|
|
769
|
+
const activityTypeId = this.getNodeParameter('activityTypeId', i);
|
|
770
|
+
const leadId = this.getNodeParameter('leadId', i);
|
|
771
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
772
|
+
const body = { activity_at: new Date().toISOString(), lead_id: leadId, _type: activityTypeId };
|
|
773
|
+
if (additionalFields.status)
|
|
774
|
+
body.status = additionalFields.status;
|
|
775
|
+
if (additionalFields.custom_fields_json) {
|
|
776
|
+
try {
|
|
777
|
+
Object.assign(body, JSON.parse(additionalFields.custom_fields_json));
|
|
778
|
+
}
|
|
779
|
+
catch (_) { }
|
|
780
|
+
}
|
|
781
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'POST', '/activity/custom/', body);
|
|
782
|
+
}
|
|
783
|
+
else if (operation === 'update') {
|
|
784
|
+
const id = this.getNodeParameter('customActivityId', i);
|
|
785
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
786
|
+
const body = {};
|
|
787
|
+
if (additionalFields.status)
|
|
788
|
+
body.status = additionalFields.status;
|
|
789
|
+
if (additionalFields.custom_fields_json) {
|
|
790
|
+
try {
|
|
791
|
+
Object.assign(body, JSON.parse(additionalFields.custom_fields_json));
|
|
792
|
+
}
|
|
793
|
+
catch (_) { }
|
|
794
|
+
}
|
|
795
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'PUT', `/activity/custom/${id}/`, body);
|
|
796
|
+
}
|
|
797
|
+
else if (operation === 'delete') {
|
|
798
|
+
const id = this.getNodeParameter('customActivityId', i);
|
|
799
|
+
await GenericFunctions_1.closeApiRequest.call(this, 'DELETE', `/activity/custom/${id}/`);
|
|
800
|
+
responseData = { success: true };
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
// ── COMMENT ───────────────────────────────────────────────────────────
|
|
804
|
+
else if (resource === 'comment') {
|
|
805
|
+
if (operation === 'getAll') {
|
|
806
|
+
const leadId = this.getNodeParameter('leadId', i);
|
|
807
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/activity/note/', {}, { lead_id: leadId });
|
|
808
|
+
responseData = res.data || [];
|
|
809
|
+
}
|
|
810
|
+
else if (operation === 'create') {
|
|
811
|
+
const leadId = this.getNodeParameter('leadId', i);
|
|
812
|
+
const note = this.getNodeParameter('note', i);
|
|
813
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'POST', '/activity/note/', { lead_id: leadId, note });
|
|
814
|
+
}
|
|
815
|
+
else if (operation === 'delete') {
|
|
816
|
+
const commentId = this.getNodeParameter('commentId', i);
|
|
817
|
+
await GenericFunctions_1.closeApiRequest.call(this, 'DELETE', `/activity/note/${commentId}/`);
|
|
818
|
+
responseData = { success: true };
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
// ── EMAIL TEMPLATE ────────────────────────────────────────────────────
|
|
822
|
+
else if (resource === 'emailTemplate') {
|
|
823
|
+
if (operation === 'get') {
|
|
824
|
+
const templateId = this.getNodeParameter('templateId', i);
|
|
825
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'GET', `/email_template/${templateId}/`);
|
|
826
|
+
}
|
|
827
|
+
else if (operation === 'getAll') {
|
|
828
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/email_template/');
|
|
829
|
+
responseData = res.data || [];
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
// ── LEAD STATUS ───────────────────────────────────────────────────────
|
|
833
|
+
else if (resource === 'leadStatus') {
|
|
834
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/status/lead/');
|
|
835
|
+
responseData = res.data || [];
|
|
836
|
+
}
|
|
837
|
+
// ── OPPORTUNITY STATUS ────────────────────────────────────────────────
|
|
838
|
+
else if (resource === 'opportunityStatus') {
|
|
839
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/status/opportunity/');
|
|
840
|
+
responseData = res.data || [];
|
|
841
|
+
}
|
|
842
|
+
// ── PIPELINE ──────────────────────────────────────────────────────────
|
|
843
|
+
else if (resource === 'pipeline') {
|
|
844
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/pipeline/');
|
|
845
|
+
responseData = res.data || [];
|
|
846
|
+
}
|
|
847
|
+
// ── SMART VIEW ────────────────────────────────────────────────────────
|
|
848
|
+
else if (resource === 'smartView') {
|
|
849
|
+
if (operation === 'getAll') {
|
|
850
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/saved_search/');
|
|
851
|
+
responseData = res.data || [];
|
|
852
|
+
}
|
|
853
|
+
else if (operation === 'getLeads') {
|
|
854
|
+
const smartViewId = this.getNodeParameter('smartViewId', i);
|
|
855
|
+
responseData = await GenericFunctions_1.closeApiRequestAllItems.call(this, 'GET', '/lead/', {}, { saved_search_id: smartViewId });
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
// ── USER ──────────────────────────────────────────────────────────────
|
|
859
|
+
else if (resource === 'user') {
|
|
860
|
+
if (operation === 'getAll') {
|
|
861
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/user/');
|
|
862
|
+
responseData = res.data || [];
|
|
863
|
+
}
|
|
864
|
+
else if (operation === 'getMe') {
|
|
865
|
+
responseData = await GenericFunctions_1.closeApiRequest.call(this, 'GET', '/me/');
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
// ── CUSTOM FIELD ──────────────────────────────────────────────────────
|
|
869
|
+
else if (resource === 'customField') {
|
|
870
|
+
const objectType = this.getNodeParameter('objectType', i);
|
|
871
|
+
const res = await GenericFunctions_1.closeApiRequest.call(this, 'GET', `/custom_field/${objectType}/`);
|
|
872
|
+
responseData = res.data || [];
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown resource: ${resource}`, { itemIndex: i });
|
|
876
|
+
}
|
|
877
|
+
// Normalize to array
|
|
878
|
+
const items2 = Array.isArray(responseData) ? responseData : [responseData];
|
|
879
|
+
returnData.push(...items2.map((item) => ({ json: item })));
|
|
880
|
+
}
|
|
881
|
+
catch (error) {
|
|
882
|
+
if (this.continueOnFail()) {
|
|
883
|
+
returnData.push({ json: { error: error.message } });
|
|
884
|
+
continue;
|
|
885
|
+
}
|
|
886
|
+
throw error;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return [returnData];
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
exports.Close = Close;
|
|
893
|
+
//# sourceMappingURL=Close.node.js.map
|