n8n-nodes-perfexcrm 0.1.9 → 0.1.10
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.
|
@@ -86,6 +86,11 @@ class PerfexCrm {
|
|
|
86
86
|
let responseData;
|
|
87
87
|
const baseUrl = credentials.baseUrl;
|
|
88
88
|
const apiVersion = credentials.apiVersion;
|
|
89
|
+
const apiKey = credentials.apiKey;
|
|
90
|
+
// Headers with API key for authentication
|
|
91
|
+
const headers = {
|
|
92
|
+
'X-API-KEY': apiKey,
|
|
93
|
+
};
|
|
89
94
|
for (let i = 0; i < items.length; i++) {
|
|
90
95
|
try {
|
|
91
96
|
if (resource === 'customer') {
|
|
@@ -101,6 +106,7 @@ class PerfexCrm {
|
|
|
101
106
|
url: `${baseUrl}/api/${apiVersion}/customers`,
|
|
102
107
|
body,
|
|
103
108
|
json: true,
|
|
109
|
+
headers,
|
|
104
110
|
});
|
|
105
111
|
}
|
|
106
112
|
else if (operation === 'get') {
|
|
@@ -109,6 +115,7 @@ class PerfexCrm {
|
|
|
109
115
|
method: 'GET',
|
|
110
116
|
url: `${baseUrl}/api/${apiVersion}/customers/${customerId}`,
|
|
111
117
|
json: true,
|
|
118
|
+
headers,
|
|
112
119
|
});
|
|
113
120
|
}
|
|
114
121
|
else if (operation === 'getAll') {
|
|
@@ -127,6 +134,7 @@ class PerfexCrm {
|
|
|
127
134
|
url: `${baseUrl}/api/${apiVersion}/customers`,
|
|
128
135
|
qs,
|
|
129
136
|
json: true,
|
|
137
|
+
headers,
|
|
130
138
|
});
|
|
131
139
|
if (responseData.data) {
|
|
132
140
|
responseData = responseData.data;
|
|
@@ -141,6 +149,7 @@ class PerfexCrm {
|
|
|
141
149
|
url: `${baseUrl}/api/${apiVersion}/customers/${customerId}`,
|
|
142
150
|
body,
|
|
143
151
|
json: true,
|
|
152
|
+
headers,
|
|
144
153
|
});
|
|
145
154
|
}
|
|
146
155
|
else if (operation === 'delete') {
|
|
@@ -149,6 +158,7 @@ class PerfexCrm {
|
|
|
149
158
|
method: 'DELETE',
|
|
150
159
|
url: `${baseUrl}/api/${apiVersion}/customers/${customerId}`,
|
|
151
160
|
json: true,
|
|
161
|
+
headers,
|
|
152
162
|
});
|
|
153
163
|
}
|
|
154
164
|
else if (operation === 'getContacts') {
|
|
@@ -157,6 +167,7 @@ class PerfexCrm {
|
|
|
157
167
|
method: 'GET',
|
|
158
168
|
url: `${baseUrl}/api/${apiVersion}/customers/${customerId}/contacts`,
|
|
159
169
|
json: true,
|
|
170
|
+
headers,
|
|
160
171
|
});
|
|
161
172
|
if (responseData.data) {
|
|
162
173
|
responseData = responseData.data;
|
|
@@ -168,6 +179,7 @@ class PerfexCrm {
|
|
|
168
179
|
method: 'GET',
|
|
169
180
|
url: `${baseUrl}/api/${apiVersion}/customers/${customerId}/contracts`,
|
|
170
181
|
json: true,
|
|
182
|
+
headers,
|
|
171
183
|
});
|
|
172
184
|
if (responseData.data) {
|
|
173
185
|
responseData = responseData.data;
|
|
@@ -179,6 +191,7 @@ class PerfexCrm {
|
|
|
179
191
|
method: 'GET',
|
|
180
192
|
url: `${baseUrl}/api/${apiVersion}/customers/${customerId}/invoices`,
|
|
181
193
|
json: true,
|
|
194
|
+
headers,
|
|
182
195
|
});
|
|
183
196
|
if (responseData.data) {
|
|
184
197
|
responseData = responseData.data;
|
|
@@ -190,6 +203,7 @@ class PerfexCrm {
|
|
|
190
203
|
method: 'GET',
|
|
191
204
|
url: `${baseUrl}/api/${apiVersion}/customers/${customerId}/projects`,
|
|
192
205
|
json: true,
|
|
206
|
+
headers,
|
|
193
207
|
});
|
|
194
208
|
if (responseData.data) {
|
|
195
209
|
responseData = responseData.data;
|
|
@@ -201,6 +215,7 @@ class PerfexCrm {
|
|
|
201
215
|
method: 'GET',
|
|
202
216
|
url: `${baseUrl}/api/${apiVersion}/customers/${customerId}/tickets`,
|
|
203
217
|
json: true,
|
|
218
|
+
headers,
|
|
204
219
|
});
|
|
205
220
|
if (responseData.data) {
|
|
206
221
|
responseData = responseData.data;
|
|
@@ -222,6 +237,7 @@ class PerfexCrm {
|
|
|
222
237
|
url: `${baseUrl}/api/${apiVersion}/tickets`,
|
|
223
238
|
body,
|
|
224
239
|
json: true,
|
|
240
|
+
headers,
|
|
225
241
|
});
|
|
226
242
|
}
|
|
227
243
|
else if (operation === 'get') {
|
|
@@ -236,6 +252,7 @@ class PerfexCrm {
|
|
|
236
252
|
url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}`,
|
|
237
253
|
qs,
|
|
238
254
|
json: true,
|
|
255
|
+
headers,
|
|
239
256
|
});
|
|
240
257
|
}
|
|
241
258
|
else if (operation === 'getAll') {
|
|
@@ -263,6 +280,7 @@ class PerfexCrm {
|
|
|
263
280
|
url: `${baseUrl}/api/${apiVersion}/tickets`,
|
|
264
281
|
qs,
|
|
265
282
|
json: true,
|
|
283
|
+
headers,
|
|
266
284
|
});
|
|
267
285
|
if (responseData.data) {
|
|
268
286
|
responseData = responseData.data;
|
|
@@ -277,6 +295,7 @@ class PerfexCrm {
|
|
|
277
295
|
url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}`,
|
|
278
296
|
body,
|
|
279
297
|
json: true,
|
|
298
|
+
headers,
|
|
280
299
|
});
|
|
281
300
|
}
|
|
282
301
|
else if (operation === 'delete') {
|
|
@@ -285,6 +304,7 @@ class PerfexCrm {
|
|
|
285
304
|
method: 'DELETE',
|
|
286
305
|
url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}`,
|
|
287
306
|
json: true,
|
|
307
|
+
headers,
|
|
288
308
|
});
|
|
289
309
|
}
|
|
290
310
|
else if (operation === 'addReply') {
|
|
@@ -300,6 +320,7 @@ class PerfexCrm {
|
|
|
300
320
|
url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}/replies`,
|
|
301
321
|
body,
|
|
302
322
|
json: true,
|
|
323
|
+
headers,
|
|
303
324
|
});
|
|
304
325
|
}
|
|
305
326
|
else if (operation === 'getReply') {
|
|
@@ -309,6 +330,7 @@ class PerfexCrm {
|
|
|
309
330
|
method: 'GET',
|
|
310
331
|
url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}/replies/${replyId}`,
|
|
311
332
|
json: true,
|
|
333
|
+
headers,
|
|
312
334
|
});
|
|
313
335
|
}
|
|
314
336
|
else if (operation === 'updateReply') {
|
|
@@ -320,6 +342,7 @@ class PerfexCrm {
|
|
|
320
342
|
url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}/replies/${replyId}`,
|
|
321
343
|
body: updateFields,
|
|
322
344
|
json: true,
|
|
345
|
+
headers,
|
|
323
346
|
});
|
|
324
347
|
}
|
|
325
348
|
else if (operation === 'deleteReply') {
|
|
@@ -329,6 +352,7 @@ class PerfexCrm {
|
|
|
329
352
|
method: 'DELETE',
|
|
330
353
|
url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}/replies/${replyId}`,
|
|
331
354
|
json: true,
|
|
355
|
+
headers,
|
|
332
356
|
});
|
|
333
357
|
}
|
|
334
358
|
else if (operation === 'listReplies') {
|
|
@@ -337,6 +361,7 @@ class PerfexCrm {
|
|
|
337
361
|
method: 'GET',
|
|
338
362
|
url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}/replies`,
|
|
339
363
|
json: true,
|
|
364
|
+
headers,
|
|
340
365
|
});
|
|
341
366
|
if (responseData.data) {
|
|
342
367
|
responseData = responseData.data;
|
|
@@ -362,6 +387,7 @@ class PerfexCrm {
|
|
|
362
387
|
url: `${baseUrl}/api/${apiVersion}/invoices`,
|
|
363
388
|
body,
|
|
364
389
|
json: true,
|
|
390
|
+
headers,
|
|
365
391
|
});
|
|
366
392
|
}
|
|
367
393
|
else if (operation === 'get') {
|
|
@@ -370,6 +396,7 @@ class PerfexCrm {
|
|
|
370
396
|
method: 'GET',
|
|
371
397
|
url: `${baseUrl}/api/${apiVersion}/invoices/${invoiceId}`,
|
|
372
398
|
json: true,
|
|
399
|
+
headers,
|
|
373
400
|
});
|
|
374
401
|
}
|
|
375
402
|
else if (operation === 'getAll') {
|
|
@@ -388,6 +415,7 @@ class PerfexCrm {
|
|
|
388
415
|
url: `${baseUrl}/api/${apiVersion}/invoices`,
|
|
389
416
|
qs,
|
|
390
417
|
json: true,
|
|
418
|
+
headers,
|
|
391
419
|
});
|
|
392
420
|
if (responseData.data) {
|
|
393
421
|
responseData = responseData.data;
|
|
@@ -402,6 +430,7 @@ class PerfexCrm {
|
|
|
402
430
|
url: `${baseUrl}/api/${apiVersion}/invoices/${invoiceId}`,
|
|
403
431
|
body,
|
|
404
432
|
json: true,
|
|
433
|
+
headers,
|
|
405
434
|
});
|
|
406
435
|
}
|
|
407
436
|
else if (operation === 'delete') {
|
|
@@ -410,6 +439,7 @@ class PerfexCrm {
|
|
|
410
439
|
method: 'DELETE',
|
|
411
440
|
url: `${baseUrl}/api/${apiVersion}/invoices/${invoiceId}`,
|
|
412
441
|
json: true,
|
|
442
|
+
headers,
|
|
413
443
|
});
|
|
414
444
|
}
|
|
415
445
|
}
|
|
@@ -426,6 +456,7 @@ class PerfexCrm {
|
|
|
426
456
|
url: `${baseUrl}/api/${apiVersion}/leads`,
|
|
427
457
|
body,
|
|
428
458
|
json: true,
|
|
459
|
+
headers,
|
|
429
460
|
});
|
|
430
461
|
}
|
|
431
462
|
else if (operation === 'get') {
|
|
@@ -434,6 +465,7 @@ class PerfexCrm {
|
|
|
434
465
|
method: 'GET',
|
|
435
466
|
url: `${baseUrl}/api/${apiVersion}/leads/${leadId}`,
|
|
436
467
|
json: true,
|
|
468
|
+
headers,
|
|
437
469
|
});
|
|
438
470
|
}
|
|
439
471
|
else if (operation === 'getAll') {
|
|
@@ -452,6 +484,7 @@ class PerfexCrm {
|
|
|
452
484
|
url: `${baseUrl}/api/${apiVersion}/leads`,
|
|
453
485
|
qs,
|
|
454
486
|
json: true,
|
|
487
|
+
headers,
|
|
455
488
|
});
|
|
456
489
|
if (responseData.data) {
|
|
457
490
|
responseData = responseData.data;
|
|
@@ -466,6 +499,7 @@ class PerfexCrm {
|
|
|
466
499
|
url: `${baseUrl}/api/${apiVersion}/leads/${leadId}`,
|
|
467
500
|
body,
|
|
468
501
|
json: true,
|
|
502
|
+
headers,
|
|
469
503
|
});
|
|
470
504
|
}
|
|
471
505
|
else if (operation === 'delete') {
|
|
@@ -474,6 +508,7 @@ class PerfexCrm {
|
|
|
474
508
|
method: 'DELETE',
|
|
475
509
|
url: `${baseUrl}/api/${apiVersion}/leads/${leadId}`,
|
|
476
510
|
json: true,
|
|
511
|
+
headers,
|
|
477
512
|
});
|
|
478
513
|
}
|
|
479
514
|
else if (operation === 'convert') {
|
|
@@ -482,6 +517,7 @@ class PerfexCrm {
|
|
|
482
517
|
method: 'POST',
|
|
483
518
|
url: `${baseUrl}/api/${apiVersion}/leads/${leadId}/convert`,
|
|
484
519
|
json: true,
|
|
520
|
+
headers,
|
|
485
521
|
});
|
|
486
522
|
}
|
|
487
523
|
}
|
|
@@ -500,6 +536,7 @@ class PerfexCrm {
|
|
|
500
536
|
url: `${baseUrl}/api/${apiVersion}/projects`,
|
|
501
537
|
body,
|
|
502
538
|
json: true,
|
|
539
|
+
headers,
|
|
503
540
|
});
|
|
504
541
|
}
|
|
505
542
|
else if (operation === 'get') {
|
|
@@ -508,6 +545,7 @@ class PerfexCrm {
|
|
|
508
545
|
method: 'GET',
|
|
509
546
|
url: `${baseUrl}/api/${apiVersion}/projects/${projectId}`,
|
|
510
547
|
json: true,
|
|
548
|
+
headers,
|
|
511
549
|
});
|
|
512
550
|
}
|
|
513
551
|
else if (operation === 'getAll') {
|
|
@@ -526,6 +564,7 @@ class PerfexCrm {
|
|
|
526
564
|
url: `${baseUrl}/api/${apiVersion}/projects`,
|
|
527
565
|
qs,
|
|
528
566
|
json: true,
|
|
567
|
+
headers,
|
|
529
568
|
});
|
|
530
569
|
if (responseData.data) {
|
|
531
570
|
responseData = responseData.data;
|
|
@@ -540,6 +579,7 @@ class PerfexCrm {
|
|
|
540
579
|
url: `${baseUrl}/api/${apiVersion}/projects/${projectId}`,
|
|
541
580
|
body,
|
|
542
581
|
json: true,
|
|
582
|
+
headers,
|
|
543
583
|
});
|
|
544
584
|
}
|
|
545
585
|
else if (operation === 'delete') {
|
|
@@ -548,6 +588,7 @@ class PerfexCrm {
|
|
|
548
588
|
method: 'DELETE',
|
|
549
589
|
url: `${baseUrl}/api/${apiVersion}/projects/${projectId}`,
|
|
550
590
|
json: true,
|
|
591
|
+
headers,
|
|
551
592
|
});
|
|
552
593
|
}
|
|
553
594
|
}
|
|
@@ -570,6 +611,7 @@ class PerfexCrm {
|
|
|
570
611
|
url: `${baseUrl}/api/${apiVersion}/contracts`,
|
|
571
612
|
body,
|
|
572
613
|
json: true,
|
|
614
|
+
headers,
|
|
573
615
|
});
|
|
574
616
|
}
|
|
575
617
|
else if (operation === 'get') {
|
|
@@ -578,6 +620,7 @@ class PerfexCrm {
|
|
|
578
620
|
method: 'GET',
|
|
579
621
|
url: `${baseUrl}/api/${apiVersion}/contracts/${contractId}`,
|
|
580
622
|
json: true,
|
|
623
|
+
headers,
|
|
581
624
|
});
|
|
582
625
|
}
|
|
583
626
|
else if (operation === 'getAll') {
|
|
@@ -596,6 +639,7 @@ class PerfexCrm {
|
|
|
596
639
|
url: `${baseUrl}/api/${apiVersion}/contracts`,
|
|
597
640
|
qs,
|
|
598
641
|
json: true,
|
|
642
|
+
headers,
|
|
599
643
|
});
|
|
600
644
|
if (responseData.data) {
|
|
601
645
|
responseData = responseData.data;
|
|
@@ -610,6 +654,7 @@ class PerfexCrm {
|
|
|
610
654
|
url: `${baseUrl}/api/${apiVersion}/contracts/${contractId}`,
|
|
611
655
|
body,
|
|
612
656
|
json: true,
|
|
657
|
+
headers,
|
|
613
658
|
});
|
|
614
659
|
}
|
|
615
660
|
else if (operation === 'delete') {
|
|
@@ -618,6 +663,7 @@ class PerfexCrm {
|
|
|
618
663
|
method: 'DELETE',
|
|
619
664
|
url: `${baseUrl}/api/${apiVersion}/contracts/${contractId}`,
|
|
620
665
|
json: true,
|
|
666
|
+
headers,
|
|
621
667
|
});
|
|
622
668
|
}
|
|
623
669
|
else if (operation === 'sign') {
|
|
@@ -633,6 +679,7 @@ class PerfexCrm {
|
|
|
633
679
|
url: `${baseUrl}/api/${apiVersion}/contracts/${contractId}/sign`,
|
|
634
680
|
body,
|
|
635
681
|
json: true,
|
|
682
|
+
headers,
|
|
636
683
|
});
|
|
637
684
|
}
|
|
638
685
|
}
|
|
@@ -307,6 +307,10 @@ class PerfexCrmTrigger {
|
|
|
307
307
|
const credentials = await this.getCredentials('perfexCrmApi');
|
|
308
308
|
const baseUrl = credentials.baseUrl;
|
|
309
309
|
const apiVersion = credentials.apiVersion;
|
|
310
|
+
const apiKey = credentials.apiKey;
|
|
311
|
+
const headers = {
|
|
312
|
+
'X-API-KEY': apiKey,
|
|
313
|
+
};
|
|
310
314
|
// Check if webhook exists
|
|
311
315
|
if (webhookData.webhookId) {
|
|
312
316
|
try {
|
|
@@ -314,6 +318,7 @@ class PerfexCrmTrigger {
|
|
|
314
318
|
method: 'GET',
|
|
315
319
|
url: `${baseUrl}/api/${apiVersion}/webhooks/${webhookData.webhookId}`,
|
|
316
320
|
json: true,
|
|
321
|
+
headers,
|
|
317
322
|
});
|
|
318
323
|
if (response && response.data) {
|
|
319
324
|
return true;
|
|
@@ -333,6 +338,10 @@ class PerfexCrmTrigger {
|
|
|
333
338
|
const credentials = await this.getCredentials('perfexCrmApi');
|
|
334
339
|
const baseUrl = credentials.baseUrl;
|
|
335
340
|
const apiVersion = credentials.apiVersion;
|
|
341
|
+
const apiKey = credentials.apiKey;
|
|
342
|
+
const headers = {
|
|
343
|
+
'X-API-KEY': apiKey,
|
|
344
|
+
};
|
|
336
345
|
const body = {
|
|
337
346
|
name: `n8n-webhook-${this.getWorkflow().id}`,
|
|
338
347
|
url: webhookUrl,
|
|
@@ -345,6 +354,7 @@ class PerfexCrmTrigger {
|
|
|
345
354
|
url: `${baseUrl}/api/${apiVersion}/webhooks`,
|
|
346
355
|
body,
|
|
347
356
|
json: true,
|
|
357
|
+
headers,
|
|
348
358
|
});
|
|
349
359
|
if (response.data && response.data.id) {
|
|
350
360
|
webhookData.webhookId = response.data.id;
|
|
@@ -358,11 +368,16 @@ class PerfexCrmTrigger {
|
|
|
358
368
|
if (webhookData.webhookId) {
|
|
359
369
|
const baseUrl = credentials.baseUrl;
|
|
360
370
|
const apiVersion = credentials.apiVersion;
|
|
371
|
+
const apiKey = credentials.apiKey;
|
|
372
|
+
const headers = {
|
|
373
|
+
'X-API-KEY': apiKey,
|
|
374
|
+
};
|
|
361
375
|
try {
|
|
362
376
|
await this.helpers.request({
|
|
363
377
|
method: 'DELETE',
|
|
364
378
|
url: `${baseUrl}/api/${apiVersion}/webhooks/${webhookData.webhookId}`,
|
|
365
379
|
json: true,
|
|
380
|
+
headers,
|
|
366
381
|
});
|
|
367
382
|
}
|
|
368
383
|
catch (error) {
|