n8n-nodes-linq 0.1.6 → 0.1.8

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Linq = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
4
5
  class Linq {
5
6
  constructor() {
6
7
  this.description = {
@@ -214,7 +215,7 @@ class Linq {
214
215
  displayName: 'Phone Number',
215
216
  name: 'phoneNumber',
216
217
  type: 'string',
217
- displayOptions: { show: { resource: ['chat'], operation: ['getAll'] } },
218
+ displayOptions: { show: { resource: ['chat'], operation: ['getAll', 'find'] } },
218
219
  default: '',
219
220
  description: 'Filter chats by phone number',
220
221
  },
@@ -420,6 +421,7 @@ class Linq {
420
421
  };
421
422
  }
422
423
  async execute() {
424
+ var _a;
423
425
  const items = this.getInputData();
424
426
  const returnData = [];
425
427
  const credentials = await this.getCredentials('linqApi');
@@ -427,381 +429,387 @@ class Linq {
427
429
  const resource = this.getNodeParameter('resource', i);
428
430
  const operation = this.getNodeParameter('operation', i);
429
431
  let responseData;
430
- // Chat operations
431
- if (resource === 'chat') {
432
- if (operation === 'getAll') {
433
- const phoneNumber = this.getNodeParameter('phoneNumber', i, '');
434
- const page = this.getNodeParameter('page', i, 1);
435
- const perPage = this.getNodeParameter('perPage', i, 25);
436
- const qs = { page, per_page: perPage };
437
- if (phoneNumber)
438
- qs.phone_number = phoneNumber;
439
- responseData = await this.helpers.request({
440
- method: 'GET',
441
- url: 'https://api.linqapp.com/api/partner/v2/chats',
442
- qs,
443
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
444
- json: true,
445
- });
446
- }
447
- if (operation === 'getOne') {
448
- const chatId = this.getNodeParameter('chatId', i);
449
- responseData = await this.helpers.request({
450
- method: 'GET',
451
- url: `https://api.linqapp.com/api/partner/v2/chats/${chatId}`,
452
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
453
- json: true,
454
- });
455
- }
456
- if (operation === 'find') {
457
- const phoneNumber = this.getNodeParameter('phoneNumber', i, '');
458
- const qs = {};
459
- if (phoneNumber)
460
- qs.phone_number = phoneNumber;
461
- responseData = await this.helpers.request({
462
- method: 'GET',
463
- url: 'https://api.linqapp.com/api/partner/v2/chats/find',
464
- qs,
465
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
466
- json: true,
467
- });
468
- }
469
- if (operation === 'create') {
470
- const sendFrom = this.getNodeParameter('sendFrom', i);
471
- const displayName = this.getNodeParameter('displayName', i);
472
- const phoneNumbers = this.getNodeParameter('phoneNumbers', i);
473
- const messageText = this.getNodeParameter('messageText', i);
474
- const body = {
475
- chat: {
476
- phone_numbers: phoneNumbers.split(',').map(p => p.trim())
477
- },
478
- message: {
479
- text: messageText
432
+ try {
433
+ // Chat operations
434
+ if (resource === 'chat') {
435
+ if (operation === 'getAll') {
436
+ const phoneNumber = this.getNodeParameter('phoneNumber', i, '');
437
+ const page = this.getNodeParameter('page', i, 1);
438
+ const perPage = this.getNodeParameter('perPage', i, 25);
439
+ const qs = { page, per_page: perPage };
440
+ if (phoneNumber)
441
+ qs.phone_number = phoneNumber;
442
+ responseData = await this.helpers.request({
443
+ method: 'GET',
444
+ url: 'https://api.linqapp.com/api/partner/v2/chats',
445
+ qs,
446
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
447
+ json: true,
448
+ });
449
+ }
450
+ if (operation === 'getOne') {
451
+ const chatId = this.getNodeParameter('chatId', i);
452
+ responseData = await this.helpers.request({
453
+ method: 'GET',
454
+ url: `https://api.linqapp.com/api/partner/v2/chats/${chatId}`,
455
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
456
+ json: true,
457
+ });
458
+ }
459
+ if (operation === 'find') {
460
+ const phoneNumber = this.getNodeParameter('phoneNumber', i, '');
461
+ const qs = {};
462
+ if (phoneNumber)
463
+ qs.phone_number = phoneNumber;
464
+ responseData = await this.helpers.request({
465
+ method: 'GET',
466
+ url: 'https://api.linqapp.com/api/partner/v2/chats/find',
467
+ qs,
468
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
469
+ json: true,
470
+ });
471
+ }
472
+ if (operation === 'create') {
473
+ const sendFrom = this.getNodeParameter('sendFrom', i);
474
+ const displayName = this.getNodeParameter('displayName', i);
475
+ const phoneNumbers = this.getNodeParameter('phoneNumbers', i);
476
+ const messageText = this.getNodeParameter('messageText', i);
477
+ const body = {
478
+ chat: {
479
+ phone_numbers: phoneNumbers.split(',').map(p => p.trim())
480
+ },
481
+ message: {
482
+ text: messageText
483
+ }
484
+ };
485
+ if (sendFrom) {
486
+ body.send_from = sendFrom;
480
487
  }
481
- };
482
- if (sendFrom) {
483
- body.send_from = sendFrom;
488
+ if (displayName) {
489
+ body.chat.display_name = displayName;
490
+ }
491
+ responseData = await this.helpers.request({
492
+ method: 'POST',
493
+ url: 'https://api.linqapp.com/api/partner/v2/chats',
494
+ headers: {
495
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
496
+ 'Content-Type': 'application/json'
497
+ },
498
+ body: body,
499
+ json: true,
500
+ });
484
501
  }
485
- if (displayName) {
486
- body.chat.display_name = displayName;
502
+ if (operation === 'shareContact') {
503
+ responseData = await this.helpers.request({
504
+ method: 'POST',
505
+ url: 'https://api.linqapp.com/api/partner/v2/chats/share-contact',
506
+ headers: {
507
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
508
+ 'Content-Type': 'application/json'
509
+ },
510
+ json: true,
511
+ });
487
512
  }
488
- responseData = await this.helpers.request({
489
- method: 'POST',
490
- url: 'https://api.linqapp.com/api/partner/v2/chats',
491
- headers: {
492
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
493
- 'Content-Type': 'application/json'
494
- },
495
- body: JSON.stringify(body),
496
- json: true,
497
- });
498
- }
499
- if (operation === 'shareContact') {
500
- responseData = await this.helpers.request({
501
- method: 'POST',
502
- url: 'https://api.linqapp.com/api/partner/v2/chats/share-contact',
503
- headers: {
504
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
505
- 'Content-Type': 'application/json'
506
- },
507
- json: true,
508
- });
509
- }
510
- }
511
- // Chat Message operations
512
- if (resource === 'chatMessage') {
513
- if (operation === 'getAll') {
514
- const chatId = this.getNodeParameter('chatId', i);
515
- responseData = await this.helpers.request({
516
- method: 'GET',
517
- url: `https://api.linqapp.com/api/partner/v2/chat_messages`,
518
- qs: { chat_id: chatId },
519
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
520
- json: true,
521
- });
522
513
  }
523
- if (operation === 'getOne') {
524
- const chatMessageId = this.getNodeParameter('chatMessageId', i);
525
- responseData = await this.helpers.request({
526
- method: 'GET',
527
- url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}`,
528
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
529
- json: true,
530
- });
531
- }
532
- if (operation === 'create') {
533
- const chatId = this.getNodeParameter('chatId', i);
534
- const messageText = this.getNodeParameter('messageText', i);
535
- const body = {
536
- chat_message: {
514
+ // Chat Message operations
515
+ if (resource === 'chatMessage') {
516
+ if (operation === 'getAll') {
517
+ const chatId = this.getNodeParameter('chatId', i);
518
+ responseData = await this.helpers.request({
519
+ method: 'GET',
520
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages`,
521
+ qs: { chat_id: chatId },
522
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
523
+ json: true,
524
+ });
525
+ }
526
+ if (operation === 'getOne') {
527
+ const chatMessageId = this.getNodeParameter('chatMessageId', i);
528
+ responseData = await this.helpers.request({
529
+ method: 'GET',
530
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}`,
531
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
532
+ json: true,
533
+ });
534
+ }
535
+ if (operation === 'create') {
536
+ const chatId = this.getNodeParameter('chatId', i);
537
+ const messageText = this.getNodeParameter('messageText', i);
538
+ const body = {
537
539
  chat_id: chatId,
538
540
  text: messageText
539
- }
540
- };
541
- responseData = await this.helpers.request({
542
- method: 'POST',
543
- url: 'https://api.linqapp.com/api/partner/v2/chat_messages',
544
- headers: {
545
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
546
- 'Content-Type': 'application/json'
547
- },
548
- body: JSON.stringify(body),
549
- json: true,
550
- });
551
- }
552
- if (operation === 'delete') {
553
- const chatMessageId = this.getNodeParameter('chatMessageId', i);
554
- responseData = await this.helpers.request({
555
- method: 'DELETE',
556
- url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}`,
557
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
558
- json: true,
559
- });
560
- }
561
- if (operation === 'edit') {
562
- const chatMessageId = this.getNodeParameter('chatMessageId', i);
563
- const messageText = this.getNodeParameter('messageText', i);
564
- const body = {
565
- text: messageText
566
- };
567
- responseData = await this.helpers.request({
568
- method: 'POST',
569
- url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/edit`,
570
- headers: {
571
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
572
- 'Content-Type': 'application/json'
573
- },
574
- body: JSON.stringify(body),
575
- json: true,
576
- });
577
- }
578
- if (operation === 'react') {
579
- const chatMessageId = this.getNodeParameter('chatMessageId', i);
580
- const reaction = this.getNodeParameter('reaction', i);
581
- const body = {
582
- reaction: reaction
583
- };
584
- responseData = await this.helpers.request({
585
- method: 'POST',
586
- url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/react`,
587
- headers: {
588
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
589
- 'Content-Type': 'application/json'
590
- },
591
- body: JSON.stringify(body),
592
- json: true,
593
- });
594
- }
595
- if (operation === 'getReaction') {
596
- const chatMessageId = this.getNodeParameter('chatMessageId', i);
597
- responseData = await this.helpers.request({
598
- method: 'GET',
599
- url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/reaction`,
600
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
601
- json: true,
602
- });
603
- }
604
- }
605
- // Phone Number operations
606
- if (resource === 'phoneNumber') {
607
- if (operation === 'getAll') {
608
- responseData = await this.helpers.request({
609
- method: 'GET',
610
- url: 'https://api.linqapp.com/api/partner/v2/phone_numbers',
611
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
612
- json: true,
613
- });
614
- }
615
- if (operation === 'checkIMessageAvailability') {
616
- const phoneNumber = this.getNodeParameter('phoneNumber', i);
617
- const body = {
618
- phone_number: phoneNumber
619
- };
620
- responseData = await this.helpers.request({
621
- method: 'POST',
622
- url: 'https://api.linqapp.com/api/partner/v2/i_message_availability/check',
623
- headers: {
624
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
625
- 'Content-Type': 'application/json'
626
- },
627
- body: JSON.stringify(body),
628
- json: true,
629
- });
630
- }
631
- }
632
- // Webhook Subscription operations
633
- if (resource === 'webhookSubscription') {
634
- if (operation === 'getAll') {
635
- responseData = await this.helpers.request({
636
- method: 'GET',
637
- url: 'https://api.linqapp.com/api/partner/v2/webhook_subscriptions',
638
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
639
- json: true,
640
- });
641
- }
642
- if (operation === 'getOne') {
643
- const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
644
- responseData = await this.helpers.request({
645
- method: 'GET',
646
- url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
647
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
648
- json: true,
649
- });
541
+ };
542
+ responseData = await this.helpers.request({
543
+ method: 'POST',
544
+ url: 'https://api.linqapp.com/api/partner/v2/chat_messages',
545
+ headers: {
546
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
547
+ 'Content-Type': 'application/json'
548
+ },
549
+ body: body,
550
+ json: true,
551
+ });
552
+ }
553
+ if (operation === 'delete') {
554
+ const chatMessageId = this.getNodeParameter('chatMessageId', i);
555
+ responseData = await this.helpers.request({
556
+ method: 'DELETE',
557
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}`,
558
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
559
+ json: true,
560
+ });
561
+ }
562
+ if (operation === 'edit') {
563
+ const chatMessageId = this.getNodeParameter('chatMessageId', i);
564
+ const messageText = this.getNodeParameter('messageText', i);
565
+ const body = {
566
+ text: messageText
567
+ };
568
+ responseData = await this.helpers.request({
569
+ method: 'POST',
570
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/edit`,
571
+ headers: {
572
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
573
+ 'Content-Type': 'application/json'
574
+ },
575
+ body: body,
576
+ json: true,
577
+ });
578
+ }
579
+ if (operation === 'react') {
580
+ const chatMessageId = this.getNodeParameter('chatMessageId', i);
581
+ const reaction = this.getNodeParameter('reaction', i);
582
+ const body = {
583
+ reaction: reaction
584
+ };
585
+ responseData = await this.helpers.request({
586
+ method: 'POST',
587
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/react`,
588
+ headers: {
589
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
590
+ 'Content-Type': 'application/json'
591
+ },
592
+ body: body,
593
+ json: true,
594
+ });
595
+ }
596
+ if (operation === 'getReaction') {
597
+ const chatMessageId = this.getNodeParameter('chatMessageId', i);
598
+ responseData = await this.helpers.request({
599
+ method: 'GET',
600
+ url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/reaction`,
601
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
602
+ json: true,
603
+ });
604
+ }
650
605
  }
651
- if (operation === 'create') {
652
- const webhookUrl = this.getNodeParameter('webhookUrl', i);
653
- const events = this.getNodeParameter('events', i);
654
- const version = this.getNodeParameter('version', i);
655
- const active = this.getNodeParameter('active', i);
656
- const body = {
657
- webhook_url: webhookUrl,
658
- version: version,
659
- active: active
660
- };
661
- if (events) {
662
- body.events = events.split(',').map(e => e.trim());
606
+ // Phone Number operations
607
+ if (resource === 'phoneNumber') {
608
+ if (operation === 'getAll') {
609
+ responseData = await this.helpers.request({
610
+ method: 'GET',
611
+ url: 'https://api.linqapp.com/api/partner/v2/phone_numbers',
612
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
613
+ json: true,
614
+ });
615
+ }
616
+ if (operation === 'checkIMessageAvailability') {
617
+ const phoneNumber = this.getNodeParameter('phoneNumber', i);
618
+ const body = {
619
+ phone_number: phoneNumber
620
+ };
621
+ responseData = await this.helpers.request({
622
+ method: 'POST',
623
+ url: 'https://api.linqapp.com/api/partner/v2/i_message_availability/check',
624
+ headers: {
625
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
626
+ 'Content-Type': 'application/json'
627
+ },
628
+ body: body,
629
+ json: true,
630
+ });
663
631
  }
664
- responseData = await this.helpers.request({
665
- method: 'POST',
666
- url: 'https://api.linqapp.com/api/partner/v2/webhook_subscriptions',
667
- headers: {
668
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
669
- 'Content-Type': 'application/json'
670
- },
671
- body: JSON.stringify(body),
672
- json: true,
673
- });
674
632
  }
675
- if (operation === 'update') {
676
- const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
677
- const webhookUrl = this.getNodeParameter('webhookUrl', i);
678
- const events = this.getNodeParameter('events', i);
679
- const version = this.getNodeParameter('version', i);
680
- const active = this.getNodeParameter('active', i);
681
- const body = {
682
- version: version,
683
- active: active
684
- };
685
- if (webhookUrl) {
686
- body.webhook_url = webhookUrl;
633
+ // Webhook Subscription operations
634
+ if (resource === 'webhookSubscription') {
635
+ if (operation === 'getAll') {
636
+ responseData = await this.helpers.request({
637
+ method: 'GET',
638
+ url: 'https://api.linqapp.com/api/partner/v2/webhook_subscriptions',
639
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
640
+ json: true,
641
+ });
687
642
  }
688
- if (events) {
689
- body.events = events.split(',').map(e => e.trim());
643
+ if (operation === 'getOne') {
644
+ const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
645
+ responseData = await this.helpers.request({
646
+ method: 'GET',
647
+ url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
648
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
649
+ json: true,
650
+ });
651
+ }
652
+ if (operation === 'create') {
653
+ const webhookUrl = this.getNodeParameter('webhookUrl', i);
654
+ const events = this.getNodeParameter('events', i);
655
+ const version = this.getNodeParameter('version', i);
656
+ const active = this.getNodeParameter('active', i);
657
+ const body = {
658
+ webhook_url: webhookUrl,
659
+ version: version,
660
+ active: active
661
+ };
662
+ if (events) {
663
+ body.events = events.split(',').map(e => e.trim());
664
+ }
665
+ responseData = await this.helpers.request({
666
+ method: 'POST',
667
+ url: 'https://api.linqapp.com/api/partner/v2/webhook_subscriptions',
668
+ headers: {
669
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
670
+ 'Content-Type': 'application/json'
671
+ },
672
+ body: body,
673
+ json: true,
674
+ });
675
+ }
676
+ if (operation === 'update') {
677
+ const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
678
+ const webhookUrl = this.getNodeParameter('webhookUrl', i);
679
+ const events = this.getNodeParameter('events', i);
680
+ const version = this.getNodeParameter('version', i);
681
+ const active = this.getNodeParameter('active', i);
682
+ const body = {
683
+ version: version,
684
+ active: active
685
+ };
686
+ if (webhookUrl) {
687
+ body.webhook_url = webhookUrl;
688
+ }
689
+ if (events) {
690
+ body.events = events.split(',').map(e => e.trim());
691
+ }
692
+ responseData = await this.helpers.request({
693
+ method: 'PUT',
694
+ url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
695
+ headers: {
696
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
697
+ 'Content-Type': 'application/json'
698
+ },
699
+ body: body,
700
+ json: true,
701
+ });
702
+ }
703
+ if (operation === 'delete') {
704
+ const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
705
+ responseData = await this.helpers.request({
706
+ method: 'DELETE',
707
+ url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
708
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
709
+ json: true,
710
+ });
690
711
  }
691
- responseData = await this.helpers.request({
692
- method: 'PUT',
693
- url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
694
- headers: {
695
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
696
- 'Content-Type': 'application/json'
697
- },
698
- body: JSON.stringify(body),
699
- json: true,
700
- });
701
712
  }
702
- if (operation === 'delete') {
703
- const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
704
- responseData = await this.helpers.request({
705
- method: 'DELETE',
706
- url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
707
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
708
- json: true,
709
- });
713
+ // Contact operations
714
+ if (resource === 'contact') {
715
+ if (operation === 'create') {
716
+ const firstName = this.getNodeParameter('firstName', i);
717
+ const lastName = this.getNodeParameter('lastName', i);
718
+ const email = this.getNodeParameter('email', i);
719
+ const phoneNumber = this.getNodeParameter('phoneNumber', i);
720
+ const company = this.getNodeParameter('company', i);
721
+ const title = this.getNodeParameter('title', i);
722
+ const location = this.getNodeParameter('location', i);
723
+ const body = {
724
+ contact: {}
725
+ };
726
+ if (firstName)
727
+ body.contact.first_name = firstName;
728
+ if (lastName)
729
+ body.contact.last_name = lastName;
730
+ if (email)
731
+ body.contact.email = email;
732
+ if (phoneNumber)
733
+ body.contact.phone_number = phoneNumber;
734
+ if (company)
735
+ body.contact.company = company;
736
+ if (title)
737
+ body.contact.title = title;
738
+ if (location)
739
+ body.contact.location = location;
740
+ responseData = await this.helpers.request({
741
+ method: 'POST',
742
+ url: 'https://api.linqapp.com/api/partner/v2/contacts',
743
+ headers: {
744
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
745
+ 'Content-Type': 'application/json'
746
+ },
747
+ body: body,
748
+ json: true,
749
+ });
750
+ }
751
+ if (operation === 'getOne') {
752
+ const contactId = this.getNodeParameter('contactId', i);
753
+ responseData = await this.helpers.request({
754
+ method: 'GET',
755
+ url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
756
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
757
+ json: true,
758
+ });
759
+ }
760
+ if (operation === 'update') {
761
+ const contactId = this.getNodeParameter('contactId', i);
762
+ const firstName = this.getNodeParameter('firstName', i);
763
+ const lastName = this.getNodeParameter('lastName', i);
764
+ const email = this.getNodeParameter('email', i);
765
+ const phoneNumber = this.getNodeParameter('phoneNumber', i);
766
+ const company = this.getNodeParameter('company', i);
767
+ const title = this.getNodeParameter('title', i);
768
+ const location = this.getNodeParameter('location', i);
769
+ const body = {
770
+ contact: {}
771
+ };
772
+ if (firstName)
773
+ body.contact.first_name = firstName;
774
+ if (lastName)
775
+ body.contact.last_name = lastName;
776
+ if (email)
777
+ body.contact.email = email;
778
+ if (phoneNumber)
779
+ body.contact.phone_number = phoneNumber;
780
+ if (company)
781
+ body.contact.company = company;
782
+ if (title)
783
+ body.contact.title = title;
784
+ if (location)
785
+ body.contact.location = location;
786
+ responseData = await this.helpers.request({
787
+ method: 'PUT',
788
+ url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
789
+ headers: {
790
+ 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
791
+ 'Content-Type': 'application/json'
792
+ },
793
+ body: body,
794
+ json: true,
795
+ });
796
+ }
797
+ if (operation === 'delete') {
798
+ const contactId = this.getNodeParameter('contactId', i);
799
+ responseData = await this.helpers.request({
800
+ method: 'DELETE',
801
+ url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
802
+ headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
803
+ json: true,
804
+ });
805
+ }
710
806
  }
711
807
  }
712
- // Contact operations
713
- if (resource === 'contact') {
714
- if (operation === 'create') {
715
- const firstName = this.getNodeParameter('firstName', i);
716
- const lastName = this.getNodeParameter('lastName', i);
717
- const email = this.getNodeParameter('email', i);
718
- const phoneNumber = this.getNodeParameter('phoneNumber', i);
719
- const company = this.getNodeParameter('company', i);
720
- const title = this.getNodeParameter('title', i);
721
- const location = this.getNodeParameter('location', i);
722
- const body = {
723
- contact: {}
724
- };
725
- if (firstName)
726
- body.contact.first_name = firstName;
727
- if (lastName)
728
- body.contact.last_name = lastName;
729
- if (email)
730
- body.contact.email = email;
731
- if (phoneNumber)
732
- body.contact.phone_number = phoneNumber;
733
- if (company)
734
- body.contact.company = company;
735
- if (title)
736
- body.contact.title = title;
737
- if (location)
738
- body.contact.location = location;
739
- responseData = await this.helpers.request({
740
- method: 'POST',
741
- url: 'https://api.linqapp.com/api/partner/v2/contacts',
742
- headers: {
743
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
744
- 'Content-Type': 'application/json'
745
- },
746
- body: JSON.stringify(body),
747
- json: true,
748
- });
749
- }
750
- if (operation === 'getOne') {
751
- const contactId = this.getNodeParameter('contactId', i);
752
- responseData = await this.helpers.request({
753
- method: 'GET',
754
- url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
755
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
756
- json: true,
757
- });
758
- }
759
- if (operation === 'update') {
760
- const contactId = this.getNodeParameter('contactId', i);
761
- const firstName = this.getNodeParameter('firstName', i);
762
- const lastName = this.getNodeParameter('lastName', i);
763
- const email = this.getNodeParameter('email', i);
764
- const phoneNumber = this.getNodeParameter('phoneNumber', i);
765
- const company = this.getNodeParameter('company', i);
766
- const title = this.getNodeParameter('title', i);
767
- const location = this.getNodeParameter('location', i);
768
- const body = {
769
- contact: {}
770
- };
771
- if (firstName)
772
- body.contact.first_name = firstName;
773
- if (lastName)
774
- body.contact.last_name = lastName;
775
- if (email)
776
- body.contact.email = email;
777
- if (phoneNumber)
778
- body.contact.phone_number = phoneNumber;
779
- if (company)
780
- body.contact.company = company;
781
- if (title)
782
- body.contact.title = title;
783
- if (location)
784
- body.contact.location = location;
785
- responseData = await this.helpers.request({
786
- method: 'PUT',
787
- url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
788
- headers: {
789
- 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
790
- 'Content-Type': 'application/json'
791
- },
792
- body: JSON.stringify(body),
793
- json: true,
794
- });
795
- }
796
- if (operation === 'delete') {
797
- const contactId = this.getNodeParameter('contactId', i);
798
- responseData = await this.helpers.request({
799
- method: 'DELETE',
800
- url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
801
- headers: { 'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken },
802
- json: true,
803
- });
808
+ catch (error) {
809
+ if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 429) {
810
+ throw new n8n_workflow_1.ApplicationError('Rate limit exceeded. Please try again after 10 seconds.');
804
811
  }
812
+ throw error;
805
813
  }
806
814
  returnData.push({ json: responseData });
807
815
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-linq",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Linq API integration for n8n",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",