bandwidth-sdk 2.1.0 → 3.0.1

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 (137) hide show
  1. package/.github/workflows/deploy.yml +4 -2
  2. package/.github/workflows/test-pr.yml +4 -2
  3. package/.github/workflows/{test-nightly.yml → test-smoke.yml} +6 -5
  4. package/.openapi-generator/FILES +2 -0
  5. package/README.md +22 -5
  6. package/api/transcriptions-api.ts +4 -4
  7. package/bandwidth.yml +70 -41
  8. package/coverage/clover.xml +1501 -138
  9. package/coverage/coverage-final.json +65 -47
  10. package/coverage/lcov-report/index.html +51 -21
  11. package/coverage/lcov-report/node-sdk/api/calls-api.ts.html +1702 -0
  12. package/coverage/lcov-report/node-sdk/api/conferences-api.ts.html +2725 -0
  13. package/coverage/lcov-report/node-sdk/api/index.html +236 -0
  14. package/coverage/lcov-report/node-sdk/api/media-api.ts.html +1315 -0
  15. package/coverage/lcov-report/node-sdk/api/messages-api.ts.html +1138 -0
  16. package/coverage/lcov-report/node-sdk/api/mfaapi.ts.html +1051 -0
  17. package/coverage/lcov-report/node-sdk/api/phone-number-lookup-api.ts.html +775 -0
  18. package/coverage/lcov-report/node-sdk/api/recordings-api.ts.html +2971 -0
  19. package/coverage/lcov-report/node-sdk/api/statistics-api.ts.html +496 -0
  20. package/coverage/lcov-report/node-sdk/api/transcriptions-api.ts.html +1045 -0
  21. package/coverage/lcov-report/node-sdk/api.ts.html +163 -0
  22. package/coverage/lcov-report/node-sdk/base.ts.html +1045 -0
  23. package/coverage/lcov-report/node-sdk/common.ts.html +535 -0
  24. package/coverage/lcov-report/node-sdk/configuration.ts.html +415 -0
  25. package/coverage/lcov-report/node-sdk/index.html +161 -0
  26. package/coverage/lcov-report/{models → node-sdk/models}/bxml/Bxml.ts.html +13 -13
  27. package/coverage/lcov-report/{models → node-sdk/models}/bxml/NestableVerb.ts.html +15 -15
  28. package/coverage/lcov-report/{models → node-sdk/models}/bxml/Response.ts.html +13 -13
  29. package/coverage/lcov-report/{models → node-sdk/models}/bxml/Root.ts.html +17 -17
  30. package/coverage/lcov-report/{models → node-sdk/models}/bxml/Verb.ts.html +15 -15
  31. package/coverage/lcov-report/{models → node-sdk/models}/bxml/index.html +29 -14
  32. package/coverage/lcov-report/node-sdk/models/bxml/index.ts.html +94 -0
  33. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/Bridge.ts.html +13 -13
  34. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/Conference.ts.html +13 -13
  35. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/CustomParam.ts.html +13 -13
  36. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/Forward.ts.html +13 -13
  37. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/Gather.ts.html +16 -16
  38. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/Hangup.ts.html +13 -13
  39. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/Pause.ts.html +13 -13
  40. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/PauseRecording.ts.html +13 -13
  41. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/PhoneNumber.ts.html +13 -13
  42. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/PlayAudio.ts.html +13 -13
  43. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/Record.ts.html +13 -13
  44. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/Redirect.ts.html +13 -13
  45. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/ResumeRecording.ts.html +13 -13
  46. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/Ring.ts.html +13 -13
  47. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/SendDtmf.ts.html +13 -13
  48. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/SipUri.ts.html +13 -13
  49. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/SpeakSentence.ts.html +15 -15
  50. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/StartGather.ts.html +13 -13
  51. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/StartRecording.ts.html +13 -13
  52. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/StartStream.ts.html +14 -14
  53. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/StartTranscription.ts.html +14 -14
  54. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/StopGather.ts.html +13 -13
  55. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/StopRecording.ts.html +13 -13
  56. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/StopStream.ts.html +13 -13
  57. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/StopTranscription.ts.html +13 -13
  58. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/StreamParam.ts.html +13 -13
  59. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/Tag.ts.html +13 -13
  60. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/Transfer.ts.html +14 -14
  61. package/coverage/lcov-report/{models → node-sdk/models}/bxml/verbs/index.html +27 -12
  62. package/coverage/lcov-report/node-sdk/models/bxml/verbs/index.ts.html +175 -0
  63. package/coverage/lcov-report/{models → node-sdk/models}/call-direction-enum.ts.html +11 -11
  64. package/coverage/lcov-report/{models → node-sdk/models}/call-state-enum.ts.html +11 -11
  65. package/coverage/lcov-report/node-sdk/models/call-transcription-detected-language-enum.ts.html +181 -0
  66. package/coverage/lcov-report/node-sdk/models/call-transcription-track-enum.ts.html +178 -0
  67. package/coverage/lcov-report/{models → node-sdk/models}/callback-method-enum.ts.html +11 -11
  68. package/coverage/lcov-report/{models → node-sdk/models}/conference-state-enum.ts.html +11 -11
  69. package/coverage/lcov-report/{models → node-sdk/models}/file-format-enum.ts.html +11 -11
  70. package/coverage/lcov-report/{models → node-sdk/models}/index.html +57 -12
  71. package/coverage/lcov-report/node-sdk/models/index.ts.html +367 -0
  72. package/coverage/lcov-report/{models → node-sdk/models}/list-message-direction-enum.ts.html +11 -11
  73. package/coverage/lcov-report/{models → node-sdk/models}/lookup-status-enum.ts.html +11 -11
  74. package/coverage/lcov-report/{models → node-sdk/models}/machine-detection-mode-enum.ts.html +11 -11
  75. package/coverage/lcov-report/{models → node-sdk/models}/message-direction-enum.ts.html +11 -11
  76. package/coverage/lcov-report/{models → node-sdk/models}/message-status-enum.ts.html +11 -11
  77. package/coverage/lcov-report/{models → node-sdk/models}/message-type-enum.ts.html +11 -11
  78. package/coverage/lcov-report/{models → node-sdk/models}/priority-enum.ts.html +11 -11
  79. package/coverage/lcov-report/{models → node-sdk/models}/recording-state-enum.ts.html +11 -11
  80. package/coverage/lcov-report/{models → node-sdk/models}/redirect-method-enum.ts.html +11 -11
  81. package/coverage/lcov.info +3366 -162
  82. package/custom_templates/README.mustache +22 -5
  83. package/custom_templates/package.mustache +2 -1
  84. package/custom_templates/tsconfig.mustache +2 -1
  85. package/dist/api/calls-api.js +2 -2
  86. package/dist/api/conferences-api.js +2 -2
  87. package/dist/api/media-api.js +2 -2
  88. package/dist/api/messages-api.js +2 -2
  89. package/dist/api/mfaapi.js +2 -2
  90. package/dist/api/phone-number-lookup-api.js +2 -2
  91. package/dist/api/recordings-api.js +2 -2
  92. package/dist/api/statistics-api.js +2 -2
  93. package/dist/api/transcriptions-api.d.ts +4 -4
  94. package/dist/api/transcriptions-api.js +6 -6
  95. package/dist/common.js +2 -2
  96. package/dist/models/call-recording-metadata.d.ts +6 -0
  97. package/dist/models/call-transcription-detected-language-enum.d.ts +22 -0
  98. package/dist/models/call-transcription-detected-language-enum.js +26 -0
  99. package/dist/models/call-transcription-metadata.d.ts +6 -0
  100. package/dist/models/call-transcription-track-enum.d.ts +21 -0
  101. package/dist/models/call-transcription-track-enum.js +25 -0
  102. package/dist/models/call-transcription.d.ts +7 -16
  103. package/dist/models/call-transcription.js +0 -10
  104. package/dist/models/conference-recording-metadata.d.ts +6 -0
  105. package/dist/models/index.d.ts +2 -0
  106. package/dist/models/index.js +2 -0
  107. package/jest.config.js +1 -0
  108. package/models/call-recording-metadata.ts +6 -0
  109. package/models/call-transcription-detected-language-enum.ts +32 -0
  110. package/models/call-transcription-metadata.ts +6 -0
  111. package/models/call-transcription-track-enum.ts +31 -0
  112. package/models/call-transcription.ts +11 -18
  113. package/models/conference-recording-metadata.ts +6 -0
  114. package/models/index.ts +2 -0
  115. package/package.json +3 -2
  116. package/tests/callUtils.ts +11 -11
  117. package/tests/smoke/bxml.test.ts +17 -17
  118. package/tests/smoke/calls-api.test.ts +38 -38
  119. package/tests/smoke/conferences-api.test.ts +19 -19
  120. package/tests/smoke/media-api.test.ts +11 -11
  121. package/tests/smoke/messages-api.test.ts +26 -26
  122. package/tests/smoke/mfaapi.test.ts +18 -18
  123. package/tests/smoke/phone-number-lookup-api.test.ts +16 -6
  124. package/tests/smoke/recordings-api.test.ts +31 -31
  125. package/tests/smoke/statistics-api.test.ts +7 -7
  126. package/tests/smoke/transcriptions-api.test.ts +16 -15
  127. package/tests/unit/api/calls-api.test.ts +180 -0
  128. package/tests/unit/api/conferences-api.test.ts +160 -0
  129. package/tests/unit/api/media-api.test.ts +59 -0
  130. package/tests/unit/api/messages-api.test.ts +122 -0
  131. package/tests/unit/api/mfaapi.test.ts +76 -0
  132. package/tests/unit/api/phone-number-lookup-api.test.ts +96 -0
  133. package/tests/unit/api/recordings-api.test.ts +179 -0
  134. package/tests/unit/api/statistics-api.test.ts +35 -0
  135. package/tests/unit/api/transcriptions-api.test.ts +61 -0
  136. package/tests/unit/models/call-transcription-detected-language-enum.test.ts +9 -0
  137. package/tests/unit/models/call-transcription-track-enum.test.ts +8 -0
