n8n-nodes-perfexcrm 0.1.8 → 0.1.9

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.
@@ -20,8 +20,8 @@ class PerfexCrm {
20
20
  defaults: {
21
21
  name: 'PerfexCRM',
22
22
  },
23
- inputs: ["main" /* NodeConnectionType.Main */],
24
- outputs: ["main" /* NodeConnectionType.Main */],
23
+ inputs: ['main'],
24
+ outputs: ['main'],
25
25
  credentials: [
26
26
  {
27
27
  name: 'perfexCrmApi',
@@ -151,6 +151,61 @@ class PerfexCrm {
151
151
  json: true,
152
152
  });
153
153
  }
154
+ else if (operation === 'getContacts') {
155
+ const customerId = this.getNodeParameter('customerId', i);
156
+ responseData = await this.helpers.request({
157
+ method: 'GET',
158
+ url: `${baseUrl}/api/${apiVersion}/customers/${customerId}/contacts`,
159
+ json: true,
160
+ });
161
+ if (responseData.data) {
162
+ responseData = responseData.data;
163
+ }
164
+ }
165
+ else if (operation === 'getContracts') {
166
+ const customerId = this.getNodeParameter('customerId', i);
167
+ responseData = await this.helpers.request({
168
+ method: 'GET',
169
+ url: `${baseUrl}/api/${apiVersion}/customers/${customerId}/contracts`,
170
+ json: true,
171
+ });
172
+ if (responseData.data) {
173
+ responseData = responseData.data;
174
+ }
175
+ }
176
+ else if (operation === 'getInvoices') {
177
+ const customerId = this.getNodeParameter('customerId', i);
178
+ responseData = await this.helpers.request({
179
+ method: 'GET',
180
+ url: `${baseUrl}/api/${apiVersion}/customers/${customerId}/invoices`,
181
+ json: true,
182
+ });
183
+ if (responseData.data) {
184
+ responseData = responseData.data;
185
+ }
186
+ }
187
+ else if (operation === 'getProjects') {
188
+ const customerId = this.getNodeParameter('customerId', i);
189
+ responseData = await this.helpers.request({
190
+ method: 'GET',
191
+ url: `${baseUrl}/api/${apiVersion}/customers/${customerId}/projects`,
192
+ json: true,
193
+ });
194
+ if (responseData.data) {
195
+ responseData = responseData.data;
196
+ }
197
+ }
198
+ else if (operation === 'getTickets') {
199
+ const customerId = this.getNodeParameter('customerId', i);
200
+ responseData = await this.helpers.request({
201
+ method: 'GET',
202
+ url: `${baseUrl}/api/${apiVersion}/customers/${customerId}/tickets`,
203
+ json: true,
204
+ });
205
+ if (responseData.data) {
206
+ responseData = responseData.data;
207
+ }
208
+ }
154
209
  }
155
210
  else if (resource === 'ticket') {
156
211
  if (operation === 'create') {
@@ -247,6 +302,46 @@ class PerfexCrm {
247
302
  json: true,
248
303
  });
249
304
  }
