bandwidth-sdk 0.1.0 → 0.2.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 (109) hide show
  1. package/.github/workflows/test-nightly.yml +1 -0
  2. package/.github/workflows/test-pr.yml +1 -0
  3. package/README.md +2 -2
  4. package/coverage/clover.xml +61 -51
  5. package/coverage/coverage-final.json +11 -11
  6. package/coverage/lcov-report/index.html +14 -14
  7. package/coverage/lcov-report/node-sdk/api/calls-api.ts.html +1 -1
  8. package/coverage/lcov-report/node-sdk/api/conferences-api.ts.html +1 -1
  9. package/coverage/lcov-report/node-sdk/api/index.html +1 -1
  10. package/coverage/lcov-report/node-sdk/api/media-api.ts.html +1 -1
  11. package/coverage/lcov-report/node-sdk/api/messages-api.ts.html +1 -1
  12. package/coverage/lcov-report/node-sdk/api/mfaapi.ts.html +1 -1
  13. package/coverage/lcov-report/node-sdk/api/phone-number-lookup-api.ts.html +1 -1
  14. package/coverage/lcov-report/node-sdk/api/recordings-api.ts.html +1 -1
  15. package/coverage/lcov-report/node-sdk/api/statistics-api.ts.html +1 -1
  16. package/coverage/lcov-report/node-sdk/base.ts.html +1 -1
  17. package/coverage/lcov-report/node-sdk/common.ts.html +1 -1
  18. package/coverage/lcov-report/node-sdk/configuration.ts.html +1 -1
  19. package/coverage/lcov-report/node-sdk/index.html +1 -1
  20. package/coverage/lcov-report/node-sdk/models/bxml/Bxml.ts.html +4 -4
  21. package/coverage/lcov-report/node-sdk/models/bxml/NestableVerb.ts.html +38 -14
  22. package/coverage/lcov-report/node-sdk/models/bxml/Response.ts.html +4 -4
  23. package/coverage/lcov-report/node-sdk/models/bxml/Root.ts.html +63 -15
  24. package/coverage/lcov-report/node-sdk/models/bxml/Verb.ts.html +11 -11
  25. package/coverage/lcov-report/node-sdk/models/bxml/index.html +15 -15
  26. package/coverage/lcov-report/node-sdk/models/bxml/index.ts.html +1 -1
  27. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Bridge.ts.html +1 -1
  28. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Conference.ts.html +1 -1
  29. package/coverage/lcov-report/node-sdk/models/bxml/verbs/CustomParam.ts.html +1 -1
  30. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Forward.ts.html +1 -1
  31. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Gather.ts.html +10 -10
  32. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Hangup.ts.html +1 -1
  33. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Pause.ts.html +1 -1
  34. package/coverage/lcov-report/node-sdk/models/bxml/verbs/PauseRecording.ts.html +5 -5
  35. package/coverage/lcov-report/node-sdk/models/bxml/verbs/PhoneNumber.ts.html +1 -1
  36. package/coverage/lcov-report/node-sdk/models/bxml/verbs/PlayAudio.ts.html +1 -1
  37. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Record.ts.html +1 -1
  38. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Redirect.ts.html +1 -1
  39. package/coverage/lcov-report/node-sdk/models/bxml/verbs/ResumeRecording.ts.html +1 -1
  40. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Ring.ts.html +1 -1
  41. package/coverage/lcov-report/node-sdk/models/bxml/verbs/SendDtmf.ts.html +1 -1
  42. package/coverage/lcov-report/node-sdk/models/bxml/verbs/SipUri.ts.html +1 -1
  43. package/coverage/lcov-report/node-sdk/models/bxml/verbs/SpeakSentence.ts.html +1 -1
  44. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StartGather.ts.html +1 -1
  45. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StartRecording.ts.html +1 -1
  46. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StartStream.ts.html +9 -9
  47. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StartTranscription.ts.html +9 -9
  48. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StopGather.ts.html +1 -1
  49. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StopRecording.ts.html +1 -1
  50. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StopStream.ts.html +1 -1
  51. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StopTranscription.ts.html +1 -1
  52. package/coverage/lcov-report/node-sdk/models/bxml/verbs/StreamParam.ts.html +1 -1
  53. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Tag.ts.html +1 -1
  54. package/coverage/lcov-report/node-sdk/models/bxml/verbs/Transfer.ts.html +9 -9
  55. package/coverage/lcov-report/node-sdk/models/bxml/verbs/index.html +1 -1
  56. package/coverage/lcov-report/node-sdk/models/bxml/verbs/index.ts.html +1 -1
  57. package/coverage/lcov-report/node-sdk/models/call-direction-enum.ts.html +1 -1
  58. package/coverage/lcov-report/node-sdk/models/call-state-enum.ts.html +1 -1
  59. package/coverage/lcov-report/node-sdk/models/callback-method-enum.ts.html +1 -1
  60. package/coverage/lcov-report/node-sdk/models/conference-state-enum.ts.html +1 -1
  61. package/coverage/lcov-report/node-sdk/models/file-format-enum.ts.html +1 -1
  62. package/coverage/lcov-report/node-sdk/models/index.html +1 -1
  63. package/coverage/lcov-report/node-sdk/models/index.ts.html +1 -1
  64. package/coverage/lcov-report/node-sdk/models/list-message-direction-enum.ts.html +1 -1
  65. package/coverage/lcov-report/node-sdk/models/lookup-status-enum.ts.html +1 -1
  66. package/coverage/lcov-report/node-sdk/models/machine-detection-mode-enum.ts.html +1 -1
  67. package/coverage/lcov-report/node-sdk/models/message-direction-enum.ts.html +1 -1
  68. package/coverage/lcov-report/node-sdk/models/message-status-enum.ts.html +1 -1
  69. package/coverage/lcov-report/node-sdk/models/message-type-enum.ts.html +1 -1
  70. package/coverage/lcov-report/node-sdk/models/priority-enum.ts.html +1 -1
  71. package/coverage/lcov-report/node-sdk/models/recording-state-enum.ts.html +1 -1
  72. package/coverage/lcov-report/node-sdk/models/redirect-method-enum.ts.html +1 -1
  73. package/coverage/lcov-report/node-sdk/tests/callUtils.js.html +5 -5
  74. package/coverage/lcov-report/node-sdk/tests/index.html +1 -1
  75. package/coverage/lcov.info +127 -109
  76. package/custom_templates/README.mustache +45 -0
  77. package/custom_templates/package.mustache +1 -1
  78. package/dist/models/bxml/Bxml.d.ts +2 -2
  79. package/dist/models/bxml/Bxml.js +1 -1
  80. package/dist/models/bxml/NestableVerb.d.ts +2 -2
  81. package/dist/models/bxml/NestableVerb.js +12 -2
  82. package/dist/models/bxml/Response.d.ts +2 -2
  83. package/dist/models/bxml/Response.js +1 -1
  84. package/dist/models/bxml/Root.d.ts +7 -2
  85. package/dist/models/bxml/Root.js +19 -2
  86. package/dist/models/bxml/verbs/Gather.d.ts +5 -5
  87. package/dist/models/bxml/verbs/Gather.js +5 -5
  88. package/dist/models/bxml/verbs/StartStream.d.ts +5 -5
  89. package/dist/models/bxml/verbs/StartStream.js +5 -5
  90. package/dist/models/bxml/verbs/StartTranscription.d.ts +5 -5
  91. package/dist/models/bxml/verbs/StartTranscription.js +5 -5
  92. package/dist/models/bxml/verbs/Transfer.d.ts +5 -5
  93. package/dist/models/bxml/verbs/Transfer.js +5 -5
  94. package/models/bxml/Bxml.ts +2 -2
  95. package/models/bxml/NestableVerb.ts +11 -3
  96. package/models/bxml/Response.ts +2 -2
  97. package/models/bxml/Root.ts +19 -3
  98. package/models/bxml/verbs/Gather.ts +6 -6
  99. package/models/bxml/verbs/StartStream.ts +6 -6
  100. package/models/bxml/verbs/StartTranscription.ts +6 -6
  101. package/models/bxml/verbs/Transfer.ts +6 -6
  102. package/package.json +2 -2
  103. package/tests/unit/bxml/Bxml.test.js +33 -0
  104. package/tests/unit/bxml/Response.test.js +35 -2
  105. package/tests/unit/bxml/verbs/Gather.test.js +11 -3
  106. package/tests/unit/bxml/verbs/StartStream.test.js +11 -3
  107. package/tests/unit/bxml/verbs/StartTranscription.test.js +11 -3
  108. package/tests/unit/bxml/verbs/Transfer.test.js +11 -3
  109. package/.github/workflows/update-sdk.yml +0 -95
