bandwidth-sdk 0.1.1 → 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.
Files changed (104) hide show
  1. package/coverage/clover.xml +64 -54
  2. package/coverage/coverage-final.json +11 -11
  3. package/coverage/lcov-report/index.html +15 -15
  4. package/coverage/lcov-report/node-sdk/api/calls-api.ts.html +2 -2
  5. package/coverage/lcov-report/node-sdk/api/conferences-api.ts.html +2 -2
  6. package/coverage/lcov-report/node-sdk/api/index.html +2 -2
  7. package/coverage/lcov-report/node-sdk/api/media-api.ts.html +2 -2
  8. package/coverage/lcov-report/node-sdk/api/messages-api.ts.html +2 -2
  9. package/coverage/lcov-report/node-sdk/api/mfaapi.ts.html +2 -2
  10. package/coverage/lcov-report/node-sdk/api/phone-number-lookup-api.ts.html +2 -2
  11. package/coverage/lcov-report/node-sdk/api/recordings-api.ts.html +2 -2
  12. package/coverage/lcov-report/node-sdk/api/statistics-api.ts.html +2 -2
  13. package/coverage/lcov-report/node-sdk/base.ts.html +2 -2
  14. package/coverage/lcov-report/node-sdk/common.ts.html +2 -2
  15. package/coverage/lcov-report/node-sdk/configuration.ts.html +2 -2
  16. package/coverage/lcov-report/node-sdk/index.html +2 -2
  17. package/coverage/lcov-report/node-sdk/models/bxml/Bxml.ts.html +5 -5
  18. package/coverage/lcov-report/node-sdk/models/bxml/NestableVerb.ts.html +39 -15
  19. package/coverage/lcov-report/node-sdk/models/bxml/Response.ts.html +5 -5
  20. package/coverage/lcov-report/node-sdk/models/bxml/Root.ts.html +64 -16
  21. package/coverage/lcov-report/node-sdk/models/bxml/Verb.ts.html +12 -12
  22. package/coverage/lcov-report/node-sdk/models/bxml/index.html +16 -16
  23. package/coverage/lcov-report/node-sdk/models/bxml/index.ts.html +2 -2
  24. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Bridge.ts.html +2 -2
  25. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Conference.ts.html +2 -2
  26. package/coverage/lcov-report/node-sdk/models/bxml/verbs/CustomParam.ts.html +2 -2
  27. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Forward.ts.html +2 -2
  28. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Gather.ts.html +11 -11
  29. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Hangup.ts.html +2 -2
  30. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Pause.ts.html +2 -2
  31. package/coverage/lcov-report/node-sdk/models/bxml/verbs/PauseRecording.ts.html +6 -6
  32. package/coverage/lcov-report/node-sdk/models/bxml/verbs/PhoneNumber.ts.html +2 -2
  33. package/coverage/lcov-report/node-sdk/models/bxml/verbs/PlayAudio.ts.html +2 -2
  34. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Record.ts.html +2 -2
  35. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Redirect.ts.html +2 -2
  36. package/coverage/lcov-report/node-sdk/models/bxml/verbs/ResumeRecording.ts.html +2 -2
  37. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Ring.ts.html +2 -2
  38. package/coverage/lcov-report/node-sdk/models/bxml/verbs/SendDtmf.ts.html +2 -2
  39. package/coverage/lcov-report/node-sdk/models/bxml/verbs/SipUri.ts.html +2 -2
  40. package/coverage/lcov-report/node-sdk/models/bxml/verbs/SpeakSentence.ts.html +2 -2
  41. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StartGather.ts.html +2 -2
  42. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StartRecording.ts.html +2 -2
  43. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StartStream.ts.html +10 -10
  44. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StartTranscription.ts.html +10 -10
  45. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StopGather.ts.html +2 -2
  46. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StopRecording.ts.html +2 -2
  47. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StopStream.ts.html +2 -2
  48. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StopTranscription.ts.html +2 -2
  49. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StreamParam.ts.html +2 -2
  50. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Tag.ts.html +2 -2
  51. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Transfer.ts.html +14 -11
  52. package/coverage/lcov-report/node-sdk/models/bxml/verbs/index.html +2 -2
  53. package/coverage/lcov-report/node-sdk/models/bxml/verbs/index.ts.html +2 -2
  54. package/coverage/lcov-report/node-sdk/models/call-direction-enum.ts.html +2 -2
  55. package/coverage/lcov-report/node-sdk/models/call-state-enum.ts.html +2 -2
  56. package/coverage/lcov-report/node-sdk/models/callback-method-enum.ts.html +2 -2
  57. package/coverage/lcov-report/node-sdk/models/conference-state-enum.ts.html +2 -2
  58. package/coverage/lcov-report/node-sdk/models/file-format-enum.ts.html +2 -2
  59. package/coverage/lcov-report/node-sdk/models/index.html +2 -2
  60. package/coverage/lcov-report/node-sdk/models/index.ts.html +2 -2
  61. package/coverage/lcov-report/node-sdk/models/list-message-direction-enum.ts.html +2 -2
  62. package/coverage/lcov-report/node-sdk/models/lookup-status-enum.ts.html +2 -2
  63. package/coverage/lcov-report/node-sdk/models/machine-detection-mode-enum.ts.html +2 -2
  64. package/coverage/lcov-report/node-sdk/models/message-direction-enum.ts.html +2 -2
  65. package/coverage/lcov-report/node-sdk/models/message-status-enum.ts.html +2 -2
  66. package/coverage/lcov-report/node-sdk/models/message-type-enum.ts.html +2 -2
  67. package/coverage/lcov-report/node-sdk/models/priority-enum.ts.html +2 -2
  68. package/coverage/lcov-report/node-sdk/models/recording-state-enum.ts.html +2 -2
  69. package/coverage/lcov-report/node-sdk/models/redirect-method-enum.ts.html +2 -2
  70. package/coverage/lcov-report/node-sdk/tests/callUtils.js.html +6 -6
  71. package/coverage/lcov-report/node-sdk/tests/index.html +2 -2
  72. package/coverage/lcov.info +134 -116
  73. package/dist/models/bxml/Bxml.d.ts +2 -2
  74. package/dist/models/bxml/Bxml.js +1 -1
  75. package/dist/models/bxml/NestableVerb.d.ts +2 -2
  76. package/dist/models/bxml/NestableVerb.js +12 -2
  77. package/dist/models/bxml/Response.d.ts +2 -2
  78. package/dist/models/bxml/Response.js +1 -1
  79. package/dist/models/bxml/Root.d.ts +7 -2
  80. package/dist/models/bxml/Root.js +19 -2
  81. package/dist/models/bxml/verbs/Gather.d.ts +5 -5
  82. package/dist/models/bxml/verbs/Gather.js +5 -5
  83. package/dist/models/bxml/verbs/StartStream.d.ts +5 -5
  84. package/dist/models/bxml/verbs/StartStream.js +5 -5
  85. package/dist/models/bxml/verbs/StartTranscription.d.ts +5 -5
  86. package/dist/models/bxml/verbs/StartTranscription.js +5 -5
  87. package/dist/models/bxml/verbs/Transfer.d.ts +6 -5
  88. package/dist/models/bxml/verbs/Transfer.js +5 -5
  89. package/models/bxml/Bxml.ts +2 -2
  90. package/models/bxml/NestableVerb.ts +11 -3
  91. package/models/bxml/Response.ts +2 -2
  92. package/models/bxml/Root.ts +19 -3
  93. package/models/bxml/verbs/Gather.ts +6 -6
  94. package/models/bxml/verbs/StartStream.ts +6 -6
  95. package/models/bxml/verbs/StartTranscription.ts +6 -6
  96. package/models/bxml/verbs/Transfer.ts +7 -6
  97. package/package.json +1 -1
  98. package/tests/integration/bxml.test.js +1 -0
  99. package/tests/unit/bxml/Bxml.test.js +33 -0
  100. package/tests/unit/bxml/Response.test.js +35 -2
  101. package/tests/unit/bxml/verbs/Gather.test.js +11 -3
  102. package/tests/unit/bxml/verbs/StartStream.test.js +11 -3
  103. package/tests/unit/bxml/verbs/StartTranscription.test.js +11 -3
  104. package/tests/unit/bxml/verbs/Transfer.test.js +16 -7
