@webex/calling 0.0.1-next.0 → 0.0.1-next.2

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 (122) hide show
  1. package/README.md +51 -66
  2. package/dist/module/CallHistory/CallHistory.js +84 -84
  3. package/dist/module/CallHistory/callHistoryFixtures.js +307 -307
  4. package/dist/module/CallHistory/constants.js +9 -9
  5. package/dist/module/CallHistory/types.js +1 -1
  6. package/dist/module/CallSettings/CallSettings.js +65 -65
  7. package/dist/module/CallSettings/UcmBackendConnector.js +100 -100
  8. package/dist/module/CallSettings/WxCallBackendConnector.js +287 -287
  9. package/dist/module/CallSettings/constants.js +11 -11
  10. package/dist/module/CallSettings/testFixtures.js +62 -62
  11. package/dist/module/CallSettings/types.js +1 -1
  12. package/dist/module/CallingClient/CallingClient.js +268 -268
  13. package/dist/module/CallingClient/callRecordFixtures.js +93 -93
  14. package/dist/module/CallingClient/calling/CallerId/index.js +169 -169
  15. package/dist/module/CallingClient/calling/CallerId/types.js +1 -1
  16. package/dist/module/CallingClient/calling/call.js +1649 -1649
  17. package/dist/module/CallingClient/calling/callManager.js +274 -274
  18. package/dist/module/CallingClient/calling/index.js +2 -2
  19. package/dist/module/CallingClient/calling/types.js +53 -53
  20. package/dist/module/CallingClient/callingClientFixtures.js +38 -38
  21. package/dist/module/CallingClient/constants.js +122 -122
  22. package/dist/module/CallingClient/line/index.js +110 -110
  23. package/dist/module/CallingClient/line/types.js +14 -14
  24. package/dist/module/CallingClient/registration/index.js +1 -1
  25. package/dist/module/CallingClient/registration/register.js +507 -507
  26. package/dist/module/CallingClient/registration/registerFixtures.js +28 -28
  27. package/dist/module/CallingClient/registration/types.js +1 -1
  28. package/dist/module/CallingClient/types.js +1 -1
  29. package/dist/module/Contacts/ContactsClient.js +487 -487
  30. package/dist/module/Contacts/constants.js +20 -20
  31. package/dist/module/Contacts/contactFixtures.js +284 -284
  32. package/dist/module/Contacts/types.js +10 -10
  33. package/dist/module/Errors/catalog/CallError.js +26 -26
  34. package/dist/module/Errors/catalog/CallingDeviceError.js +18 -18
  35. package/dist/module/Errors/catalog/ExtendedError.js +10 -10
  36. package/dist/module/Errors/catalog/LineError.js +24 -24
  37. package/dist/module/Errors/index.js +2 -2
  38. package/dist/module/Errors/types.js +48 -48
  39. package/dist/module/Events/impl/index.js +19 -19
  40. package/dist/module/Events/types.js +74 -74
  41. package/dist/module/Logger/index.js +114 -114
  42. package/dist/module/Logger/types.js +25 -25
  43. package/dist/module/Metrics/index.js +232 -232
  44. package/dist/module/Metrics/types.js +37 -37
  45. package/dist/module/SDKConnector/index.js +39 -39
  46. package/dist/module/SDKConnector/types.js +1 -1
  47. package/dist/module/SDKConnector/utils.js +12 -12
  48. package/dist/module/Voicemail/BroadworksBackendConnector.js +289 -289
  49. package/dist/module/Voicemail/UcmBackendConnector.js +275 -275
  50. package/dist/module/Voicemail/Voicemail.js +110 -110
  51. package/dist/module/Voicemail/WxCallBackendConnector.js +279 -279
  52. package/dist/module/Voicemail/constants.js +29 -29
  53. package/dist/module/Voicemail/types.js +1 -1
  54. package/dist/module/Voicemail/voicemailFixture.js +449 -449
  55. package/dist/module/common/Utils.js +802 -802
  56. package/dist/module/common/constants.js +40 -40
  57. package/dist/module/common/index.js +1 -1
  58. package/dist/module/common/testUtil.js +938 -938
  59. package/dist/module/common/types.js +57 -57
  60. package/dist/module/index.js +8 -8
  61. package/dist/types/CallHistory/CallHistory.d.ts +18 -18
  62. package/dist/types/CallHistory/callHistoryFixtures.d.ts +94 -94
  63. package/dist/types/CallHistory/constants.d.ts +9 -9
  64. package/dist/types/CallHistory/types.d.ts +20 -20
  65. package/dist/types/CallSettings/CallSettings.d.ts +19 -19
  66. package/dist/types/CallSettings/UcmBackendConnector.d.ts +19 -19
  67. package/dist/types/CallSettings/WxCallBackendConnector.d.ts +21 -21
  68. package/dist/types/CallSettings/constants.d.ts +11 -11
  69. package/dist/types/CallSettings/testFixtures.d.ts +15 -15
  70. package/dist/types/CallSettings/types.d.ts +107 -107
  71. package/dist/types/CallingClient/CallingClient.d.ts +37 -37
  72. package/dist/types/CallingClient/callRecordFixtures.d.ts +3 -3
  73. package/dist/types/CallingClient/calling/CallerId/index.d.ts +17 -17
  74. package/dist/types/CallingClient/calling/CallerId/types.d.ts +41 -41
  75. package/dist/types/CallingClient/calling/call.d.ts +94 -94
  76. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  77. package/dist/types/CallingClient/calling/callManager.d.ts +21 -21
  78. package/dist/types/CallingClient/calling/index.d.ts +2 -2
  79. package/dist/types/CallingClient/calling/types.d.ts +203 -203
  80. package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
  81. package/dist/types/CallingClient/callingClientFixtures.d.ts +18 -18
  82. package/dist/types/CallingClient/constants.d.ts +122 -122
  83. package/dist/types/CallingClient/line/index.d.ts +38 -38
  84. package/dist/types/CallingClient/line/types.d.ts +50 -50
  85. package/dist/types/CallingClient/registration/index.d.ts +1 -1
  86. package/dist/types/CallingClient/registration/register.d.ts +64 -64
  87. package/dist/types/CallingClient/registration/registerFixtures.d.ts +28 -28
  88. package/dist/types/CallingClient/registration/types.d.ts +20 -20
  89. package/dist/types/CallingClient/types.d.ts +29 -29
  90. package/dist/types/Contacts/ContactsClient.d.ts +27 -27
  91. package/dist/types/Contacts/constants.d.ts +19 -19
  92. package/dist/types/Contacts/contactFixtures.d.ts +280 -280
  93. package/dist/types/Contacts/types.d.ts +74 -74
  94. package/dist/types/Errors/catalog/CallError.d.ts +11 -11
  95. package/dist/types/Errors/catalog/CallingDeviceError.d.ts +10 -10
  96. package/dist/types/Errors/catalog/ExtendedError.d.ts +6 -6
  97. package/dist/types/Errors/catalog/LineError.d.ts +10 -10
  98. package/dist/types/Errors/index.d.ts +2 -2
  99. package/dist/types/Errors/types.d.ts +60 -60
  100. package/dist/types/Events/impl/index.d.ts +8 -8
  101. package/dist/types/Events/types.d.ts +283 -283
  102. package/dist/types/Logger/index.d.ts +12 -12
  103. package/dist/types/Logger/types.d.ts +25 -25
  104. package/dist/types/Metrics/index.d.ts +5 -5
  105. package/dist/types/Metrics/types.d.ts +42 -42
  106. package/dist/types/SDKConnector/index.d.ts +12 -12
  107. package/dist/types/SDKConnector/types.d.ts +128 -128
  108. package/dist/types/SDKConnector/utils.d.ts +5 -5
  109. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts +27 -27
  110. package/dist/types/Voicemail/UcmBackendConnector.d.ts +34 -34
  111. package/dist/types/Voicemail/Voicemail.d.ts +27 -27
  112. package/dist/types/Voicemail/WxCallBackendConnector.d.ts +23 -23
  113. package/dist/types/Voicemail/constants.d.ts +29 -29
  114. package/dist/types/Voicemail/types.d.ts +133 -133
  115. package/dist/types/Voicemail/voicemailFixture.d.ts +349 -349
  116. package/dist/types/common/Utils.d.ts +34 -34
  117. package/dist/types/common/constants.d.ts +40 -40
  118. package/dist/types/common/index.d.ts +1 -1
  119. package/dist/types/common/testUtil.d.ts +3611 -3611
  120. package/dist/types/common/types.d.ts +191 -191
  121. package/dist/types/index.d.ts +8 -8
  122. package/package.json +6 -41