@@ -28,17 +28,17 @@ var StartTranscription = /** @class */ (function (_super) {
28
28
  /**
29
29
  * Creates an instance of StartTranscription
30
30
  * @param {StartTranscriptionAttributes} attributes The attributes to add to the element
31
- * @param {CustomParam[]} customParams The custom params to add to the element
31
+ * @param {CustomParam | CustomParam[]} customParams The custom params to add to the element
32
32
  */
33
33
  function StartTranscription(attributes, customParams) {
34
34
  return _super.call(this, 'StartTranscription', undefined, attributes, customParams) || this;
35
35
  }
36
36
  /**
37
- * Add a custom param to the StartTranscription
38
- * @param {CustomParam} customParam The custom param to add
37
+ * Add a custom param or params to the StartTranscription
38
+ * @param {CustomParam | CustomParam[]} customParams The custom param or params to add
39
39
  */
40
- StartTranscription.prototype.addCustomParam = function (customParam) {
41
- this.nestedVerbs = this.nestedVerbs.concat(customParam);
40
+ StartTranscription.prototype.addCustomParams = function (customParams) {
41
+ this.nestedVerbs = this.nestedVerbs.concat(customParams);
42
42
  };
43
43
  return StartTranscription;
44
44
  }(NestableVerb_1.NestableVerb));
@@ -28,13 +28,13 @@ export declare class Transfer extends NestableVerb {
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
- constructor(attributes?: TransferAttributes, transferTo?: NumberEntities);
33
+ constructor(attributes?: TransferAttributes, transferTo?: PhoneNumber | SipUri | NumberEntities);
34
34
  /**
35
- * Add a number entity to the transfer
36
- * @param {NumberEntities} recipient The number entity or entities to add
35
+ * Add a number entity or entities to the transfer
36
+ * @param {PhoneNumber | SipUri | NumberEntities} recipients The number entity or entities to add
37
37
  */
38
- addTransferRecipient(recipient: PhoneNumber | SipUri | NumberEntities): void;
38
+ addTransferRecipients(recipients: PhoneNumber | SipUri | NumberEntities): void;
39
39
  }
40
40
  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
  }
