n8n-nodes-linq 0.1.16 → 3.0.0
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/LICENSE.md +20 -20
- package/README.md +194 -193
- package/dist/credentials/LinqApi.credentials.d.ts +8 -0
- package/dist/credentials/LinqApi.credentials.js +10 -2
- package/dist/nodes/Linq/Linq.node.js +237 -93
- package/dist/nodes/LinqTrigger/LinqTrigger.node.d.ts +2 -2
- package/dist/nodes/LinqTrigger/LinqTrigger.node.js +78 -19
- package/index.js +1 -1
- package/package.json +59 -54
|
@@ -129,16 +129,16 @@ class Linq {
|
|
|
129
129
|
noDataExpression: true,
|
|
130
130
|
displayOptions: { show: { resource: ['phoneNumber'] } },
|
|
131
131
|
options: [
|
|
132
|
-
{
|
|
133
|
-
name: 'Check iMessage Availability',
|
|
134
|
-
value: 'checkIMessageAvailability',
|
|
135
|
-
action: 'Check imessage availability'
|
|
136
|
-
},
|
|
137
132
|
{
|
|
138
133
|
name: 'Get Many',
|
|
139
134
|
value: 'getAll',
|
|
140
135
|
action: 'Get many phone numbers'
|
|
141
136
|
},
|
|
137
|
+
{
|
|
138
|
+
name: 'Update',
|
|
139
|
+
value: 'update',
|
|
140
|
+
action: 'Update a phone number'
|
|
141
|
+
},
|
|
142
142
|
],
|
|
143
143
|
default: 'getAll',
|
|
144
144
|
},
|
|
@@ -214,7 +214,7 @@ class Linq {
|
|
|
214
214
|
displayName: 'Chat ID',
|
|
215
215
|
name: 'chatId',
|
|
216
216
|
type: 'string',
|
|
217
|
-
displayOptions: { show: { resource: ['chat'], operation: ['getOne'] } },
|
|
217
|
+
displayOptions: { show: { resource: ['chat'], operation: ['getOne', 'shareContact'] } },
|
|
218
218
|
default: '',
|
|
219
219
|
description: 'The ID of the chat to retrieve',
|
|
220
220
|
},
|
|
@@ -224,7 +224,15 @@ class Linq {
|
|
|
224
224
|
type: 'string',
|
|
225
225
|
displayOptions: { show: { resource: ['chat'], operation: ['getAll'] } },
|
|
226
226
|
default: '',
|
|
227
|
-
description: '
|
|
227
|
+
description: 'Required: your Linq phone number (phone_number)',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
displayName: 'From Phone Number',
|
|
231
|
+
name: 'fromPhoneNumber',
|
|
232
|
+
type: 'string',
|
|
233
|
+
displayOptions: { show: { resource: ['chat'], operation: ['find'] } },
|
|
234
|
+
default: '',
|
|
235
|
+
description: 'Required: your Linq phone number (phone_number)',
|
|
228
236
|
},
|
|
229
237
|
{
|
|
230
238
|
displayName: 'Phone Numbers',
|
|
@@ -235,12 +243,12 @@ class Linq {
|
|
|
235
243
|
description: 'Comma-separated list of phone numbers to find chat between them',
|
|
236
244
|
},
|
|
237
245
|
{
|
|
238
|
-
displayName: '
|
|
239
|
-
name: '
|
|
240
|
-
type: '
|
|
246
|
+
displayName: 'Cursor',
|
|
247
|
+
name: 'cursor',
|
|
248
|
+
type: 'string',
|
|
241
249
|
displayOptions: { show: { resource: ['chat'], operation: ['getAll'] } },
|
|
242
|
-
default:
|
|
243
|
-
description: '
|
|
250
|
+
default: '',
|
|
251
|
+
description: 'Cursor for pagination',
|
|
244
252
|
},
|
|
245
253
|
{
|
|
246
254
|
displayName: 'Per Page',
|
|
@@ -283,12 +291,20 @@ class Linq {
|
|
|
283
291
|
default: '',
|
|
284
292
|
description: 'The text of the message to send',
|
|
285
293
|
},
|
|
294
|
+
{
|
|
295
|
+
displayName: 'Attachment URLs',
|
|
296
|
+
name: 'attachmentUrls',
|
|
297
|
+
type: 'string',
|
|
298
|
+
displayOptions: { show: { resource: ['chat'], operation: ['create'] } },
|
|
299
|
+
default: '',
|
|
300
|
+
description: 'Comma-separated list of attachment URLs',
|
|
301
|
+
},
|
|
286
302
|
// Chat Message parameters
|
|
287
303
|
{
|
|
288
304
|
displayName: 'Chat Message ID',
|
|
289
305
|
name: 'chatMessageId',
|
|
290
306
|
type: 'string',
|
|
291
|
-
displayOptions: { show: { resource: ['chatMessage'], operation: ['getOne', 'delete', 'edit', 'react'
|
|
307
|
+
displayOptions: { show: { resource: ['chatMessage'], operation: ['getOne', 'delete', 'edit', 'react'] } },
|
|
292
308
|
default: '',
|
|
293
309
|
description: 'The ID of the chat message',
|
|
294
310
|
},
|
|
@@ -308,6 +324,22 @@ class Linq {
|
|
|
308
324
|
default: '',
|
|
309
325
|
description: 'The text of the message',
|
|
310
326
|
},
|
|
327
|
+
{
|
|
328
|
+
displayName: 'Attachment URLs',
|
|
329
|
+
name: 'attachmentUrls',
|
|
330
|
+
type: 'string',
|
|
331
|
+
displayOptions: { show: { resource: ['chatMessage'], operation: ['create'] } },
|
|
332
|
+
default: '',
|
|
333
|
+
description: 'Comma-separated list of attachment URLs (attachment_urls[])',
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
displayName: 'Idempotency Key',
|
|
337
|
+
name: 'idempotencyKey',
|
|
338
|
+
type: 'string',
|
|
339
|
+
displayOptions: { show: { resource: ['chatMessage'], operation: ['create'] } },
|
|
340
|
+
default: '',
|
|
341
|
+
description: 'Optional idempotency key for message creation',
|
|
342
|
+
},
|
|
311
343
|
{
|
|
312
344
|
displayName: 'Reaction',
|
|
313
345
|
name: 'reaction',
|
|
@@ -316,14 +348,38 @@ class Linq {
|
|
|
316
348
|
default: '',
|
|
317
349
|
description: 'The reaction to add',
|
|
318
350
|
},
|
|
351
|
+
{
|
|
352
|
+
displayName: 'Reaction ID',
|
|
353
|
+
name: 'reactionId',
|
|
354
|
+
type: 'string',
|
|
355
|
+
displayOptions: { show: { resource: ['chatMessage'], operation: ['getReaction'] } },
|
|
356
|
+
default: '',
|
|
357
|
+
description: 'The reaction ID to retrieve',
|
|
358
|
+
},
|
|
319
359
|
// Phone Number parameters
|
|
320
360
|
{
|
|
321
|
-
displayName: 'Phone Number',
|
|
322
|
-
name: '
|
|
361
|
+
displayName: 'Phone Number ID',
|
|
362
|
+
name: 'phoneNumberId',
|
|
363
|
+
type: 'string',
|
|
364
|
+
displayOptions: { show: { resource: ['phoneNumber'], operation: ['update'] } },
|
|
365
|
+
default: '',
|
|
366
|
+
description: 'The ID of the phone number to update',
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
displayName: 'Forward To',
|
|
370
|
+
name: 'forwardTo',
|
|
371
|
+
type: 'string',
|
|
372
|
+
displayOptions: { show: { resource: ['phoneNumber'], operation: ['update'] } },
|
|
373
|
+
default: '',
|
|
374
|
+
description: 'Optional forwarding destination phone number',
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
displayName: 'Label',
|
|
378
|
+
name: 'label',
|
|
323
379
|
type: 'string',
|
|
324
|
-
displayOptions: { show: { resource: ['phoneNumber'], operation: ['
|
|
380
|
+
displayOptions: { show: { resource: ['phoneNumber'], operation: ['update'] } },
|
|
325
381
|
default: '',
|
|
326
|
-
description: '
|
|
382
|
+
description: 'Optional label for the phone number',
|
|
327
383
|
},
|
|
328
384
|
// Webhook Subscription parameters
|
|
329
385
|
{
|
|
@@ -440,6 +496,67 @@ class Linq {
|
|
|
440
496
|
const items = this.getInputData();
|
|
441
497
|
const returnData = [];
|
|
442
498
|
const credentials = await this.getCredentials('linqApi');
|
|
499
|
+
const uploadAttachment = async (url) => {
|
|
500
|
+
const fileResponse = await this.helpers.request({
|
|
501
|
+
method: 'GET',
|
|
502
|
+
url,
|
|
503
|
+
encoding: null,
|
|
504
|
+
resolveWithFullResponse: true,
|
|
505
|
+
});
|
|
506
|
+
const buffer = fileResponse.body;
|
|
507
|
+
// Limit file size to 50MB to avoid OOM
|
|
508
|
+
// Note: This loads the file into memory. For larger files, streaming would be preferred
|
|
509
|
+
// but is not implemented here to maintain compatibility with n8n helper request patterns.
|
|
510
|
+
const MAX_SIZE = 50 * 1024 * 1024;
|
|
511
|
+
if (buffer.length > MAX_SIZE) {
|
|
512
|
+
throw new n8n_workflow_1.ApplicationError(`File at ${url} exceeds the 50MB size limit.`);
|
|
513
|
+
}
|
|
514
|
+
const contentType = fileResponse.headers['content-type'];
|
|
515
|
+
const uploadConfig = await this.helpers.request({
|
|
516
|
+
method: 'POST',
|
|
517
|
+
url: 'https://api.linqapp.com/api/partner/v3/attachments',
|
|
518
|
+
headers: {
|
|
519
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
520
|
+
'Content-Type': 'application/json',
|
|
521
|
+
'Accept': 'application/json',
|
|
522
|
+
},
|
|
523
|
+
body: {
|
|
524
|
+
content_type: contentType,
|
|
525
|
+
},
|
|
526
|
+
json: true,
|
|
527
|
+
});
|
|
528
|
+
await this.helpers.request({
|
|
529
|
+
method: 'PUT',
|
|
530
|
+
url: uploadConfig.upload_url,
|
|
531
|
+
headers: {
|
|
532
|
+
'Content-Type': contentType,
|
|
533
|
+
},
|
|
534
|
+
body: buffer,
|
|
535
|
+
json: false,
|
|
536
|
+
});
|
|
537
|
+
return uploadConfig.id;
|
|
538
|
+
};
|
|
539
|
+
const createParts = async (text, attachmentUrlsString) => {
|
|
540
|
+
const parts = [];
|
|
541
|
+
if (text) {
|
|
542
|
+
parts.push({ type: 'text', value: text });
|
|
543
|
+
}
|
|
544
|
+
if (attachmentUrlsString) {
|
|
545
|
+
const urls = attachmentUrlsString.split(',').map(u => u.trim()).filter(Boolean);
|
|
546
|
+
// Upload attachments in batches to limit concurrency and avoid OOM
|
|
547
|
+
const CONCURRENCY_LIMIT = 3;
|
|
548
|
+
const attachmentIds = [];
|
|
549
|
+
for (let i = 0; i < urls.length; i += CONCURRENCY_LIMIT) {
|
|
550
|
+
const chunk = urls.slice(i, i + CONCURRENCY_LIMIT);
|
|
551
|
+
const chunkResults = await Promise.all(chunk.map(url => uploadAttachment(url)));
|
|
552
|
+
attachmentIds.push(...chunkResults);
|
|
553
|
+
}
|
|
554
|
+
attachmentIds.forEach(id => {
|
|
555
|
+
parts.push({ type: 'media', attachment_id: id });
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
return parts;
|
|
559
|
+
};
|
|
443
560
|
for (let i = 0; i < items.length; i++) {
|
|
444
561
|
const resource = this.getNodeParameter('resource', i);
|
|
445
562
|
const operation = this.getNodeParameter('operation', i);
|
|
@@ -449,21 +566,23 @@ class Linq {
|
|
|
449
566
|
if (resource === 'chat') {
|
|
450
567
|
if (operation === 'getAll') {
|
|
451
568
|
const phoneNumber = this.getNodeParameter('phoneNumber', i, '');
|
|
452
|
-
const
|
|
569
|
+
const cursor = this.getNodeParameter('cursor', i, '');
|
|
453
570
|
const perPage = this.getNodeParameter('perPage', i);
|
|
571
|
+
if (!phoneNumber) {
|
|
572
|
+
throw new n8n_workflow_1.ApplicationError('phone_number is required by Linq API');
|
|
573
|
+
}
|
|
454
574
|
const qs = {};
|
|
455
|
-
|
|
456
|
-
|
|
575
|
+
qs.phone_number = formatPhoneNumber(phoneNumber);
|
|
576
|
+
if (cursor)
|
|
577
|
+
qs.cursor = cursor;
|
|
457
578
|
if (perPage && perPage !== 25)
|
|
458
579
|
qs.per_page = perPage;
|
|
459
|
-
if (phoneNumber)
|
|
460
|
-
qs.phone_number = formatPhoneNumber(phoneNumber);
|
|
461
580
|
responseData = await this.helpers.request({
|
|
462
581
|
method: 'GET',
|
|
463
|
-
url: 'https://api.linqapp.com/api/partner/
|
|
582
|
+
url: 'https://api.linqapp.com/api/partner/v3/chats',
|
|
464
583
|
qs,
|
|
465
584
|
headers: {
|
|
466
|
-
'
|
|
585
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
467
586
|
'Accept': 'application/json'
|
|
468
587
|
},
|
|
469
588
|
json: true,
|
|
@@ -473,35 +592,31 @@ class Linq {
|
|
|
473
592
|
const chatId = this.getNodeParameter('chatId', i);
|
|
474
593
|
responseData = await this.helpers.request({
|
|
475
594
|
method: 'GET',
|
|
476
|
-
url: `https://api.linqapp.com/api/partner/
|
|
595
|
+
url: `https://api.linqapp.com/api/partner/v3/chats/${chatId}`,
|
|
477
596
|
headers: {
|
|
478
|
-
'
|
|
597
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
479
598
|
'Accept': 'application/json'
|
|
480
599
|
},
|
|
481
600
|
json: true,
|
|
482
601
|
});
|
|
483
602
|
}
|
|
484
603
|
if (operation === 'find') {
|
|
604
|
+
const fromPhoneNumber = this.getNodeParameter('fromPhoneNumber', i, '');
|
|
485
605
|
const phoneNumbers = this.getNodeParameter('phoneNumbers', i, '');
|
|
606
|
+
if (!fromPhoneNumber) {
|
|
607
|
+
throw new n8n_workflow_1.ApplicationError('phone_number is required when finding chats');
|
|
608
|
+
}
|
|
486
609
|
const qs = {};
|
|
487
610
|
if (phoneNumbers) {
|
|
488
|
-
// Check if we have a single phone number or multiple
|
|
489
611
|
const phoneNumbersArray = phoneNumbers.split(',').map(p => formatPhoneNumber(p.trim()));
|
|
490
|
-
|
|
491
|
-
// For single phone number, use 'phone' parameter
|
|
492
|
-
qs.phone = phoneNumbersArray[0];
|
|
493
|
-
}
|
|
494
|
-
else {
|
|
495
|
-
// For multiple phone numbers, use 'phone_numbers[]' parameter
|
|
496
|
-
qs['phone_numbers[]'] = phoneNumbersArray;
|
|
497
|
-
}
|
|
612
|
+
qs['phone_numbers[]'] = phoneNumbersArray;
|
|
498
613
|
}
|
|
499
614
|
responseData = await this.helpers.request({
|
|
500
615
|
method: 'GET',
|
|
501
|
-
url: 'https://api.linqapp.com/api/partner/
|
|
616
|
+
url: 'https://api.linqapp.com/api/partner/v3/chats/find',
|
|
502
617
|
qs,
|
|
503
618
|
headers: {
|
|
504
|
-
'
|
|
619
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
505
620
|
'Accept': 'application/json'
|
|
506
621
|
},
|
|
507
622
|
json: true,
|
|
@@ -512,38 +627,45 @@ class Linq {
|
|
|
512
627
|
const displayName = this.getNodeParameter('displayName', i);
|
|
513
628
|
const phoneNumbers = this.getNodeParameter('phoneNumbers', i);
|
|
514
629
|
const messageText = this.getNodeParameter('messageText', i);
|
|
630
|
+
const attachmentUrls = this.getNodeParameter('attachmentUrls', i, '');
|
|
631
|
+
if (!sendFrom) {
|
|
632
|
+
throw new n8n_workflow_1.ApplicationError('send_from is required by Linq when creating chats');
|
|
633
|
+
}
|
|
634
|
+
const parts = await createParts(messageText, attachmentUrls);
|
|
515
635
|
const body = {
|
|
516
636
|
chat: {
|
|
517
637
|
phone_numbers: phoneNumbers.split(',').map(p => formatPhoneNumber(p.trim()))
|
|
518
638
|
},
|
|
519
639
|
message: {
|
|
520
|
-
|
|
640
|
+
parts
|
|
521
641
|
}
|
|
522
642
|
};
|
|
523
|
-
|
|
524
|
-
body.send_from = formatPhoneNumber(sendFrom);
|
|
525
|
-
}
|
|
643
|
+
body.send_from = formatPhoneNumber(sendFrom);
|
|
526
644
|
if (displayName) {
|
|
527
645
|
body.chat.display_name = displayName;
|
|
528
646
|
}
|
|
529
647
|
responseData = await this.helpers.request({
|
|
530
648
|
method: 'POST',
|
|
531
|
-
url: 'https://api.linqapp.com/api/partner/
|
|
649
|
+
url: 'https://api.linqapp.com/api/partner/v3/chats',
|
|
532
650
|
headers: {
|
|
533
|
-
'
|
|
651
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
534
652
|
'Content-Type': 'application/json',
|
|
535
|
-
'Accept': 'application/
|
|
653
|
+
'Accept': 'application/json'
|
|
536
654
|
},
|
|
537
655
|
body: body,
|
|
538
656
|
json: true,
|
|
539
657
|
});
|
|
540
658
|
}
|
|
541
659
|
if (operation === 'shareContact') {
|
|
660
|
+
const chatId = this.getNodeParameter('chatId', i);
|
|
661
|
+
if (!chatId) {
|
|
662
|
+
throw new n8n_workflow_1.ApplicationError('chatId is required to share contact');
|
|
663
|
+
}
|
|
542
664
|
responseData = await this.helpers.request({
|
|
543
665
|
method: 'POST',
|
|
544
|
-
url:
|
|
666
|
+
url: `https://api.linqapp.com/api/partner/v3/chats/${chatId}/share_contact`,
|
|
545
667
|
headers: {
|
|
546
|
-
'
|
|
668
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
547
669
|
'Content-Type': 'application/json',
|
|
548
670
|
'Accept': 'application/json'
|
|
549
671
|
},
|
|
@@ -555,12 +677,14 @@ class Linq {
|
|
|
555
677
|
if (resource === 'chatMessage') {
|
|
556
678
|
if (operation === 'getAll') {
|
|
557
679
|
const chatId = this.getNodeParameter('chatId', i);
|
|
680
|
+
if (!chatId) {
|
|
681
|
+
throw new n8n_workflow_1.ApplicationError('chatId is required to list chat messages');
|
|
682
|
+
}
|
|
558
683
|
responseData = await this.helpers.request({
|
|
559
684
|
method: 'GET',
|
|
560
|
-
url: `https://api.linqapp.com/api/partner/
|
|
561
|
-
qs: { chat_id: chatId },
|
|
685
|
+
url: `https://api.linqapp.com/api/partner/v3/chats/${chatId}/messages`,
|
|
562
686
|
headers: {
|
|
563
|
-
'
|
|
687
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
564
688
|
'Accept': 'application/json'
|
|
565
689
|
},
|
|
566
690
|
json: true,
|
|
@@ -570,9 +694,9 @@ class Linq {
|
|
|
570
694
|
const chatMessageId = this.getNodeParameter('chatMessageId', i);
|
|
571
695
|
responseData = await this.helpers.request({
|
|
572
696
|
method: 'GET',
|
|
573
|
-
url: `https://api.linqapp.com/api/partner/
|
|
697
|
+
url: `https://api.linqapp.com/api/partner/v3/messages/${chatMessageId}`,
|
|
574
698
|
headers: {
|
|
575
|
-
'
|
|
699
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
576
700
|
'Accept': 'application/json'
|
|
577
701
|
},
|
|
578
702
|
json: true,
|
|
@@ -581,15 +705,23 @@ class Linq {
|
|
|
581
705
|
if (operation === 'create') {
|
|
582
706
|
const chatId = this.getNodeParameter('chatId', i);
|
|
583
707
|
const messageText = this.getNodeParameter('messageText', i);
|
|
708
|
+
const attachmentUrls = this.getNodeParameter('attachmentUrls', i, '');
|
|
709
|
+
const idempotencyKey = this.getNodeParameter('idempotencyKey', i, '');
|
|
710
|
+
if (!chatId) {
|
|
711
|
+
throw new n8n_workflow_1.ApplicationError('chatId is required to create a chat message');
|
|
712
|
+
}
|
|
713
|
+
const parts = await createParts(messageText, attachmentUrls);
|
|
584
714
|
const body = {
|
|
585
|
-
|
|
586
|
-
text: messageText
|
|
715
|
+
parts
|
|
587
716
|
};
|
|
717
|
+
if (idempotencyKey) {
|
|
718
|
+
body.idempotency_key = idempotencyKey;
|
|
719
|
+
}
|
|
588
720
|
responseData = await this.helpers.request({
|
|
589
721
|
method: 'POST',
|
|
590
|
-
url:
|
|
722
|
+
url: `https://api.linqapp.com/api/partner/v3/chats/${chatId}/messages`,
|
|
591
723
|
headers: {
|
|
592
|
-
'
|
|
724
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
593
725
|
'Content-Type': 'application/json',
|
|
594
726
|
'Accept': 'application/json'
|
|
595
727
|
},
|
|
@@ -601,9 +733,9 @@ class Linq {
|
|
|
601
733
|
const chatMessageId = this.getNodeParameter('chatMessageId', i);
|
|
602
734
|
responseData = await this.helpers.request({
|
|
603
735
|
method: 'DELETE',
|
|
604
|
-
url: `https://api.linqapp.com/api/partner/
|
|
736
|
+
url: `https://api.linqapp.com/api/partner/v3/messages/${chatMessageId}`,
|
|
605
737
|
headers: {
|
|
606
|
-
'
|
|
738
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
607
739
|
'Accept': 'application/json'
|
|
608
740
|
},
|
|
609
741
|
json: true,
|
|
@@ -617,9 +749,9 @@ class Linq {
|
|
|
617
749
|
};
|
|
618
750
|
responseData = await this.helpers.request({
|
|
619
751
|
method: 'POST',
|
|
620
|
-
url: `https://api.linqapp.com/api/partner/
|
|
752
|
+
url: `https://api.linqapp.com/api/partner/v3/messages/${chatMessageId}/edit`,
|
|
621
753
|
headers: {
|
|
622
|
-
'
|
|
754
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
623
755
|
'Content-Type': 'application/json',
|
|
624
756
|
'Accept': 'application/json'
|
|
625
757
|
},
|
|
@@ -635,9 +767,9 @@ class Linq {
|
|
|
635
767
|
};
|
|
636
768
|
responseData = await this.helpers.request({
|
|
637
769
|
method: 'POST',
|
|
638
|
-
url: `https://api.linqapp.com/api/partner/
|
|
770
|
+
url: `https://api.linqapp.com/api/partner/v3/messages/${chatMessageId}/reactions`,
|
|
639
771
|
headers: {
|
|
640
|
-
'
|
|
772
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
641
773
|
'Content-Type': 'application/json',
|
|
642
774
|
'Accept': 'application/json'
|
|
643
775
|
},
|
|
@@ -646,12 +778,15 @@ class Linq {
|
|
|
646
778
|
});
|
|
647
779
|
}
|
|
648
780
|
if (operation === 'getReaction') {
|
|
649
|
-
const
|
|
781
|
+
const reactionId = this.getNodeParameter('reactionId', i);
|
|
782
|
+
if (!reactionId) {
|
|
783
|
+
throw new n8n_workflow_1.ApplicationError('reactionId is required to get reaction');
|
|
784
|
+
}
|
|
650
785
|
responseData = await this.helpers.request({
|
|
651
786
|
method: 'GET',
|
|
652
|
-
url: `https://api.linqapp.com/api/partner/
|
|
787
|
+
url: `https://api.linqapp.com/api/partner/v3/chat_message_reactions/${reactionId}`,
|
|
653
788
|
headers: {
|
|
654
|
-
'
|
|
789
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
655
790
|
'Accept': 'application/json'
|
|
656
791
|
},
|
|
657
792
|
json: true,
|
|
@@ -663,28 +798,37 @@ class Linq {
|
|
|
663
798
|
if (operation === 'getAll') {
|
|
664
799
|
responseData = await this.helpers.request({
|
|
665
800
|
method: 'GET',
|
|
666
|
-
url: 'https://api.linqapp.com/api/partner/
|
|
801
|
+
url: 'https://api.linqapp.com/api/partner/v3/phone_numbers',
|
|
667
802
|
headers: {
|
|
668
|
-
'
|
|
803
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
669
804
|
'Accept': 'application/json'
|
|
670
805
|
},
|
|
671
806
|
json: true,
|
|
672
807
|
});
|
|
673
808
|
}
|
|
674
|
-
if (operation === '
|
|
675
|
-
const
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
|
|
809
|
+
if (operation === 'update') {
|
|
810
|
+
const phoneNumberId = this.getNodeParameter('phoneNumberId', i);
|
|
811
|
+
const forwardTo = this.getNodeParameter('forwardTo', i, '');
|
|
812
|
+
const label = this.getNodeParameter('label', i, '');
|
|
813
|
+
if (!phoneNumberId) {
|
|
814
|
+
throw new n8n_workflow_1.ApplicationError('phoneNumberId is required to update phone number');
|
|
815
|
+
}
|
|
816
|
+
const body = { phone_number: {} };
|
|
817
|
+
if (forwardTo) {
|
|
818
|
+
body.phone_number.forward_to = formatPhoneNumber(forwardTo);
|
|
819
|
+
}
|
|
820
|
+
if (label) {
|
|
821
|
+
body.phone_number.label = label;
|
|
822
|
+
}
|
|
679
823
|
responseData = await this.helpers.request({
|
|
680
|
-
method: '
|
|
681
|
-
url:
|
|
824
|
+
method: 'PUT',
|
|
825
|
+
url: `https://api.linqapp.com/api/partner/v3/phone_numbers/${phoneNumberId}`,
|
|
682
826
|
headers: {
|
|
683
|
-
'
|
|
827
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
684
828
|
'Content-Type': 'application/json',
|
|
685
829
|
'Accept': 'application/json'
|
|
686
830
|
},
|
|
687
|
-
body
|
|
831
|
+
body,
|
|
688
832
|
json: true,
|
|
689
833
|
});
|
|
690
834
|
}
|
|
@@ -694,9 +838,9 @@ class Linq {
|
|
|
694
838
|
if (operation === 'getAll') {
|
|
695
839
|
responseData = await this.helpers.request({
|
|
696
840
|
method: 'GET',
|
|
697
|
-
url: 'https://api.linqapp.com/api/partner/
|
|
841
|
+
url: 'https://api.linqapp.com/api/partner/v3/webhook_subscriptions',
|
|
698
842
|
headers: {
|
|
699
|
-
'
|
|
843
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
700
844
|
'Accept': 'application/json'
|
|
701
845
|
},
|
|
702
846
|
json: true,
|
|
@@ -706,9 +850,9 @@ class Linq {
|
|
|
706
850
|
const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
|
|
707
851
|
responseData = await this.helpers.request({
|
|
708
852
|
method: 'GET',
|
|
709
|
-
url: `https://api.linqapp.com/api/partner/
|
|
853
|
+
url: `https://api.linqapp.com/api/partner/v3/webhook_subscriptions/${webhookSubscriptionId}`,
|
|
710
854
|
headers: {
|
|
711
|
-
'
|
|
855
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
712
856
|
'Accept': 'application/json'
|
|
713
857
|
},
|
|
714
858
|
json: true,
|
|
@@ -729,9 +873,9 @@ class Linq {
|
|
|
729
873
|
}
|
|
730
874
|
responseData = await this.helpers.request({
|
|
731
875
|
method: 'POST',
|
|
732
|
-
url: 'https://api.linqapp.com/api/partner/
|
|
876
|
+
url: 'https://api.linqapp.com/api/partner/v3/webhook_subscriptions',
|
|
733
877
|
headers: {
|
|
734
|
-
'
|
|
878
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
735
879
|
'Content-Type': 'application/json',
|
|
736
880
|
'Accept': 'application/json'
|
|
737
881
|
},
|
|
@@ -757,9 +901,9 @@ class Linq {
|
|
|
757
901
|
}
|
|
758
902
|
responseData = await this.helpers.request({
|
|
759
903
|
method: 'PUT',
|
|
760
|
-
url: `https://api.linqapp.com/api/partner/
|
|
904
|
+
url: `https://api.linqapp.com/api/partner/v3/webhook_subscriptions/${webhookSubscriptionId}`,
|
|
761
905
|
headers: {
|
|
762
|
-
'
|
|
906
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
763
907
|
'Content-Type': 'application/json',
|
|
764
908
|
'Accept': 'application/json'
|
|
765
909
|
},
|
|
@@ -771,9 +915,9 @@ class Linq {
|
|
|
771
915
|
const webhookSubscriptionId = this.getNodeParameter('webhookSubscriptionId', i);
|
|
772
916
|
responseData = await this.helpers.request({
|
|
773
917
|
method: 'DELETE',
|
|
774
|
-
url: `https://api.linqapp.com/api/partner/
|
|
918
|
+
url: `https://api.linqapp.com/api/partner/v3/webhook_subscriptions/${webhookSubscriptionId}`,
|
|
775
919
|
headers: {
|
|
776
|
-
'
|
|
920
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
777
921
|
'Accept': 'application/json'
|
|
778
922
|
},
|
|
779
923
|
json: true,
|
|
@@ -809,9 +953,9 @@ class Linq {
|
|
|
809
953
|
body.contact.location = location;
|
|
810
954
|
responseData = await this.helpers.request({
|
|
811
955
|
method: 'POST',
|
|
812
|
-
url: 'https://api.linqapp.com/api/partner/
|
|
956
|
+
url: 'https://api.linqapp.com/api/partner/v3/contacts',
|
|
813
957
|
headers: {
|
|
814
|
-
'
|
|
958
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
815
959
|
'Content-Type': 'application/json',
|
|
816
960
|
'Accept': 'application/json'
|
|
817
961
|
},
|
|
@@ -823,9 +967,9 @@ class Linq {
|
|
|
823
967
|
const contactId = this.getNodeParameter('contactId', i);
|
|
824
968
|
responseData = await this.helpers.request({
|
|
825
969
|
method: 'GET',
|
|
826
|
-
url: `https://api.linqapp.com/api/partner/
|
|
970
|
+
url: `https://api.linqapp.com/api/partner/v3/contacts/${contactId}`,
|
|
827
971
|
headers: {
|
|
828
|
-
'
|
|
972
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
829
973
|
'Accept': 'application/json'
|
|
830
974
|
},
|
|
831
975
|
json: true,
|
|
@@ -859,9 +1003,9 @@ class Linq {
|
|
|
859
1003
|
body.contact.location = location;
|
|
860
1004
|
responseData = await this.helpers.request({
|
|
861
1005
|
method: 'PUT',
|
|
862
|
-
url: `https://api.linqapp.com/api/partner/
|
|
1006
|
+
url: `https://api.linqapp.com/api/partner/v3/contacts/${contactId}`,
|
|
863
1007
|
headers: {
|
|
864
|
-
'
|
|
1008
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
865
1009
|
'Content-Type': 'application/json',
|
|
866
1010
|
'Accept': 'application/json'
|
|
867
1011
|
},
|
|
@@ -873,9 +1017,9 @@ class Linq {
|
|
|
873
1017
|
const contactId = this.getNodeParameter('contactId', i);
|
|
874
1018
|
responseData = await this.helpers.request({
|
|
875
1019
|
method: 'DELETE',
|
|
876
|
-
url: `https://api.linqapp.com/api/partner/
|
|
1020
|
+
url: `https://api.linqapp.com/api/partner/v3/contacts/${contactId}`,
|
|
877
1021
|
headers: {
|
|
878
|
-
'
|
|
1022
|
+
'Authorization': `Bearer ${credentials.integrationToken}`,
|
|
879
1023
|
'Accept': 'application/json'
|
|
880
1024
|
},
|
|
881
1025
|
json: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow';
|
|
1
|
+
import { IWebhookFunctions, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow';
|
|
2
2
|
export declare class LinqTrigger implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
|
-
webhook(this:
|
|
4
|
+
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
|
5
5
|
}
|