@@ -1,275 +1,275 @@
1
- import SDKConnector from '../SDKConnector';
2
- import { HTTP_METHODS, CALLING_BACKEND, } from '../common/types';
3
- import { getVgActionEndpoint, serviceErrorCodeHandler } from '../common/Utils';
4
- import { SUCCESS_MESSAGE, USERS, CONTENT, UCM_CONNECTOR_FILE } from '../common/constants';
5
- import log from '../Logger';
6
- import { API_V1, LIMIT, OFFSET, SORT_ORDER, VMGATEWAY, VOICEMAILS } from './constants';
7
- export class UcmBackendConnector {
8
- vgEndpoint;
9
- userId;
10
- orgId;
11
- sdkConnector;
12
- webex;
13
- vgVoiceMessageURI;
14
- constructor(webex, logger) {
15
- this.sdkConnector = SDKConnector;
16
- if (!this.sdkConnector.getWebex()) {
17
- SDKConnector.setWebex(webex);
18
- }
19
- this.webex = this.sdkConnector.getWebex();
20
- this.userId = this.webex.internal.device.userId;
21
- this.orgId = this.webex.internal.device.orgId;
22
- log.setLogger(logger.level, UCM_CONNECTOR_FILE);
23
- }
24
- init() {
25
- const loggerContext = {
26
- file: UCM_CONNECTOR_FILE,
27
- method: 'init',
28
- };
29
- log.info('Initializing UCM calling voicemail connector', loggerContext);
30
- const response = this.setUcmVoiceMessageBaseURI();
31
- return response;
32
- }
33
- getSDKConnector() {
34
- return this.sdkConnector;
35
- }
36
- setUcmVoiceMessageBaseURI() {
37
- this.vgEndpoint = getVgActionEndpoint(this.webex, CALLING_BACKEND.UCM);
38
- this.vgVoiceMessageURI = `${this.vgEndpoint}/${VMGATEWAY}/${API_V1}/${USERS}/${this.userId}/`;
39
- return this.vgVoiceMessageURI;
40
- }
41
- async getVoicemailList(offset, offsetLimit, sort) {
42
- const loggerContext = {
43
- file: UCM_CONNECTOR_FILE,
44
- method: 'getVoicemailList',
45
- };
46
- log.info(`Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
47
- const urlVg = `${this.vgVoiceMessageURI}${VOICEMAILS}/${OFFSET}=${offset}${LIMIT}=${offsetLimit}${SORT_ORDER}=${sort}`;
48
- try {
49
- const response = await this.webex.request({
50
- uri: `${urlVg}`,
51
- method: HTTP_METHODS.GET,
52
- headers: {
53
- orgId: this.orgId,
54
- },
55
- });
56
- const msgInfo = response.body;
57
- const messageinfoArray = [];
58
- const ucmVmMsgInfo = msgInfo.Message;
59
- ucmVmMsgInfo.forEach((msgInfoObj) => {
60
- const message = {};
61
- let stringObj = {};
62
- const numberObj = {};
63
- stringObj.$ = msgInfoObj.Duration;
64
- message.duration = stringObj;
65
- numberObj.$ = Number(msgInfoObj.ArrivalTime);
66
- message.time = numberObj;
67
- stringObj = { $: '' };
68
- stringObj.$ = msgInfoObj.MsgId;
69
- message.messageId = stringObj;
70
- if (msgInfoObj.Read === 'true') {
71
- message.read = {};
72
- }
73
- const callerIdObj = msgInfoObj.CallerId;
74
- const callingParty = {};
75
- stringObj = { $: '' };
76
- stringObj.$ = callerIdObj.CallerName;
77
- callingParty.name = stringObj;
78
- stringObj = { $: '' };
79
- stringObj.$ = this.userId;
80
- callingParty.userId = stringObj;
81
- stringObj = { $: '' };
82
- stringObj.$ = callerIdObj.CallerNumber;
83
- callingParty.address = stringObj;
84
- message.callingPartyInfo = callingParty;
85
- messageinfoArray.push(message);
86
- });
87
- const responseDetails = {
88
- statusCode: response.statusCode,
89
- data: {
90
- voicemailList: messageinfoArray,
91
- },
92
- message: SUCCESS_MESSAGE,
93
- };
94
- return responseDetails;
95
- }
96
- catch (err) {
97
- const errorInfo = err;
98
- const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
99
- return errorStatus;
100
- }
101
- }
102
- async getVoicemailContent(messageId) {
103
- const loggerContext = {
104
- file: UCM_CONNECTOR_FILE,
105
- method: 'getVoicemailContent',
106
- };
107
- try {
108
- const response = (await this.getVoicemailContentUcm(messageId));
109
- return response;
110
- }
111
- catch (err) {
112
- const errorInfo = err;
113
- const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
114
- log.info(`Voice mail content error is ${errorStatus}`, loggerContext);
115
- return errorStatus;
116
- }
117
- }
118
- async getVoicemailSummary() {
119
- return Promise.resolve(null);
120
- }
121
- async getVoicemailContentUcm(messageId) {
122
- return new Promise((resolve, reject) => {
123
- const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}/${CONTENT}`;
124
- const mercuryApi = `${this.webex.internal.services._serviceUrls.mercuryApi}`;
125
- this.returnUcmPromise(voicemailContentUrl, mercuryApi)
126
- .then((response) => {
127
- if (response.statusCode === 200) {
128
- resolve(response);
129
- }
130
- else if (response.statusCode === 202) {
131
- this.sdkConnector.registerListener('event:ucm.voicemail_download_complete', async (event) => {
132
- const responseEvent = event;
133
- const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${responseEvent?.data?.messageId}/${CONTENT}`;
134
- const response = await this.returnUcmPromise(voicemailContentUrl, mercuryApi);
135
- if (response.statusCode === 200) {
136
- this.sdkConnector.unregisterListener('event:ucm.voicemail_download_complete');
137
- resolve(response);
138
- }
139
- else {
140
- this.sdkConnector.unregisterListener('event:ucm.voicemail_download_complete');
141
- reject(response);
142
- }
143
- });
144
- }
145
- else {
146
- reject(response);
147
- }
148
- })
149
- .catch((err) => {
150
- reject(err);
151
- });
152
- });
153
- }
154
- async returnUcmPromise(voicemailContentUrl, mercuryApi) {
155
- const response = await this.webex.request({
156
- uri: `${voicemailContentUrl}`,
157
- method: HTTP_METHODS.GET,
158
- headers: {
159
- orgId: this.orgId,
160
- deviceUrl: this.webex.internal.device.url,
161
- mercuryHostname: mercuryApi,
162
- },
163
- });
164
- const contentInfo = response?.body;
165
- const respHeaders = response.headers;
166
- const mediaType = respHeaders?.mediatype;
167
- const mediaContent = contentInfo;
168
- const responseDetails = {
169
- statusCode: response.statusCode,
170
- data: {
171
- voicemailContent: {
172
- type: mediaType,
173
- content: mediaContent,
174
- },
175
- },
176
- message: SUCCESS_MESSAGE,
177
- };
178
- return responseDetails;
179
- }
180
- async voicemailMarkAsRead(messageId) {
181
- const loggerContext = {
182
- file: UCM_CONNECTOR_FILE,
183
- method: 'voicemailMarkAsRead',
184
- };
185
- try {
186
- const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
187
- const response = await this.webex.request({
188
- uri: voicemailContentUrl,
189
- method: HTTP_METHODS.PUT,
190
- headers: {
191
- orgId: this.orgId,
192
- },
193
- body: {
194
- read: 'true',
195
- },
196
- });
197
- const responseDetails = {
198
- statusCode: response.statusCode,
199
- data: {},
200
- message: SUCCESS_MESSAGE,
201
- };
202
- return responseDetails;
203
- }
204
- catch (err) {
205
- const errorInfo = err;
206
- const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
207
- return errorStatus;
208
- }
209
- }
210
- async voicemailMarkAsUnread(messageId) {
211
- const loggerContext = {
212
- file: UCM_CONNECTOR_FILE,
213
- method: 'voicemailMarkAsUnread',
214
- };
215
- try {
216
- const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
217
- const response = await this.webex.request({
218
- uri: voicemailContentUrl,
219
- method: HTTP_METHODS.PUT,
220
- headers: {
221
- orgId: this.orgId,
222
- },
223
- body: {
224
- read: 'false',
225
- },
226
- });
227
- const responseDetails = {
228
- statusCode: response.statusCode,
229
- data: {},
230
- message: SUCCESS_MESSAGE,
231
- };
232
- return responseDetails;
233
- }
234
- catch (err) {
235
- const errorInfo = err;
236
- const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
237
- return errorStatus;
238
- }
239
- }
240
- async deleteVoicemail(messageId) {
241
- const loggerContext = {
242
- file: UCM_CONNECTOR_FILE,
243
- method: 'deleteVoicemail',
244
- };
245
- try {
246
- const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
247
- const response = await this.webex.request({
248
- uri: voicemailContentUrl,
249
- method: HTTP_METHODS.DELETE,
250
- headers: {
251
- orgId: this.orgId,
252
- },
253
- });
254
- const responseDetails = {
255
- statusCode: response.statusCode,
256
- data: {},
257
- message: SUCCESS_MESSAGE,
258
- };
259
- return responseDetails;
260
- }
261
- catch (err) {
262
- const errorInfo = err;
263
- const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
264
- return errorStatus;
265
- }
266
- }
267
- async getVMTranscript(messageId) {
268
- log.info(`Message Id: ${messageId}`, {});
269
- return Promise.resolve(null);
270
- }
271
- resolveContact(callingPartyInfo) {
272
- log.info(`Calling Party Info: ${callingPartyInfo}`, {});
273
- return Promise.resolve(null);
274
- }
275
- }
1
+ import SDKConnector from '../SDKConnector';
2
+ import { HTTP_METHODS, CALLING_BACKEND, } from '../common/types';
3
+ import { getVgActionEndpoint, serviceErrorCodeHandler } from '../common/Utils';
4
+ import { SUCCESS_MESSAGE, USERS, CONTENT, UCM_CONNECTOR_FILE } from '../common/constants';
5
+ import log from '../Logger';
6
+ import { API_V1, LIMIT, OFFSET, SORT_ORDER, VMGATEWAY, VOICEMAILS } from './constants';
7
+ export class UcmBackendConnector {
8
+ vgEndpoint;
9
+ userId;
10
+ orgId;
11
+ sdkConnector;
12
+ webex;
13
+ vgVoiceMessageURI;
14
+ constructor(webex, logger) {
15
+ this.sdkConnector = SDKConnector;
16
+ if (!this.sdkConnector.getWebex()) {
17
+ SDKConnector.setWebex(webex);
18
+ }
19
+ this.webex = this.sdkConnector.getWebex();
20
+ this.userId = this.webex.internal.device.userId;
21
+ this.orgId = this.webex.internal.device.orgId;
22
+ log.setLogger(logger.level, UCM_CONNECTOR_FILE);
23
+ }
24
+ init() {
25
+ const loggerContext = {
26
+ file: UCM_CONNECTOR_FILE,
27
+ method: 'init',
28
+ };
29
+ log.info('Initializing UCM calling voicemail connector', loggerContext);
30
+ const response = this.setUcmVoiceMessageBaseURI();
31
+ return response;
32
+ }
33
+ getSDKConnector() {
34
+ return this.sdkConnector;
35
+ }
36
+ setUcmVoiceMessageBaseURI() {
37
+ this.vgEndpoint = getVgActionEndpoint(this.webex, CALLING_BACKEND.UCM);
38
+ this.vgVoiceMessageURI = `${this.vgEndpoint}/${VMGATEWAY}/${API_V1}/${USERS}/${this.userId}/`;
39
+ return this.vgVoiceMessageURI;
40
+ }
41
+ async getVoicemailList(offset, offsetLimit, sort) {
42
+ const loggerContext = {
43
+ file: UCM_CONNECTOR_FILE,
44
+ method: 'getVoicemailList',
45
+ };
46
+ log.info(`Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
47
+ const urlVg = `${this.vgVoiceMessageURI}${VOICEMAILS}/${OFFSET}=${offset}${LIMIT}=${offsetLimit}${SORT_ORDER}=${sort}`;
48
+ try {
49
+ const response = await this.webex.request({
50
+ uri: `${urlVg}`,
51
+ method: HTTP_METHODS.GET,
52
+ headers: {
53
+ orgId: this.orgId,
54
+ },
55
+ });
56
+ const msgInfo = response.body;
57
+ const messageinfoArray = [];
58
+ const ucmVmMsgInfo = msgInfo.Message;
59
+ ucmVmMsgInfo.forEach((msgInfoObj) => {
60
+ const message = {};
61
+ let stringObj = {};
62
+ const numberObj = {};
63
+ stringObj.$ = msgInfoObj.Duration;
64
+ message.duration = stringObj;
65
+ numberObj.$ = Number(msgInfoObj.ArrivalTime);
66
+ message.time = numberObj;
67
+ stringObj = { $: '' };
68
+ stringObj.$ = msgInfoObj.MsgId;
69
+ message.messageId = stringObj;
70
+ if (msgInfoObj.Read === 'true') {
71
+ message.read = {};
72
+ }
73
+ const callerIdObj = msgInfoObj.CallerId;
74
+ const callingParty = {};
75
+ stringObj = { $: '' };
76
+ stringObj.$ = callerIdObj.CallerName;
77
+ callingParty.name = stringObj;
78
+ stringObj = { $: '' };
79
+ stringObj.$ = this.userId;
80
+ callingParty.userId = stringObj;
81
+ stringObj = { $: '' };
82
+ stringObj.$ = callerIdObj.CallerNumber;
83
+ callingParty.address = stringObj;
84
+ message.callingPartyInfo = callingParty;
85
+ messageinfoArray.push(message);
86
+ });
87
+ const responseDetails = {
88
+ statusCode: response.statusCode,
89
+ data: {
90
+ voicemailList: messageinfoArray,
91
+ },
92
+ message: SUCCESS_MESSAGE,
93
+ };
94
+ return responseDetails;
95
+ }
96
+ catch (err) {
97
+ const errorInfo = err;
98
+ const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
99
+ return errorStatus;
100
+ }
101
+ }
102
+ async getVoicemailContent(messageId) {
103
+ const loggerContext = {
104
+ file: UCM_CONNECTOR_FILE,
105
+ method: 'getVoicemailContent',
106
+ };
107
+ try {
108
+ const response = (await this.getVoicemailContentUcm(messageId));
109
+ return response;
110
+ }
111
+ catch (err) {
112
+ const errorInfo = err;
113
+ const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
114
+ log.info(`Voice mail content error is ${errorStatus}`, loggerContext);
115
+ return errorStatus;
116
+ }
117
+ }
118
+ async getVoicemailSummary() {
119
+ return Promise.resolve(null);
120
+ }
121
+ async getVoicemailContentUcm(messageId) {
122
+ return new Promise((resolve, reject) => {
123
+ const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}/${CONTENT}`;
124
+ const mercuryApi = `${this.webex.internal.services._serviceUrls.mercuryApi}`;
125
+ this.returnUcmPromise(voicemailContentUrl, mercuryApi)
126
+ .then((response) => {
127
+ if (response.statusCode === 200) {
128
+ resolve(response);
129
+ }
130
+ else if (response.statusCode === 202) {
131
+ this.sdkConnector.registerListener('event:ucm.voicemail_download_complete', async (event) => {
132
+ const responseEvent = event;
133
+ const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${responseEvent?.data?.messageId}/${CONTENT}`;
134
+ const response = await this.returnUcmPromise(voicemailContentUrl, mercuryApi);
135
+ if (response.statusCode === 200) {
136
+ this.sdkConnector.unregisterListener('event:ucm.voicemail_download_complete');
137
+ resolve(response);
138
+ }
139
+ else {
140
+ this.sdkConnector.unregisterListener('event:ucm.voicemail_download_complete');
141
+ reject(response);
142
+ }
143
+ });
144
+ }
145
+ else {
146
+ reject(response);
147
+ }
148
+ })
149
+ .catch((err) => {
150
+ reject(err);
151
+ });
152
+ });
153
+ }
154
+ async returnUcmPromise(voicemailContentUrl, mercuryApi) {
155
+ const response = await this.webex.request({
156
+ uri: `${voicemailContentUrl}`,
157
+ method: HTTP_METHODS.GET,
158
+ headers: {
159
+ orgId: this.orgId,
160
+ deviceUrl: this.webex.internal.device.url,
161
+ mercuryHostname: mercuryApi,
162
+ },
163
+ });
164
+ const contentInfo = response?.body;
165
+ const respHeaders = response.headers;
166
+ const mediaType = respHeaders?.mediatype;
167
+ const mediaContent = contentInfo;
168
+ const responseDetails = {
169
+ statusCode: response.statusCode,
170
+ data: {
171
+ voicemailContent: {
172
+ type: mediaType,
173
+ content: mediaContent,
174
+ },
175
+ },
176
+ message: SUCCESS_MESSAGE,
177
+ };
178
+ return responseDetails;
179
+ }
180
+ async voicemailMarkAsRead(messageId) {
181
+ const loggerContext = {
182
+ file: UCM_CONNECTOR_FILE,
183
+ method: 'voicemailMarkAsRead',
184
+ };
185
+ try {
186
+ const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
187
+ const response = await this.webex.request({
188
+ uri: voicemailContentUrl,
189
+ method: HTTP_METHODS.PUT,
190
+ headers: {
191
+ orgId: this.orgId,
192
+ },
193
+ body: {
194
+ read: 'true',
195
+ },
196
+ });
197
+ const responseDetails = {
198
+ statusCode: response.statusCode,
199
+ data: {},
200
+ message: SUCCESS_MESSAGE,
201
+ };
202
+ return responseDetails;
203
+ }
204
+ catch (err) {
205
+ const errorInfo = err;
206
+ const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
207
+ return errorStatus;
208
+ }
209
+ }
210
+ async voicemailMarkAsUnread(messageId) {
211
+ const loggerContext = {
212
+ file: UCM_CONNECTOR_FILE,
213
+ method: 'voicemailMarkAsUnread',
214
+ };
215
+ try {
216
+ const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
217
+ const response = await this.webex.request({
218
+ uri: voicemailContentUrl,
219
+ method: HTTP_METHODS.PUT,
220
+ headers: {
221
+ orgId: this.orgId,
222
+ },
223
+ body: {
224
+ read: 'false',
225
+ },
226
+ });
227
+ const responseDetails = {
228
+ statusCode: response.statusCode,
229
+ data: {},
230
+ message: SUCCESS_MESSAGE,
231
+ };
232
+ return responseDetails;
233
+ }
234
+ catch (err) {
235
+ const errorInfo = err;
236
+ const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
237
+ return errorStatus;
238
+ }
239
+ }
240
+ async deleteVoicemail(messageId) {
241
+ const loggerContext = {
242
+ file: UCM_CONNECTOR_FILE,
243
+ method: 'deleteVoicemail',
244
+ };
245
+ try {
246
+ const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
247
+ const response = await this.webex.request({
248
+ uri: voicemailContentUrl,
249
+ method: HTTP_METHODS.DELETE,
250
+ headers: {
251
+ orgId: this.orgId,
252
+ },
253
+ });
254
+ const responseDetails = {
255
+ statusCode: response.statusCode,
256
+ data: {},
257
+ message: SUCCESS_MESSAGE,
258
+ };
259
+ return responseDetails;
260
+ }
261
+ catch (err) {
262
+ const errorInfo = err;
263
+ const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
264
+ return errorStatus;
265
+ }
266
+ }
267
+ async getVMTranscript(messageId) {
268
+ log.info(`Message Id: ${messageId}`, {});
269
+ return Promise.resolve(null);
270
+ }
271
+ resolveContact(callingPartyInfo) {
272
+ log.info(`Calling Party Info: ${callingPartyInfo}`, {});
273
+ return Promise.resolve(null);
274
+ }
275
+ }