n8n-nodes-mightycall 1.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.
@@ -0,0 +1,2797 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MightyCall = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class MightyCall {
6
+ constructor() {
7
+ this.description = {
8
+ displayName: 'MightyCall',
9
+ name: 'mightyCall',
10
+ icon: 'file:mightycall.svg',
11
+ group: ['transform'],
12
+ version: 2.1,
13
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
14
+ description: 'Interact with MightyCall API. Note: Communication and Interaction resources require Contact Center accounts.',
15
+ defaults: {
16
+ name: 'MightyCall',
17
+ },
18
+ inputs: ['main'],
19
+ outputs: ['main'],
20
+ credentials: [
21
+ {
22
+ name: 'mightyCallApi',
23
+ required: true,
24
+ },
25
+ ],
26
+ properties: [
27
+ {
28
+ displayName: 'Resource',
29
+ name: 'resource',
30
+ type: 'options',
31
+ noDataExpression: true,
32
+ options: [
33
+ {
34
+ name: 'Call',
35
+ value: 'call',
36
+ description: 'Active calls and call operations',
37
+ },
38
+ {
39
+ name: 'Contact',
40
+ value: 'contact',
41
+ description: 'Contact management',
42
+ },
43
+ {
44
+ name: 'Journal',
45
+ value: 'journal',
46
+ description: 'Call history and records',
47
+ },
48
+ {
49
+ name: 'Voicemail',
50
+ value: 'voicemail',
51
+ description: 'Voicemail management',
52
+ },
53
+ {
54
+ name: 'Business Number',
55
+ value: 'businessNumber',
56
+ description: 'Business phone numbers',
57
+ },
58
+ {
59
+ name: 'User',
60
+ value: 'user',
61
+ description: 'User management',
62
+ },
63
+ {
64
+ name: 'Message',
65
+ value: 'message',
66
+ description: 'SMS/MMS messaging',
67
+ },
68
+ {
69
+ name: 'Team',
70
+ value: 'team',
71
+ description: 'Team members and groups',
72
+ },
73
+ {
74
+ name: 'Profile',
75
+ value: 'profile',
76
+ description: 'User profile information',
77
+ },
78
+ {
79
+ name: 'Ping',
80
+ value: 'ping',
81
+ description: 'API health check',
82
+ },
83
+ {
84
+ name: '⚠️ Communication (Contact Center Only)',
85
+ value: 'communication',
86
+ description: '⚠️ REQUIRES CONTACT CENTER ACCOUNT - Communication thread management',
87
+ },
88
+ {
89
+ name: '⚠️ Interaction (Contact Center Only)',
90
+ value: 'interaction',
91
+ description: '⚠️ REQUIRES CONTACT CENTER ACCOUNT - View interactions',
92
+ },
93
+ ],
94
+ default: 'journal',
95
+ },
96
+ // Call Operations
97
+ {
98
+ displayName: 'Operation',
99
+ name: 'operation',
100
+ type: 'options',
101
+ noDataExpression: true,
102
+ displayOptions: {
103
+ show: {
104
+ resource: ['call'],
105
+ },
106
+ },
107
+ options: [
108
+ {
109
+ name: 'Get Many',
110
+ value: 'getAll',
111
+ description: 'Get call history with filters',
112
+ action: 'Get call history',
113
+ },
114
+ {
115
+ name: 'Get Active Calls',
116
+ value: 'getActive',
117
+ description: 'Get currently active calls',
118
+ action: 'Get active calls',
119
+ },
120
+ {
121
+ name: 'Make Call',
122
+ value: 'make',
123
+ description: 'Initiate a new call',
124
+ action: 'Make a call',
125
+ },
126
+ {
127
+ name: 'Hang Up',
128
+ value: 'hangUp',
129
+ description: 'Hang up a call',
130
+ action: 'Hang up a call',
131
+ },
132
+ ],
133
+ default: 'getActive',
134
+ },
135
+ // Journal Operations
136
+ {
137
+ displayName: 'Operation',
138
+ name: 'operation',
139
+ type: 'options',
140
+ noDataExpression: true,
141
+ displayOptions: {
142
+ show: {
143
+ resource: ['journal'],
144
+ },
145
+ },
146
+ options: [
147
+ {
148
+ name: 'Get Many',
149
+ value: 'getAll',
150
+ description: 'Get call history records',
151
+ action: 'Get call history',
152
+ },
153
+ {
154
+ name: 'Get Count',
155
+ value: 'getCount',
156
+ description: 'Get total count of requests',
157
+ action: 'Get requests count',
158
+ },
159
+ {
160
+ name: 'Get by ID',
161
+ value: 'getById',
162
+ description: 'Get specific request by ID',
163
+ action: 'Get request by ID',
164
+ },
165
+ {
166
+ name: 'Delete Messages',
167
+ value: 'deleteMessages',
168
+ description: 'Delete existing messages',
169
+ action: 'Delete messages',
170
+ },
171
+ {
172
+ name: 'Add/Update Comment',
173
+ value: 'addComment',
174
+ description: 'Add or update request comment',
175
+ action: 'Add comment',
176
+ },
177
+ {
178
+ name: 'Delete Comment',
179
+ value: 'deleteComment',
180
+ description: 'Delete existing comment for the request',
181
+ action: 'Delete comment',
182
+ },
183
+ {
184
+ name: 'Delete Voicemail',
185
+ value: 'deleteVoicemail',
186
+ description: 'Delete existing voicemail for the requests',
187
+ action: 'Delete voicemail',
188
+ },
189
+ {
190
+ name: 'Set Workflow State',
191
+ value: 'setWorkflowState',
192
+ description: 'Set workflow state of requests',
193
+ action: 'Set workflow state',
194
+ },
195
+ {
196
+ name: 'Set Flags',
197
+ value: 'setFlags',
198
+ description: 'Set flags of requests',
199
+ action: 'Set flags',
200
+ },
201
+ {
202
+ name: 'Remove Flags',
203
+ value: 'removeFlags',
204
+ description: 'Remove flags of requests',
205
+ action: 'Remove flags',
206
+ },
207
+ {
208
+ name: 'Get Block List Count',
209
+ value: 'getBlockListCount',
210
+ description: 'Count of available numbers in block list',
211
+ action: 'Get block list count',
212
+ },
213
+ {
214
+ name: 'Get VIP List Count',
215
+ value: 'getVipListCount',
216
+ description: 'Count of available numbers in VIP list',
217
+ action: 'Get VIP list count',
218
+ },
219
+ {
220
+ name: 'Add to Block List',
221
+ value: 'addToBlockList',
222
+ description: 'Add number to block list',
223
+ action: 'Add to block list',
224
+ },
225
+ {
226
+ name: 'Remove from Block List',
227
+ value: 'removeFromBlockList',
228
+ description: 'Remove number from block list',
229
+ action: 'Remove from block list',
230
+ },
231
+ {
232
+ name: 'Restore Message',
233
+ value: 'restoreMessage',
234
+ description: 'Restore deleted message',
235
+ action: 'Restore message',
236
+ },
237
+ {
238
+ name: 'Get Message Attachments',
239
+ value: 'getMessageAttachments',
240
+ description: 'Get message attachments',
241
+ action: 'Get attachments',
242
+ },
243
+ ],
244
+ default: 'getAll',
245
+ },
246
+ // Contact Operations
247
+ {
248
+ displayName: 'Operation',
249
+ name: 'operation',
250
+ type: 'options',
251
+ noDataExpression: true,
252
+ displayOptions: {
253
+ show: {
254
+ resource: ['contact'],
255
+ },
256
+ },
257
+ options: [
258
+ {
259
+ name: 'Get Many',
260
+ value: 'getAll',
261
+ description: 'Get many contacts',
262
+ action: 'Get many contacts',
263
+ },
264
+ {
265
+ name: 'Create',
266
+ value: 'create',
267
+ description: 'Create a new contact',
268
+ action: 'Create a contact',
269
+ },
270
+ {
271
+ name: 'Update',
272
+ value: 'update',
273
+ description: 'Update an existing contact',
274
+ action: 'Update a contact',
275
+ },
276
+ {
277
+ name: 'Delete',
278
+ value: 'delete',
279
+ description: 'Delete a contact',
280
+ action: 'Delete a contact',
281
+ },
282
+ ],
283
+ default: 'getAll',
284
+ },
285
+ // Voicemail Operations
286
+ {
287
+ displayName: 'Operation',
288
+ name: 'operation',
289
+ type: 'options',
290
+ noDataExpression: true,
291
+ displayOptions: {
292
+ show: {
293
+ resource: ['voicemail'],
294
+ },
295
+ },
296
+ options: [
297
+ {
298
+ name: 'Get Many',
299
+ value: 'getAll',
300
+ description: 'Get many voicemails',
301
+ action: 'Get many voicemails',
302
+ },
303
+ {
304
+ name: 'Get Single',
305
+ value: 'get',
306
+ description: 'Get a specific voicemail',
307
+ action: 'Get a voicemail',
308
+ },
309
+ ],
310
+ default: 'getAll',
311
+ },
312
+ // Business Number Operations
313
+ {
314
+ displayName: 'Operation',
315
+ name: 'operation',
316
+ type: 'options',
317
+ noDataExpression: true,
318
+ displayOptions: {
319
+ show: {
320
+ resource: ['businessNumber'],
321
+ },
322
+ },
323
+ options: [
324
+ {
325
+ name: 'Get Many',
326
+ value: 'getAll',
327
+ description: 'Get all business phone numbers',
328
+ action: 'Get all business numbers',
329
+ },
330
+ {
331
+ name: 'Get Single',
332
+ value: 'get',
333
+ description: 'Get a specific phone number',
334
+ action: 'Get a phone number',
335
+ },
336
+ {
337
+ name: 'Delete',
338
+ value: 'delete',
339
+ description: 'Delete one or more phone numbers',
340
+ action: 'Delete phone numbers',
341
+ },
342
+ ],
343
+ default: 'getAll',
344
+ },
345
+ // User Operations
346
+ {
347
+ displayName: 'Operation',
348
+ name: 'operation',
349
+ type: 'options',
350
+ noDataExpression: true,
351
+ displayOptions: {
352
+ show: {
353
+ resource: ['user'],
354
+ },
355
+ },
356
+ options: [
357
+ {
358
+ name: 'Get Status',
359
+ value: 'getStatus',
360
+ description: 'Get user status',
361
+ action: 'Get user status',
362
+ },
363
+ {
364
+ name: 'Set Status',
365
+ value: 'setStatus',
366
+ description: 'Set user status',
367
+ action: 'Set user status',
368
+ },
369
+ {
370
+ name: 'Get Info',
371
+ value: 'getInfo',
372
+ description: 'Get user information',
373
+ action: 'Get user info',
374
+ },
375
+ ],
376
+ default: 'getStatus',
377
+ },
378
+ // Message Operations
379
+ {
380
+ displayName: 'Operation',
381
+ name: 'operation',
382
+ type: 'options',
383
+ noDataExpression: true,
384
+ displayOptions: {
385
+ show: {
386
+ resource: ['message'],
387
+ },
388
+ },
389
+ options: [
390
+ {
391
+ name: 'Send',
392
+ value: 'send',
393
+ description: 'Send SMS/MMS message',
394
+ action: 'Send a message',
395
+ },
396
+ ],
397
+ default: 'send',
398
+ },
399
+ // Team Operations
400
+ {
401
+ displayName: 'Operation',
402
+ name: 'operation',
403
+ type: 'options',
404
+ noDataExpression: true,
405
+ displayOptions: {
406
+ show: {
407
+ resource: ['team'],
408
+ },
409
+ },
410
+ options: [
411
+ {
412
+ name: 'Get Team',
413
+ value: 'get',
414
+ description: 'Get team members and groups',
415
+ action: 'Get team',
416
+ },
417
+ ],
418
+ default: 'get',
419
+ },
420
+ // Profile Operations
421
+ {
422
+ displayName: 'Operation',
423
+ name: 'operation',
424
+ type: 'options',
425
+ noDataExpression: true,
426
+ displayOptions: {
427
+ show: {
428
+ resource: ['profile'],
429
+ },
430
+ },
431
+ options: [
432
+ {
433
+ name: 'Get Profile',
434
+ value: 'get',
435
+ description: 'Get current user profile',
436
+ action: 'Get profile',
437
+ },
438
+ {
439
+ name: 'Get by Extension',
440
+ value: 'getByExtension',
441
+ description: 'Get profile by extension number',
442
+ action: 'Get profile by extension',
443
+ },
444
+ ],
445
+ default: 'get',
446
+ },
447
+ // Ping Operations
448
+ {
449
+ displayName: 'Operation',
450
+ name: 'operation',
451
+ type: 'options',
452
+ noDataExpression: true,
453
+ displayOptions: {
454
+ show: {
455
+ resource: ['ping'],
456
+ },
457
+ },
458
+ options: [
459
+ {
460
+ name: 'Ping',
461
+ value: 'ping',
462
+ description: 'Check API status',
463
+ action: 'Ping API',
464
+ },
465
+ ],
466
+ default: 'ping',
467
+ },
468
+ // Communication Operations
469
+ {
470
+ displayName: 'Operation',
471
+ name: 'operation',
472
+ type: 'options',
473
+ noDataExpression: true,
474
+ displayOptions: {
475
+ show: {
476
+ resource: ['communication'],
477
+ },
478
+ },
479
+ options: [
480
+ {
481
+ name: 'Get Many',
482
+ value: 'getAll',
483
+ description: 'Get communications',
484
+ action: 'Get communications',
485
+ },
486
+ {
487
+ name: 'Add Comment',
488
+ value: 'addComment',
489
+ description: 'Add comment to communication',
490
+ action: 'Add comment',
491
+ },
492
+ {
493
+ name: 'Delete Comment',
494
+ value: 'deleteComment',
495
+ description: 'Delete comment from communication',
496
+ action: 'Delete comment',
497
+ },
498
+ {
499
+ name: 'Delete Voicemails',
500
+ value: 'deleteVoicemails',
501
+ description: 'Delete voicemails (bulk)',
502
+ action: 'Delete voicemails',
503
+ },
504
+ ],
505
+ default: 'getAll',
506
+ },
507
+ // Interaction Operations
508
+ {
509
+ displayName: 'Operation',
510
+ name: 'operation',
511
+ type: 'options',
512
+ noDataExpression: true,
513
+ displayOptions: {
514
+ show: {
515
+ resource: ['interaction'],
516
+ },
517
+ },
518
+ options: [
519
+ {
520
+ name: 'Get Interactions',
521
+ value: 'getAll',
522
+ description: 'Get interactions by tab',
523
+ action: 'Get interactions',
524
+ },
525
+ ],
526
+ default: 'getAll',
527
+ },
528
+ // Make Call Parameters
529
+ {
530
+ displayName: 'From',
531
+ name: 'from',
532
+ type: 'string',
533
+ required: true,
534
+ displayOptions: {
535
+ show: {
536
+ resource: ['call'],
537
+ operation: ['make'],
538
+ },
539
+ },
540
+ default: '',
541
+ description: 'The phone number or extension to call from',
542
+ },
543
+ {
544
+ displayName: 'To',
545
+ name: 'to',
546
+ type: 'string',
547
+ required: true,
548
+ displayOptions: {
549
+ show: {
550
+ resource: ['call'],
551
+ operation: ['make'],
552
+ },
553
+ },
554
+ default: '',
555
+ description: 'The phone number to call',
556
+ },
557
+ // Hang Up Parameters
558
+ {
559
+ displayName: 'Call ID',
560
+ name: 'callId',
561
+ type: 'string',
562
+ required: true,
563
+ displayOptions: {
564
+ show: {
565
+ resource: ['call'],
566
+ operation: ['hangUp'],
567
+ },
568
+ },
569
+ default: '',
570
+ description: 'The ID of the call to hang up',
571
+ },
572
+ // Contact Parameters
573
+ {
574
+ displayName: 'Contact ID',
575
+ name: 'contactId',
576
+ type: 'string',
577
+ required: true,
578
+ displayOptions: {
579
+ show: {
580
+ resource: ['contact'],
581
+ operation: ['update', 'delete'],
582
+ },
583
+ },
584
+ default: '',
585
+ description: 'The ID of the contact',
586
+ },
587
+ {
588
+ displayName: 'First Name',
589
+ name: 'firstName',
590
+ type: 'string',
591
+ required: true,
592
+ displayOptions: {
593
+ show: {
594
+ resource: ['contact'],
595
+ operation: ['create'],
596
+ },
597
+ },
598
+ default: '',
599
+ description: 'First name of the contact',
600
+ },
601
+ {
602
+ displayName: 'Last Name',
603
+ name: 'lastName',
604
+ type: 'string',
605
+ displayOptions: {
606
+ show: {
607
+ resource: ['contact'],
608
+ operation: ['create', 'update'],
609
+ },
610
+ },
611
+ default: '',
612
+ description: 'Last name of the contact',
613
+ },
614
+ {
615
+ displayName: 'Phone Number',
616
+ name: 'phoneNumber',
617
+ type: 'string',
618
+ required: true,
619
+ displayOptions: {
620
+ show: {
621
+ resource: ['contact'],
622
+ operation: ['create'],
623
+ },
624
+ },
625
+ default: '',
626
+ description: 'Phone number of the contact',
627
+ },
628
+ {
629
+ displayName: 'Email',
630
+ name: 'email',
631
+ type: 'string',
632
+ displayOptions: {
633
+ show: {
634
+ resource: ['contact'],
635
+ operation: ['create', 'update'],
636
+ },
637
+ },
638
+ default: '',
639
+ description: 'Email address of the contact',
640
+ },
641
+ // Voicemail Parameters
642
+ {
643
+ displayName: 'Voicemail ID',
644
+ name: 'voicemailId',
645
+ type: 'string',
646
+ required: true,
647
+ displayOptions: {
648
+ show: {
649
+ resource: ['voicemail'],
650
+ operation: ['get'],
651
+ },
652
+ },
653
+ default: '',
654
+ description: 'The ID of the voicemail',
655
+ },
656
+ // User Parameters
657
+ {
658
+ displayName: 'Status',
659
+ name: 'status',
660
+ type: 'options',
661
+ required: true,
662
+ displayOptions: {
663
+ show: {
664
+ resource: ['user'],
665
+ operation: ['setStatus'],
666
+ },
667
+ },
668
+ options: [
669
+ {
670
+ name: 'Available',
671
+ value: 'available',
672
+ },
673
+ {
674
+ name: 'Away',
675
+ value: 'away',
676
+ },
677
+ {
678
+ name: 'Busy',
679
+ value: 'busy',
680
+ },
681
+ {
682
+ name: 'Do Not Disturb',
683
+ value: 'dnd',
684
+ },
685
+ ],
686
+ default: 'available',
687
+ description: 'User status to set',
688
+ },
689
+ // Journal Query Parameters - Get All Pages
690
+ {
691
+ displayName: 'Get All Pages',
692
+ name: 'getAllPages',
693
+ type: 'boolean',
694
+ default: false,
695
+ displayOptions: {
696
+ show: {
697
+ resource: ['journal'],
698
+ operation: ['getAll'],
699
+ },
700
+ },
701
+ description: 'Whether to automatically fetch all pages until complete',
702
+ },
703
+ // Journal Query Parameters - Pagination
704
+ {
705
+ displayName: 'Page Size',
706
+ name: 'pageSize',
707
+ type: 'number',
708
+ typeOptions: {
709
+ minValue: 1,
710
+ maxValue: 1000,
711
+ },
712
+ default: 100,
713
+ displayOptions: {
714
+ show: {
715
+ resource: ['journal'],
716
+ operation: ['getAll'],
717
+ },
718
+ },
719
+ description: 'Maximum number of records per page (max: 1000)',
720
+ },
721
+ {
722
+ displayName: 'Page',
723
+ name: 'page',
724
+ type: 'number',
725
+ typeOptions: {
726
+ minValue: 1,
727
+ },
728
+ default: 1,
729
+ displayOptions: {
730
+ show: {
731
+ resource: ['journal'],
732
+ operation: ['getAll'],
733
+ getAllPages: [false],
734
+ },
735
+ },
736
+ description: 'The page number to retrieve (only used when Get All Pages is false)',
737
+ },
738
+ // Contact Resolution
739
+ {
740
+ displayName: 'Resolve Contacts',
741
+ name: 'resolveContacts',
742
+ type: 'boolean',
743
+ default: true,
744
+ displayOptions: {
745
+ show: {
746
+ resource: ['journal'],
747
+ operation: ['getAll'],
748
+ },
749
+ },
750
+ description: 'Whether to resolve contact information in the results',
751
+ },
752
+ {
753
+ displayName: 'Show Users',
754
+ name: 'showUsers',
755
+ type: 'boolean',
756
+ default: true,
757
+ displayOptions: {
758
+ show: {
759
+ resource: ['journal'],
760
+ operation: ['getAll'],
761
+ },
762
+ },
763
+ description: 'Whether to show user information in the results',
764
+ },
765
+ // Optional Filters Collection
766
+ {
767
+ displayName: 'Additional Filters',
768
+ name: 'additionalFilters',
769
+ type: 'collection',
770
+ placeholder: 'Add Filter',
771
+ default: {},
772
+ displayOptions: {
773
+ show: {
774
+ resource: ['journal'],
775
+ operation: ['getAll', 'getCount'],
776
+ },
777
+ },
778
+ options: [
779
+ // Call Classification
780
+ {
781
+ displayName: 'Origin',
782
+ name: 'origin',
783
+ type: 'options',
784
+ options: [
785
+ {
786
+ name: 'All',
787
+ value: 'All',
788
+ },
789
+ {
790
+ name: 'Inbound',
791
+ value: 'Inbound',
792
+ },
793
+ {
794
+ name: 'Outbound',
795
+ value: 'Outbound',
796
+ },
797
+ {
798
+ name: 'Callback',
799
+ value: 'Callback',
800
+ },
801
+ {
802
+ name: 'Internal',
803
+ value: 'Internal',
804
+ },
805
+ {
806
+ name: 'Unspecified',
807
+ value: 'Unspecified',
808
+ },
809
+ ],
810
+ default: 'All',
811
+ description: 'Specifies from where request coming from',
812
+ },
813
+ {
814
+ displayName: 'State',
815
+ name: 'state',
816
+ type: 'options',
817
+ options: [
818
+ {
819
+ name: 'All',
820
+ value: 'All',
821
+ },
822
+ {
823
+ name: 'Missed',
824
+ value: 'Missed',
825
+ },
826
+ {
827
+ name: 'Connected',
828
+ value: 'Connected',
829
+ },
830
+ {
831
+ name: 'VoiceMail',
832
+ value: 'VoiceMail',
833
+ },
834
+ {
835
+ name: 'Dropped',
836
+ value: 'Dropped',
837
+ },
838
+ {
839
+ name: 'NoAnswer',
840
+ value: 'NoAnswer',
841
+ },
842
+ {
843
+ name: 'Scheduled',
844
+ value: 'Scheduled',
845
+ },
846
+ {
847
+ name: 'Message',
848
+ value: 'Message',
849
+ },
850
+ ],
851
+ default: 'All',
852
+ description: 'Specifies the result state of the request',
853
+ },
854
+ {
855
+ displayName: 'Type',
856
+ name: 'type',
857
+ type: 'options',
858
+ options: [
859
+ {
860
+ name: 'All',
861
+ value: 'All',
862
+ },
863
+ {
864
+ name: 'Call',
865
+ value: 'Call',
866
+ },
867
+ {
868
+ name: 'Message',
869
+ value: 'Message',
870
+ },
871
+ {
872
+ name: 'MessageThread',
873
+ value: 'MessageThread',
874
+ },
875
+ {
876
+ name: 'Task',
877
+ value: 'Task',
878
+ },
879
+ {
880
+ name: 'CallbackRequest',
881
+ value: 'CallbackRequest',
882
+ },
883
+ {
884
+ name: 'Service',
885
+ value: 'Service',
886
+ },
887
+ {
888
+ name: 'Default',
889
+ value: 'Default',
890
+ },
891
+ {
892
+ name: 'Unspecified',
893
+ value: 'Unspecified',
894
+ },
895
+ ],
896
+ default: 'All',
897
+ description: 'Specifies type of request',
898
+ },
899
+ // Date Filtering
900
+ {
901
+ displayName: 'From Date',
902
+ name: 'from',
903
+ type: 'dateTime',
904
+ default: '',
905
+ description: 'The start date and time in UTC of the period to get records from (ISO 8601 format)',
906
+ },
907
+ {
908
+ displayName: 'To Date',
909
+ name: 'to',
910
+ type: 'dateTime',
911
+ default: '',
912
+ description: 'The end date and time in UTC of the period to get records from (ISO 8601 format)',
913
+ },
914
+ // Contact Filtering
915
+ {
916
+ displayName: 'Phone',
917
+ name: 'phone',
918
+ type: 'string',
919
+ default: '',
920
+ description: 'One or several client phone numbers, comma separated if multiple',
921
+ },
922
+ {
923
+ displayName: 'Email',
924
+ name: 'email',
925
+ type: 'string',
926
+ default: '',
927
+ description: 'Filter by email address',
928
+ },
929
+ {
930
+ displayName: 'Business Number',
931
+ name: 'businessNumber',
932
+ type: 'string',
933
+ default: '',
934
+ description: 'One or more business phone numbers without a plus sign, comma separated if multiple',
935
+ },
936
+ // Advanced Filtering
937
+ {
938
+ displayName: 'Is Read',
939
+ name: 'isRead',
940
+ type: 'boolean',
941
+ default: false,
942
+ description: 'Filter read voicemails and unread voicemails (only works with inbound=voiceMail)',
943
+ },
944
+ {
945
+ displayName: 'Group ID',
946
+ name: 'groupId',
947
+ type: 'string',
948
+ default: '',
949
+ description: 'Comma separated sequence of Guid',
950
+ },
951
+ {
952
+ displayName: 'User ID',
953
+ name: 'userId',
954
+ type: 'string',
955
+ default: '',
956
+ description: 'Comma separated sequence of Guid',
957
+ },
958
+ {
959
+ displayName: 'VM Box ID',
960
+ name: 'vmBoxId',
961
+ type: 'string',
962
+ default: '',
963
+ description: 'Comma separated sequence of Guid',
964
+ },
965
+ {
966
+ displayName: 'Workflow State',
967
+ name: 'wfState',
968
+ type: 'options',
969
+ options: [
970
+ {
971
+ name: 'All',
972
+ value: 'All',
973
+ },
974
+ {
975
+ name: 'Open',
976
+ value: 'Open',
977
+ },
978
+ {
979
+ name: 'Finished',
980
+ value: 'Finished',
981
+ },
982
+ {
983
+ name: 'Resolved',
984
+ value: 'Resolved',
985
+ },
986
+ ],
987
+ default: 'All',
988
+ description: 'Specifies the workflow state of requests',
989
+ },
990
+ {
991
+ displayName: 'Search Property',
992
+ name: 'searchProperty',
993
+ type: 'options',
994
+ options: [
995
+ {
996
+ name: 'Do Not Send',
997
+ value: '',
998
+ },
999
+ {
1000
+ name: 'Client',
1001
+ value: 'Client',
1002
+ },
1003
+ {
1004
+ name: 'BusinessNumber',
1005
+ value: 'BusinessNumber',
1006
+ },
1007
+ {
1008
+ name: 'Comment',
1009
+ value: 'Comment',
1010
+ },
1011
+ {
1012
+ name: 'VTT',
1013
+ value: 'VTT',
1014
+ },
1015
+ ],
1016
+ default: '',
1017
+ description: 'Property to search within (select "Do Not Send" to skip search)',
1018
+ },
1019
+ {
1020
+ displayName: 'Search Text',
1021
+ name: 'searchText',
1022
+ type: 'string',
1023
+ default: '',
1024
+ displayOptions: {
1025
+ show: {
1026
+ searchProperty: ['Client', 'BusinessNumber', 'Comment', 'VTT'],
1027
+ },
1028
+ },
1029
+ description: 'Text to search for in the selected property',
1030
+ },
1031
+ ],
1032
+ },
1033
+ // Journal Get Count Parameters
1034
+ {
1035
+ displayName: 'From Date (Required)',
1036
+ name: 'fromDateRequired',
1037
+ type: 'dateTime',
1038
+ required: true,
1039
+ displayOptions: {
1040
+ show: {
1041
+ resource: ['journal'],
1042
+ operation: ['getCount'],
1043
+ },
1044
+ },
1045
+ default: '',
1046
+ description: 'The start date and time in UTC - REQUIRED for Get Count operation',
1047
+ },
1048
+ {
1049
+ displayName: 'Request ID',
1050
+ name: 'requestId',
1051
+ type: 'string',
1052
+ required: true,
1053
+ displayOptions: {
1054
+ show: {
1055
+ resource: ['journal'],
1056
+ operation: ['getById', 'addComment', 'deleteComment', 'deleteVoicemail', 'setWorkflowState', 'setFlags', 'removeFlags', 'restoreMessage', 'getMessageAttachments'],
1057
+ },
1058
+ },
1059
+ default: '',
1060
+ description: 'The ID of the request',
1061
+ },
1062
+ // Journal Comment Parameters
1063
+ {
1064
+ displayName: 'Comment',
1065
+ name: 'comment',
1066
+ type: 'string',
1067
+ required: true,
1068
+ displayOptions: {
1069
+ show: {
1070
+ resource: ['journal'],
1071
+ operation: ['addComment'],
1072
+ },
1073
+ },
1074
+ default: '',
1075
+ description: 'Comment text to add or update',
1076
+ },
1077
+ // Journal Workflow State Parameters
1078
+ {
1079
+ displayName: 'Workflow State',
1080
+ name: 'workflowState',
1081
+ type: 'options',
1082
+ required: true,
1083
+ displayOptions: {
1084
+ show: {
1085
+ resource: ['journal'],
1086
+ operation: ['setWorkflowState'],
1087
+ },
1088
+ },
1089
+ options: [
1090
+ {
1091
+ name: 'Open',
1092
+ value: 'open',
1093
+ },
1094
+ {
1095
+ name: 'Finished',
1096
+ value: 'finished',
1097
+ },
1098
+ {
1099
+ name: 'Resolved',
1100
+ value: 'resolved',
1101
+ },
1102
+ ],
1103
+ default: 'open',
1104
+ description: 'Workflow state to set',
1105
+ },
1106
+ // Journal Flags Parameters
1107
+ {
1108
+ displayName: 'Flags',
1109
+ name: 'flags',
1110
+ type: 'multiOptions',
1111
+ required: true,
1112
+ displayOptions: {
1113
+ show: {
1114
+ resource: ['journal'],
1115
+ operation: ['setFlags', 'removeFlags'],
1116
+ },
1117
+ },
1118
+ options: [
1119
+ {
1120
+ name: 'Favorite',
1121
+ value: 'favorite',
1122
+ },
1123
+ {
1124
+ name: 'Important',
1125
+ value: 'important',
1126
+ },
1127
+ {
1128
+ name: 'Follow Up',
1129
+ value: 'followup',
1130
+ },
1131
+ ],
1132
+ default: ['favorite'],
1133
+ description: 'Flags to set or remove',
1134
+ },
1135
+ // Journal Block List Parameters
1136
+ {
1137
+ displayName: 'Phone Number',
1138
+ name: 'phoneNumber',
1139
+ type: 'string',
1140
+ required: true,
1141
+ displayOptions: {
1142
+ show: {
1143
+ resource: ['journal'],
1144
+ operation: ['addToBlockList', 'removeFromBlockList'],
1145
+ },
1146
+ },
1147
+ default: '',
1148
+ description: 'Phone number to add to or remove from block list (E.164 format)',
1149
+ },
1150
+ // Journal Message Parameters
1151
+ {
1152
+ displayName: 'Message IDs',
1153
+ name: 'messageIds',
1154
+ type: 'string',
1155
+ required: true,
1156
+ displayOptions: {
1157
+ show: {
1158
+ resource: ['journal'],
1159
+ operation: ['deleteMessages'],
1160
+ },
1161
+ },
1162
+ default: '',
1163
+ placeholder: 'id1,id2,id3',
1164
+ description: 'Comma-separated list of message IDs to delete',
1165
+ },
1166
+ {
1167
+ displayName: 'Request IDs',
1168
+ name: 'requestIds',
1169
+ type: 'string',
1170
+ required: true,
1171
+ displayOptions: {
1172
+ show: {
1173
+ resource: ['journal'],
1174
+ operation: ['deleteVoicemail'],
1175
+ },
1176
+ },
1177
+ default: '',
1178
+ placeholder: 'id1,id2,id3',
1179
+ description: 'Comma-separated list of request IDs to delete voicemails for',
1180
+ },
1181
+ // Contact Query Parameters
1182
+ {
1183
+ displayName: 'Query Parameters',
1184
+ name: 'queryParameters',
1185
+ type: 'collection',
1186
+ placeholder: 'Add Parameter',
1187
+ default: {},
1188
+ displayOptions: {
1189
+ show: {
1190
+ resource: ['contact'],
1191
+ operation: ['getAll'],
1192
+ },
1193
+ },
1194
+ options: [
1195
+ {
1196
+ displayName: 'Limit',
1197
+ name: 'limit',
1198
+ type: 'number',
1199
+ typeOptions: {
1200
+ minValue: 1,
1201
+ maxValue: 100,
1202
+ },
1203
+ default: 50,
1204
+ description: 'Max number of results to return',
1205
+ },
1206
+ {
1207
+ displayName: 'Offset',
1208
+ name: 'offset',
1209
+ type: 'number',
1210
+ default: 0,
1211
+ description: 'Number of results to skip',
1212
+ },
1213
+ ],
1214
+ },
1215
+ // Voicemail Parameters
1216
+ {
1217
+ displayName: 'Page Size',
1218
+ name: 'pageSize',
1219
+ type: 'number',
1220
+ typeOptions: {
1221
+ minValue: 1,
1222
+ maxValue: 2147483647,
1223
+ },
1224
+ default: 50,
1225
+ displayOptions: {
1226
+ show: {
1227
+ resource: ['voicemail'],
1228
+ operation: ['getAll'],
1229
+ },
1230
+ },
1231
+ description: 'Number of voicemails to return (1-2147483647)',
1232
+ },
1233
+ {
1234
+ displayName: 'Skip',
1235
+ name: 'skip',
1236
+ type: 'number',
1237
+ typeOptions: {
1238
+ minValue: 0,
1239
+ maxValue: 2147483647,
1240
+ },
1241
+ default: 0,
1242
+ displayOptions: {
1243
+ show: {
1244
+ resource: ['voicemail'],
1245
+ operation: ['getAll'],
1246
+ },
1247
+ },
1248
+ description: 'Number of voicemails to skip for pagination (0-2147483647)',
1249
+ },
1250
+ {
1251
+ displayName: 'Start UTC',
1252
+ name: 'startUtc',
1253
+ type: 'dateTime',
1254
+ default: '',
1255
+ displayOptions: {
1256
+ show: {
1257
+ resource: ['voicemail'],
1258
+ operation: ['getAll'],
1259
+ },
1260
+ },
1261
+ description: 'Start of the date/time voicemails interval in yyyy-MM-ddThh:mm:ss format',
1262
+ },
1263
+ {
1264
+ displayName: 'End UTC',
1265
+ name: 'endUtc',
1266
+ type: 'dateTime',
1267
+ default: '',
1268
+ displayOptions: {
1269
+ show: {
1270
+ resource: ['voicemail'],
1271
+ operation: ['getAll'],
1272
+ },
1273
+ },
1274
+ description: 'End of date/time voicemails interval in yyyy-MM-ddThh:mm:ss format',
1275
+ },
1276
+ {
1277
+ displayName: 'Voicemail Filter',
1278
+ name: 'voicemailFilter',
1279
+ type: 'multiOptions',
1280
+ options: [
1281
+ {
1282
+ name: 'Read',
1283
+ value: 'Read',
1284
+ },
1285
+ {
1286
+ name: 'UnRead',
1287
+ value: 'UnRead',
1288
+ },
1289
+ {
1290
+ name: 'ReadAndUnRead',
1291
+ value: 'ReadAndUnRead',
1292
+ },
1293
+ {
1294
+ name: 'CallerName',
1295
+ value: 'CallerName',
1296
+ },
1297
+ {
1298
+ name: 'CallerAddress',
1299
+ value: 'CallerAddress',
1300
+ },
1301
+ {
1302
+ name: 'CalledName',
1303
+ value: 'CalledName',
1304
+ },
1305
+ {
1306
+ name: 'CalledAddress',
1307
+ value: 'CalledAddress',
1308
+ },
1309
+ {
1310
+ name: 'StartTime',
1311
+ value: 'StartTime',
1312
+ },
1313
+ {
1314
+ name: 'StartDate',
1315
+ value: 'StartDate',
1316
+ },
1317
+ {
1318
+ name: 'Duration',
1319
+ value: 'Duration',
1320
+ },
1321
+ {
1322
+ name: 'TextFields',
1323
+ value: 'TextFields',
1324
+ },
1325
+ ],
1326
+ default: [],
1327
+ displayOptions: {
1328
+ show: {
1329
+ resource: ['voicemail'],
1330
+ operation: ['getAll'],
1331
+ },
1332
+ },
1333
+ description: 'Voicemails filter types (multiple values supported - leave empty for no filters)',
1334
+ },
1335
+ {
1336
+ displayName: 'Custom Filter',
1337
+ name: 'customFilter',
1338
+ type: 'string',
1339
+ default: '',
1340
+ displayOptions: {
1341
+ show: {
1342
+ resource: ['voicemail'],
1343
+ operation: ['getAll'],
1344
+ },
1345
+ },
1346
+ description: 'Voicemails search string (used with specific voicemailFilter types)',
1347
+ },
1348
+ {
1349
+ displayName: 'Voicemail ID',
1350
+ name: 'voicemailId',
1351
+ type: 'string',
1352
+ required: true,
1353
+ displayOptions: {
1354
+ show: {
1355
+ resource: ['voicemail'],
1356
+ operation: ['get'],
1357
+ },
1358
+ },
1359
+ default: '',
1360
+ description: 'The ID of the voicemail to retrieve',
1361
+ },
1362
+ // Business Number Parameters
1363
+ {
1364
+ displayName: 'Phone Number',
1365
+ name: 'phoneNumber',
1366
+ type: 'string',
1367
+ required: true,
1368
+ displayOptions: {
1369
+ show: {
1370
+ resource: ['businessNumber'],
1371
+ operation: ['get'],
1372
+ },
1373
+ },
1374
+ default: '',
1375
+ description: 'The phone number or subsequence of digits (1-11 digits, without + sign). Example: 555 or 17775550078',
1376
+ },
1377
+ {
1378
+ displayName: 'Phone IDs',
1379
+ name: 'phoneIds',
1380
+ type: 'string',
1381
+ required: true,
1382
+ displayOptions: {
1383
+ show: {
1384
+ resource: ['businessNumber'],
1385
+ operation: ['delete'],
1386
+ },
1387
+ },
1388
+ default: '',
1389
+ placeholder: '+15551112233,+15550152729',
1390
+ description: 'Comma-separated list of phone numbers to delete (with + sign). Example: +15551112233,+15550152729',
1391
+ },
1392
+ // Message Parameters
1393
+ {
1394
+ displayName: 'From',
1395
+ name: 'from',
1396
+ type: 'string',
1397
+ required: true,
1398
+ displayOptions: {
1399
+ show: {
1400
+ resource: ['message'],
1401
+ operation: ['send'],
1402
+ },
1403
+ },
1404
+ default: '',
1405
+ description: 'Source phone number (E.164 format, e.g. +12345678910)',
1406
+ },
1407
+ {
1408
+ displayName: 'To',
1409
+ name: 'to',
1410
+ type: 'string',
1411
+ required: true,
1412
+ displayOptions: {
1413
+ show: {
1414
+ resource: ['message'],
1415
+ operation: ['send'],
1416
+ },
1417
+ },
1418
+ default: '',
1419
+ placeholder: '+12345678901,+12345678902',
1420
+ description: 'Comma-separated list of destination phone numbers (E.164 format)',
1421
+ },
1422
+ {
1423
+ displayName: 'Message',
1424
+ name: 'message',
1425
+ type: 'string',
1426
+ displayOptions: {
1427
+ show: {
1428
+ resource: ['message'],
1429
+ operation: ['send'],
1430
+ },
1431
+ },
1432
+ default: '',
1433
+ description: 'Message text',
1434
+ },
1435
+ // Profile Parameters
1436
+ {
1437
+ displayName: 'Extension',
1438
+ name: 'extension',
1439
+ type: 'string',
1440
+ required: true,
1441
+ displayOptions: {
1442
+ show: {
1443
+ resource: ['profile'],
1444
+ operation: ['getByExtension'],
1445
+ },
1446
+ },
1447
+ default: '',
1448
+ description: 'Extension number (e.g. 100)',
1449
+ },
1450
+ // Communication Parameters
1451
+ {
1452
+ displayName: 'Request ID',
1453
+ name: 'requestId',
1454
+ type: 'string',
1455
+ required: true,
1456
+ displayOptions: {
1457
+ show: {
1458
+ resource: ['communication'],
1459
+ operation: ['addComment', 'deleteComment'],
1460
+ },
1461
+ },
1462
+ default: '',
1463
+ description: 'Request ID of the communication',
1464
+ },
1465
+ {
1466
+ displayName: 'Comment',
1467
+ name: 'comment',
1468
+ type: 'string',
1469
+ required: true,
1470
+ displayOptions: {
1471
+ show: {
1472
+ resource: ['communication'],
1473
+ operation: ['addComment'],
1474
+ },
1475
+ },
1476
+ default: '',
1477
+ description: 'Comment text',
1478
+ },
1479
+ {
1480
+ displayName: 'Request IDs',
1481
+ name: 'requestIds',
1482
+ type: 'string',
1483
+ required: true,
1484
+ displayOptions: {
1485
+ show: {
1486
+ resource: ['communication'],
1487
+ operation: ['deleteVoicemails'],
1488
+ },
1489
+ },
1490
+ default: '',
1491
+ placeholder: 'id1,id2',
1492
+ description: 'Comma-separated list of request IDs',
1493
+ },
1494
+ {
1495
+ displayName: 'Remove Text',
1496
+ name: 'removeText',
1497
+ type: 'boolean',
1498
+ required: true,
1499
+ displayOptions: {
1500
+ show: {
1501
+ resource: ['communication'],
1502
+ operation: ['deleteVoicemails'],
1503
+ },
1504
+ },
1505
+ default: false,
1506
+ description: 'Whether to remove transcribed text',
1507
+ },
1508
+ // Interaction Parameters
1509
+ {
1510
+ displayName: 'Tab',
1511
+ name: 'tab',
1512
+ type: 'options',
1513
+ displayOptions: {
1514
+ show: {
1515
+ resource: ['interaction'],
1516
+ operation: ['getAll'],
1517
+ },
1518
+ },
1519
+ options: [
1520
+ {
1521
+ name: 'Recent',
1522
+ value: 'Recent',
1523
+ },
1524
+ {
1525
+ name: 'Internal',
1526
+ value: 'Internal',
1527
+ },
1528
+ {
1529
+ name: 'Recent with Internal',
1530
+ value: 'RecentWithInternal',
1531
+ },
1532
+ {
1533
+ name: 'Clients',
1534
+ value: 'Clients',
1535
+ },
1536
+ {
1537
+ name: 'Colleagues',
1538
+ value: 'Colleagues',
1539
+ },
1540
+ ],
1541
+ default: 'Recent',
1542
+ description: 'Tab to filter interactions',
1543
+ },
1544
+ {
1545
+ displayName: 'Page Size',
1546
+ name: 'pageSize',
1547
+ type: 'number',
1548
+ displayOptions: {
1549
+ show: {
1550
+ resource: ['interaction'],
1551
+ operation: ['getAll'],
1552
+ },
1553
+ },
1554
+ typeOptions: {
1555
+ minValue: 1,
1556
+ },
1557
+ default: 50,
1558
+ description: 'Number of interactions to return',
1559
+ },
1560
+ {
1561
+ displayName: 'Page Number',
1562
+ name: 'pageNumber',
1563
+ type: 'number',
1564
+ displayOptions: {
1565
+ show: {
1566
+ resource: ['interaction'],
1567
+ operation: ['getAll'],
1568
+ },
1569
+ },
1570
+ typeOptions: {
1571
+ minValue: 1,
1572
+ },
1573
+ default: 1,
1574
+ description: 'Page number',
1575
+ },
1576
+ {
1577
+ displayName: 'Latest',
1578
+ name: 'latest',
1579
+ type: 'dateTime',
1580
+ displayOptions: {
1581
+ show: {
1582
+ resource: ['interaction'],
1583
+ operation: ['getAll'],
1584
+ },
1585
+ },
1586
+ default: '',
1587
+ description: 'Latest date/time (ISO 8601)',
1588
+ },
1589
+ {
1590
+ displayName: 'Earliest',
1591
+ name: 'earliest',
1592
+ type: 'dateTime',
1593
+ displayOptions: {
1594
+ show: {
1595
+ resource: ['interaction'],
1596
+ operation: ['getAll'],
1597
+ },
1598
+ },
1599
+ default: '',
1600
+ description: 'Earliest date/time (ISO 8601)',
1601
+ },
1602
+ ],
1603
+ };
1604
+ }
1605
+ async execute() {
1606
+ const items = this.getInputData();
1607
+ const returnData = [];
1608
+ const resource = this.getNodeParameter('resource', 0);
1609
+ const operation = this.getNodeParameter('operation', 0);
1610
+ // Get credentials and determine base URL
1611
+ const credentials = await this.getCredentials('mightyCallApi');
1612
+ const accountType = credentials.accountType;
1613
+ const baseUrl = accountType === 'contactCenter'
1614
+ ? 'https://ccapi.mightycall.com/v4'
1615
+ : 'https://api.mightycall.com/v4';
1616
+ // Validate Contact Center-only resources
1617
+ const contactCenterOnlyResources = ['communication', 'interaction'];
1618
+ if (contactCenterOnlyResources.includes(resource) && accountType !== 'contactCenter') {
1619
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `⚠️ The '${resource}' resource is only available for Contact Center accounts. ` +
1620
+ `Your current credentials are set to 'Standard Account'. ` +
1621
+ `Please either:\n` +
1622
+ `1. Change your credentials to use a Contact Center account type, or\n` +
1623
+ `2. Select a different resource (Call, Contact, Journal, Voicemail, etc.)`);
1624
+ }
1625
+ // Get access token
1626
+ const authMethod = credentials.authMethod;
1627
+ const clientSecret = authMethod === 'userKey'
1628
+ ? credentials.userKey
1629
+ : credentials.extension;
1630
+ const tokenResponse = await this.helpers.request({
1631
+ method: 'POST',
1632
+ url: `${baseUrl}/auth/token`,
1633
+ headers: {
1634
+ 'Content-Type': 'application/x-www-form-urlencoded',
1635
+ 'x-api-key': credentials.apiKey,
1636
+ },
1637
+ body: new URLSearchParams({
1638
+ client_id: credentials.apiKey,
1639
+ client_secret: clientSecret,
1640
+ grant_type: 'client_credentials',
1641
+ }).toString(),
1642
+ json: true,
1643
+ });
1644
+ const accessToken = tokenResponse.access_token;
1645
+ for (let i = 0; i < items.length; i++) {
1646
+ try {
1647
+ let responseData;
1648
+ // ==================== JOURNAL OPERATIONS ====================
1649
+ if (resource === 'journal') {
1650
+ if (operation === 'getAll') {
1651
+ // Get main parameters
1652
+ const getAllPages = this.getNodeParameter('getAllPages', i);
1653
+ const pageSize = this.getNodeParameter('pageSize', i);
1654
+ const resolveContacts = this.getNodeParameter('resolveContacts', i);
1655
+ const showUsers = this.getNodeParameter('showUsers', i);
1656
+ const additionalFilters = this.getNodeParameter('additionalFilters', i);
1657
+ // Build query parameters
1658
+ const buildQueryParams = (currentPage) => {
1659
+ const qs = {};
1660
+ // Pagination
1661
+ qs.pageSize = pageSize;
1662
+ qs.page = currentPage;
1663
+ // Contact resolution
1664
+ if (resolveContacts !== undefined) {
1665
+ qs.resolveContacts = resolveContacts;
1666
+ }
1667
+ if (showUsers !== undefined) {
1668
+ qs.showUsers = showUsers;
1669
+ }
1670
+ // Additional filters from collection
1671
+ if (additionalFilters.origin && additionalFilters.origin !== 'All') {
1672
+ qs.origin = additionalFilters.origin;
1673
+ }
1674
+ if (additionalFilters.state && additionalFilters.state !== 'All') {
1675
+ qs.state = additionalFilters.state;
1676
+ }
1677
+ if (additionalFilters.type && additionalFilters.type !== 'All') {
1678
+ qs.type = additionalFilters.type;
1679
+ }
1680
+ // Date filtering (ISO 8601 format)
1681
+ if (additionalFilters.from) {
1682
+ const fromDate = new Date(additionalFilters.from);
1683
+ qs.from = fromDate.toISOString();
1684
+ }
1685
+ if (additionalFilters.to) {
1686
+ const toDate = new Date(additionalFilters.to);
1687
+ qs.to = toDate.toISOString();
1688
+ }
1689
+ // Contact filtering
1690
+ if (additionalFilters.phone) {
1691
+ qs.phone = additionalFilters.phone;
1692
+ }
1693
+ if (additionalFilters.email) {
1694
+ qs.email = additionalFilters.email;
1695
+ }
1696
+ if (additionalFilters.businessNumber) {
1697
+ qs.businessNumber = additionalFilters.businessNumber;
1698
+ }
1699
+ // Voicemail filtering
1700
+ if (additionalFilters.isRead !== undefined && additionalFilters.isRead !== '') {
1701
+ qs.isRead = additionalFilters.isRead;
1702
+ }
1703
+ // ID filtering
1704
+ if (additionalFilters.groupId) {
1705
+ qs.groupId = additionalFilters.groupId;
1706
+ }
1707
+ if (additionalFilters.userId) {
1708
+ qs.userId = additionalFilters.userId;
1709
+ }
1710
+ if (additionalFilters.vmBoxId) {
1711
+ qs.vmBoxId = additionalFilters.vmBoxId;
1712
+ }
1713
+ // Workflow state
1714
+ if (additionalFilters.wfState && additionalFilters.wfState !== 'All') {
1715
+ qs.wfState = additionalFilters.wfState;
1716
+ }
1717
+ // Search
1718
+ if (additionalFilters.searchProperty && additionalFilters.searchProperty !== '') {
1719
+ qs.searchProperty = additionalFilters.searchProperty;
1720
+ }
1721
+ if (additionalFilters.searchText) {
1722
+ qs.searchText = additionalFilters.searchText;
1723
+ }
1724
+ return qs;
1725
+ };
1726
+ if (getAllPages) {
1727
+ // Get all pages
1728
+ let allRequests = [];
1729
+ let currentPage = 1;
1730
+ let hasMorePages = true;
1731
+ const maxPages = 100; // Safety limit
1732
+ while (hasMorePages && currentPage <= maxPages) {
1733
+ const qs = buildQueryParams(currentPage);
1734
+ const pageResponse = await this.helpers.request({
1735
+ method: 'GET',
1736
+ url: `${baseUrl}/api/journal/requests`,
1737
+ headers: {
1738
+ 'Authorization': `Bearer ${accessToken}`,
1739
+ },
1740
+ qs,
1741
+ json: true,
1742
+ });
1743
+ // Extract requests from response
1744
+ let pageRequests = [];
1745
+ if (Array.isArray(pageResponse) && pageResponse.length > 0 && pageResponse[0].requests) {
1746
+ pageRequests = pageResponse[0].requests;
1747
+ }
1748
+ else if (pageResponse.requests) {
1749
+ pageRequests = pageResponse.requests;
1750
+ }
1751
+ allRequests = allRequests.concat(pageRequests);
1752
+ // Check if there are more pages
1753
+ hasMorePages = pageRequests.length === pageSize;
1754
+ currentPage++;
1755
+ // Small delay to avoid rate limiting
1756
+ if (hasMorePages) {
1757
+ await new Promise(resolve => setTimeout(resolve, 50));
1758
+ }
1759
+ }
1760
+ // Return all collected requests
1761
+ responseData = {
1762
+ requests: allRequests,
1763
+ currentPage: 'all',
1764
+ totalPages: currentPage - 1,
1765
+ totalRecords: allRequests.length,
1766
+ };
1767
+ }
1768
+ else {
1769
+ // Single page request
1770
+ const page = this.getNodeParameter('page', i);
1771
+ const qs = buildQueryParams(page);
1772
+ responseData = await this.helpers.request({
1773
+ method: 'GET',
1774
+ url: `${baseUrl}/api/journal/requests`,
1775
+ headers: {
1776
+ 'Authorization': `Bearer ${accessToken}`,
1777
+ },
1778
+ qs,
1779
+ json: true,
1780
+ });
1781
+ }
1782
+ }
1783
+ if (operation === 'getCount') {
1784
+ // Get count of requests with same filters as getAll
1785
+ const fromDateRequired = this.getNodeParameter('fromDateRequired', i);
1786
+ const additionalFilters = this.getNodeParameter('additionalFilters', i);
1787
+ const buildQueryParams = () => {
1788
+ const qs = {};
1789
+ // Required from date
1790
+ const fromDate = new Date(fromDateRequired);
1791
+ qs.from = fromDate.toISOString();
1792
+ // Additional filters from collection (same as getAll)
1793
+ if (additionalFilters.origin && additionalFilters.origin !== 'All') {
1794
+ qs.origin = additionalFilters.origin;
1795
+ }
1796
+ if (additionalFilters.state && additionalFilters.state !== 'All') {
1797
+ qs.state = additionalFilters.state;
1798
+ }
1799
+ if (additionalFilters.type && additionalFilters.type !== 'All') {
1800
+ qs.type = additionalFilters.type;
1801
+ }
1802
+ // Optional to date
1803
+ if (additionalFilters.to) {
1804
+ const toDate = new Date(additionalFilters.to);
1805
+ qs.to = toDate.toISOString();
1806
+ }
1807
+ // Contact filtering
1808
+ if (additionalFilters.phone) {
1809
+ qs.phone = additionalFilters.phone;
1810
+ }
1811
+ if (additionalFilters.email) {
1812
+ qs.email = additionalFilters.email;
1813
+ }
1814
+ if (additionalFilters.businessNumber) {
1815
+ qs.businessNumber = additionalFilters.businessNumber;
1816
+ }
1817
+ // Voicemail filtering
1818
+ if (additionalFilters.isRead !== undefined && additionalFilters.isRead !== '') {
1819
+ qs.isRead = additionalFilters.isRead;
1820
+ }
1821
+ // ID filtering
1822
+ if (additionalFilters.groupId) {
1823
+ qs.groupId = additionalFilters.groupId;
1824
+ }
1825
+ if (additionalFilters.userId) {
1826
+ qs.userId = additionalFilters.userId;
1827
+ }
1828
+ if (additionalFilters.vmBoxId) {
1829
+ qs.vmBoxId = additionalFilters.vmBoxId;
1830
+ }
1831
+ // Workflow state
1832
+ if (additionalFilters.wfState && additionalFilters.wfState !== 'All') {
1833
+ qs.wfState = additionalFilters.wfState;
1834
+ }
1835
+ // Search
1836
+ if (additionalFilters.searchProperty && additionalFilters.searchProperty !== '') {
1837
+ qs.searchProperty = additionalFilters.searchProperty;
1838
+ }
1839
+ if (additionalFilters.searchText) {
1840
+ qs.searchText = additionalFilters.searchText;
1841
+ }
1842
+ return qs;
1843
+ };
1844
+ const qs = buildQueryParams();
1845
+ responseData = await this.helpers.request({
1846
+ method: 'GET',
1847
+ url: `${baseUrl}/api/journal/requests/counts`,
1848
+ headers: {
1849
+ 'Authorization': `Bearer ${accessToken}`,
1850
+ },
1851
+ qs,
1852
+ json: true,
1853
+ });
1854
+ }
1855
+ if (operation === 'getById') {
1856
+ const requestId = this.getNodeParameter('requestId', i);
1857
+ responseData = await this.helpers.request({
1858
+ method: 'GET',
1859
+ url: `${baseUrl}/api/journal/requests/${requestId}`,
1860
+ headers: {
1861
+ 'Authorization': `Bearer ${accessToken}`,
1862
+ },
1863
+ json: true,
1864
+ });
1865
+ }
1866
+ if (operation === 'deleteMessages') {
1867
+ const messageIds = this.getNodeParameter('messageIds', i);
1868
+ const messageIdsArray = messageIds.split(',').map(id => id.trim());
1869
+ responseData = await this.helpers.request({
1870
+ method: 'DELETE',
1871
+ url: `${baseUrl}/api/journal/messages`,
1872
+ headers: {
1873
+ 'Authorization': `Bearer ${accessToken}`,
1874
+ 'Content-Type': 'application/json',
1875
+ },
1876
+ body: messageIdsArray,
1877
+ json: true,
1878
+ });
1879
+ }
1880
+ if (operation === 'addComment') {
1881
+ const requestId = this.getNodeParameter('requestId', i);
1882
+ const comment = this.getNodeParameter('comment', i);
1883
+ responseData = await this.helpers.request({
1884
+ method: 'POST',
1885
+ url: `${baseUrl}/api/journal/requests/${requestId}/comment`,
1886
+ headers: {
1887
+ 'Authorization': `Bearer ${accessToken}`,
1888
+ 'Content-Type': 'text/plain',
1889
+ },
1890
+ body: comment,
1891
+ json: true,
1892
+ });
1893
+ }
1894
+ if (operation === 'deleteComment') {
1895
+ const requestId = this.getNodeParameter('requestId', i);
1896
+ responseData = await this.helpers.request({
1897
+ method: 'DELETE',
1898
+ url: `${baseUrl}/api/journal/requests/${requestId}/comment`,
1899
+ headers: {
1900
+ 'Authorization': `Bearer ${accessToken}`,
1901
+ },
1902
+ json: true,
1903
+ });
1904
+ }
1905
+ if (operation === 'deleteVoicemail') {
1906
+ const requestIds = this.getNodeParameter('requestIds', i);
1907
+ responseData = await this.helpers.request({
1908
+ method: 'DELETE',
1909
+ url: `${baseUrl}/api/journal/requests/voicemail`,
1910
+ headers: {
1911
+ 'Authorization': `Bearer ${accessToken}`,
1912
+ },
1913
+ qs: {
1914
+ requestIds,
1915
+ },
1916
+ json: true,
1917
+ });
1918
+ }
1919
+ if (operation === 'setWorkflowState') {
1920
+ const requestId = this.getNodeParameter('requestId', i);
1921
+ const workflowState = this.getNodeParameter('workflowState', i);
1922
+ responseData = await this.helpers.request({
1923
+ method: 'PUT',
1924
+ url: `${baseUrl}/api/journal/requests/wfstate`,
1925
+ headers: {
1926
+ 'Authorization': `Bearer ${accessToken}`,
1927
+ 'Content-Type': 'application/json',
1928
+ },
1929
+ qs: {
1930
+ requestId,
1931
+ },
1932
+ body: {
1933
+ state: workflowState,
1934
+ },
1935
+ json: true,
1936
+ });
1937
+ }
1938
+ if (operation === 'setFlags') {
1939
+ const requestId = this.getNodeParameter('requestId', i);
1940
+ const flags = this.getNodeParameter('flags', i);
1941
+ responseData = await this.helpers.request({
1942
+ method: 'POST',
1943
+ url: `${baseUrl}/api/journal/requests/flags`,
1944
+ headers: {
1945
+ 'Authorization': `Bearer ${accessToken}`,
1946
+ 'Content-Type': 'application/json',
1947
+ },
1948
+ qs: {
1949
+ requestId,
1950
+ },
1951
+ body: {
1952
+ flags,
1953
+ },
1954
+ json: true,
1955
+ });
1956
+ }
1957
+ if (operation === 'removeFlags') {
1958
+ const requestId = this.getNodeParameter('requestId', i);
1959
+ const flags = this.getNodeParameter('flags', i);
1960
+ responseData = await this.helpers.request({
1961
+ method: 'DELETE',
1962
+ url: `${baseUrl}/api/journal/requests/flags`,
1963
+ headers: {
1964
+ 'Authorization': `Bearer ${accessToken}`,
1965
+ 'Content-Type': 'application/json',
1966
+ },
1967
+ qs: {
1968
+ requestId,
1969
+ },
1970
+ body: {
1971
+ flags,
1972
+ },
1973
+ json: true,
1974
+ });
1975
+ }
1976
+ if (operation === 'getBlockListCount') {
1977
+ responseData = await this.helpers.request({
1978
+ method: 'GET',
1979
+ url: `${baseUrl}/api/journal/blocklist/availableNumbers`,
1980
+ headers: {
1981
+ 'Authorization': `Bearer ${accessToken}`,
1982
+ },
1983
+ json: true,
1984
+ });
1985
+ }
1986
+ if (operation === 'getVipListCount') {
1987
+ responseData = await this.helpers.request({
1988
+ method: 'GET',
1989
+ url: `${baseUrl}/api/journal/viplist/availableNumbers`,
1990
+ headers: {
1991
+ 'Authorization': `Bearer ${accessToken}`,
1992
+ },
1993
+ json: true,
1994
+ });
1995
+ }
1996
+ if (operation === 'addToBlockList') {
1997
+ const phoneNumber = this.getNodeParameter('phoneNumber', i);
1998
+ responseData = await this.helpers.request({
1999
+ method: 'POST',
2000
+ url: `${baseUrl}/api/journal/blocklist/add`,
2001
+ headers: {
2002
+ 'Authorization': `Bearer ${accessToken}`,
2003
+ 'Content-Type': 'application/json',
2004
+ },
2005
+ body: {
2006
+ phoneNumber,
2007
+ },
2008
+ json: true,
2009
+ });
2010
+ }
2011
+ if (operation === 'removeFromBlockList') {
2012
+ const phoneNumber = this.getNodeParameter('phoneNumber', i);
2013
+ responseData = await this.helpers.request({
2014
+ method: 'POST',
2015
+ url: `${baseUrl}/api/journal/blocklist/remove`,
2016
+ headers: {
2017
+ 'Authorization': `Bearer ${accessToken}`,
2018
+ 'Content-Type': 'application/json',
2019
+ },
2020
+ body: {
2021
+ phoneNumber,
2022
+ },
2023
+ json: true,
2024
+ });
2025
+ }
2026
+ if (operation === 'restoreMessage') {
2027
+ const requestId = this.getNodeParameter('requestId', i);
2028
+ responseData = await this.helpers.request({
2029
+ method: 'POST',
2030
+ url: `${baseUrl}/api/journal/requests/message`,
2031
+ headers: {
2032
+ 'Authorization': `Bearer ${accessToken}`,
2033
+ },
2034
+ qs: {
2035
+ requestId,
2036
+ },
2037
+ json: true,
2038
+ });
2039
+ }
2040
+ if (operation === 'getMessageAttachments') {
2041
+ const requestId = this.getNodeParameter('requestId', i);
2042
+ responseData = await this.helpers.request({
2043
+ method: 'GET',
2044
+ url: `${baseUrl}/api/journal/requests/${requestId}/mmsAttachments`,
2045
+ headers: {
2046
+ 'Authorization': `Bearer ${accessToken}`,
2047
+ },
2048
+ json: true,
2049
+ });
2050
+ }
2051
+ }
2052
+ // ==================== CALL OPERATIONS ====================
2053
+ if (resource === 'call') {
2054
+ if (operation === 'getAll') {
2055
+ // Call history - use same logic as journal for now
2056
+ const qs = {};
2057
+ // Get all individual parameters
2058
+ const pageSize = this.getNodeParameter('pageSize', i);
2059
+ const page = this.getNodeParameter('page', i);
2060
+ const resolveContacts = this.getNodeParameter('resolveContacts', i);
2061
+ const showUsers = this.getNodeParameter('showUsers', i);
2062
+ const origin = this.getNodeParameter('origin', i);
2063
+ const state = this.getNodeParameter('state', i);
2064
+ const type = this.getNodeParameter('type', i);
2065
+ const from = this.getNodeParameter('from', i);
2066
+ const to = this.getNodeParameter('to', i);
2067
+ const phone = this.getNodeParameter('phone', i);
2068
+ const email = this.getNodeParameter('email', i);
2069
+ const businessNumber = this.getNodeParameter('businessNumber', i);
2070
+ const isRead = this.getNodeParameter('isRead', i);
2071
+ const groupId = this.getNodeParameter('groupId', i);
2072
+ const userId = this.getNodeParameter('userId', i);
2073
+ const vmBoxId = this.getNodeParameter('vmBoxId', i);
2074
+ const wfState = this.getNodeParameter('wfState', i);
2075
+ const searchProperty = this.getNodeParameter('searchProperty', i);
2076
+ const searchText = this.getNodeParameter('searchText', i);
2077
+ // Pagination
2078
+ if (pageSize) {
2079
+ qs.pageSize = pageSize;
2080
+ }
2081
+ if (page) {
2082
+ qs.page = page;
2083
+ }
2084
+ // Contact resolution
2085
+ if (resolveContacts !== undefined) {
2086
+ qs.resolveContacts = resolveContacts;
2087
+ }
2088
+ if (showUsers !== undefined) {
2089
+ qs.showUsers = showUsers;
2090
+ }
2091
+ // Filtering
2092
+ if (origin && origin !== 'All') {
2093
+ qs.origin = origin;
2094
+ }
2095
+ if (state && state !== 'All') {
2096
+ qs.state = state;
2097
+ }
2098
+ if (type && type !== 'All') {
2099
+ qs.type = type;
2100
+ }
2101
+ // Date filtering (ISO 8601 format)
2102
+ if (from) {
2103
+ const fromDate = new Date(from);
2104
+ qs.from = fromDate.toISOString();
2105
+ }
2106
+ if (to) {
2107
+ const toDate = new Date(to);
2108
+ qs.to = toDate.toISOString();
2109
+ }
2110
+ // Contact filtering
2111
+ if (phone) {
2112
+ qs.phone = phone;
2113
+ }
2114
+ if (email) {
2115
+ qs.email = email;
2116
+ }
2117
+ if (businessNumber) {
2118
+ qs.businessNumber = businessNumber;
2119
+ }
2120
+ // Voicemail filtering
2121
+ if (isRead !== undefined && isRead !== '') {
2122
+ qs.isRead = isRead === 'true';
2123
+ }
2124
+ // ID filtering
2125
+ if (groupId) {
2126
+ qs.groupId = groupId;
2127
+ }
2128
+ if (userId) {
2129
+ qs.userId = userId;
2130
+ }
2131
+ if (vmBoxId) {
2132
+ qs.vmBoxId = vmBoxId;
2133
+ }
2134
+ // Workflow state
2135
+ if (wfState && wfState !== 'All') {
2136
+ qs.wfState = wfState;
2137
+ }
2138
+ // Search
2139
+ if (searchProperty) {
2140
+ qs.searchProperty = searchProperty;
2141
+ }
2142
+ if (searchText) {
2143
+ qs.searchText = searchText;
2144
+ }
2145
+ responseData = await this.helpers.request({
2146
+ method: 'GET',
2147
+ url: `${baseUrl}/api/calls`,
2148
+ headers: {
2149
+ 'Authorization': `Bearer ${accessToken}`,
2150
+ },
2151
+ qs,
2152
+ json: true,
2153
+ });
2154
+ }
2155
+ if (operation === 'getActive') {
2156
+ responseData = await this.helpers.request({
2157
+ method: 'GET',
2158
+ url: `${baseUrl}/api/calls/active`,
2159
+ headers: {
2160
+ 'Authorization': `Bearer ${accessToken}`,
2161
+ },
2162
+ json: true,
2163
+ });
2164
+ }
2165
+ if (operation === 'make') {
2166
+ const from = this.getNodeParameter('from', i);
2167
+ const to = this.getNodeParameter('to', i);
2168
+ responseData = await this.helpers.request({
2169
+ method: 'POST',
2170
+ url: `${baseUrl}/api/calls`,
2171
+ headers: {
2172
+ 'Authorization': `Bearer ${accessToken}`,
2173
+ 'Content-Type': 'application/json',
2174
+ },
2175
+ body: {
2176
+ from,
2177
+ to,
2178
+ },
2179
+ json: true,
2180
+ });
2181
+ }
2182
+ if (operation === 'hangUp') {
2183
+ const callId = this.getNodeParameter('callId', i);
2184
+ responseData = await this.helpers.request({
2185
+ method: 'DELETE',
2186
+ url: `${baseUrl}/api/calls/${callId}`,
2187
+ headers: {
2188
+ 'Authorization': `Bearer ${accessToken}`,
2189
+ },
2190
+ json: true,
2191
+ });
2192
+ }
2193
+ }
2194
+ // ==================== CONTACT OPERATIONS ====================
2195
+ if (resource === 'contact') {
2196
+ if (operation === 'getAll') {
2197
+ const queryParameters = this.getNodeParameter('queryParameters', i);
2198
+ const qs = {};
2199
+ if (queryParameters.limit) {
2200
+ qs.limit = queryParameters.limit;
2201
+ }
2202
+ if (queryParameters.offset) {
2203
+ qs.offset = queryParameters.offset;
2204
+ }
2205
+ responseData = await this.helpers.request({
2206
+ method: 'GET',
2207
+ url: `${baseUrl}/api/contacts`,
2208
+ headers: {
2209
+ 'Authorization': `Bearer ${accessToken}`,
2210
+ },
2211
+ qs,
2212
+ json: true,
2213
+ });
2214
+ }
2215
+ if (operation === 'create') {
2216
+ const firstName = this.getNodeParameter('firstName', i);
2217
+ const lastName = this.getNodeParameter('lastName', i);
2218
+ const phoneNumber = this.getNodeParameter('phoneNumber', i);
2219
+ const email = this.getNodeParameter('email', i);
2220
+ const body = {
2221
+ firstName,
2222
+ phoneNumber,
2223
+ };
2224
+ if (lastName) {
2225
+ body.lastName = lastName;
2226
+ }
2227
+ if (email) {
2228
+ body.email = email;
2229
+ }
2230
+ responseData = await this.helpers.request({
2231
+ method: 'POST',
2232
+ url: `${baseUrl}/api/contacts`,
2233
+ headers: {
2234
+ 'Authorization': `Bearer ${accessToken}`,
2235
+ 'Content-Type': 'application/json',
2236
+ },
2237
+ body,
2238
+ json: true,
2239
+ });
2240
+ }
2241
+ if (operation === 'update') {
2242
+ const contactId = this.getNodeParameter('contactId', i);
2243
+ const lastName = this.getNodeParameter('lastName', i);
2244
+ const email = this.getNodeParameter('email', i);
2245
+ const body = {};
2246
+ if (lastName) {
2247
+ body.lastName = lastName;
2248
+ }
2249
+ if (email) {
2250
+ body.email = email;
2251
+ }
2252
+ responseData = await this.helpers.request({
2253
+ method: 'PUT',
2254
+ url: `${baseUrl}/api/contacts/${contactId}`,
2255
+ headers: {
2256
+ 'Authorization': `Bearer ${accessToken}`,
2257
+ 'Content-Type': 'application/json',
2258
+ },
2259
+ body,
2260
+ json: true,
2261
+ });
2262
+ }
2263
+ if (operation === 'delete') {
2264
+ const contactId = this.getNodeParameter('contactId', i);
2265
+ responseData = await this.helpers.request({
2266
+ method: 'DELETE',
2267
+ url: `${baseUrl}/api/contacts/${contactId}`,
2268
+ headers: {
2269
+ 'Authorization': `Bearer ${accessToken}`,
2270
+ },
2271
+ json: true,
2272
+ });
2273
+ }
2274
+ }
2275
+ // ==================== VOICEMAIL OPERATIONS ====================
2276
+ if (resource === 'voicemail') {
2277
+ if (operation === 'getAll') {
2278
+ // Get voicemail parameters according to actual API spec
2279
+ const pageSize = this.getNodeParameter('pageSize', i);
2280
+ const skip = this.getNodeParameter('skip', i);
2281
+ const startUtc = this.getNodeParameter('startUtc', i);
2282
+ const endUtc = this.getNodeParameter('endUtc', i);
2283
+ const voicemailFilter = this.getNodeParameter('voicemailFilter', i);
2284
+ const customFilter = this.getNodeParameter('customFilter', i);
2285
+ // Build query parameters according to actual API
2286
+ const qs = {};
2287
+ if (pageSize) {
2288
+ qs.pageSize = pageSize;
2289
+ }
2290
+ if (skip) {
2291
+ qs.skip = skip;
2292
+ }
2293
+ if (startUtc) {
2294
+ // Convert to yyyy-MM-ddThh:mm:ss format
2295
+ const startDate = new Date(startUtc);
2296
+ qs.startUtc = startDate.toISOString().replace(/\.\d{3}Z$/, '');
2297
+ }
2298
+ if (endUtc) {
2299
+ // Convert to yyyy-MM-ddThh:mm:ss format
2300
+ const endDate = new Date(endUtc);
2301
+ qs.endUtc = endDate.toISOString().replace(/\.\d{3}Z$/, '');
2302
+ }
2303
+ if (voicemailFilter && voicemailFilter.length > 0) {
2304
+ // Handle multiple filter values - join with commas as per API spec
2305
+ qs.voicemailFilter = voicemailFilter.join(',');
2306
+ }
2307
+ if (customFilter) {
2308
+ qs.customFilter = customFilter;
2309
+ }
2310
+ // Use the dedicated voicemails endpoint with correct parameters
2311
+ responseData = await this.helpers.request({
2312
+ method: 'GET',
2313
+ url: `${baseUrl}/api/voicemails`,
2314
+ headers: {
2315
+ 'Authorization': `Bearer ${accessToken}`,
2316
+ },
2317
+ qs,
2318
+ json: true,
2319
+ });
2320
+ }
2321
+ if (operation === 'get') {
2322
+ const voicemailId = this.getNodeParameter('voicemailId', i);
2323
+ // Use the dedicated voicemails endpoint for specific voicemail
2324
+ responseData = await this.helpers.request({
2325
+ method: 'GET',
2326
+ url: `${baseUrl}/api/voicemails/${voicemailId}`,
2327
+ headers: {
2328
+ 'Authorization': `Bearer ${accessToken}`,
2329
+ },
2330
+ json: true,
2331
+ });
2332
+ }
2333
+ }
2334
+ // ==================== BUSINESS NUMBER OPERATIONS ====================
2335
+ if (resource === 'businessNumber') {
2336
+ if (operation === 'getAll') {
2337
+ // Get all business phone numbers
2338
+ responseData = await this.helpers.request({
2339
+ method: 'GET',
2340
+ url: `${baseUrl}/api/phonenumbers`,
2341
+ headers: {
2342
+ 'Authorization': `Bearer ${accessToken}`,
2343
+ 'x-api-key': credentials.apiKey,
2344
+ },
2345
+ json: true,
2346
+ });
2347
+ }
2348
+ if (operation === 'get') {
2349
+ // Get specific phone number by number or subsequence
2350
+ const phoneNumber = this.getNodeParameter('phoneNumber', i);
2351
+ responseData = await this.helpers.request({
2352
+ method: 'GET',
2353
+ url: `${baseUrl}/api/phonenumbers/${phoneNumber}`,
2354
+ headers: {
2355
+ 'Authorization': `Bearer ${accessToken}`,
2356
+ 'x-api-key': credentials.apiKey,
2357
+ },
2358
+ json: true,
2359
+ });
2360
+ }
2361
+ if (operation === 'delete') {
2362
+ // Delete one or more phone numbers
2363
+ const phoneIds = this.getNodeParameter('phoneIds', i);
2364
+ const phoneIdsArray = phoneIds.split(',').map(id => id.trim());
2365
+ responseData = await this.helpers.request({
2366
+ method: 'DELETE',
2367
+ url: `${baseUrl}/api/phonenumbers`,
2368
+ headers: {
2369
+ 'Authorization': `Bearer ${accessToken}`,
2370
+ 'x-api-key': credentials.apiKey,
2371
+ 'Content-Type': 'application/json',
2372
+ },
2373
+ body: phoneIdsArray,
2374
+ json: true,
2375
+ });
2376
+ }
2377
+ }
2378
+ // ==================== USER OPERATIONS ====================
2379
+ if (resource === 'user') {
2380
+ if (operation === 'getStatus') {
2381
+ // Try different possible endpoints for user status
2382
+ try {
2383
+ responseData = await this.helpers.request({
2384
+ method: 'GET',
2385
+ url: `${baseUrl}/api/user/status`,
2386
+ headers: {
2387
+ 'Authorization': `Bearer ${accessToken}`,
2388
+ },
2389
+ json: true,
2390
+ });
2391
+ }
2392
+ catch (error) {
2393
+ if (error.statusCode === 404) {
2394
+ // Try alternative endpoint
2395
+ try {
2396
+ responseData = await this.helpers.request({
2397
+ method: 'GET',
2398
+ url: `${baseUrl}/api/users/me`,
2399
+ headers: {
2400
+ 'Authorization': `Bearer ${accessToken}`,
2401
+ },
2402
+ json: true,
2403
+ });
2404
+ }
2405
+ catch (error2) {
2406
+ if (error2.statusCode === 404) {
2407
+ // Return a placeholder response since endpoint doesn't exist
2408
+ responseData = {
2409
+ message: 'User status endpoint not available in this API version',
2410
+ status: 'unknown'
2411
+ };
2412
+ }
2413
+ else {
2414
+ throw error2;
2415
+ }
2416
+ }
2417
+ }
2418
+ else {
2419
+ throw error;
2420
+ }
2421
+ }
2422
+ }
2423
+ if (operation === 'setStatus') {
2424
+ const status = this.getNodeParameter('status', i);
2425
+ // Try different possible endpoints for setting user status
2426
+ try {
2427
+ responseData = await this.helpers.request({
2428
+ method: 'PUT',
2429
+ url: `${baseUrl}/api/user/status`,
2430
+ headers: {
2431
+ 'Authorization': `Bearer ${accessToken}`,
2432
+ 'Content-Type': 'application/json',
2433
+ },
2434
+ body: {
2435
+ status,
2436
+ },
2437
+ json: true,
2438
+ });
2439
+ }
2440
+ catch (error) {
2441
+ if (error.statusCode === 404) {
2442
+ // Return a placeholder response since endpoint doesn't exist
2443
+ responseData = {
2444
+ message: 'User status setting not available in this API version',
2445
+ requestedStatus: status
2446
+ };
2447
+ }
2448
+ else {
2449
+ throw error;
2450
+ }
2451
+ }
2452
+ }
2453
+ if (operation === 'getInfo') {
2454
+ // Try different possible endpoints for user info
2455
+ try {
2456
+ responseData = await this.helpers.request({
2457
+ method: 'GET',
2458
+ url: `${baseUrl}/api/user/info`,
2459
+ headers: {
2460
+ 'Authorization': `Bearer ${accessToken}`,
2461
+ },
2462
+ json: true,
2463
+ });
2464
+ }
2465
+ catch (error) {
2466
+ if (error.statusCode === 404) {
2467
+ // Try alternative endpoint
2468
+ try {
2469
+ responseData = await this.helpers.request({
2470
+ method: 'GET',
2471
+ url: `${baseUrl}/api/users/me`,
2472
+ headers: {
2473
+ 'Authorization': `Bearer ${accessToken}`,
2474
+ },
2475
+ json: true,
2476
+ });
2477
+ }
2478
+ catch (error2) {
2479
+ if (error2.statusCode === 404) {
2480
+ // Return a placeholder response since endpoint doesn't exist
2481
+ responseData = {
2482
+ message: 'User info endpoint not available in this API version'
2483
+ };
2484
+ }
2485
+ else {
2486
+ throw error2;
2487
+ }
2488
+ }
2489
+ }
2490
+ else {
2491
+ throw error;
2492
+ }
2493
+ }
2494
+ }
2495
+ }
2496
+ // ==================== MESSAGE OPERATIONS ====================
2497
+ if (resource === 'message' && operation === 'send') {
2498
+ const from = this.getNodeParameter('from', i);
2499
+ const to = this.getNodeParameter('to', i);
2500
+ const message = this.getNodeParameter('message', i);
2501
+ const toArray = to.split(',').map(num => num.trim());
2502
+ const body = {
2503
+ from,
2504
+ to: toArray,
2505
+ };
2506
+ if (message) {
2507
+ body.message = message;
2508
+ }
2509
+ responseData = await this.helpers.request({
2510
+ method: 'POST',
2511
+ url: `${baseUrl}/api/messages/send`,
2512
+ headers: {
2513
+ 'Authorization': `Bearer ${accessToken}`,
2514
+ 'x-api-key': credentials.apiKey,
2515
+ 'Content-Type': 'application/json',
2516
+ },
2517
+ body,
2518
+ json: true,
2519
+ });
2520
+ }
2521
+ // ==================== TEAM OPERATIONS ====================
2522
+ if (resource === 'team' && operation === 'get') {
2523
+ responseData = await this.helpers.request({
2524
+ method: 'GET',
2525
+ url: `${baseUrl}/api/team`,
2526
+ headers: {
2527
+ 'Authorization': `Bearer ${accessToken}`,
2528
+ 'x-api-key': credentials.apiKey,
2529
+ },
2530
+ json: true,
2531
+ });
2532
+ }
2533
+ // ==================== PROFILE OPERATIONS ====================
2534
+ if (resource === 'profile') {
2535
+ if (operation === 'get') {
2536
+ responseData = await this.helpers.request({
2537
+ method: 'GET',
2538
+ url: `${baseUrl}/api/profile`,
2539
+ headers: {
2540
+ 'Authorization': `Bearer ${accessToken}`,
2541
+ 'x-api-key': credentials.apiKey,
2542
+ },
2543
+ json: true,
2544
+ });
2545
+ }
2546
+ if (operation === 'getByExtension') {
2547
+ const extension = this.getNodeParameter('extension', i);
2548
+ responseData = await this.helpers.request({
2549
+ method: 'GET',
2550
+ url: `${baseUrl}/api/profile/${extension}`,
2551
+ headers: {
2552
+ 'Authorization': `Bearer ${accessToken}`,
2553
+ 'x-api-key': credentials.apiKey,
2554
+ },
2555
+ json: true,
2556
+ });
2557
+ }
2558
+ }
2559
+ // ==================== PING OPERATIONS ====================
2560
+ if (resource === 'ping' && operation === 'ping') {
2561
+ responseData = await this.helpers.request({
2562
+ method: 'GET',
2563
+ url: `${baseUrl}/api/ping`,
2564
+ headers: {
2565
+ 'x-api-key': credentials.apiKey,
2566
+ },
2567
+ json: true,
2568
+ });
2569
+ }
2570
+ // ==================== COMMUNICATION OPERATIONS ====================
2571
+ if (resource === 'communication') {
2572
+ if (operation === 'getAll') {
2573
+ // Get all individual parameters (similar to Journal)
2574
+ const qs = {};
2575
+ const pageSize = this.getNodeParameter('pageSize', i);
2576
+ const page = this.getNodeParameter('page', i);
2577
+ const resolveContacts = this.getNodeParameter('resolveContacts', i);
2578
+ const showUsers = this.getNodeParameter('showUsers', i);
2579
+ const origin = this.getNodeParameter('origin', i);
2580
+ const state = this.getNodeParameter('state', i);
2581
+ const type = this.getNodeParameter('type', i);
2582
+ const from = this.getNodeParameter('from', i);
2583
+ const to = this.getNodeParameter('to', i);
2584
+ const phone = this.getNodeParameter('phone', i);
2585
+ const email = this.getNodeParameter('email', i);
2586
+ const businessNumber = this.getNodeParameter('businessNumber', i);
2587
+ const isRead = this.getNodeParameter('isRead', i);
2588
+ const groupId = this.getNodeParameter('groupId', i);
2589
+ const userId = this.getNodeParameter('userId', i);
2590
+ const vmBoxId = this.getNodeParameter('vmBoxId', i);
2591
+ const wfState = this.getNodeParameter('wfState', i);
2592
+ const searchProperty = this.getNodeParameter('searchProperty', i);
2593
+ const searchText = this.getNodeParameter('searchText', i);
2594
+ // Pagination
2595
+ if (pageSize)
2596
+ qs.pageSize = pageSize;
2597
+ if (page)
2598
+ qs.page = page;
2599
+ // Contact resolution
2600
+ if (resolveContacts !== undefined)
2601
+ qs.resolveContacts = resolveContacts;
2602
+ if (showUsers !== undefined)
2603
+ qs.showUsers = showUsers;
2604
+ // Filtering
2605
+ if (origin && origin !== 'All')
2606
+ qs.origin = origin;
2607
+ if (state && state !== 'All')
2608
+ qs.state = state;
2609
+ if (type && type !== 'All')
2610
+ qs.type = type;
2611
+ // Date filtering
2612
+ if (from) {
2613
+ const fromDate = new Date(from);
2614
+ qs.from = fromDate.toISOString();
2615
+ }
2616
+ if (to) {
2617
+ const toDate = new Date(to);
2618
+ qs.to = toDate.toISOString();
2619
+ }
2620
+ // Contact filtering
2621
+ if (phone)
2622
+ qs.phone = phone;
2623
+ if (email)
2624
+ qs.email = email;
2625
+ if (businessNumber)
2626
+ qs.businessNumber = businessNumber;
2627
+ // Voicemail filtering
2628
+ if (isRead !== undefined && isRead !== '')
2629
+ qs.isRead = isRead === 'true';
2630
+ // ID filtering
2631
+ if (groupId)
2632
+ qs.groupId = groupId;
2633
+ if (userId)
2634
+ qs.userId = userId;
2635
+ if (vmBoxId)
2636
+ qs.vmBoxId = vmBoxId;
2637
+ // Workflow state
2638
+ if (wfState && wfState !== 'All')
2639
+ qs.wfState = wfState;
2640
+ // Search
2641
+ if (searchProperty)
2642
+ qs.searchProperty = searchProperty;
2643
+ if (searchText)
2644
+ qs.searchText = searchText;
2645
+ responseData = await this.helpers.request({
2646
+ method: 'GET',
2647
+ url: `${baseUrl}/api/contactCenter/communications`,
2648
+ headers: {
2649
+ 'Authorization': `Bearer ${accessToken}`,
2650
+ 'x-api-key': credentials.apiKey,
2651
+ },
2652
+ qs,
2653
+ json: true,
2654
+ });
2655
+ }
2656
+ if (operation === 'addComment') {
2657
+ const requestId = this.getNodeParameter('requestId', i);
2658
+ const comment = this.getNodeParameter('comment', i);
2659
+ responseData = await this.helpers.request({
2660
+ method: 'POST',
2661
+ url: `${baseUrl}/api/contactCenter/communications/${requestId}/comment`,
2662
+ headers: {
2663
+ 'Authorization': `Bearer ${accessToken}`,
2664
+ 'x-api-key': credentials.apiKey,
2665
+ 'Content-Type': 'text/plain',
2666
+ },
2667
+ body: comment,
2668
+ json: true,
2669
+ });
2670
+ }
2671
+ if (operation === 'deleteComment') {
2672
+ const requestId = this.getNodeParameter('requestId', i);
2673
+ responseData = await this.helpers.request({
2674
+ method: 'DELETE',
2675
+ url: `${baseUrl}/api/contactCenter/communications/${requestId}/comment`,
2676
+ headers: {
2677
+ 'Authorization': `Bearer ${accessToken}`,
2678
+ 'x-api-key': credentials.apiKey,
2679
+ },
2680
+ json: true,
2681
+ });
2682
+ }
2683
+ if (operation === 'deleteVoicemails') {
2684
+ const requestIds = this.getNodeParameter('requestIds', i);
2685
+ const removeText = this.getNodeParameter('removeText', i);
2686
+ responseData = await this.helpers.request({
2687
+ method: 'DELETE',
2688
+ url: `${baseUrl}/api/contactCenter/communications/voicemails`,
2689
+ headers: {
2690
+ 'Authorization': `Bearer ${accessToken}`,
2691
+ 'x-api-key': credentials.apiKey,
2692
+ },
2693
+ qs: {
2694
+ requestIds,
2695
+ removeText,
2696
+ },
2697
+ json: true,
2698
+ });
2699
+ }
2700
+ }
2701
+ // ==================== INTERACTION OPERATIONS ====================
2702
+ if (resource === 'interaction' && operation === 'getAll') {
2703
+ const tab = this.getNodeParameter('tab', i);
2704
+ const pageSize = this.getNodeParameter('pageSize', i);
2705
+ const pageNumber = this.getNodeParameter('pageNumber', i);
2706
+ const latest = this.getNodeParameter('latest', i);
2707
+ const earliest = this.getNodeParameter('earliest', i);
2708
+ const qs = {};
2709
+ if (tab)
2710
+ qs.tab = tab;
2711
+ if (pageSize)
2712
+ qs.pageSize = pageSize;
2713
+ if (pageNumber)
2714
+ qs.pageNumber = pageNumber;
2715
+ if (latest) {
2716
+ const latestDate = new Date(latest);
2717
+ qs.latest = latestDate.toISOString();
2718
+ }
2719
+ if (earliest) {
2720
+ const earliestDate = new Date(earliest);
2721
+ qs.earliest = earliestDate.toISOString();
2722
+ }
2723
+ responseData = await this.helpers.request({
2724
+ method: 'GET',
2725
+ url: `${baseUrl}/api/contactcenter/interactions`,
2726
+ headers: {
2727
+ 'Authorization': `Bearer ${accessToken}`,
2728
+ 'x-api-key': credentials.apiKey,
2729
+ },
2730
+ qs,
2731
+ json: true,
2732
+ });
2733
+ }
2734
+ if (responseData) {
2735
+ // Handle Journal, Call, and Communication responses (has special structure with requests array)
2736
+ if ((resource === 'journal' && operation === 'getAll') ||
2737
+ (resource === 'call' && operation === 'getAll') ||
2738
+ (resource === 'communication' && operation === 'getAll')) {
2739
+ // Returns: [{ currentPage: 1, requests: [...] }]
2740
+ if (Array.isArray(responseData) && responseData.length > 0 && responseData[0].requests) {
2741
+ const requests = responseData[0].requests;
2742
+ requests.forEach((request) => {
2743
+ returnData.push({
2744
+ json: {
2745
+ ...request,
2746
+ _pagination: {
2747
+ currentPage: responseData[0].currentPage,
2748
+ },
2749
+ },
2750
+ });
2751
+ });
2752
+ }
2753
+ else if (responseData.requests) {
2754
+ // Single object with requests array
2755
+ const requests = responseData.requests;
2756
+ requests.forEach((request) => {
2757
+ returnData.push({
2758
+ json: {
2759
+ ...request,
2760
+ _pagination: {
2761
+ currentPage: responseData.currentPage,
2762
+ },
2763
+ },
2764
+ });
2765
+ });
2766
+ }
2767
+ else {
2768
+ // Fallback: return as-is
2769
+ returnData.push({ json: responseData });
2770
+ }
2771
+ }
2772
+ else {
2773
+ // Handle standard array/object responses for other operations
2774
+ if (Array.isArray(responseData)) {
2775
+ responseData.forEach((item) => {
2776
+ returnData.push({ json: item });
2777
+ });
2778
+ }
2779
+ else {
2780
+ // Handle object response
2781
+ returnData.push({ json: responseData });
2782
+ }
2783
+ }
2784
+ }
2785
+ }
2786
+ catch (error) {
2787
+ if (this.continueOnFail()) {
2788
+ returnData.push({ json: { error: error.message } });
2789
+ continue;
2790
+ }
2791
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
2792
+ }
2793
+ }
2794
+ return [returnData];
2795
+ }
2796
+ }
2797
+ exports.MightyCall = MightyCall;