-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebHook.postman_collection.json
708 lines (708 loc) · 26.4 KB
/
WebHook.postman_collection.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
{
"info": {
"_postman_id": "10acf20d-05c4-4b79-b7f8-3c9034634db5",
"name": "WebHook",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "26165058"
},
"item": [
{
"name": "Listing Extensions",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check for 200 OK response",
"pm.test('Status code is 200 OK', function () {",
" pm.response.to.have.status(200);",
"});",
"",
"// Parse the response JSON",
"var responseBody = pm.response.json();",
"",
"// Check if there is an error field in the response",
"if ('error' in responseBody) {",
" console.error(\"Test Failed: \" + responseBody.error);",
" pm.test('API Response Error', function () {",
" pm.expect.fail(responseBody.error);",
" });",
"} else {",
" // Check if the response contains an array of extensions",
" pm.test('Response Validation', function () {",
" var extensionKeys = Object.keys(responseBody);",
" pm.expect(extensionKeys).to.have.length.above(0);",
"",
" // Store extension IDs in an array",
" var extensionIDs = [];",
" for (var extId in responseBody) {",
" if (responseBody.hasOwnProperty(extId)) {",
" var extension = responseBody[extId];",
" pm.test('Extension ' + extId + ' Validation', function () {",
" pm.expect(extension).to.have.property('name').that.is.a('string');",
" pm.expect(extension).to.have.property('email').that.is.a('string');",
" pm.expect(extension).to.have.property('protocol').that.is.a('string');",
" pm.expect(extension).to.have.property('ext').that.is.a('string');",
" pm.expect(extension).to.have.property('location').that.is.a('string');",
" pm.expect(extension).to.have.property('ua_id').that.is.a('string');",
" pm.expect(extension).to.have.property('ua_name').that.is.a('string');",
" pm.expect(extension).to.have.property('ua_fullname').that.is.a('string');",
" pm.expect(extension).to.have.property('status').that.is.a('string');",
" pm.expect(extension).to.have.property('linenum').that.is.a('string');",
" pm.expect(extension).to.have.property('user_location').that.is.a('string');",
" // 'macaddress' and 'department' are optional fields, so we will not perform type checks for them.",
" });",
"",
" // Add the new extension ID to the array",
" extensionIDs.push(parseInt(extId));",
" }",
" }",
"",
" // Save the extension IDs to the Postman environment variable",
" pm.environment.set('ExtensionIDs', JSON.stringify(extensionIDs));",
" });",
"}"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{IP}}/index.php?apikey={{API_Key}}&action=pbxware.ext.list&server={{Server}}",
"protocol": "http",
"host": [
"{{IP}}"
],
"path": [
"index.php"
],
"query": [
{
"key": "apikey",
"value": "{{API_Key}}"
},
{
"key": "action",
"value": "pbxware.ext.list"
},
{
"key": "server",
"value": "{{Server}}",
"description": "Server or tenant ID"
}
]
}
},
"response": []
},
{
"name": "Extension Configuration",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check for 200 OK response",
"pm.test('Status code is 200 OK', function () {",
" pm.response.to.have.status(200);",
"});",
"",
"// Parse the response JSON",
"var responseBody = pm.response.json();",
"",
"// Check if there is an error field in the response",
"if ('error' in responseBody) {",
" console.error(\"Test Failed: \" + responseBody.error);",
" pm.test('API Response Error', function () {",
" pm.expect.fail(responseBody.error);",
" });",
"} else {",
" // Check if the response contains the expected fields",
" pm.test('Response Validation', function () {",
" pm.expect(responseBody).to.be.an('object');",
"",
" for (var extId in responseBody) {",
" if (responseBody.hasOwnProperty(extId)) {",
" var extension = responseBody[extId];",
" pm.test('Extension ' + extId + ' Fields Validation', function () {",
" pm.expect(extension).to.have.property('name').that.is.a('string');",
" pm.expect(extension).to.have.property('email').that.is.a('string');",
" pm.expect(extension).to.have.property('pin').that.is.a('string');",
" pm.expect(extension).to.have.property('protocol').that.is.a('string');",
" pm.expect(extension).to.have.property('ext').that.is.a('string');",
" pm.expect(extension).to.have.property('location').that.is.a('string');",
" pm.expect(extension).to.have.property('user_language').that.is.a('string');",
" pm.expect(extension).to.have.property('ua_id').that.is.a('string');",
" pm.expect(extension).to.have.property('ua_name').that.is.a('string');",
" pm.expect(extension).to.have.property('ua_fullname').that.is.a('string');",
" pm.expect(extension).to.have.property('status').that.is.a('string');",
" pm.expect(extension).to.have.property('smuser').that.is.a('string');",
" pm.expect(extension).to.have.property('options').that.is.an('object');",
" pm.expect(extension.options).to.have.property('type').that.is.a('string');",
" pm.expect(extension.options).to.have.property('dtmfmode').that.is.a('string');",
" // Add more checks for other fields in the 'options' object if needed",
" // ...",
"",
" // 'options_raw', 'ua_autoprov', 'additional_macaddress', 'additional_config', and other fields are optional,",
" // so we will not perform type checks for them.",
" });",
" }",
" }",
" });",
"}",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{IP}}/index.php?apikey={{API_Key}}&action=pbxware.ext.configuration&server={{Server}}&id={{ExtensionIDs}}",
"protocol": "http",
"host": [
"{{IP}}"
],
"path": [
"index.php"
],
"query": [
{
"key": "apikey",
"value": "{{API_Key}}"
},
{
"key": "action",
"value": "pbxware.ext.configuration"
},
{
"key": "server",
"value": "{{Server}}",
"description": "Server or tenant ID"
},
{
"key": "id",
"value": "{{ExtensionIDs}}",
"description": "Extension ID of which we want to get configuration."
},
{
"key": "ext",
"value": "{{name}}",
"description": "Note: You cannot supply id and ext at the same time!",
"disabled": true
}
]
}
},
"response": []
},
{
"name": "Listing DIDs",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.environment.unset(\"DID-IDs\");",
"pm.collectionVariables.unset(\"DID-IDs\");",
"",
"// Check for 200 OK response",
"pm.test('Status code is 200 OK', function () {",
" pm.response.to.have.status(200);",
"});",
"",
"// Parse the response JSON",
"var responseBody = pm.response.json();",
"",
"// Check if there is an error field in the response",
"if ('error' in responseBody) {",
" console.error(\"Test Failed: \" + responseBody.error);",
" pm.test('API Response Error', function () {",
" pm.expect.fail(responseBody.error);",
" });",
"} else {",
" // Check if the response is an empty array",
" if (Array.isArray(responseBody) && responseBody.length === 0) {",
" console.log(\"No DID found. Try with different values for Server or Ext field!\");",
" pm.test('No found error', function () {",
" pm.expect.fail(\"No DID found for given inputs.Try with different values for Server or Ext field!\");",
" });",
" } else {",
" // Validate the response structure and loop through DIDs data",
" pm.test('Response Validation', function () {",
" pm.expect(responseBody).to.be.an('object');",
"",
" // Get the existing DIDs array from the environment",
" var didIDs = pm.collectionVariables.get('DID-IDs') || [];",
" ",
" for (var didID in responseBody) {",
" var didData = responseBody[didID];",
" ",
" // Validate specific properties for each DID",
" pm.test('DID ' + didID + ' Data Validation', function () {",
" pm.expect(didData).to.be.an('object');",
" pm.expect(didData).to.have.property('number').that.is.a('string');",
" pm.expect(didData).to.have.property('number2').that.is.oneOf([null, 'string']);",
" pm.expect(didData).to.have.property('server').that.is.a('string');",
" pm.expect(didData).to.have.property('trunk').that.is.a('string');",
" pm.expect(didData).to.have.property('type').that.is.a('string');",
" pm.expect(didData).to.have.property('ext').that.is.a('string');",
" pm.expect(didData).to.have.property('status').that.is.oneOf(['enabled', 'disabled']);",
" pm.expect(didData).to.have.property('sms_enabled').that.is.oneOf([null,'1', '0']);",
"",
" // Validate e164 field",
" if (didData.e164 !== null) {",
" pm.expect(didData.e164).to.be.a('string').and.match(/^\\d+$/);",
" }",
"",
" // Validate e164_2 field",
" if (didData.e164_2 !== null) {",
" pm.expect(didData.e164_2).to.be.a('string').and.match(/^\\d+$/);",
" }",
" ",
" // Print the result for each DID",
" console.log('DID ID:', didID);",
" console.log('DID Number:', didData.number);",
" console.log('DID Number2:', didData.number2);",
" console.log('Server ID:', didData.server);",
" console.log('Trunk ID:', didData.trunk);",
" console.log('DID Type:', didData.type);",
" console.log('Extension:', didData.ext);",
" console.log('E.164 Number:', didData.e164);",
" console.log('E.164 Number2:', didData.e164_2);",
" console.log('Status:', didData.status);",
" console.log('SMS Enabled:', didData.sms_enabled);",
" console.log();",
"",
" // Push the new DID ID to the DIDs array",
" didIDs.push(didID);",
" });",
" }",
" // Update the DIDs array in the environment",
" pm.collectionVariables.set('DID-IDs', didIDs);",
" pm.environment.set('DID-IDs', didIDs);",
" });",
" }",
"}",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{IP}}/index.php?apikey={{API_Key}}&action=pbxware.did.list&server={{Server}}",
"protocol": "http",
"host": [
"{{IP}}"
],
"path": [
"index.php"
],
"query": [
{
"key": "apikey",
"value": "{{API_Key}}"
},
{
"key": "action",
"value": "pbxware.did.list",
"description": "Listing of DIDs, by default, will include all DIDs."
},
{
"key": "server",
"value": "{{Server}}",
"description": "Filter DID list by Tenant ID. If PBXware is running in Tenant Mode this is a required field and must contain a valid Tenant ID. ID 1 is always assigned to Master tenant and cannot be used. You can use CSV file \"SrvTenantIDs.csv\" to get all DIDs of tenants."
},
{
"key": "ext",
"value": "",
"description": "Filter DID list by Destination Number. (Regex: /^[\\\\d,]+$/)",
"disabled": true
}
]
}
},
"response": []
},
{
"name": "Listing Ring Groups",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check for 200 OK response",
"pm.test('Status code is 200 OK', function () {",
" pm.response.to.have.status(200);",
"});",
"",
"// Parse the response JSON",
"var responseBody = pm.response.json();",
"",
"// Check if there is an error field in the response",
"if ('error' in responseBody) {",
" console.error(\"Test Failed: \" + responseBody.error);",
" pm.test('API Response Error', function () {",
" pm.expect.fail(responseBody.error);",
" });",
"} else if (Object.keys(responseBody).length === 0) {",
" console.log(\"There is no Ring Groups for this Server/Tenant!\");",
" pm.test('No Ring Groups!', function () {",
" pm.expect.fail(\"No Ring Groups for this Server/Tenant!\");",
" });",
"} else {",
" // Validate the response structure",
" pm.test('Response Validation', function () {",
" pm.expect(responseBody).to.be.an('object');",
" ",
" // Initialize array to store Ring Group IDs",
" var rgIDs = [];",
" ",
" // Loop through Ring Group data",
" for (var ringGroupID in responseBody) {",
" var ringGroupData = responseBody[ringGroupID];",
" ",
" // Validate specific properties for each Ring Group",
" pm.test('Ring Group ' + ringGroupID + ' Data Validation', function () {",
" pm.expect(ringGroupData).to.be.an('object');",
" pm.expect(ringGroupData).to.have.property('name').that.is.a('string');",
" pm.expect(ringGroupData).to.have.property('ext').that.is.a('string');",
" pm.expect(ringGroupData).to.have.property('destinations').that.is.a('string');",
" pm.expect(ringGroupData).to.have.property('last_dest').that.is.a('string');",
" pm.expect(ringGroupData).to.have.property('last_dest_vm').that.is.oneOf(['yes', 'no']);",
" ",
" // Print the result for each Ring Group",
" console.log('Ring Group ID:', ringGroupID);",
" console.log('Ring Group Name:', ringGroupData.name);",
" console.log('Ring Group Extension:', ringGroupData.ext);",
" console.log('Ring Group Destinations:', ringGroupData.destinations);",
" console.log('Ring Group Last Destination:', ringGroupData.last_dest);",
" console.log('Ring Group Last Destination is Voicemail:', ringGroupData.last_dest_vm);",
" ",
" // Push the Ring Group ID to the array",
" rgIDs.push(ringGroupID);",
" });",
" }",
" ",
" // Save the Ring Group IDs to variables",
" pm.collectionVariables.set('RGsID', rgIDs);",
" pm.environment.set('RGsID', rgIDs);",
" });",
"}",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{IP}}/index.php?apikey={{API_Key}}&action=pbxware.ring_group.list&server={{Server}}",
"protocol": "http",
"host": [
"{{IP}}"
],
"path": [
"index.php"
],
"query": [
{
"key": "apikey",
"value": "{{API_Key}}"
},
{
"key": "action",
"value": "pbxware.ring_group.list"
},
{
"key": "server",
"value": "{{Server}}",
"description": "Filter Ring Group list by Server/Tenant ID. If PBXware is running in Tenant Mode this is a required field and must contain a valid Tenant ID. ID 1 is always assigned to Master tenant and cannot be used."
}
]
}
},
"response": []
},
{
"name": "Listing Tenant Packages",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check for 200 OK response",
"pm.test('Status code is 200 OK', function () {",
" pm.response.to.have.status(200);",
"});",
"",
"// Parse the response JSON",
"var responseBody = pm.response.json();",
"",
"// Check if there is an error field in the response",
"if ('error' in responseBody) {",
" console.error(\"Test Failed: \" + responseBody.error);",
" pm.test('API Response Error', function () {",
" pm.expect.fail(responseBody.error);",
" });",
"} else {",
" // Validate the response structure",
" pm.test('Response Validation', function () {",
" pm.expect(responseBody).to.be.an('object');",
"",
" // Iterate through the keys (IDs) in the response",
" for (var id in responseBody) {",
" var packageName = responseBody[id];",
"",
" // Validate specific properties for each package",
" pm.expect(packageName).to.be.a('string');",
" }",
" });",
"}",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{IP}}/index.php?apikey={{API_Key}}&action=pbxware.package.list",
"protocol": "http",
"host": [
"{{IP}}"
],
"path": [
"index.php"
],
"query": [
{
"key": "apikey",
"value": "{{API_Key}}"
},
{
"key": "action",
"value": "pbxware.package.list",
"description": "Response will consist of an array of tenants with array key being the Tenant Package ID."
}
]
}
},
"response": []
},
{
"name": "Listing Tenants",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Check for 200 OK response",
"pm.test('Status code is 200 OK', function () {",
" pm.response.to.have.status(200);",
"});",
"",
"// Parse the response JSON",
"var responseBody = pm.response.json();",
"",
"// Check if there is an error field in the response",
"if ('error' in responseBody) {",
" console.error(\"Test Failed: \" + responseBody.error);",
" pm.test('API Response Error', function () {",
" pm.expect.fail(responseBody.error);",
" });",
"} else {",
" // Check if the response body is an empty array",
" if (Array.isArray(responseBody) && responseBody.length === 0) {",
" console.error(\"Test Failed: There is no Tenant created on this system!\");",
" pm.test('Empty Response', function () {",
" pm.expect.fail(\"There is no Tenant created on this system!\");",
" });",
" } else {",
" // Validate the response structure",
" pm.test('Response Validation', function () {",
" // Iterate through each object in the response",
" for (var key in responseBody) {",
" if (responseBody.hasOwnProperty(key)) {",
" var tenant = responseBody[key];",
"",
" pm.test('Tenant ' + tenant.name + ' Validation', function () {",
" pm.expect(tenant).to.be.an('object');",
" pm.expect(tenant).to.have.property('name').that.is.a('string');",
" pm.expect(tenant).to.have.property('tenantcode').that.is.a('string');",
" pm.expect(tenant).to.have.property('package_id').that.is.a('number');",
" pm.expect(tenant).to.have.property('package').that.is.a('string');",
" pm.expect(tenant).to.have.property('ext_length').that.is.a('number');",
" pm.expect(tenant).to.have.property('country_id').that.is.a('number');",
" pm.expect(tenant).to.have.property('country_code').that.is.a('number');",
" });",
" }",
" }",
" });",
" }",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{IP}}/index.php?apikey={{API_Key}}&action=pbxware.tenant.list",
"protocol": "http",
"host": [
"{{IP}}"
],
"path": [
"index.php"
],
"query": [
{
"key": "apikey",
"value": "{{API_Key}}"
},
{
"key": "action",
"value": "pbxware.tenant.list",
"description": "Response will consist of an array of tenants with array key being the Tenant ID."
}
]
}
},
"response": []
},
{
"name": "Listing Trunks",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.collectionVariables.unset(\"TrunkIDs\");",
"// Check for 200 OK response",
"pm.test('Status code is 200 OK', function () {",
" pm.response.to.have.status(200);",
"});",
"",
"// Parse the response JSON",
"var responseBody = pm.response.json();",
"",
"// Check if there is an error field in the response",
"if ('error' in responseBody) {",
" console.error(\"Test Failed: \" + responseBody.error);",
" pm.test('API Response Error', function () {",
" pm.expect.fail(responseBody.error);",
" });",
"} else {",
" // Validate the response structure",
" pm.test('Response Validation', function () {",
" pm.expect(responseBody).to.be.an('object');",
" ",
" // Get the existing TrunkIDs array from the collection variable",
" var trunkIDs = pm.collectionVariables.get('TrunkIDs') || [];",
"",
" // Loop through trunk data",
" for (var trunkID in responseBody) {",
" var trunkData = responseBody[trunkID];",
" ",
" // Validate specific properties for each trunk",
" pm.test('Trunk ' + trunkID + ' Data Validation', function () {",
" pm.expect(trunkData).to.be.an('object');",
" pm.expect(trunkData).to.have.property('name').that.is.a('string');",
" pm.expect(trunkData).to.have.property('protocol').that.is.a('string');",
" pm.expect(trunkData).to.have.property('provider_id').that.is.a('string');",
" pm.expect(trunkData).to.have.property('provider_name').that.is.a('string');",
" pm.expect(trunkData).to.have.property('status').that.is.oneOf(['enabled', 'disabled']);",
" ",
" // Push the trunk ID to the TrunkIDs array",
" trunkIDs.push(trunkID);",
" ",
" // Print the result for each trunk",
" console.log('Trunk ID:', trunkID);",
" console.log('Trunk Name:', trunkData.name);",
" console.log('Protocol:', trunkData.protocol);",
" console.log('Provider ID:', trunkData.provider_id);",
" console.log('Provider Name:', trunkData.provider_name);",
" console.log('Status:', trunkData.status);",
" });",
" }",
"",
" // Update the TrunkIDs array in the collection variable",
" pm.collectionVariables.set('TrunkIDs', trunkIDs);",
" pm.environment.set(\"TrunkIDs\", trunkIDs);",
" });",
"}",
""
],
"type": "text/javascript"
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://{{IP}}/index.php?apikey={{API_Key}}&action=pbxware.trunk.list",
"protocol": "http",
"host": [
"{{IP}}"
],
"path": [
"index.php"
],
"query": [
{
"key": "apikey",
"value": "{{API_Key}}"
},
{
"key": "action",
"value": "pbxware.trunk.list"
},
{
"key": "server",
"value": "{{Srv/Tenant-ID}}",
"description": "Filter trunks by server (does not apply in Tenant Mode)",
"disabled": true
}
]
}
},
"response": []
}
],
"variable": [
{
"key": "DID-IDs",
"value": ""
}
]
}