@@ -32,17 +32,17 @@ export class Transfer extends NestableVerb {
32
32
  /**
33
33
  * Creates an instance of Transfer
34
34
  * @param {TransferAttributes} attributes The attributes to add to the element
35
- * @param {NumberEntities} transferTo The number entities to transfer to
35
+ * @param {PhoneNumber | SipUri | NumberEntities} transferTo The number entities to transfer to
36
36
  */
37
- constructor(attributes?: TransferAttributes, transferTo?: NumberEntities) {
37
+ constructor(attributes?: TransferAttributes, transferTo?: PhoneNumber | SipUri | NumberEntities) {
38
38
  super('Transfer', undefined, attributes, transferTo);
39
39
  }
40
40
 
41
41
  /**
42
- * Add a number entity to the transfer
43
- * @param {NumberEntities} recipient The number entity or entities to add
42
+ * Add a number entity or entities to the transfer
43
+ * @param {PhoneNumber | SipUri | NumberEntities} recipients The number entity or entities to add
44
44
  */
45
- addTransferRecipient(recipient: PhoneNumber | SipUri | NumberEntities): void {
46
- this.nestedVerbs = this.nestedVerbs.concat(recipient);
45
+ addTransferRecipients(recipients: PhoneNumber | SipUri | NumberEntities): void {
46
+ this.nestedVerbs = this.nestedVerbs.concat(recipients);
47
47
  }
48
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bandwidth-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "OpenAPI client for bandwidth-sdk",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "repository": {
@@ -23,7 +23,7 @@
23
23
  "test": "jest --coverage --detectOpenHandles"
24
24
  },
25
25
  "dependencies": {
26
- "axios": "^0.27.2",
26
+ "axios": "^1.6.4",
27
27
  "xmlbuilder2": "^3.1.1"
28
28
  },
29
29
  "devDependencies": {
@@ -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
  });
@@ -33,7 +33,7 @@ describe('Transfer', () => {
33
33
  });
34
34
 
35
35
  test('should create a Transfer Verb with nested PhoneNumber and SipUri', () => {
36
- let transfer = new Transfer(attributes, [phoneNumber]);
36
+ let transfer = new Transfer(attributes, phoneNumber);
37
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
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
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>';
@@ -42,10 +42,18 @@ describe('Transfer', () => {
42
42
  expect(transfer).toBeInstanceOf(Verb);
43
43
  expect(transfer.toBxml()).toBe(expected);
44
44
 
45
- transfer.addTransferRecipient(sipUri);
45
+ transfer.addTransferRecipients(sipUri);
46
46
  expect(transfer.toBxml()).toBe(expectedSingle);
47
47
 
48
- transfer.addTransferRecipient([sipUri, phoneNumber]);
48
+ transfer.addTransferRecipients([sipUri, phoneNumber]);
49
49
  expect(transfer.toBxml()).toBe(expectedMultiple);
50
50
  });
51
+
52
+ test('should test the addTransferRecipients method method when no verbs are initially nested', () => {
53
+ const transfer = new Transfer(attributes);
54
+ 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>';
55
+
56
+ transfer.addTransferRecipients(phoneNumber);
57
+ expect(transfer.toBxml()).toBe(expected);
58
+ });
51
59
  });
@@ -1,95 +0,0 @@
1
- name: Update SDK
2
-
3
- on:
4
- schedule:
5
- - cron: "0 14 * * 2"
6
- workflow_dispatch:
7
-
8
- jobs:
9
- update-sdk:
10
- name: Update SDK if Necessary
11
- runs-on: ubuntu-latest
12
- outputs:
13
- generate: ${{ steps.compare.outputs.generate }}
14
- steps:
15
- - name: Checkout
16
- uses: actions/checkout@v4
17
-
18
- - name: Combine Product Specs
19
- uses: Bandwidth/api-specs-combine-action@v1.0.0
20
- with:
21
- token: ${{ secrets.DX_GITHUB_TOKEN }}
22
-
23
- - name: Determine if a New SDK is Needed
24
- id: compare
25
- run: |
26
- if cmp -s "bandwidth.yml" "api-specs/bandwidth.yml"; then :; else mv -f api-specs/bandwidth.yml bandwidth.yml; rm -r -f api-specs; echo "generate=true" >> $GITHUB_OUTPUT; fi
27
-
28
- - name: Create JIRA Card for SDK Update
29
- if: ${{ steps.compare.outputs.generate == 'true' }}
30
- id: jira
31
- run: |
32
- JIRA_KEY=$(jq -r '.key' <<< $(curl -s -u $JIRA_USERNAME:$JIRA_TOKEN \
33
- -X POST https://bandwidth-jira.atlassian.net/rest/api/2/issue \
34
- -H "Content-Type: application/json" \
35
- --data-binary @- << EOF
36
- {
37
- "fields": {
38
- "project": {
39
- "key": "SWI"
40
- },
41
- "summary": "[$LANGUAGE] Update SDK for New Spec Version",
42
- "description": "Prepare the $LANGUAGE SDK for release based on the latest spec changes.",
43
- "issuetype": {
44
- "name": "Story"
45
- },
46
- "customfield_12108": "$LANGUAGE SDK is ready for release. Tests are created/updated if need be.",
47
- "customfield_10205": "$EPIC",
48
- "components": [{
49
- "name": "Client SDKs"
50
- }]
51
- }
52
- }
53
- EOF
54
- ))
55
- echo "jira-key=$JIRA_KEY" >> $GITHUB_OUTPUT
56
- env:
57
- LANGUAGE: Node
58
- EPIC: SWI-1876
59
- JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }}
60
- JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }}
61
-
62
- - name: Build SDK
63
- id: build
64
- if: ${{ startsWith(steps.jira.outputs.jira-key, 'SWI') }}
65
- uses: Bandwidth/generate-sdk-action@v3.0.0
66
- with:
67
- branch-name: ${{ steps.jira.outputs.jira-key }}
68
- token: ${{ secrets.DX_GITHUB_TOKEN }}
69
- openapi-generator-version: 7.1.0
70
- language: typescript-axios
71
- config: ./openapi-config.yml
72
-
73
- - name: Setup Node
74
- if: steps.build.outputs.changes
75
- uses: actions/setup-node@v4
76
-
77
- - name: Open Pull Request
78
- if: steps.build.outputs.changes
79
- run: |
80
- gh pr create -B main -H Bandwidth:${{ steps.jira.outputs.jira-key }} -t '${{ steps.jira.outputs.jira-key }} Update SDK Based on Recent Spec Changes' -b 'Auto-generated by Update SDK Workflow'
81
- env:
82
- GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }}
83
-
84
- notify-for-failures:
85
- name: Notify for Failures
86
- needs: [update-sdk]
87
- if: failure()
88
- runs-on: ubuntu-latest
89
- steps:
90
- - name: Notify Slack of Failures
91
- uses: Bandwidth/build-notify-slack-action@v1.0.0
92
- with:
93
- job-status: failure
94
- slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
95
- slack-channel: ${{ secrets.SLACK_CHANNEL }}