@@ -5,7 +5,7 @@ import { BinaryLike, createHash, randomUUID } from 'crypto';
5
5
  import * as fs from 'fs';
6
6
 
7
7
  describe('MediaApi', () => {
8
- const config = new Configuration({ username: globalThis.BW_USERNAME, password: globalThis.BW_PASSWORD });
8
+ const config = new Configuration({ username: BW_USERNAME, password: BW_PASSWORD });
9
9
  const mediaApi = new MediaApi(config);
10
10
 
11
11
  const binaryMediaData = '123456';
@@ -20,13 +20,13 @@ describe('MediaApi', () => {
20
20
 
21
21
  describe('uploadMedia', () => {
22
22
  test('should upload binary media', async () => {
23
- const { status } = await mediaApi.uploadMedia(globalThis.BW_ACCOUNT_ID, binaryMediaName, binaryMediaData);
23
+ const { status } = await mediaApi.uploadMedia(BW_ACCOUNT_ID, binaryMediaName, binaryMediaData);
24
24
 
25
25
  expect(status).toEqual(204);
26
26
  });
27
27
 
28
28
  test('should upload media file', async () => {
29
- const { status } = await mediaApi.uploadMedia(globalThis.BW_ACCOUNT_ID, mediaFileName, mediaFileData);
29
+ const { status } = await mediaApi.uploadMedia(BW_ACCOUNT_ID, mediaFileName, mediaFileData);
30
30
 
31
31
  expect(status).toEqual(204);
32
32
  });
@@ -34,25 +34,25 @@ describe('MediaApi', () => {
34
34
 
35
35
  describe('listMedia', () => {
36
36
  test('should list media', async () => {
37
- const { status, data } = await mediaApi.listMedia(globalThis.BW_ACCOUNT_ID);
37
+ const { status, data } = await mediaApi.listMedia(BW_ACCOUNT_ID);
38
38
 
39
39
  expect(status).toEqual(200);
40
40
  expect(data).toBeInstanceOf(Array);
41
- expect(data[0].content).toBeDefined();
42
- expect(data[0].contentLength).toBeGreaterThan(0);
41
+ expect(data[0].content).toBeString();
42
+ expect(data[0].contentLength).toBePositive();
43
43
  });
44
44
  });
45
45
 
46
46
  describe('getMedia', () => {
47
47
  test('should get binary media', async () => {
48
- const { status, data } = await mediaApi.getMedia(globalThis.BW_ACCOUNT_ID, binaryMediaName);
48
+ const { status, data } = await mediaApi.getMedia(BW_ACCOUNT_ID, binaryMediaName);
49
49
 
50
50
  expect(status).toEqual(200);
51
51
  expect(data.toString()).toEqual(binaryMediaData);
52
52
  });
53
53
 
54
54
  test('should get media file', async () => {
55
- const { status, data } = await mediaApi.getMedia(globalThis.BW_ACCOUNT_ID, mediaFileName);
55
+ const { status, data } = await mediaApi.getMedia(BW_ACCOUNT_ID, mediaFileName);
56
56
  // fs.writeFile('./tests/fixtures/test.jpeg', Buffer.from(data), (err) => {
57
57
  // if (err) throw err;
58
58
  // });
@@ -65,13 +65,13 @@ describe('MediaApi', () => {
65
65
 
66
66
  describe('deleteMedia', () => {
67
67
  test('should delete binary media', async () => {
68
- const { status } = await mediaApi.deleteMedia(globalThis.BW_ACCOUNT_ID, binaryMediaName);
68
+ const { status } = await mediaApi.deleteMedia(BW_ACCOUNT_ID, binaryMediaName);
69
69
 
70
70
  expect(status).toEqual(204);
71
71
  });
72
72
 
73
73
  test('should delete media file', async () => {
74
- const { status } = await mediaApi.deleteMedia(globalThis.BW_ACCOUNT_ID, mediaFileName);
74
+ const { status } = await mediaApi.deleteMedia(BW_ACCOUNT_ID, mediaFileName);
75
75
 
76
76
  expect(status).toEqual(204);
77
77
  });
@@ -80,7 +80,7 @@ describe('MediaApi', () => {
80
80
  describe('HTTP Errors', () => {
81
81
  test('404', async () => {
82
82
  try{
83
- await mediaApi.getMedia(globalThis.BW_ACCOUNT_ID, 'does-not-exist');
83
+ await mediaApi.getMedia(BW_ACCOUNT_ID, 'does-not-exist');
84
84
  } catch (e) {
85
85
  expect(e.response.status).toEqual(404);
86
86
  }
@@ -4,7 +4,7 @@ import { Configuration } from '../../configuration';
4
4
  import { ListMessageDirectionEnum, MessageRequest, PriorityEnum } from '../../models';
5
5
 
6
6
  describe('MessagesApi', () => {
7
- const config = new Configuration({username: globalThis.BW_USERNAME, password: globalThis.BW_PASSWORD});
7
+ const config = new Configuration({username: BW_USERNAME, password: BW_PASSWORD});
8
8
  const messagesApi = new MessagesApi(config);
9
9
 
10
10
  const mmsText = 'nodejs sdk test MMS';
@@ -20,22 +20,22 @@ describe('MessagesApi', () => {
20
20
  describe('createMessage', () => {
21
21
  test('should create SMS message', async () => {
22
22
  const messageRequest: MessageRequest = {
23
- to: new Set([globalThis.USER_NUMBER]),
24
- from: globalThis.BW_NUMBER,
23
+ to: new Set([USER_NUMBER]),
24
+ from: BW_NUMBER,
25
25
  text: smsText,
26
- applicationId: globalThis.BW_MESSAGING_APPLICATION_ID,
26
+ applicationId: BW_MESSAGING_APPLICATION_ID,
27
27
  tag: smsTag,
28
28
  priority: priority,
29
29
  expiration: expiration
30
30
  };
31
31
 
32
- const { status, data } = await messagesApi.createMessage(globalThis.BW_ACCOUNT_ID, messageRequest);
32
+ const { status, data } = await messagesApi.createMessage(BW_ACCOUNT_ID, messageRequest);
33
33
 
34
34
  expect(status).toEqual(202);
35
35
  expect(data.id).toHaveLength(29);
36
- expect(data.owner).toEqual(globalThis.BW_NUMBER);
37
- expect(data.to).toEqual([globalThis.USER_NUMBER]);
38
- expect(data.from).toEqual(globalThis.BW_NUMBER);
36
+ expect(data.owner).toEqual(BW_NUMBER);
37
+ expect(data.to).toEqual([USER_NUMBER]);
38
+ expect(data.from).toEqual(BW_NUMBER);
39
39
  expect(data.text).toEqual(smsText);
40
40
  expect(data.tag).toEqual(smsTag);
41
41
  expect(data.priority).toEqual(priority);
@@ -43,21 +43,21 @@ describe('MessagesApi', () => {
43
43
 
44
44
  test('should create MMS message', async () => {
45
45
  const messageRequest: MessageRequest = {
46
- to: new Set([globalThis.USER_NUMBER]),
47
- from: globalThis.BW_NUMBER,
46
+ to: new Set([USER_NUMBER]),
47
+ from: BW_NUMBER,
48
48
  text: mmsText,
49
- applicationId: globalThis.BW_MESSAGING_APPLICATION_ID,
49
+ applicationId: BW_MESSAGING_APPLICATION_ID,
50
50
  tag: mmsTag,
51
51
  media: [mediaUrl]
52
52
  };
53
53
 
54
- const { status, data } = await messagesApi.createMessage(globalThis.BW_ACCOUNT_ID, messageRequest);
54
+ const { status, data } = await messagesApi.createMessage(BW_ACCOUNT_ID, messageRequest);
55
55
 
56
56
  expect(status).toEqual(202);
57
57
  expect(data.id).toHaveLength(29);
58
- expect(data.owner).toEqual(globalThis.BW_NUMBER);
59
- expect(data.to).toEqual([globalThis.USER_NUMBER]);
60
- expect(data.from).toEqual(globalThis.BW_NUMBER);
58
+ expect(data.owner).toEqual(BW_NUMBER);
59
+ expect(data.to).toEqual([USER_NUMBER]);
60
+ expect(data.from).toEqual(BW_NUMBER);
61
61
  expect(data.text).toEqual(mmsText);
62
62
  expect(data.tag).toEqual(mmsTag);
63
63
  expect(data.media).toEqual([mediaUrl]);
@@ -67,13 +67,13 @@ describe('MessagesApi', () => {
67
67
  describe('listMessages', () => {
68
68
  test('should list messages', async () => {
69
69
  const { status, data } =
70
- await messagesApi.listMessages(globalThis.BW_ACCOUNT_ID, undefined, globalThis.BW_NUMBER, undefined, undefined, listMessageDirection);
70
+ await messagesApi.listMessages(BW_ACCOUNT_ID, undefined, BW_NUMBER, undefined, undefined, listMessageDirection);
71
71
 
72
72
  expect(status).toEqual(200);
73
73
  expect(data.messages).toBeInstanceOf(Array);
74
- expect(data.messages![0].accountId).toEqual(globalThis.BW_ACCOUNT_ID);
74
+ expect(data.messages![0].accountId).toEqual(BW_ACCOUNT_ID);
75
75
  expect(data.messages![0].messageId).toHaveLength(29);
76
- expect(data.messages![0].sourceTn).toEqual(globalThis.BW_NUMBER);
76
+ expect(data.messages![0].sourceTn).toEqual(BW_NUMBER);
77
77
  expect(data.messages![0].messageDirection).toEqual(listMessageDirection);
78
78
  });
79
79
  });
@@ -81,32 +81,32 @@ describe('MessagesApi', () => {
81
81
  describe('HTTP Errors', () => {
82
82
  test('400', async () => {
83
83
  const messageRequest: MessageRequest = {
84
- applicationId: globalThis.BW_MESSAGING_APPLICATION_ID,
84
+ applicationId: BW_MESSAGING_APPLICATION_ID,
85
85
  to: new Set(['+1invalid']),
86
- from: globalThis.BW_NUMBER,
86
+ from: BW_NUMBER,
87
87
  text: smsText
88
88
  };
89
89
 
90
90
  try {
91
- await messagesApi.createMessage(globalThis.BW_ACCOUNT_ID, messageRequest);
91
+ await messagesApi.createMessage(BW_ACCOUNT_ID, messageRequest);
92
92
  } catch (e) {
93
93
  expect(e.response.status).toEqual(400);
94
94
  }
95
95
  });
96
96
 
97
97
  test('401', async () => {
98
- const configBad = new Configuration({username: globalThis.UNAUTHORIZED_USERNAME, password: globalThis.UNAUTHORIZED_PASSWORD});
98
+ const configBad = new Configuration({username: UNAUTHORIZED_USERNAME, password: UNAUTHORIZED_PASSWORD});
99
99
  const messagesApiBad = new MessagesApi(configBad);
100
100
 
101
101
  const messageRequest: MessageRequest = {
102
- applicationId: globalThis.BW_MESSAGING_APPLICATION_ID,
103
- to: new Set([globalThis.USER_NUMBER]),
104
- from: globalThis.BW_NUMBER,
102
+ applicationId: BW_MESSAGING_APPLICATION_ID,
103
+ to: new Set([USER_NUMBER]),
104
+ from: BW_NUMBER,
105
105
  text: smsText
106
106
  };
107
107
 
108
108
  try {
109
- await messagesApiBad.createMessage(globalThis.BW_ACCOUNT_ID, messageRequest);
109
+ await messagesApiBad.createMessage(BW_ACCOUNT_ID, messageRequest);
110
110
  } catch (e) {
111
111
  expect(e.response.status).toEqual(401);
112
112
  }
@@ -4,7 +4,7 @@ import { Configuration } from '../../configuration';
4
4
  import { CodeRequest, VerifyCodeRequest } from '../../models';
5
5
 
6
6
  describe('MFAApi', () => {
7
- const config = new Configuration({username: globalThis.BW_USERNAME, password: globalThis.BW_PASSWORD});
7
+ const config = new Configuration({username: BW_USERNAME, password: BW_PASSWORD});
8
8
  const mfaApi = new MFAApi(config);
9
9
 
10
10
  const message = 'Your temporary {NAME} {SCOPE} code is {CODE}';
@@ -13,14 +13,14 @@ describe('MFAApi', () => {
13
13
  describe('generateMessagingCode', () => {
14
14
  test('should generate messaging code', async () => {
15
15
  const codeRequest: CodeRequest = {
16
- to: globalThis.USER_NUMBER,
17
- from: globalThis.BW_NUMBER,
18
- applicationId: globalThis.BW_MESSAGING_APPLICATION_ID,
16
+ to: USER_NUMBER,
17
+ from: BW_NUMBER,
18
+ applicationId: BW_MESSAGING_APPLICATION_ID,
19
19
  message: message,
20
20
  digits: digits
21
21
  };
22
22
 
23
- const { status, data } = await mfaApi.generateMessagingCode(globalThis.BW_ACCOUNT_ID, codeRequest);
23
+ const { status, data } = await mfaApi.generateMessagingCode(BW_ACCOUNT_ID, codeRequest);
24
24
 
25
25
  expect(status).toEqual(200);
26
26
  expect(data.messageId).toHaveLength(29);
@@ -30,14 +30,14 @@ describe('MFAApi', () => {
30
30
  describe('generateVoiceCode', () => {
31
31
  test('should generate voice code', async () => {
32
32
  const codeRequest: CodeRequest = {
33
- to: globalThis.USER_NUMBER,
34
- from: globalThis.BW_NUMBER,
35
- applicationId: globalThis.BW_VOICE_APPLICATION_ID,
33
+ to: USER_NUMBER,
34
+ from: BW_NUMBER,
35
+ applicationId: BW_VOICE_APPLICATION_ID,
36
36
  message: message,
37
37
  digits: digits
38
38
  };
39
39
 
40
- const { status, data } = await mfaApi.generateVoiceCode(globalThis.BW_ACCOUNT_ID, codeRequest);
40
+ const { status, data } = await mfaApi.generateVoiceCode(BW_ACCOUNT_ID, codeRequest);
41
41
 
42
42
  expect(status).toEqual(200);
43
43
  expect(data.callId).toHaveLength(47);
@@ -53,7 +53,7 @@ describe('MFAApi', () => {
53
53
  code: '12345'
54
54
  };
55
55
 
56
- const { status, data } = await mfaApi.verifyCode(globalThis.BW_ACCOUNT_ID, verifyRequest);
56
+ const { status, data } = await mfaApi.verifyCode(BW_ACCOUNT_ID, verifyRequest);
57
57
 
58
58
  expect(status).toEqual(200);
59
59
  expect(data.valid).toEqual(false);
@@ -63,34 +63,34 @@ describe('MFAApi', () => {
63
63
  describe('HTTP Errors', () => {
64
64
  test('400', async () => {
65
65
  const codeRequest: CodeRequest = {
66
- to: globalThis.USER_NUMBER,
67
- from: globalThis.BW_NUMBER,
66
+ to: USER_NUMBER,
67
+ from: BW_NUMBER,
68
68
  applicationId: 'not-an-app-id',
69
69
  message: message,
70
70
  digits: digits
71
71
  };
72
72
 
73
73
  try {
74
- await mfaApi.generateMessagingCode(globalThis.BW_ACCOUNT_ID, codeRequest);
74
+ await mfaApi.generateMessagingCode(BW_ACCOUNT_ID, codeRequest);
75
75
  } catch (e) {
76
76
  expect(e.response.status).toEqual(400);
77
77
  }
78
78
  });
79
79
 
80
80
  test('403', async () => {
81
- const configBad = new Configuration({username: globalThis.UNAUTHORIZED_USERNAME, password: globalThis.UNAUTHORIZED_PASSWORD});
81
+ const configBad = new Configuration({username: UNAUTHORIZED_USERNAME, password: UNAUTHORIZED_PASSWORD});
82
82
  const mfaApiBad = new MFAApi(configBad);
83
83
 
84
84
  const codeRequest: CodeRequest = {
85
- to: globalThis.USER_NUMBER,
86
- from: globalThis.BW_NUMBER,
87
- applicationId: globalThis.BW_MESSAGING_APPLICATION_ID,
85
+ to: USER_NUMBER,
86
+ from: BW_NUMBER,
87
+ applicationId: BW_MESSAGING_APPLICATION_ID,
88
88
  message: message,
89
89
  digits: digits
90
90
  };
91
91
 
92
92
  try {
93
- await mfaApiBad.generateMessagingCode(globalThis.BW_ACCOUNT_ID, codeRequest);
93
+ await mfaApiBad.generateMessagingCode(BW_ACCOUNT_ID, codeRequest);
94
94
  } catch (e) {
95
95
  expect(e.response.status).toEqual(403);
96
96
  }
@@ -1,7 +1,7 @@
1
1
  //@ts-nocheck
2
2
  import { PhoneNumberLookupApi } from "../../api";
3
3
  import { Configuration } from "../../configuration";
4
- import { LookupRequest } from "../../models";
4
+ import { LookupRequest, LookupStatusEnum } from "../../models";
5
5
  import { sleep } from "../callUtils";
6
6
 
7
7
  describe('PhoneNumberLookupApi', () => {
@@ -21,9 +21,14 @@ describe('PhoneNumberLookupApi', () => {
21
21
 
22
22
  expect(status).toEqual(202);
23
23
  expect(data.requestId).toHaveLength(36);
24
- expect(data.status).toBeDefined();
24
+ expect(data.status).toBeOneOf([
25
+ LookupStatusEnum.Complete,
26
+ LookupStatusEnum.InProgress,
27
+ LookupStatusEnum.Failed,
28
+ LookupStatusEnum.PartialComplete
29
+ ]);
25
30
 
26
- lookupRequestId = data.requestId;
31
+ lookupRequestId = data.requestId!;
27
32
  await sleep(1);
28
33
  });
29
34
  });
@@ -34,10 +39,15 @@ describe('PhoneNumberLookupApi', () => {
34
39
 
35
40
  expect(status).toEqual(200);
36
41
  expect(data.requestId).toEqual(lookupRequestId);
37
- expect(data.status).toBeDefined();
42
+ expect(data.status).toBeOneOf([
43
+ LookupStatusEnum.Complete,
44
+ LookupStatusEnum.InProgress,
45
+ LookupStatusEnum.Failed,
46
+ LookupStatusEnum.PartialComplete
47
+ ]);
38
48
  expect(data.result).toBeInstanceOf(Array);
39
- expect(data.result[0]['Response Code']).toBeDefined();
40
- expect(data.result[0]['E.164 Format']).toEqual(BW_NUMBER);
49
+ expect(data.result![0]['Response Code']).toBeInteger();
50
+ expect(data.result![0]['E.164 Format']).toEqual(BW_NUMBER);
41
51
  });
42
52
  });
43
53
 
@@ -6,7 +6,7 @@ import { getMantecaTestStatus, setupManteca, createMantecaCall, cleanupCalls, sl
6
6
 
7
7
  describe('RecordingsApi', () => {
8
8
  jest.setTimeout(240000);
9
- const config = new Configuration({username: globalThis.BW_USERNAME, password: globalThis.BW_PASSWORD});
9
+ const config = new Configuration({username: BW_USERNAME, password: BW_PASSWORD});
10
10
  const callsApi = new CallsApi(config);
11
11
  const recordingsApi = new RecordingsApi(config);
12
12
 
@@ -28,29 +28,29 @@ describe('RecordingsApi', () => {
28
28
  const pauseRecording = { state: RecordingStateEnum.Paused };
29
29
  const startRecording = { state: RecordingStateEnum.Recording };
30
30
 
31
- await sleep(globalThis.SLEEP_TIME_S * 2);
31
+ await sleep(SLEEP_TIME_S * 2);
32
32
  const { status: pauseStatus } =
33
- await recordingsApi.updateCallRecordingState(globalThis.BW_ACCOUNT_ID, mantecaCallId, pauseRecording);
33
+ await recordingsApi.updateCallRecordingState(BW_ACCOUNT_ID, mantecaCallId, pauseRecording);
34
34
  expect(pauseStatus).toEqual(200);
35
35
 
36
- await sleep(globalThis.SLEEP_TIME_S * 2);
36
+ await sleep(SLEEP_TIME_S * 2);
37
37
  const { status: startStatus } =
38
- await recordingsApi.updateCallRecordingState(globalThis.BW_ACCOUNT_ID, mantecaCallId, startRecording);
38
+ await recordingsApi.updateCallRecordingState(BW_ACCOUNT_ID, mantecaCallId, startRecording);
39
39
  expect(startStatus).toEqual(200);
40
40
 
41
- await sleep(globalThis.SLEEP_TIME_S * 2);
41
+ await sleep(SLEEP_TIME_S * 2);
42
42
  const { status: completeStatus } =
43
- await callsApi.updateCall(globalThis.BW_ACCOUNT_ID, mantecaCallId, { state: CallStateEnum.Completed });
43
+ await callsApi.updateCall(BW_ACCOUNT_ID, mantecaCallId, { state: CallStateEnum.Completed });
44
44
  expect(completeStatus).toEqual(200);
45
45
 
46
46
  let retries = 0;
47
47
  let recordingComplete = false;
48
48
  try {
49
- while (!recordingComplete && retries < globalThis.MAX_RETRIES) {
49
+ while (!recordingComplete && retries < MAX_RETRIES) {
50
50
  const { callRecorded } = await getMantecaTestStatus(mantecaTestId);
51
51
  recordingComplete = callRecorded;
52
52
  retries++;
53
- await sleep(globalThis.SLEEP_TIME_S);
53
+ await sleep(SLEEP_TIME_S);
54
54
  }
55
55
  } catch (e) {
56
56
  console.log(e);
@@ -62,25 +62,25 @@ describe('RecordingsApi', () => {
62
62
 
63
63
  describe('listAccountCallRecordings', () => {
64
64
  test('should list account call recordings', async () => {
65
- const { status, data } = await recordingsApi.listAccountCallRecordings(globalThis.BW_ACCOUNT_ID);
65
+ const { status, data } = await recordingsApi.listAccountCallRecordings(BW_ACCOUNT_ID);
66
66
 
67
67
  expect(status).toEqual(200);
68
68
  expect(data).toBeInstanceOf(Array);
69
- expect(data[0].accountId).toEqual(globalThis.BW_ACCOUNT_ID);
69
+ expect(data[0].accountId).toEqual(BW_ACCOUNT_ID);
70
70
  });
71
71
  });
72
72
 
73
73
  describe('listCallRecordings', () => {
74
74
  test('should list call recordings', async () => {
75
- const { status, data } = await recordingsApi.listCallRecordings(globalThis.BW_ACCOUNT_ID, mantecaCallId);
75
+ const { status, data } = await recordingsApi.listCallRecordings(BW_ACCOUNT_ID, mantecaCallId);
76
76
 
77
77
  expect(status).toEqual(200);
78
78
  expect(data).toBeInstanceOf(Array);
79
- expect(data[0].applicationId).toEqual(globalThis.MANTECA_APPLICATION_ID);
80
- expect(data[0].accountId).toEqual(globalThis.BW_ACCOUNT_ID);
79
+ expect(data[0].applicationId).toEqual(MANTECA_APPLICATION_ID);
80
+ expect(data[0].accountId).toEqual(BW_ACCOUNT_ID);
81
81
  expect(data[0].callId).toEqual(mantecaCallId);
82
82
  expect(data[0].recordingId).toHaveLength(47);
83
- expect(['partial', 'complete']).toContain(data[0].status);
83
+ expect(data[0].status).toBeOneOf(['partial', 'complete']);
84
84
 
85
85
  recordingId = data[0].recordingId!;
86
86
  });
@@ -88,20 +88,20 @@ describe('RecordingsApi', () => {
88
88
 
89
89
  describe('getCallRecording', () => {
90
90
  test('should get call recording', async () => {
91
- const { status, data } = await recordingsApi.getCallRecording(globalThis.BW_ACCOUNT_ID, mantecaCallId, recordingId);
91
+ const { status, data } = await recordingsApi.getCallRecording(BW_ACCOUNT_ID, mantecaCallId, recordingId);
92
92
 
93
93
  expect(status).toEqual(200);
94
- expect(data.applicationId).toEqual(globalThis.MANTECA_APPLICATION_ID);
95
- expect(data.accountId).toEqual(globalThis.BW_ACCOUNT_ID);
94
+ expect(data.applicationId).toEqual(MANTECA_APPLICATION_ID);
95
+ expect(data.accountId).toEqual(BW_ACCOUNT_ID);
96
96
  expect(data.callId).toEqual(mantecaCallId);
97
97
  expect(data.recordingId).toEqual(recordingId);
98
- expect(['partial', 'complete']).toContain(data.status);
98
+ expect(data.status).toBeOneOf(['partial', 'complete']);
99
99
  });
100
100
  });
101
101
 
102
102
  describe('downloadCallRecording', () => {
103
103
  test('should download call recording', async () => {
104
- const { status, data } = await recordingsApi.downloadCallRecording(globalThis.BW_ACCOUNT_ID, mantecaCallId, recordingId);
104
+ const { status, data } = await recordingsApi.downloadCallRecording(BW_ACCOUNT_ID, mantecaCallId, recordingId);
105
105
 
106
106
  expect(status).toEqual(200);
107
107
  expect(data).toBeDefined();
@@ -111,23 +111,23 @@ describe('RecordingsApi', () => {
111
111
  describe('transcribeCallRecording', () => {
112
112
  test('should create a transcription request', async () => {
113
113
  const transcribeRecording = {
114
- callbackUrl: `${globalThis.MANTECA_BASE_URL}/transcriptions`,
114
+ callbackUrl: `${MANTECA_BASE_URL}/transcriptions`,
115
115
  tag: mantecaTestId
116
116
  };
117
117
  const { status } =
118
- await recordingsApi.transcribeCallRecording(globalThis.BW_ACCOUNT_ID, mantecaCallId, recordingId, transcribeRecording);
118
+ await recordingsApi.transcribeCallRecording(BW_ACCOUNT_ID, mantecaCallId, recordingId, transcribeRecording);
119
119
 
120
120
  expect(status).toEqual(204);
121
121
 
122
122
  let retries = 0;
123
123
  let transcriptionComplete = false;
124
- await sleep(globalThis.SLEEP_TIME_S * 10);
124
+ await sleep(SLEEP_TIME_S * 10);
125
125
  try {
126
- while (!transcriptionComplete && retries < globalThis.MAX_RETRIES) {
126
+ while (!transcriptionComplete && retries < MAX_RETRIES) {
127
127
  const { callTranscribed } = await getMantecaTestStatus(mantecaTestId);
128
128
  transcriptionComplete = callTranscribed;
129
129
  retries++;
130
- await sleep(globalThis.SLEEP_TIME_S);
130
+ await sleep(SLEEP_TIME_S);
131
131
  }
132
132
  } catch (e) {
133
133
  console.log(e);
@@ -139,18 +139,18 @@ describe('RecordingsApi', () => {
139
139
 
140
140
  describe('getRecordingTranscription', () => {
141
141
  test('should get recording transcription', async () => {
142
- const { status, data } = await recordingsApi.getRecordingTranscription(globalThis.BW_ACCOUNT_ID, mantecaCallId, recordingId);
142
+ const { status, data } = await recordingsApi.getRecordingTranscription(BW_ACCOUNT_ID, mantecaCallId, recordingId);
143
143
 
144
144
  expect(status).toEqual(200);
145
145
  expect(data.transcripts).toBeInstanceOf(Array);
146
- expect(data.transcripts![0].text).toBeDefined();
147
- expect(data.transcripts![0].confidence).toBeDefined();
146
+ expect(data.transcripts![0].text).toBeString();
147
+ expect(data.transcripts![0].confidence).toBeNumber();
148
148
  });
149
149
  });
150
150
 
151
151
  describe('deleteRecordingTranscription', () => {
152
152
  test('should delete recording transcription', async () => {
153
- const { status } = await recordingsApi.deleteRecordingTranscription(globalThis.BW_ACCOUNT_ID, mantecaCallId, recordingId);
153
+ const { status } = await recordingsApi.deleteRecordingTranscription(BW_ACCOUNT_ID, mantecaCallId, recordingId);
154
154
 
155
155
  expect(status).toEqual(204);
156
156
  });
@@ -158,7 +158,7 @@ describe('RecordingsApi', () => {
158
158
 
159
159
  describe('deleteRecordingMedia', () => {
160
160
  test('should delete recording media', async () => {
161
- const { status } = await recordingsApi.deleteRecordingMedia(globalThis.BW_ACCOUNT_ID, mantecaCallId, recordingId);
161
+ const { status } = await recordingsApi.deleteRecordingMedia(BW_ACCOUNT_ID, mantecaCallId, recordingId);
162
162
 
163
163
  expect(status).toEqual(204);
164
164
  });
@@ -166,7 +166,7 @@ describe('RecordingsApi', () => {
166
166
 
167
167
  describe('deleteRecording', () => {
168
168
  test('should delete recording', async () => {
169
- const { status } = await recordingsApi.deleteRecording(globalThis.BW_ACCOUNT_ID, mantecaCallId, recordingId);
169
+ const { status } = await recordingsApi.deleteRecording(BW_ACCOUNT_ID, mantecaCallId, recordingId);
170
170
 
171
171
  expect(status).toEqual(204);
172
172
  });
@@ -3,37 +3,37 @@ import { StatisticsApi } from '../../api';
3
3
  import { Configuration } from '../../configuration';
4
4
 
5
5
  describe('StatisticsApi', () => {
6
- const config = new Configuration({username: globalThis.BW_USERNAME, password: globalThis.BW_PASSWORD});
6
+ const config = new Configuration({username: BW_USERNAME, password: BW_PASSWORD});
7
7
  const statisticsApi = new StatisticsApi(config);
8
8
 
9
9
  describe('getStatistics', () => {
10
10
  test('should get statistics', async () => {
11
- const { status, data } = await statisticsApi.getStatistics(globalThis.BW_ACCOUNT_ID);
11
+ const { status, data } = await statisticsApi.getStatistics(BW_ACCOUNT_ID);
12
12
 
13
13
  expect(status).toEqual(200);
14
- expect(data.currentCallQueueSize).toBeDefined();
14
+ expect(data.currentCallQueueSize).toBeNumber();
15
15
  expect(data.maxCallQueueSize).toEqual(7500);
16
16
  });
17
17
  });
18
18
 
19
19
  describe('HTTP Errors', () => {
20
20
  test('401', async () => {
21
- const configBad = new Configuration({username: globalThis.UNAUTHORIZED_USERNAME, password: globalThis.UNAUTHORIZED_PASSWORD});
21
+ const configBad = new Configuration({username: UNAUTHORIZED_USERNAME, password: UNAUTHORIZED_PASSWORD});
22
22
  const statisticsApiBad = new StatisticsApi(configBad);
23
23
 
24
24
  try {
25
- await statisticsApiBad.getStatistics(globalThis.BW_ACCOUNT_ID);
25
+ await statisticsApiBad.getStatistics(BW_ACCOUNT_ID);
26
26
  } catch (e) {
27
27
  expect(e.response.status).toEqual(401);
28
28
  }
29
29
  });
30
30
 
31
31
  test('403', async () => {
32
- const configBad = new Configuration({username: globalThis.FORBIDDEN_USERNAME, password: globalThis.FORBIDDEN_PASSWORD});
32
+ const configBad = new Configuration({username: FORBIDDEN_USERNAME, password: FORBIDDEN_PASSWORD});
33
33
  const statisticsApiBad = new StatisticsApi(configBad);
34
34
 
35
35
  try {
36
- await statisticsApiBad.getStatistics(globalThis.BW_ACCOUNT_ID);
36
+ await statisticsApiBad.getStatistics(BW_ACCOUNT_ID);
37
37
  } catch (e) {
38
38
  expect(e.response.status).toEqual(403);
39
39
  }
@@ -6,7 +6,7 @@ import { cleanupCalls, createMantecaCall, setupManteca, sleep } from "../callUti
6
6
 
7
7
  describe('TranscriptionsApi', () => {
8
8
  jest.setTimeout(240000);
9
- const config = new Configuration({username: globalThis.BW_USERNAME, password: globalThis.BW_PASSWORD});
9
+ const config = new Configuration({username: BW_USERNAME, password: BW_PASSWORD});
10
10
  const callsApi = new CallsApi(config);
11
11
  const transcriptionsApi = new TranscriptionsApi(config);
12
12
 
@@ -25,38 +25,39 @@ describe('TranscriptionsApi', () => {
25
25
 
26
26
  describe('createCallTranscription', () => {
27
27
  test('should create call transcription', async () => {
28
- await sleep(globalThis.SLEEP_TIME_S);
28
+ await sleep(SLEEP_TIME_S);
29
29
 
30
30
  const startTranscriptionBxml =
31
31
  `<?xml version="1.0" encoding="UTF-8"?><Response><StartTranscription name="${mantecaCallId}" tracks="inbound"></StartTranscription><Pause duration="6"/></Response>`;
32
32
  const { status: startStatus } =
33
- await callsApi.updateCallBxml(globalThis.BW_ACCOUNT_ID, mantecaCallId, startTranscriptionBxml);
33
+ await callsApi.updateCallBxml(BW_ACCOUNT_ID, mantecaCallId, startTranscriptionBxml);
34
34
  expect(startStatus).toEqual(204);
35
- await sleep(globalThis.SLEEP_TIME_S);
35
+ await sleep(SLEEP_TIME_S);
36
36
 
37
37
  const stopTranscriptionBxml =
38
38
  `<?xml version="1.0" encoding="UTF-8"?><Response><StopTranscription name="${mantecaCallId}"></StopTranscription></Response>`;
39
39
  const { status: stopStatus } =
40
- await callsApi.updateCallBxml(globalThis.BW_ACCOUNT_ID, mantecaCallId, stopTranscriptionBxml);
40
+ await callsApi.updateCallBxml(BW_ACCOUNT_ID, mantecaCallId, stopTranscriptionBxml);
41
41
  expect(stopStatus).toEqual(204);
42
- await sleep(globalThis.SLEEP_TIME_S);
42
+ await sleep(SLEEP_TIME_S);
43
43
 
44
44
  const { status: completeStatus } =
45
- await callsApi.updateCall(globalThis.BW_ACCOUNT_ID, mantecaCallId, { state: CallStateEnum.Completed });
45
+ await callsApi.updateCall(BW_ACCOUNT_ID, mantecaCallId, { state: CallStateEnum.Completed });
46
46
  expect(completeStatus).toEqual(200);
47
47
  });
48
48
  });
49
49
 
50
50
  describe('listRealTimeTranscriptions', () => {
51
51
  test('should list call transcriptions', async () => {
52
- await sleep(globalThis.SLEEP_TIME_S * 20);
52
+ await sleep(SLEEP_TIME_S * 20);
53
53
 
54
54
  const { status, data } =
55
- await transcriptionsApi.listRealTimeTranscriptions(globalThis.BW_ACCOUNT_ID, mantecaCallId);
55
+ await transcriptionsApi.listRealTimeTranscriptions(BW_ACCOUNT_ID, mantecaCallId);
56
56
  expect(status).toEqual(200);
57
57
  expect(data).toBeInstanceOf(Array);
58
- expect(typeof data[0].transcriptionId).toBe('string');
59
- expect(typeof data[0].transcriptionUrl).toBe('string');
58
+ expect(data[0].transcriptionId).toBeString();
59
+ expect(data[0].transcriptionUrl).toBeString();
60
+ expect(data[0].transcriptionName).toBeString();
60
61
  transcriptionId = data[0].transcriptionId!;
61
62
  });
62
63
  });
@@ -64,21 +65,21 @@ describe('TranscriptionsApi', () => {
64
65
  describe('getRealTimeTranscription', () => {
65
66
  test('should get call transcription', async () => {
66
67
  const { status, data } =
67
- await transcriptionsApi.getRealTimeTranscription(globalThis.BW_ACCOUNT_ID, mantecaCallId, transcriptionId);
68
+ await transcriptionsApi.getRealTimeTranscription(BW_ACCOUNT_ID, mantecaCallId, transcriptionId);
68
69
  expect(status).toEqual(200);
69
- expect(data.accountId).toEqual(globalThis.BW_ACCOUNT_ID);
70
+ expect(data.accountId).toEqual(BW_ACCOUNT_ID);
70
71
  expect(data.callId).toEqual(mantecaCallId);
71
72
  expect(data.transcriptionId).toEqual(transcriptionId);
72
73
  expect(data.tracks).toBeInstanceOf(Array);
73
74
  expect(data.tracks![0].track).toEqual('inbound');
74
- expect(typeof data.tracks![0].confidence).toBe('number');
75
+ expect(data.tracks![0].confidence).toBeNumber();
75
76
  });
76
77
  });
77
78
 
78
79
  describe('deleteRealTimeTranscription', () => {
79
80
  test('should delete call transcription', async () => {
80
81
  const { status } =
81
- await transcriptionsApi.deleteRealTimeTranscription(globalThis.BW_ACCOUNT_ID, mantecaCallId, transcriptionId);
82
+ await transcriptionsApi.deleteRealTimeTranscription(BW_ACCOUNT_ID, mantecaCallId, transcriptionId);
82
83
  expect(status).toEqual(200); // This is a bug in the API, it should return 204. VAPI-1863 should fix this.
83
84
  });
84
85
  });