n8n-nodes-linq 0.1.11 → 0.1.13
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/nodes/Linq/Linq.node.js +64 -33
- package/package.json +1 -1
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Linq = void 0;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
// Helper function to format phone numbers with proper country code
|
|
6
|
+
function formatPhoneNumber(phoneNumber) {
|
|
7
|
+
// Remove any whitespace and other formatting characters
|
|
8
|
+
let cleaned = phoneNumber.replace(/\s+/g, '').replace(/[\(\)\-\.]/g, '');
|
|
9
|
+
// If it already starts with +, return as is
|
|
10
|
+
if (cleaned.startsWith('+')) {
|
|
11
|
+
return cleaned;
|
|
12
|
+
}
|
|
13
|
+
// If it starts with 00, replace with +
|
|
14
|
+
if (cleaned.startsWith('00')) {
|
|
15
|
+
return '+' + cleaned.substring(2);
|
|
16
|
+
}
|
|
17
|
+
// If it's all digits and doesn't start with +, assume it needs a +
|
|
18
|
+
if (/^\d+$/.test(cleaned)) {
|
|
19
|
+
return '+' + cleaned;
|
|
20
|
+
}
|
|
21
|
+
// For other cases, just return the cleaned number
|
|
22
|
+
return cleaned;
|
|
23
|
+
}
|
|
5
24
|
class Linq {
|
|
6
25
|
constructor() {
|
|
7
26
|
this.description = {
|
|
@@ -442,18 +461,22 @@ class Linq {
|
|
|
442
461
|
if (resource === 'chat') {
|
|
443
462
|
if (operation === 'getAll') {
|
|
444
463
|
const phoneNumber = this.getNodeParameter('phoneNumber', i, '');
|
|
445
|
-
const page = this.getNodeParameter('page', i
|
|
446
|
-
const perPage = this.getNodeParameter('perPage', i
|
|
447
|
-
const qs = {
|
|
464
|
+
const page = this.getNodeParameter('page', i);
|
|
465
|
+
const perPage = this.getNodeParameter('perPage', i);
|
|
466
|
+
const qs = {};
|
|
467
|
+
if (page && page !== 1)
|
|
468
|
+
qs.page = page;
|
|
469
|
+
if (perPage && perPage !== 25)
|
|
470
|
+
qs.per_page = perPage;
|
|
448
471
|
if (phoneNumber)
|
|
449
|
-
qs.
|
|
472
|
+
qs.phone = formatPhoneNumber(phoneNumber);
|
|
450
473
|
responseData = await this.helpers.request({
|
|
451
474
|
method: 'GET',
|
|
452
475
|
url: 'https://api.linqapp.com/api/partner/v2/chats',
|
|
453
476
|
qs,
|
|
454
477
|
headers: {
|
|
455
478
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
456
|
-
'Accept': 'application/
|
|
479
|
+
'Accept': 'application/json'
|
|
457
480
|
},
|
|
458
481
|
json: true,
|
|
459
482
|
});
|
|
@@ -465,7 +488,7 @@ class Linq {
|
|
|
465
488
|
url: `https://api.linqapp.com/api/partner/v2/chats/${chatId}`,
|
|
466
489
|
headers: {
|
|
467
490
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
468
|
-
'Accept': 'application/
|
|
491
|
+
'Accept': 'application/json'
|
|
469
492
|
},
|
|
470
493
|
json: true,
|
|
471
494
|
});
|
|
@@ -474,8 +497,16 @@ class Linq {
|
|
|
474
497
|
const phoneNumbers = this.getNodeParameter('phoneNumbers', i, '');
|
|
475
498
|
const qs = {};
|
|
476
499
|
if (phoneNumbers) {
|
|
477
|
-
//
|
|
478
|
-
|
|
500
|
+
// Check if we have a single phone number or multiple
|
|
501
|
+
const phoneNumbersArray = phoneNumbers.split(',').map(p => formatPhoneNumber(p.trim()));
|
|
502
|
+
if (phoneNumbersArray.length === 1) {
|
|
503
|
+
// For single phone number, use 'phone' parameter
|
|
504
|
+
qs.phone = phoneNumbersArray[0];
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
// For multiple phone numbers, use 'phone_numbers[]' parameter
|
|
508
|
+
qs['phone_numbers[]'] = phoneNumbersArray;
|
|
509
|
+
}
|
|
479
510
|
}
|
|
480
511
|
responseData = await this.helpers.request({
|
|
481
512
|
method: 'GET',
|
|
@@ -483,7 +514,7 @@ class Linq {
|
|
|
483
514
|
qs,
|
|
484
515
|
headers: {
|
|
485
516
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
486
|
-
'Accept': 'application/
|
|
517
|
+
'Accept': 'application/json'
|
|
487
518
|
},
|
|
488
519
|
json: true,
|
|
489
520
|
});
|
|
@@ -495,14 +526,14 @@ class Linq {
|
|
|
495
526
|
const messageText = this.getNodeParameter('messageText', i);
|
|
496
527
|
const body = {
|
|
497
528
|
chat: {
|
|
498
|
-
phone_numbers: phoneNumbers.split(',').map(p => p.trim())
|
|
529
|
+
phone_numbers: phoneNumbers.split(',').map(p => formatPhoneNumber(p.trim()))
|
|
499
530
|
},
|
|
500
531
|
message: {
|
|
501
532
|
text: messageText
|
|
502
533
|
}
|
|
503
534
|
};
|
|
504
535
|
if (sendFrom) {
|
|
505
|
-
body.send_from = sendFrom;
|
|
536
|
+
body.send_from = formatPhoneNumber(sendFrom);
|
|
506
537
|
}
|
|
507
538
|
if (displayName) {
|
|
508
539
|
body.chat.display_name = displayName;
|
|
@@ -526,7 +557,7 @@ class Linq {
|
|
|
526
557
|
headers: {
|
|
527
558
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
528
559
|
'Content-Type': 'application/json',
|
|
529
|
-
'Accept': 'application/
|
|
560
|
+
'Accept': 'application/json'
|
|
530
561
|
},
|
|
531
562
|
json: true,
|
|
532
563
|
});
|
|
@@ -542,7 +573,7 @@ class Linq {
|
|
|
542
573
|
qs: { chat_id: chatId },
|
|
543
574
|
headers: {
|
|
544
575
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
545
|
-
'Accept': 'application/
|
|
576
|
+
'Accept': 'application/json'
|
|
546
577
|
},
|
|
547
578
|
json: true,
|
|
548
579
|
});
|
|
@@ -554,7 +585,7 @@ class Linq {
|
|
|
554
585
|
url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}`,
|
|
555
586
|
headers: {
|
|
556
587
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
557
|
-
'Accept': 'application/
|
|
588
|
+
'Accept': 'application/json'
|
|
558
589
|
},
|
|
559
590
|
json: true,
|
|
560
591
|
});
|
|
@@ -572,7 +603,7 @@ class Linq {
|
|
|
572
603
|
headers: {
|
|
573
604
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
574
605
|
'Content-Type': 'application/json',
|
|
575
|
-
'Accept': 'application/
|
|
606
|
+
'Accept': 'application/json'
|
|
576
607
|
},
|
|
577
608
|
body: body,
|
|
578
609
|
json: true,
|
|
@@ -585,7 +616,7 @@ class Linq {
|
|
|
585
616
|
url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}`,
|
|
586
617
|
headers: {
|
|
587
618
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
588
|
-
'Accept': 'application/
|
|
619
|
+
'Accept': 'application/json'
|
|
589
620
|
},
|
|
590
621
|
json: true,
|
|
591
622
|
});
|
|
@@ -602,7 +633,7 @@ class Linq {
|
|
|
602
633
|
headers: {
|
|
603
634
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
604
635
|
'Content-Type': 'application/json',
|
|
605
|
-
'Accept': 'application/
|
|
636
|
+
'Accept': 'application/json'
|
|
606
637
|
},
|
|
607
638
|
body: body,
|
|
608
639
|
json: true,
|
|
@@ -620,7 +651,7 @@ class Linq {
|
|
|
620
651
|
headers: {
|
|
621
652
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
622
653
|
'Content-Type': 'application/json',
|
|
623
|
-
'Accept': 'application/
|
|
654
|
+
'Accept': 'application/json'
|
|
624
655
|
},
|
|
625
656
|
body: body,
|
|
626
657
|
json: true,
|
|
@@ -633,7 +664,7 @@ class Linq {
|
|
|
633
664
|
url: `https://api.linqapp.com/api/partner/v2/chat_messages/${chatMessageId}/reaction`,
|
|
634
665
|
headers: {
|
|
635
666
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
636
|
-
'Accept': 'application/
|
|
667
|
+
'Accept': 'application/json'
|
|
637
668
|
},
|
|
638
669
|
json: true,
|
|
639
670
|
});
|
|
@@ -647,7 +678,7 @@ class Linq {
|
|
|
647
678
|
url: 'https://api.linqapp.com/api/partner/v2/phone_numbers',
|
|
648
679
|
headers: {
|
|
649
680
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
650
|
-
'Accept': 'application/
|
|
681
|
+
'Accept': 'application/json'
|
|
651
682
|
},
|
|
652
683
|
json: true,
|
|
653
684
|
});
|
|
@@ -655,7 +686,7 @@ class Linq {
|
|
|
655
686
|
if (operation === 'checkIMessageAvailability') {
|
|
656
687
|
const phoneNumber = this.getNodeParameter('phoneNumber', i);
|
|
657
688
|
const body = {
|
|
658
|
-
phone_number: phoneNumber
|
|
689
|
+
phone_number: formatPhoneNumber(phoneNumber)
|
|
659
690
|
};
|
|
660
691
|
responseData = await this.helpers.request({
|
|
661
692
|
method: 'POST',
|
|
@@ -663,7 +694,7 @@ class Linq {
|
|
|
663
694
|
headers: {
|
|
664
695
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
665
696
|
'Content-Type': 'application/json',
|
|
666
|
-
'Accept': 'application/
|
|
697
|
+
'Accept': 'application/json'
|
|
667
698
|
},
|
|
668
699
|
body: body,
|
|
669
700
|
json: true,
|
|
@@ -678,7 +709,7 @@ class Linq {
|
|
|
678
709
|
url: 'https://api.linqapp.com/api/partner/v2/webhook_subscriptions',
|
|
679
710
|
headers: {
|
|
680
711
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
681
|
-
'Accept': 'application/
|
|
712
|
+
'Accept': 'application/json'
|
|
682
713
|
},
|
|
683
714
|
json: true,
|
|
684
715
|
});
|
|
@@ -690,7 +721,7 @@ class Linq {
|
|
|
690
721
|
url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
|
|
691
722
|
headers: {
|
|
692
723
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
693
|
-
'Accept': 'application/
|
|
724
|
+
'Accept': 'application/json'
|
|
694
725
|
},
|
|
695
726
|
json: true,
|
|
696
727
|
});
|
|
@@ -714,7 +745,7 @@ class Linq {
|
|
|
714
745
|
headers: {
|
|
715
746
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
716
747
|
'Content-Type': 'application/json',
|
|
717
|
-
'Accept': 'application/
|
|
748
|
+
'Accept': 'application/json'
|
|
718
749
|
},
|
|
719
750
|
body: body,
|
|
720
751
|
json: true,
|
|
@@ -742,7 +773,7 @@ class Linq {
|
|
|
742
773
|
headers: {
|
|
743
774
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
744
775
|
'Content-Type': 'application/json',
|
|
745
|
-
'Accept': 'application/
|
|
776
|
+
'Accept': 'application/json'
|
|
746
777
|
},
|
|
747
778
|
body: body,
|
|
748
779
|
json: true,
|
|
@@ -755,7 +786,7 @@ class Linq {
|
|
|
755
786
|
url: `https://api.linqapp.com/api/partner/v2/webhook_subscriptions/${webhookSubscriptionId}`,
|
|
756
787
|
headers: {
|
|
757
788
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
758
|
-
'Accept': 'application/
|
|
789
|
+
'Accept': 'application/json'
|
|
759
790
|
},
|
|
760
791
|
json: true,
|
|
761
792
|
});
|
|
@@ -781,7 +812,7 @@ class Linq {
|
|
|
781
812
|
if (email)
|
|
782
813
|
body.contact.email = email;
|
|
783
814
|
if (phoneNumber)
|
|
784
|
-
body.contact.phone_number = phoneNumber;
|
|
815
|
+
body.contact.phone_number = formatPhoneNumber(phoneNumber);
|
|
785
816
|
if (company)
|
|
786
817
|
body.contact.company = company;
|
|
787
818
|
if (title)
|
|
@@ -794,7 +825,7 @@ class Linq {
|
|
|
794
825
|
headers: {
|
|
795
826
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
796
827
|
'Content-Type': 'application/json',
|
|
797
|
-
'Accept': 'application/
|
|
828
|
+
'Accept': 'application/json'
|
|
798
829
|
},
|
|
799
830
|
body: body,
|
|
800
831
|
json: true,
|
|
@@ -807,7 +838,7 @@ class Linq {
|
|
|
807
838
|
url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
|
|
808
839
|
headers: {
|
|
809
840
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
810
|
-
'Accept': 'application/
|
|
841
|
+
'Accept': 'application/json'
|
|
811
842
|
},
|
|
812
843
|
json: true,
|
|
813
844
|
});
|
|
@@ -831,7 +862,7 @@ class Linq {
|
|
|
831
862
|
if (email)
|
|
832
863
|
body.contact.email = email;
|
|
833
864
|
if (phoneNumber)
|
|
834
|
-
body.contact.phone_number = phoneNumber;
|
|
865
|
+
body.contact.phone_number = formatPhoneNumber(phoneNumber);
|
|
835
866
|
if (company)
|
|
836
867
|
body.contact.company = company;
|
|
837
868
|
if (title)
|
|
@@ -844,7 +875,7 @@ class Linq {
|
|
|
844
875
|
headers: {
|
|
845
876
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
846
877
|
'Content-Type': 'application/json',
|
|
847
|
-
'Accept': 'application/
|
|
878
|
+
'Accept': 'application/json'
|
|
848
879
|
},
|
|
849
880
|
body: body,
|
|
850
881
|
json: true,
|
|
@@ -857,7 +888,7 @@ class Linq {
|
|
|
857
888
|
url: `https://api.linqapp.com/api/partner/v2/contacts/${contactId}`,
|
|
858
889
|
headers: {
|
|
859
890
|
'X-LINQ-INTEGRATION-TOKEN': credentials.integrationToken,
|
|
860
|
-
'Accept': 'application/
|
|
891
|
+
'Accept': 'application/json'
|
|
861
892
|
},
|
|
862
893
|
json: true,
|
|
863
894
|
});
|