305
+ else if (operation === 'getReply') {
306
+ const ticketId = this.getNodeParameter('ticketId', i);
307
+ const replyId = this.getNodeParameter('replyId', i);
308
+ responseData = await this.helpers.request({
309
+ method: 'GET',
310
+ url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}/replies/${replyId}`,
311
+ json: true,
312
+ });
313
+ }
314
+ else if (operation === 'updateReply') {
315
+ const ticketId = this.getNodeParameter('ticketId', i);
316
+ const replyId = this.getNodeParameter('replyId', i);
317
+ const updateFields = this.getNodeParameter('updateFields', i);
318
+ responseData = await this.helpers.request({
319
+ method: 'PUT',
320
+ url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}/replies/${replyId}`,
321
+ body: updateFields,
322
+ json: true,
323
+ });
324
+ }
325
+ else if (operation === 'deleteReply') {
326
+ const ticketId = this.getNodeParameter('ticketId', i);
327
+ const replyId = this.getNodeParameter('replyId', i);
328
+ responseData = await this.helpers.request({
329
+ method: 'DELETE',
330
+ url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}/replies/${replyId}`,
331
+ json: true,
332
+ });
333
+ }
334
+ else if (operation === 'listReplies') {
335
+ const ticketId = this.getNodeParameter('ticketId', i);
336
+ responseData = await this.helpers.request({
337
+ method: 'GET',
338
+ url: `${baseUrl}/api/${apiVersion}/tickets/${ticketId}/replies`,
339
+ json: true,
340
+ });
341
+ if (responseData.data) {
342
+ responseData = responseData.data;
343
+ }
344
+ }
250
345
  }
251
346
  else if (resource === 'invoice') {
252
347
  if (operation === 'create') {
@@ -298,6 +393,25 @@ class PerfexCrm {
298
393
  responseData = responseData.data;
299
394
  }
300
395
  }
396
+ else if (operation === 'update') {
397
+ const invoiceId = this.getNodeParameter('invoiceId', i);
398
+ const updateFields = this.getNodeParameter('updateFields', i);
399
+ const body = updateFields;
400
+ responseData = await this.helpers.request({
401
+ method: 'PUT',
402
+ url: `${baseUrl}/api/${apiVersion}/invoices/${invoiceId}`,
403
+ body,
404
+ json: true,
405
+ });
406
+ }
407
+ else if (operation === 'delete') {
408
+ const invoiceId = this.getNodeParameter('invoiceId', i);
409
+ responseData = await this.helpers.request({
410
+ method: 'DELETE',
411
+ url: `${baseUrl}/api/${apiVersion}/invoices/${invoiceId}`,
412
+ json: true,
413
+ });
414
+ }
301
415
  }
302
416
  else if (resource === 'lead') {
303
417
  if (operation === 'create') {
@@ -322,6 +436,46 @@ class PerfexCrm {
322
436
  json: true,
323
437
  });
324
438
  }
439
+ else if (operation === 'getAll') {
440
+ const returnAll = this.getNodeParameter('returnAll', i);
441
+ const filters = this.getNodeParameter('filters', i);
442
+ const qs = {};
443
+ if (!returnAll) {
444
+ qs.limit = this.getNodeParameter('limit', i);
445
+ }
446
+ else {
447
+ qs.limit = 1000;
448
+ }
449
+ Object.assign(qs, filters);
450
+ responseData = await this.helpers.request({
451
+ method: 'GET',
452
+ url: `${baseUrl}/api/${apiVersion}/leads`,
453
+ qs,
454
+ json: true,
455
+ });
456
+ if (responseData.data) {
457
+ responseData = responseData.data;
458
+ }
459
+ }
460
+ else if (operation === 'update') {
461
+ const leadId = this.getNodeParameter('leadId', i);
462
+ const updateFields = this.getNodeParameter('updateFields', i);
463
+ const body = updateFields;
464
+ responseData = await this.helpers.request({
465
+ method: 'PUT',
466
+ url: `${baseUrl}/api/${apiVersion}/leads/${leadId}`,
467
+ body,
468
+ json: true,
469
+ });
470
+ }
471
+ else if (operation === 'delete') {
472
+ const leadId = this.getNodeParameter('leadId', i);
473
+ responseData = await this.helpers.request({
474
+ method: 'DELETE',
475
+ url: `${baseUrl}/api/${apiVersion}/leads/${leadId}`,
476
+ json: true,
477
+ });
478
+ }
325
479
  else if (operation === 'convert') {
326
480
  const leadId = this.getNodeParameter('leadId', i);
327
481
  responseData = await this.helpers.request({
@@ -356,6 +510,46 @@ class PerfexCrm {
356
510
  json: true,
357
511
  });
358
512
  }
513
+ else if (operation === 'getAll') {
514
+ const returnAll = this.getNodeParameter('returnAll', i);
515
+ const filters = this.getNodeParameter('filters', i);
516
+ const qs = {};
517
+ if (!returnAll) {
518
+ qs.limit = this.getNodeParameter('limit', i);
519
+ }
520
+ else {
521
+ qs.limit = 1000;
522
+ }
523
+ Object.assign(qs, filters);
524
+ responseData = await this.helpers.request({
525
+ method: 'GET',
526
+ url: `${baseUrl}/api/${apiVersion}/projects`,
527
+ qs,
528
+ json: true,
529
+ });
530
+ if (responseData.data) {
531
+ responseData = responseData.data;
532
+ }
533
+ }
534
+ else if (operation === 'update') {
535
+ const projectId = this.getNodeParameter('projectId', i);
536
+ const updateFields = this.getNodeParameter('updateFields', i);
537
+ const body = updateFields;
538
+ responseData = await this.helpers.request({
539
+ method: 'PUT',
540
+ url: `${baseUrl}/api/${apiVersion}/projects/${projectId}`,
541
+ body,
542
+ json: true,
543
+ });
544
+ }
545
+ else if (operation === 'delete') {
546
+ const projectId = this.getNodeParameter('projectId', i);
547
+ responseData = await this.helpers.request({
548
+ method: 'DELETE',
549
+ url: `${baseUrl}/api/${apiVersion}/projects/${projectId}`,
550
+ json: true,
551
+ });
552
+ }
359
553
  }
360
554
  else if (resource === 'contract') {
361
555
  if (operation === 'create') {
@@ -386,6 +580,61 @@ class PerfexCrm {
386
580
  json: true,
387
581
  });
388
582
  }
583
+ else if (operation === 'getAll') {
584
+ const returnAll = this.getNodeParameter('returnAll', i);
585
+ const filters = this.getNodeParameter('filters', i);
586
+ const qs = {};
587
+ if (!returnAll) {
588
+ qs.limit = this.getNodeParameter('limit', i);
589
+ }
590
+ else {
591
+ qs.limit = 1000;
592
+ }
593
+ Object.assign(qs, filters);
594
+ responseData = await this.helpers.request({
595
+ method: 'GET',
596
+ url: `${baseUrl}/api/${apiVersion}/contracts`,
597
+ qs,
598
+ json: true,
599
+ });
600
+ if (responseData.data) {
601
+ responseData = responseData.data;
602
+ }
603
+ }
604
+ else if (operation === 'update') {
605
+ const contractId = this.getNodeParameter('contractId', i);
606
+ const updateFields = this.getNodeParameter('updateFields', i);
607
+ const body = updateFields;
608
+ responseData = await this.helpers.request({
609
+ method: 'PUT',
610
+ url: `${baseUrl}/api/${apiVersion}/contracts/${contractId}`,
611
+ body,
612
+ json: true,
613
+ });
614
+ }
615
+ else if (operation === 'delete') {
616
+ const contractId = this.getNodeParameter('contractId', i);
617
+ responseData = await this.helpers.request({
618
+ method: 'DELETE',
619
+ url: `${baseUrl}/api/${apiVersion}/contracts/${contractId}`,
620
+ json: true,
621
+ });
622
+ }
623
+ else if (operation === 'sign') {
624
+ const contractId = this.getNodeParameter('contractId', i);
625
+ const signature = this.getNodeParameter('signature', i);
626
+ const additionalFields = this.getNodeParameter('additionalFields', i);
627
+ const body = {
628
+ signature,
629
+ ...additionalFields,
630
+ };
631
+ responseData = await this.helpers.request({
632
+ method: 'POST',
633
+ url: `${baseUrl}/api/${apiVersion}/contracts/${contractId}/sign`,
634
+ body,
635
+ json: true,
636
+ });
637
+ }
389
638
  }
390
639
  if (Array.isArray(responseData)) {
391
640
  returnData.push(...responseData.map((item) => ({ json: item })));
@@ -15,7 +15,7 @@ class PerfexCrmTrigger {
15
15
  name: 'PerfexCRM Trigger',
16
16
  },
17
17
  inputs: [],
18
- outputs: ["main" /* NodeConnectionType.Main */],
18
+ outputs: ['main'],
19
19
  credentials: [
20
20
  {
21
21
  name: 'perfexCrmApi',