@@ -4,6 +4,7 @@ import { SipUri } from './SipUri';
4
4
  type NumberEntities = Array<PhoneNumber | SipUri>;
5
5
  interface TransferAttributes {
6
6
  transferCallerId?: string;
7
+ transferCallerDisplayName?: string;
7
8
  callTimeout?: number;
8
9
  transferCompleteUrl?: string;
9
10
  transferCompleteMethod?: string;
@@ -28,13 +29,13 @@ export declare class Transfer extends NestableVerb {
28
29
  /**
29
30
  * Creates an instance of Transfer
30
31
  * @param {TransferAttributes} attributes The attributes to add to the element
31
- * @param {NumberEntities} transferTo The number entities to transfer to
32
+ * @param {PhoneNumber | SipUri | NumberEntities} transferTo The number entities to transfer to
32
33
  */
33
- constructor(attributes?: TransferAttributes, transferTo?: NumberEntities);
34
+ constructor(attributes?: TransferAttributes, transferTo?: PhoneNumber | SipUri | NumberEntities);
34
35
  /**
35
- * Add a number entity to the transfer
36
- * @param {NumberEntities} recipient The number entity or entities to add
36
+ * Add a number entity or entities to the transfer
37
+ * @param {PhoneNumber | SipUri | NumberEntities} recipients The number entity or entities to add
37
38
  */
38
- addTransferRecipient(recipient: PhoneNumber | SipUri | NumberEntities): void;
39
+ addTransferRecipients(recipients: PhoneNumber | SipUri | NumberEntities): void;
39
40
  }
40
41
  export {};
@@ -28,17 +28,17 @@ var Transfer = /** @class */ (function (_super) {
28
28
  /**
29
29
  * Creates an instance of Transfer
30
30
  * @param {TransferAttributes} attributes The attributes to add to the element
31
- * @param {NumberEntities} transferTo The number entities to transfer to
31
+ * @param {PhoneNumber | SipUri | NumberEntities} transferTo The number entities to transfer to
32
32
  */
33
33
  function Transfer(attributes, transferTo) {
34
34
  return _super.call(this, 'Transfer', undefined, attributes, transferTo) || this;
35
35
  }
36
36
  /**
37
- * Add a number entity to the transfer
38
- * @param {NumberEntities} recipient The number entity or entities to add
37
+ * Add a number entity or entities to the transfer
38
+ * @param {PhoneNumber | SipUri | NumberEntities} recipients The number entity or entities to add
39
39
  */
40
- Transfer.prototype.addTransferRecipient = function (recipient) {
41
- this.nestedVerbs = this.nestedVerbs.concat(recipient);
40
+ Transfer.prototype.addTransferRecipients = function (recipients) {
41
+ this.nestedVerbs = this.nestedVerbs.concat(recipients);
42
42
  };
43
43
  return Transfer;
44
44
  }(NestableVerb_1.NestableVerb));
@@ -13,9 +13,9 @@ export class Bxml extends Root {
13
13
 
14
14
  /**
15
15
  * Creates an instance of Bxml
16
- * @param nestedVerbs [Array<Verb>] Array of nested verbs
16
+ * @param nestedVerbs [Verb | Array<Verb>] Nested Verb or Array of Nested Verbs
17
17
  */
18
- constructor(nestedVerbs?: Verb[]) {
18
+ constructor(nestedVerbs?: Verb | Verb[]) {
19
19
  super('Bxml', nestedVerbs)
20
20
  }
21
21
  }
@@ -19,11 +19,19 @@ export class NestableVerb extends Verb {
19
19
  * @param name [string] Name of the XML element
20
20
  * @param content [string] Content of the XML element
21
21
  * @param attributes [object] Attributes of the XML element
22
- * @param nestedVerbs [Array<Verb>] Array of nested verbs
22
+ * @param nestedVerbs [Verb | Array<Verb>] Nested Verb or Array of Nested Verbs
23
23
  */
24
- constructor(name: string, content?: string, attributes?: object, nestedVerbs?: Verb[]) {
24
+ constructor(name: string, content?: string, attributes?: object, nestedVerbs?: Verb | Verb[]) {
25
25
  super(name, content, attributes);
26
- this.nestedVerbs = nestedVerbs || [];
26
+ if (nestedVerbs) {
27
+ if (nestedVerbs instanceof Array) {
28
+ this.nestedVerbs = nestedVerbs;
29
+ } else {
30
+ this.nestedVerbs = [nestedVerbs];
31
+ }
32
+ } else {
33
+ this.nestedVerbs = [];
34
+ }
27
35
  }
28
36
 
29
37
  /**
@@ -13,9 +13,9 @@ export class Response extends Root {
13
13
 
14
14
  /**
15
15
  * Creates an instance of Response
16
- * @param nestedVerbs [Array<Verb>] Array of nested verbs
16
+ * @param nestedVerbs [Verb | Array<Verb>] Nested Verb or Array of Nested Verbs
17
17
  */
18
- constructor(nestedVerbs?: Verb[]) {
18
+ constructor(nestedVerbs?: Verb | Verb[]) {
19
19
  super('Response', nestedVerbs)
20
20
  }
21
21
  }
@@ -17,11 +17,19 @@ export class Root {
17
17
  /**
18
18
  * Creates an instance of Root
19
19
  * @param name [string] Name of the XML element
20
- * @param nestedVerbs [Array<Verb>] Array of nested verbs
20
+ * @param nestedVerbs [Verb | Array<Verb>] Nested Verb or Array of Nested Verbs
21
21
  */
22
- constructor(name: string, nestedVerbs?: Verb[]) {
22
+ constructor(name: string, nestedVerbs?: Verb | Verb[]) {
23
23
  this.name = name;
24
- this.nestedVerbs = nestedVerbs;
24
+ if (nestedVerbs) {
25
+ if (nestedVerbs instanceof Array) {
26
+ this.nestedVerbs = nestedVerbs;
27
+ } else {
28
+ this.nestedVerbs = [nestedVerbs];
29
+ }
30
+ } else {
31
+ this.nestedVerbs = [];
32
+ }
25
33
  }
26
34
 
27
35
  /**
@@ -33,6 +41,14 @@ export class Root {
33
41
  return xml;
34
42
  }
35
43
 
44
+ /**
45
+ * Add a verb or verbs to the root element
46
+ * @param {Verb | Verb[]} verbs The verb or verbs to add
47
+ */
48
+ addVerbs(verbs: Verb | Verb[]): void {
49
+ this.nestedVerbs = this.nestedVerbs.concat(verbs);
50
+ }
51
+
36
52
  /**
37
53
  * Return BXML representation of this element
38
54
  * @param options XML Serialization options
@@ -35,9 +35,9 @@ export class Gather extends NestableVerb {
35
35
  /**
36
36
  * Creates an instance of Gather
37
37
  * @param {GatherAttributes} attributes The attributes to add to the element
38
- * @param {AudioVerbs} audioVerbs The audio verbs to be played
38
+ * @param {PlayAudio | SpeakSentence | AudioVerbs} audioVerbs The audio verbs to be played
39
39
  */
40
- constructor(attributes?: GatherAttributes, audioVerbs?: AudioVerbs) {
40
+ constructor(attributes?: GatherAttributes, audioVerbs?: PlayAudio | SpeakSentence | AudioVerbs) {
41
41
  super('Gather', undefined, attributes, audioVerbs);
42
42
  }
43
43
 
@@ -50,10 +50,10 @@ export class Gather extends NestableVerb {
50
50
  }
51
51
 
52
52
  /**
53
- * Add an audio verb to the gather
54
- * @param {AudioVerbs} audioVerb The audio verb or verbs to add
53
+ * Add an audio verb or verbs to the gather
54
+ * @param {PlayAudio | SpeakSentence | AudioVerbs} audioVerbs The audio verb or verbs to add
55
55
  */
56
- addAudioVerb(audioVerb: PlayAudio | SpeakSentence | AudioVerbs): void {
57
- this.nestedVerbs = this.nestedVerbs.concat(audioVerb);
56
+ addAudioVerbs(audioVerbs: PlayAudio | SpeakSentence | AudioVerbs): void {
57
+ this.nestedVerbs = this.nestedVerbs.concat(audioVerbs);
58
58
  }
59
59
  }
@@ -23,17 +23,17 @@ export class StartStream extends NestableVerb {
23
23
  /**
24
24
  * Creates an instance of StartStream
25
25
  * @param {StartStreamAttributes} attributes The attributes to add to the element
26
- * @param {StreamParam[]} streamParams The stream params to add to the element
26
+ * @param {StreamParam | StreamParam[]} streamParams The stream params to add to the element
27
27
  */
28
- constructor(attributes?: StartStreamAttributes, streamParams?: StreamParam[]) {
28
+ constructor(attributes?: StartStreamAttributes, streamParams?: StreamParam | StreamParam[]) {
29
29
  super('StartStream', undefined, attributes, streamParams);
30
30
  }
31
31
 
32
32
  /**
33
- * Add a stream param to the StartStream
34
- * @param {StreamParam} streamParam The stream param to add
33
+ * Add a stream param or params to the StartStream
34
+ * @param {StreamParam | StreamParam[]} streamParams The stream param or params to add
35
35
  */
36
- addStreamParam(streamParam: StreamParam | StreamParam[]): void {
37
- this.nestedVerbs = this.nestedVerbs.concat(streamParam);
36
+ addStreamParams(streamParams: StreamParam | StreamParam[]): void {
37
+ this.nestedVerbs = this.nestedVerbs.concat(streamParams);
38
38
  }
39
39
  }
@@ -24,17 +24,17 @@ export class StartTranscription extends NestableVerb {
24
24
  /**
25
25
  * Creates an instance of StartTranscription
26
26
  * @param {StartTranscriptionAttributes} attributes The attributes to add to the element
27
- * @param {CustomParam[]} customParams The custom params to add to the element
27
+ * @param {CustomParam | CustomParam[]} customParams The custom params to add to the element
28
28
  */
29
- constructor(attributes?: StartTranscriptionAttributes, customParams?: CustomParam[]) {
29
+ constructor(attributes?: StartTranscriptionAttributes, customParams?: CustomParam | CustomParam[]) {
30
30
  super('StartTranscription', undefined, attributes, customParams);
31
31
  }
32
32
 
33
33
  /**
34
- * Add a custom param to the StartTranscription
35
- * @param {CustomParam} customParam The custom param to add
34
+ * Add a custom param or params to the StartTranscription
35
+ * @param {CustomParam | CustomParam[]} customParams The custom param or params to add
36
36
  */
37
- addCustomParam(customParam: CustomParam | CustomParam[]): void {
38
- this.nestedVerbs = this.nestedVerbs.concat(customParam);
37
+ addCustomParams(customParams: CustomParam | CustomParam[]): void {
38
+ this.nestedVerbs = this.nestedVerbs.concat(customParams);
39
39
  }
40
40
  }
@@ -6,6 +6,7 @@ type NumberEntities = Array<PhoneNumber | SipUri>;
6
6
 
7
7
  interface TransferAttributes {
8
8
  transferCallerId?: string;
9
+ transferCallerDisplayName?: string;
9
10
  callTimeout?: number;
10
11
  transferCompleteUrl?: string;
11
12
  transferCompleteMethod?: string;
@@ -32,17 +33,17 @@ export class Transfer extends NestableVerb {
32
33
  /**
33
34
  * Creates an instance of Transfer
34
35
  * @param {TransferAttributes} attributes The attributes to add to the element
35
- * @param {NumberEntities} transferTo The number entities to transfer to
36
+ * @param {PhoneNumber | SipUri | NumberEntities} transferTo The number entities to transfer to
36
37
  */
37
- constructor(attributes?: TransferAttributes, transferTo?: NumberEntities) {
38
+ constructor(attributes?: TransferAttributes, transferTo?: PhoneNumber | SipUri | NumberEntities) {
38
39
  super('Transfer', undefined, attributes, transferTo);
39
40
  }
40
41
 
41
42
  /**
42
- * Add a number entity to the transfer
43
- * @param {NumberEntities} recipient The number entity or entities to add
43
+ * Add a number entity or entities to the transfer
44
+ * @param {PhoneNumber | SipUri | NumberEntities} recipients The number entity or entities to add
44
45
  */
45
- addTransferRecipient(recipient: PhoneNumber | SipUri | NumberEntities): void {
46
- this.nestedVerbs = this.nestedVerbs.concat(recipient);
46
+ addTransferRecipients(recipients: PhoneNumber | SipUri | NumberEntities): void {
47
+ this.nestedVerbs = this.nestedVerbs.concat(recipients);
47
48
  }
48
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bandwidth-sdk",
3
- "version": "0.1.1",
3
+ "version": "1.0.0",
4
4
  "description": "OpenAPI client for bandwidth-sdk",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "repository": {
@@ -108,6 +108,7 @@ describe('BXML Integration Tests', () => {
108
108
 
109
109
  const transferAttributes = {
110
110
  transferCallerId: '+19195551234',
111
+ transferCallerDisplayName: 'initialDisplayName',
111
112
  callTimeout: 5,
112
113
  transferCompleteUrl: 'https://initial.com',
113
114
  transferCompleteMethod: 'POST',
@@ -1,7 +1,10 @@
1
1
  const { Bxml } = require('../../../models/bxml/Bxml');
2
+ const { PauseRecording } = require('../../../models/bxml/verbs/PauseRecording');
2
3
  const { Root } = require('../../../models/bxml/Root');
3
4
 
4
5
  describe('Bxml', () => {
6
+ const pauseRecording = new PauseRecording();
7
+
5
8
  test('should create a bxml object', () => {
6
9
  const bxml = new Bxml();
7
10
  const expected = '<?xml version="1.0" encoding="UTF-8"?><Bxml/>';
@@ -10,4 +13,34 @@ describe('Bxml', () => {
10
13
  expect(bxml).toBeInstanceOf(Root);
11
14
  expect(bxml.toBxml()).toBe(expected);
12
15
  });
16
+
17
+ test('should initialize with a single nested verb', () => {
18
+ const bxml = new Bxml(pauseRecording);
19
+ const expected = '<?xml version="1.0" encoding="UTF-8"?><Bxml><PauseRecording/></Bxml>';
20
+
21
+ expect(bxml.toBxml()).toBe(expected);
22
+ });
23
+
24
+ test('should initialize with multiple nested verbs', () => {
25
+ const bxml = new Bxml([pauseRecording, pauseRecording]);
26
+ const expected = '<?xml version="1.0" encoding="UTF-8"?><Bxml><PauseRecording/><PauseRecording/></Bxml>';
27
+
28
+ expect(bxml.toBxml()).toBe(expected);
29
+ });
30
+
31
+ test('should add a single nested verb', () => {
32
+ const bxml = new Bxml();
33
+ bxml.addVerbs(pauseRecording);
34
+ const expected = '<?xml version="1.0" encoding="UTF-8"?><Bxml><PauseRecording/></Bxml>';
35
+
36
+ expect(bxml.toBxml()).toBe(expected);
37
+ });
38
+
39
+ test('should add multiple nested verbs', () => {
40
+ const bxml = new Bxml();
41
+ bxml.addVerbs([pauseRecording, pauseRecording]);
42
+ const expected = '<?xml version="1.0" encoding="UTF-8"?><Bxml><PauseRecording/><PauseRecording/></Bxml>';
43
+
44
+ expect(bxml.toBxml()).toBe(expected);
45
+ });
13
46
  });
@@ -1,8 +1,11 @@
1
1
  const { Response } = require('../../../models/bxml/Response');
2
+ const { PauseRecording } = require('../../../models/bxml/verbs/PauseRecording');
2
3
  const { Root } = require('../../../models/bxml/Root');
3
4
 
4
- describe('Bxml', () => {
5
- test('should create a bxml object', () => {
5
+ describe('Response', () => {
6
+ const pauseRecording = new PauseRecording();
7
+
8
+ test('should create a response object', () => {
6
9
  const response = new Response();
7
10
  const expected = '<?xml version="1.0" encoding="UTF-8"?><Response/>';
8
11
 
@@ -10,4 +13,34 @@ describe('Bxml', () => {
10
13
  expect(response).toBeInstanceOf(Root);
11
14
  expect(response.toBxml()).toBe(expected);
12
15
  });
16
+
17
+ test('should initialize with a single nested verb', () => {
18
+ const response = new Response(pauseRecording);
19
+ const expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PauseRecording/></Response>';
20
+
21
+ expect(response.toBxml()).toBe(expected);
22
+ });
23
+
24
+ test('should initialize with multiple nested verbs', () => {
25
+ const response = new Response([pauseRecording, pauseRecording]);
26
+ const expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PauseRecording/><PauseRecording/></Response>';
27
+
28
+ expect(response.toBxml()).toBe(expected);
29
+ });
30
+
31
+ test('should add a single nested verb', () => {
32
+ const response = new Response();
33
+ response.addVerbs(pauseRecording);
34
+ const expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PauseRecording/></Response>';
35
+
36
+ expect(response.toBxml()).toBe(expected);
37
+ });
38
+
39
+ test('should add multiple nested verbs', () => {
40
+ const response = new Response();
41
+ response.addVerbs([pauseRecording, pauseRecording]);
42
+ const expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PauseRecording/><PauseRecording/></Response>';
43
+
44
+ expect(response.toBxml()).toBe(expected);
45
+ });
13
46
  });
@@ -34,7 +34,7 @@ describe('Gather', () => {
34
34
  });
35
35
 
36
36
  test('should create a Gather Verb with nested PlayAudio and SpeakSentence', () => {
37
- let gather = new Gather(attributes, [playAudio]);
37
+ let gather = new Gather(attributes, playAudio);
38
38
  const expected = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio></Gather>';
39
39
  const expectedSingle = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio><SpeakSentence><lang xml:lang="es-MX">Hola</lang>nodejs speak sentence <emphasis>SSML test</emphasis></SpeakSentence></Gather>';
40
40
  const expectedMultiple = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio><SpeakSentence><lang xml:lang="es-MX">Hola</lang>nodejs speak sentence <emphasis>SSML test</emphasis></SpeakSentence><SpeakSentence><lang xml:lang="es-MX">Hola</lang>nodejs speak sentence <emphasis>SSML test</emphasis></SpeakSentence><PlayAudio>https://audio.url/audio1.wav</PlayAudio></Gather>';
@@ -43,10 +43,18 @@ describe('Gather', () => {
43
43
  expect(gather).toBeInstanceOf(Verb);
44
44
  expect(gather.toBxml()).toBe(expected);
45
45
 
46
- gather.addAudioVerb(speakSentence);
46
+ gather.addAudioVerbs(speakSentence);
47
47
  expect(gather.toBxml()).toBe(expectedSingle);
48
48
 
49
- gather.addAudioVerb([speakSentence, playAudio]);
49
+ gather.addAudioVerbs([speakSentence, playAudio]);
50
50
  expect(gather.toBxml()).toBe(expectedMultiple);
51
51
  });
52
+
53
+ test('should test the addAudioVerbs method when no verbs are initially nested', () => {
54
+ const gather = new Gather(attributes);
55
+ const expected = '<Gather gatherUrl="https://initial.com" gatherMethod="POST" gatherFallbackUrl="https://initial.com" gatherFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" terminatingDigits="5" maxDigits="5" interDigitTimeout="5" firstDigitTimeout="5" repeatCount="5"><PlayAudio>https://audio.url/audio1.wav</PlayAudio></Gather>';
56
+
57
+ gather.addAudioVerbs(playAudio);
58
+ expect(gather.toBxml()).toBe(expected);
59
+ });
52
60
  });
@@ -26,7 +26,7 @@ describe('StartStream', () => {
26
26
  });
27
27
 
28
28
  test('should create a StartStream Verb with nested StreamParams', () => {
29
- let startStream = new StartStream(attributes, [streamParam1]);
29
+ let startStream = new StartStream(attributes, streamParam1);
30
30
  const expected = '<StartStream name="initialName" tracks="inbound" destination="https://initial.com" streamEventUrl="https://initial.com" streamEventMethod="POST" username="initialUsername" password="initialPassword"><StreamParam name="streamParamName1" value="streamParamValue1"/></StartStream>';
31
31
  const expectedSingle = '<StartStream name="initialName" tracks="inbound" destination="https://initial.com" streamEventUrl="https://initial.com" streamEventMethod="POST" username="initialUsername" password="initialPassword"><StreamParam name="streamParamName1" value="streamParamValue1"/><StreamParam name="streamParamName2" value="streamParamValue2"/></StartStream>';
32
32
  const expectedMultiple = '<StartStream name="initialName" tracks="inbound" destination="https://initial.com" streamEventUrl="https://initial.com" streamEventMethod="POST" username="initialUsername" password="initialPassword"><StreamParam name="streamParamName1" value="streamParamValue1"/><StreamParam name="streamParamName2" value="streamParamValue2"/><StreamParam name="streamParamName1" value="streamParamValue1"/><StreamParam name="streamParamName2" value="streamParamValue2"/></StartStream>';
@@ -35,10 +35,18 @@ describe('StartStream', () => {
35
35
  expect(startStream).toBeInstanceOf(Verb);
36
36
  expect(startStream.toBxml()).toBe(expected);
37
37
 
38
- startStream.addStreamParam(streamParam2);
38
+ startStream.addStreamParams(streamParam2);
39
39
  expect(startStream.toBxml()).toBe(expectedSingle);
40
40
 
41
- startStream.addStreamParam([streamParam1, streamParam2]);
41
+ startStream.addStreamParams([streamParam1, streamParam2]);
42
42
  expect(startStream.toBxml()).toBe(expectedMultiple);
43
43
  });
44
+
45
+ test('should test the addStreamParams method when no verbs are initially nested', () => {
46
+ const startStream = new StartStream(attributes);
47
+ const expected = '<StartStream name="initialName" tracks="inbound" destination="https://initial.com" streamEventUrl="https://initial.com" streamEventMethod="POST" username="initialUsername" password="initialPassword"><StreamParam name="streamParamName1" value="streamParamValue1"/></StartStream>';
48
+
49
+ startStream.addStreamParams(streamParam1);
50
+ expect(startStream.toBxml()).toBe(expected);
51
+ });
44
52
  });
@@ -27,7 +27,7 @@ describe('StartTranscription', () => {
27
27
  });
28
28
 
29
29
  test('should create a StartTranscription Verb with nested CustomParam', () => {
30
- let startTranscription = new StartTranscription(attributes, [customParam1]);
30
+ let startTranscription = new StartTranscription(attributes, customParam1);
31
31
  const expected = '<StartTranscription name="initialName" tracks="inbound" transcriptionEventUrl="https://initial.com" transcriptionEventMethod="POST" username="initialUsername" password="initialPassword" destination="https://initial.com" stabilized="true"><CustomParam name="customParamName1" value="customParamValue1"/></StartTranscription>';
32
32
  const expectedSingle = '<StartTranscription name="initialName" tracks="inbound" transcriptionEventUrl="https://initial.com" transcriptionEventMethod="POST" username="initialUsername" password="initialPassword" destination="https://initial.com" stabilized="true"><CustomParam name="customParamName1" value="customParamValue1"/><CustomParam name="customParamName2" value="customParamValue2"/></StartTranscription>';
33
33
  const expectedMultiple = '<StartTranscription name="initialName" tracks="inbound" transcriptionEventUrl="https://initial.com" transcriptionEventMethod="POST" username="initialUsername" password="initialPassword" destination="https://initial.com" stabilized="true"><CustomParam name="customParamName1" value="customParamValue1"/><CustomParam name="customParamName2" value="customParamValue2"/><CustomParam name="customParamName1" value="customParamValue1"/><CustomParam name="customParamName2" value="customParamValue2"/></StartTranscription>';
@@ -36,10 +36,18 @@ describe('StartTranscription', () => {
36
36
  expect(startTranscription).toBeInstanceOf(Verb);
37
37
  expect(startTranscription.toBxml()).toBe(expected);
38
38
 
39
- startTranscription.addCustomParam(customParam2);
39
+ startTranscription.addCustomParams(customParam2);
40
40
  expect(startTranscription.toBxml()).toBe(expectedSingle);
41
41
 
42
- startTranscription.addCustomParam([customParam1, customParam2]);
42
+ startTranscription.addCustomParams([customParam1, customParam2]);
43
43
  expect(startTranscription.toBxml()).toBe(expectedMultiple);
44
44
  });
45
+
46
+ test('should test the addCustomParams method method when no verbs are initially nested', () => {
47
+ const startTranscription = new StartTranscription(attributes);
48
+ const expected = '<StartTranscription name="initialName" tracks="inbound" transcriptionEventUrl="https://initial.com" transcriptionEventMethod="POST" username="initialUsername" password="initialPassword" destination="https://initial.com" stabilized="true"><CustomParam name="customParamName1" value="customParamValue1"/></StartTranscription>';
49
+
50
+ startTranscription.addCustomParams(customParam1);
51
+ expect(startTranscription.toBxml()).toBe(expected);
52
+ });
45
53
  });
@@ -6,6 +6,7 @@ const { Transfer } = require('../../../../models/bxml/verbs/Transfer');
6
6
  describe('Transfer', () => {
7
7
  const attributes = {
8
8
  transferCallerId: '+19195551234',
9
+ transferCallerDisplayName: 'initialDisplayName',
9
10
  callTimeout: 5,
10
11
  transferCompleteUrl: 'https://initial.com',
11
12
  transferCompleteMethod: 'POST',
@@ -25,7 +26,7 @@ describe('Transfer', () => {
25
26
 
26
27
  test('should create a Transfer Verb', () => {
27
28
  const transfer = new Transfer(attributes);
28
- const expected = '<Transfer transferCallerId="+19195551234" callTimeout="5" transferCompleteUrl="https://initial.com" transferCompleteMethod="POST" transferCompleteFallbackUrl="https://initial.com" transferCompleteFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" diversionTreatment="propagate" diversionReason="user-busy"/>';
29
+ const expected = '<Transfer transferCallerId="+19195551234" transferCallerDisplayName="initialDisplayName" callTimeout="5" transferCompleteUrl="https://initial.com" transferCompleteMethod="POST" transferCompleteFallbackUrl="https://initial.com" transferCompleteFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" diversionTreatment="propagate" diversionReason="user-busy"/>';
29
30
 
30
31
  expect(transfer).toBeInstanceOf(Transfer);
31
32
  expect(transfer).toBeInstanceOf(Verb);
@@ -33,19 +34,27 @@ describe('Transfer', () => {
33
34
  });
34
35
 
35
36
  test('should create a Transfer Verb with nested PhoneNumber and SipUri', () => {
36
- let transfer = new Transfer(attributes, [phoneNumber]);
37
- const expected = '<Transfer transferCallerId="+19195551234" callTimeout="5" transferCompleteUrl="https://initial.com" transferCompleteMethod="POST" transferCompleteFallbackUrl="https://initial.com" transferCompleteFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" diversionTreatment="propagate" diversionReason="user-busy"><PhoneNumber>+19195551234</PhoneNumber></Transfer>';
38
- const expectedSingle = '<Transfer transferCallerId="+19195551234" callTimeout="5" transferCompleteUrl="https://initial.com" transferCompleteMethod="POST" transferCompleteFallbackUrl="https://initial.com" transferCompleteFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" diversionTreatment="propagate" diversionReason="user-busy"><PhoneNumber>+19195551234</PhoneNumber><SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri></Transfer>';
39
- const expectedMultiple = '<Transfer transferCallerId="+19195551234" callTimeout="5" transferCompleteUrl="https://initial.com" transferCompleteMethod="POST" transferCompleteFallbackUrl="https://initial.com" transferCompleteFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" diversionTreatment="propagate" diversionReason="user-busy"><PhoneNumber>+19195551234</PhoneNumber><SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri><SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri><PhoneNumber>+19195551234</PhoneNumber></Transfer>';
37
+ let transfer = new Transfer(attributes, phoneNumber);
38
+ const expected = '<Transfer transferCallerId="+19195551234" transferCallerDisplayName="initialDisplayName" callTimeout="5" transferCompleteUrl="https://initial.com" transferCompleteMethod="POST" transferCompleteFallbackUrl="https://initial.com" transferCompleteFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" diversionTreatment="propagate" diversionReason="user-busy"><PhoneNumber>+19195551234</PhoneNumber></Transfer>';
39
+ const expectedSingle = '<Transfer transferCallerId="+19195551234" transferCallerDisplayName="initialDisplayName" callTimeout="5" transferCompleteUrl="https://initial.com" transferCompleteMethod="POST" transferCompleteFallbackUrl="https://initial.com" transferCompleteFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" diversionTreatment="propagate" diversionReason="user-busy"><PhoneNumber>+19195551234</PhoneNumber><SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri></Transfer>';
40
+ const expectedMultiple = '<Transfer transferCallerId="+19195551234" transferCallerDisplayName="initialDisplayName" callTimeout="5" transferCompleteUrl="https://initial.com" transferCompleteMethod="POST" transferCompleteFallbackUrl="https://initial.com" transferCompleteFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" diversionTreatment="propagate" diversionReason="user-busy"><PhoneNumber>+19195551234</PhoneNumber><SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri><SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri><PhoneNumber>+19195551234</PhoneNumber></Transfer>';
40
41
 
41
42
  expect(transfer).toBeInstanceOf(Transfer);
42
43
  expect(transfer).toBeInstanceOf(Verb);
43
44
  expect(transfer.toBxml()).toBe(expected);
44
45
 
45
- transfer.addTransferRecipient(sipUri);
46
+ transfer.addTransferRecipients(sipUri);
46
47
  expect(transfer.toBxml()).toBe(expectedSingle);
47
48
 
48
- transfer.addTransferRecipient([sipUri, phoneNumber]);
49
+ transfer.addTransferRecipients([sipUri, phoneNumber]);
49
50
  expect(transfer.toBxml()).toBe(expectedMultiple);
50
51
  });
52
+
53
+ test('should test the addTransferRecipients method method when no verbs are initially nested', () => {
54
+ const transfer = new Transfer(attributes);
55
+ const expected = '<Transfer transferCallerId="+19195551234" transferCallerDisplayName="initialDisplayName" callTimeout="5" transferCompleteUrl="https://initial.com" transferCompleteMethod="POST" transferCompleteFallbackUrl="https://initial.com" transferCompleteFallbackMethod="POST" username="initialUsername" password="initialPassword" fallbackUsername="initialFallbackUsername" fallbackPassword="initialFallbackPassword" tag="initialTag" diversionTreatment="propagate" diversionReason="user-busy"><PhoneNumber>+19195551234</PhoneNumber></Transfer>';
56
+
57
+ transfer.addTransferRecipients(phoneNumber);
58
+ expect(transfer.toBxml()).toBe(expected);
59
+ });
51
60
  });