@webex/calling 3.8.0 → 3.8.1-next.10
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.
- package/dist/CallHistory/CallHistory.js +100 -63
- package/dist/CallHistory/CallHistory.js.map +1 -1
- package/dist/CallHistory/CallHistory.test.js +115 -19
- package/dist/CallHistory/CallHistory.test.js.map +1 -1
- package/dist/CallHistory/constants.js +9 -1
- package/dist/CallHistory/constants.js.map +1 -1
- package/dist/CallSettings/CallSettings.js +46 -13
- package/dist/CallSettings/CallSettings.js.map +1 -1
- package/dist/CallSettings/UcmBackendConnector.js +62 -18
- package/dist/CallSettings/UcmBackendConnector.js.map +1 -1
- package/dist/CallSettings/UcmBackendConnector.test.js +70 -7
- package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -1
- package/dist/CallSettings/WxCallBackendConnector.js +153 -103
- package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
- package/dist/CallSettings/WxCallBackendConnector.test.js +52 -15
- package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
- package/dist/CallSettings/constants.js +15 -1
- package/dist/CallSettings/constants.js.map +1 -1
- package/dist/CallingClient/CallingClient.js +220 -159
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +58 -27
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +251 -189
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +96 -41
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/calling/callManager.js +73 -48
- package/dist/CallingClient/calling/callManager.js.map +1 -1
- package/dist/CallingClient/calling/callManager.test.js +96 -37
- package/dist/CallingClient/calling/callManager.test.js.map +1 -1
- package/dist/CallingClient/constants.js +105 -3
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/index.js +47 -18
- package/dist/CallingClient/line/index.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +6 -12
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +590 -522
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +821 -394
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.js +115 -0
- package/dist/CallingClient/registration/webWorker.js.map +1 -0
- package/dist/CallingClient/registration/webWorker.test.js +256 -0
- package/dist/CallingClient/registration/webWorker.test.js.map +1 -0
- package/dist/CallingClient/registration/webWorkerStr.js +15 -0
- package/dist/CallingClient/registration/webWorkerStr.js.map +1 -0
- package/dist/Contacts/ContactsClient.js +156 -102
- package/dist/Contacts/ContactsClient.js.map +1 -1
- package/dist/Contacts/ContactsClient.test.js +197 -49
- package/dist/Contacts/ContactsClient.test.js.map +1 -1
- package/dist/Contacts/constants.js +11 -1
- package/dist/Contacts/constants.js.map +1 -1
- package/dist/Errors/types.js +2 -0
- package/dist/Errors/types.js.map +1 -1
- package/dist/Events/impl/index.js +1 -1
- package/dist/Events/impl/index.js.map +1 -1
- package/dist/Metrics/index.js +102 -41
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/index.test.js +10 -4
- package/dist/Metrics/index.test.js.map +1 -1
- package/dist/Metrics/types.js +4 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/Voicemail/BroadworksBackendConnector.js +154 -91
- package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
- package/dist/Voicemail/BroadworksBackendConnector.test.js +99 -19
- package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/UcmBackendConnector.js +105 -54
- package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
- package/dist/Voicemail/UcmBackendConnector.test.js +127 -17
- package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/Voicemail.js +198 -79
- package/dist/Voicemail/Voicemail.js.map +1 -1
- package/dist/Voicemail/Voicemail.test.js +188 -23
- package/dist/Voicemail/Voicemail.test.js.map +1 -1
- package/dist/Voicemail/WxCallBackendConnector.js +277 -161
- package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
- package/dist/Voicemail/WxCallBackendConnector.test.js +268 -10
- package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
- package/dist/Voicemail/constants.js +25 -1
- package/dist/Voicemail/constants.js.map +1 -1
- package/dist/Voicemail/types.js.map +1 -1
- package/dist/common/Utils.js +168 -104
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +199 -35
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/common/constants.js +2 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/common/testUtil.js +3 -0
- package/dist/common/testUtil.js.map +1 -1
- package/dist/common/types.js +8 -1
- package/dist/common/types.js.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/module/CallHistory/CallHistory.js +32 -13
- package/dist/module/CallHistory/constants.js +6 -0
- package/dist/module/CallSettings/CallSettings.js +36 -3
- package/dist/module/CallSettings/UcmBackendConnector.js +50 -5
- package/dist/module/CallSettings/WxCallBackendConnector.js +54 -18
- package/dist/module/CallSettings/constants.js +12 -0
- package/dist/module/CallingClient/CallingClient.js +54 -16
- package/dist/module/CallingClient/calling/call.js +172 -121
- package/dist/module/CallingClient/calling/callManager.js +51 -26
- package/dist/module/CallingClient/constants.js +102 -2
- package/dist/module/CallingClient/line/index.js +37 -8
- package/dist/module/CallingClient/registration/register.js +151 -112
- package/dist/module/CallingClient/registration/webWorker.js +59 -0
- package/dist/module/CallingClient/registration/webWorkerStr.js +93 -0
- package/dist/module/Contacts/ContactsClient.js +65 -21
- package/dist/module/Contacts/constants.js +10 -0
- package/dist/module/Errors/types.js +2 -0
- package/dist/module/Events/impl/index.js +1 -1
- package/dist/module/Metrics/index.js +57 -2
- package/dist/module/Metrics/types.js +3 -0
- package/dist/module/Voicemail/BroadworksBackendConnector.js +66 -17
- package/dist/module/Voicemail/UcmBackendConnector.js +51 -11
- package/dist/module/Voicemail/Voicemail.js +109 -9
- package/dist/module/Voicemail/WxCallBackendConnector.js +67 -18
- package/dist/module/Voicemail/constants.js +21 -0
- package/dist/module/common/Utils.js +51 -12
- package/dist/module/common/constants.js +1 -0
- package/dist/module/common/testUtil.js +3 -0
- package/dist/module/common/types.js +7 -0
- package/dist/module/index.js +1 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
- package/dist/types/CallHistory/constants.d.ts +6 -0
- package/dist/types/CallHistory/constants.d.ts.map +1 -1
- package/dist/types/CallSettings/CallSettings.d.ts.map +1 -1
- package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/CallSettings/constants.d.ts +12 -0
- package/dist/types/CallSettings/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/CallingClient.d.ts +2 -3
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +102 -2
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/line/index.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +4 -3
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +1 -0
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorker.d.ts +2 -0
- package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -0
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts +3 -0
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -0
- package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
- package/dist/types/Contacts/constants.d.ts +10 -0
- package/dist/types/Contacts/constants.d.ts.map +1 -1
- package/dist/types/Errors/types.d.ts +2 -0
- package/dist/types/Errors/types.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +7 -2
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +11 -2
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/Voicemail.d.ts +1 -1
- package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts +3 -1
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
- package/dist/types/Voicemail/constants.d.ts +21 -0
- package/dist/types/Voicemail/constants.d.ts.map +1 -1
- package/dist/types/Voicemail/types.d.ts +1 -1
- package/dist/types/Voicemail/types.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +4 -4
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/constants.d.ts +1 -0
- package/dist/types/common/constants.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +3 -0
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +24 -0
- package/dist/types/common/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import SDKConnector from '../SDKConnector';
|
|
2
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, FAILURE_MESSAGE, } from '../common/constants';
|
|
3
|
+
import { getVgActionEndpoint, serviceErrorCodeHandler, uploadLogs } from '../common/Utils';
|
|
4
|
+
import { SUCCESS_MESSAGE, USERS, CONTENT, UCM_CONNECTOR_FILE, FAILURE_MESSAGE, METHOD_START_MESSAGE, } from '../common/constants';
|
|
5
5
|
import log from '../Logger';
|
|
6
|
-
import { API_V1, LIMIT, OFFSET, SORT_ORDER, VMGATEWAY, VOICEMAILS } from './constants';
|
|
6
|
+
import { API_V1, LIMIT, METHODS, OFFSET, SORT_ORDER, VMGATEWAY, VOICEMAILS } from './constants';
|
|
7
7
|
export class UcmBackendConnector {
|
|
8
8
|
vgEndpoint;
|
|
9
9
|
userId;
|
|
@@ -24,16 +24,22 @@ export class UcmBackendConnector {
|
|
|
24
24
|
init() {
|
|
25
25
|
const loggerContext = {
|
|
26
26
|
file: UCM_CONNECTOR_FILE,
|
|
27
|
-
method:
|
|
27
|
+
method: METHODS.INIT,
|
|
28
28
|
};
|
|
29
|
-
log.info(
|
|
29
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
30
30
|
const response = this.setUcmVoiceMessageBaseURI();
|
|
31
|
+
log.log('UCM calling voicemail connector initialized successfully', loggerContext);
|
|
31
32
|
return response;
|
|
32
33
|
}
|
|
33
34
|
getSDKConnector() {
|
|
34
35
|
return this.sdkConnector;
|
|
35
36
|
}
|
|
36
37
|
setUcmVoiceMessageBaseURI() {
|
|
38
|
+
const loggerContext = {
|
|
39
|
+
file: UCM_CONNECTOR_FILE,
|
|
40
|
+
method: METHODS.SET_UCM_VOICE_MESSAGE_BASE_URI,
|
|
41
|
+
};
|
|
42
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
37
43
|
this.vgEndpoint = getVgActionEndpoint(this.webex, CALLING_BACKEND.UCM);
|
|
38
44
|
this.vgVoiceMessageURI = `${this.vgEndpoint}/${VMGATEWAY}/${API_V1}/${USERS}/${this.userId}/`;
|
|
39
45
|
return this.vgVoiceMessageURI;
|
|
@@ -41,9 +47,9 @@ export class UcmBackendConnector {
|
|
|
41
47
|
async getVoicemailList(offset, offsetLimit, sort) {
|
|
42
48
|
const loggerContext = {
|
|
43
49
|
file: UCM_CONNECTOR_FILE,
|
|
44
|
-
method:
|
|
50
|
+
method: METHODS.GET_VOICEMAIL_LIST,
|
|
45
51
|
};
|
|
46
|
-
log.info(
|
|
52
|
+
log.info(`${METHOD_START_MESSAGE} with Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
|
|
47
53
|
const urlVg = `${this.vgVoiceMessageURI}${VOICEMAILS}/${OFFSET}=${offset}${LIMIT}=${offsetLimit}${SORT_ORDER}=${sort}`;
|
|
48
54
|
try {
|
|
49
55
|
const response = await this.webex.request({
|
|
@@ -91,9 +97,13 @@ export class UcmBackendConnector {
|
|
|
91
97
|
},
|
|
92
98
|
message: SUCCESS_MESSAGE,
|
|
93
99
|
};
|
|
100
|
+
log.log('Successfully retrieved voicemail list', loggerContext);
|
|
94
101
|
return responseDetails;
|
|
95
102
|
}
|
|
96
103
|
catch (err) {
|
|
104
|
+
const extendedError = new Error(`Failed to get voicemail list: ${err}`);
|
|
105
|
+
log.error(extendedError, loggerContext);
|
|
106
|
+
await uploadLogs();
|
|
97
107
|
const errorInfo = err;
|
|
98
108
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
99
109
|
return errorStatus;
|
|
@@ -102,13 +112,18 @@ export class UcmBackendConnector {
|
|
|
102
112
|
async getVoicemailContent(messageId) {
|
|
103
113
|
const loggerContext = {
|
|
104
114
|
file: UCM_CONNECTOR_FILE,
|
|
105
|
-
method:
|
|
115
|
+
method: METHODS.GET_VOICEMAIL_CONTENT,
|
|
106
116
|
};
|
|
117
|
+
log.info(`${METHOD_START_MESSAGE} with Message ID: ${messageId}`, loggerContext);
|
|
107
118
|
try {
|
|
108
119
|
const response = (await this.getVoicemailContentUcm(messageId));
|
|
120
|
+
log.log(`Successfully retrieved voicemail content with Message ID: ${messageId}`, loggerContext);
|
|
109
121
|
return response;
|
|
110
122
|
}
|
|
111
123
|
catch (err) {
|
|
124
|
+
const extendedError = new Error(`Failed to get voicemail content: ${err}`);
|
|
125
|
+
log.error(extendedError, loggerContext);
|
|
126
|
+
await uploadLogs();
|
|
112
127
|
const errorInfo = err;
|
|
113
128
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
114
129
|
log.info(`Voice mail content error is ${errorStatus}`, loggerContext);
|
|
@@ -119,6 +134,11 @@ export class UcmBackendConnector {
|
|
|
119
134
|
return Promise.resolve(null);
|
|
120
135
|
}
|
|
121
136
|
async getVoicemailContentUcm(messageId) {
|
|
137
|
+
const loggerContext = {
|
|
138
|
+
file: UCM_CONNECTOR_FILE,
|
|
139
|
+
method: METHODS.GET_VOICEMAIL_CONTENT_UCM,
|
|
140
|
+
};
|
|
141
|
+
log.info(`${METHOD_START_MESSAGE} with Message ID: ${messageId}`, loggerContext);
|
|
122
142
|
return new Promise((resolve, reject) => {
|
|
123
143
|
const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}/${CONTENT}`;
|
|
124
144
|
const mercuryApi = `${this.webex.internal.services._serviceUrls.mercuryApi}`;
|
|
@@ -152,6 +172,11 @@ export class UcmBackendConnector {
|
|
|
152
172
|
});
|
|
153
173
|
}
|
|
154
174
|
async returnUcmPromise(voicemailContentUrl, mercuryApi) {
|
|
175
|
+
const loggerContext = {
|
|
176
|
+
file: UCM_CONNECTOR_FILE,
|
|
177
|
+
method: METHODS.RETURN_UCM_PROMISE,
|
|
178
|
+
};
|
|
179
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
155
180
|
const response = await this.webex.request({
|
|
156
181
|
uri: `${voicemailContentUrl}`,
|
|
157
182
|
method: HTTP_METHODS.GET,
|
|
@@ -184,8 +209,9 @@ export class UcmBackendConnector {
|
|
|
184
209
|
async voicemailMarkAsRead(messageId) {
|
|
185
210
|
const loggerContext = {
|
|
186
211
|
file: UCM_CONNECTOR_FILE,
|
|
187
|
-
method:
|
|
212
|
+
method: METHODS.VOICEMAIL_MARK_AS_READ,
|
|
188
213
|
};
|
|
214
|
+
log.info(`${METHOD_START_MESSAGE} with Message ID: ${messageId}`, loggerContext);
|
|
189
215
|
try {
|
|
190
216
|
const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
|
|
191
217
|
const response = await this.webex.request({
|
|
@@ -203,9 +229,13 @@ export class UcmBackendConnector {
|
|
|
203
229
|
data: {},
|
|
204
230
|
message: SUCCESS_MESSAGE,
|
|
205
231
|
};
|
|
232
|
+
log.log('Successfully marked voicemail as read', loggerContext);
|
|
206
233
|
return responseDetails;
|
|
207
234
|
}
|
|
208
235
|
catch (err) {
|
|
236
|
+
const extendedError = new Error(`Failed to mark voicemail as read: ${err}`);
|
|
237
|
+
log.error(extendedError, loggerContext);
|
|
238
|
+
await uploadLogs();
|
|
209
239
|
const errorInfo = err;
|
|
210
240
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
211
241
|
return errorStatus;
|
|
@@ -214,8 +244,9 @@ export class UcmBackendConnector {
|
|
|
214
244
|
async voicemailMarkAsUnread(messageId) {
|
|
215
245
|
const loggerContext = {
|
|
216
246
|
file: UCM_CONNECTOR_FILE,
|
|
217
|
-
method:
|
|
247
|
+
method: METHODS.VOICEMAIL_MARK_AS_UNREAD,
|
|
218
248
|
};
|
|
249
|
+
log.info(`${METHOD_START_MESSAGE} with Message ID: ${messageId}`, loggerContext);
|
|
219
250
|
try {
|
|
220
251
|
const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
|
|
221
252
|
const response = await this.webex.request({
|
|
@@ -233,9 +264,13 @@ export class UcmBackendConnector {
|
|
|
233
264
|
data: {},
|
|
234
265
|
message: SUCCESS_MESSAGE,
|
|
235
266
|
};
|
|
267
|
+
log.log('Successfully marked voicemail as unread', loggerContext);
|
|
236
268
|
return responseDetails;
|
|
237
269
|
}
|
|
238
270
|
catch (err) {
|
|
271
|
+
const extendedError = new Error(`Failed to mark voicemail as unread: ${err}`);
|
|
272
|
+
log.error(extendedError, loggerContext);
|
|
273
|
+
await uploadLogs();
|
|
239
274
|
const errorInfo = err;
|
|
240
275
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
241
276
|
return errorStatus;
|
|
@@ -244,8 +279,9 @@ export class UcmBackendConnector {
|
|
|
244
279
|
async deleteVoicemail(messageId) {
|
|
245
280
|
const loggerContext = {
|
|
246
281
|
file: UCM_CONNECTOR_FILE,
|
|
247
|
-
method:
|
|
282
|
+
method: METHODS.DELETE_VOICEMAIL,
|
|
248
283
|
};
|
|
284
|
+
log.info(`${METHOD_START_MESSAGE} with Message ID: ${messageId}`, loggerContext);
|
|
249
285
|
try {
|
|
250
286
|
const voicemailContentUrl = `${this.vgVoiceMessageURI}${VOICEMAILS}/${messageId}`;
|
|
251
287
|
const response = await this.webex.request({
|
|
@@ -260,9 +296,13 @@ export class UcmBackendConnector {
|
|
|
260
296
|
data: {},
|
|
261
297
|
message: SUCCESS_MESSAGE,
|
|
262
298
|
};
|
|
299
|
+
log.log('Successfully deleted voicemail', loggerContext);
|
|
263
300
|
return responseDetails;
|
|
264
301
|
}
|
|
265
302
|
catch (err) {
|
|
303
|
+
const extendedError = new Error(`Failed to delete voicemail: ${err}`);
|
|
304
|
+
log.error(extendedError, loggerContext);
|
|
305
|
+
await uploadLogs();
|
|
266
306
|
const errorInfo = err;
|
|
267
307
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
268
308
|
return errorStatus;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { METHOD_START_MESSAGE } from '../common/constants';
|
|
1
2
|
import SDKConnector from '../SDKConnector';
|
|
2
3
|
import { CALLING_BACKEND } from '../common/types';
|
|
3
4
|
import log from '../Logger';
|
|
4
|
-
import { getCallingBackEnd } from '../common/Utils';
|
|
5
|
+
import { getCallingBackEnd, uploadLogs } from '../common/Utils';
|
|
5
6
|
import { WxCallBackendConnector } from './WxCallBackendConnector';
|
|
6
7
|
import { BroadworksBackendConnector } from './BroadworksBackendConnector';
|
|
7
8
|
import { Eventing } from '../Events/impl';
|
|
8
9
|
import { UcmBackendConnector } from './UcmBackendConnector';
|
|
9
10
|
import { METRIC_EVENT, METRIC_TYPE, VOICEMAIL_ACTION } from '../Metrics/types';
|
|
10
11
|
import { getMetricManager } from '../Metrics';
|
|
11
|
-
import { VOICEMAIL_FILE } from './constants';
|
|
12
|
+
import { VOICEMAIL_FILE, METHODS } from './constants';
|
|
12
13
|
export class Voicemail extends Eventing {
|
|
13
14
|
logger;
|
|
14
15
|
sdkConnector;
|
|
@@ -29,11 +30,34 @@ export class Voicemail extends Eventing {
|
|
|
29
30
|
this.initializeBackendConnector();
|
|
30
31
|
log.setLogger(logger.level, VOICEMAIL_FILE);
|
|
31
32
|
}
|
|
32
|
-
init() {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
async init() {
|
|
34
|
+
try {
|
|
35
|
+
log.info(METHOD_START_MESSAGE, {
|
|
36
|
+
file: VOICEMAIL_FILE,
|
|
37
|
+
method: METHODS.INIT,
|
|
38
|
+
});
|
|
39
|
+
const response = this.backendConnector.init();
|
|
40
|
+
log.log('Voicemail connector initialized successfully', {
|
|
41
|
+
file: VOICEMAIL_FILE,
|
|
42
|
+
method: METHODS.INIT,
|
|
43
|
+
});
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
const extendedError = new Error(`Failed to initialize voicemail: ${err}`);
|
|
48
|
+
log.error(extendedError, {
|
|
49
|
+
file: VOICEMAIL_FILE,
|
|
50
|
+
method: METHODS.INIT,
|
|
51
|
+
});
|
|
52
|
+
await uploadLogs();
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
35
55
|
}
|
|
36
56
|
initializeBackendConnector() {
|
|
57
|
+
log.info(METHOD_START_MESSAGE, {
|
|
58
|
+
file: VOICEMAIL_FILE,
|
|
59
|
+
method: METHODS.INITIALIZE_BACKEND_CONNECTOR,
|
|
60
|
+
});
|
|
37
61
|
switch (this.callingBackend) {
|
|
38
62
|
case CALLING_BACKEND.WXC: {
|
|
39
63
|
this.backendConnector = new WxCallBackendConnector(this.webex, this.logger);
|
|
@@ -62,46 +86,122 @@ export class Voicemail extends Eventing {
|
|
|
62
86
|
}
|
|
63
87
|
}
|
|
64
88
|
async getVoicemailList(offset, offsetLimit, sort, refresh) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
89
|
+
try {
|
|
90
|
+
log.info(`${METHOD_START_MESSAGE} with: offset=${offset}, limit=${offsetLimit}, sort=${sort}, refresh=${refresh}`, {
|
|
91
|
+
file: VOICEMAIL_FILE,
|
|
92
|
+
method: METHODS.GET_VOICEMAIL_LIST,
|
|
93
|
+
});
|
|
94
|
+
const response = await this.backendConnector.getVoicemailList(offset, offsetLimit, sort, refresh);
|
|
95
|
+
this.submitMetric(response, VOICEMAIL_ACTION.GET_VOICEMAILS);
|
|
96
|
+
log.log(`Successfully retrieved voicemail list: statusCode=${response.statusCode}`, {
|
|
97
|
+
file: VOICEMAIL_FILE,
|
|
98
|
+
method: METHODS.GET_VOICEMAIL_LIST,
|
|
99
|
+
});
|
|
100
|
+
return response;
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
const extendedError = new Error(`Failed to get voicemail list: ${err}`);
|
|
104
|
+
log.error(extendedError, {
|
|
105
|
+
file: VOICEMAIL_FILE,
|
|
106
|
+
method: METHODS.GET_VOICEMAIL_LIST,
|
|
107
|
+
});
|
|
108
|
+
await uploadLogs();
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
68
111
|
}
|
|
69
112
|
async getVoicemailContent(messageId) {
|
|
113
|
+
log.info(`${METHOD_START_MESSAGE} with: messageId=${messageId}`, {
|
|
114
|
+
file: VOICEMAIL_FILE,
|
|
115
|
+
method: METHODS.GET_VOICEMAIL_CONTENT,
|
|
116
|
+
});
|
|
70
117
|
const response = await this.backendConnector.getVoicemailContent(messageId);
|
|
71
118
|
this.submitMetric(response, VOICEMAIL_ACTION.GET_VOICEMAIL_CONTENT, messageId);
|
|
119
|
+
log.log(`Successfully retrieved voicemail content for messageId=${messageId}, statusCode=${response.statusCode}`, {
|
|
120
|
+
file: VOICEMAIL_FILE,
|
|
121
|
+
method: METHODS.GET_VOICEMAIL_CONTENT,
|
|
122
|
+
});
|
|
72
123
|
return response;
|
|
73
124
|
}
|
|
74
125
|
async getVoicemailSummary() {
|
|
126
|
+
log.info(METHOD_START_MESSAGE, {
|
|
127
|
+
file: VOICEMAIL_FILE,
|
|
128
|
+
method: METHODS.GET_VOICEMAIL_SUMMARY,
|
|
129
|
+
});
|
|
75
130
|
const response = await this.backendConnector.getVoicemailSummary();
|
|
76
131
|
if (response !== null) {
|
|
77
132
|
this.submitMetric(response, VOICEMAIL_ACTION.GET_VOICEMAIL_SUMMARY);
|
|
133
|
+
log.log(`Successfully retrieved voicemail summary: statusCode=${response.statusCode}`, {
|
|
134
|
+
file: VOICEMAIL_FILE,
|
|
135
|
+
method: METHODS.GET_VOICEMAIL_SUMMARY,
|
|
136
|
+
});
|
|
78
137
|
}
|
|
79
138
|
return response;
|
|
80
139
|
}
|
|
81
140
|
async voicemailMarkAsRead(messageId) {
|
|
141
|
+
log.info(`${METHOD_START_MESSAGE} with: messageId=${messageId}`, {
|
|
142
|
+
file: VOICEMAIL_FILE,
|
|
143
|
+
method: METHODS.VOICEMAIL_MARK_AS_READ,
|
|
144
|
+
});
|
|
82
145
|
const response = await this.backendConnector.voicemailMarkAsRead(messageId);
|
|
83
146
|
this.submitMetric(response, VOICEMAIL_ACTION.MARK_READ, messageId);
|
|
147
|
+
log.log(`Successfully marked voicemail as read: messageId=${messageId}, statusCode=${response.statusCode}`, {
|
|
148
|
+
file: VOICEMAIL_FILE,
|
|
149
|
+
method: METHODS.VOICEMAIL_MARK_AS_READ,
|
|
150
|
+
});
|
|
84
151
|
return response;
|
|
85
152
|
}
|
|
86
153
|
async voicemailMarkAsUnread(messageId) {
|
|
154
|
+
log.info(`${METHOD_START_MESSAGE} with: messageId=${messageId}`, {
|
|
155
|
+
file: VOICEMAIL_FILE,
|
|
156
|
+
method: METHODS.VOICEMAIL_MARK_AS_UNREAD,
|
|
157
|
+
});
|
|
87
158
|
const response = await this.backendConnector.voicemailMarkAsUnread(messageId);
|
|
88
159
|
this.submitMetric(response, VOICEMAIL_ACTION.MARK_UNREAD, messageId);
|
|
160
|
+
log.log(`Successfully marked voicemail as unread: messageId=${messageId}, statusCode=${response.statusCode}`, {
|
|
161
|
+
file: VOICEMAIL_FILE,
|
|
162
|
+
method: METHODS.VOICEMAIL_MARK_AS_UNREAD,
|
|
163
|
+
});
|
|
89
164
|
return response;
|
|
90
165
|
}
|
|
91
166
|
async deleteVoicemail(messageId) {
|
|
167
|
+
log.info(`${METHOD_START_MESSAGE} with: messageId=${messageId}`, {
|
|
168
|
+
file: VOICEMAIL_FILE,
|
|
169
|
+
method: METHODS.DELETE_VOICEMAIL,
|
|
170
|
+
});
|
|
92
171
|
const response = await this.backendConnector.deleteVoicemail(messageId);
|
|
93
172
|
this.submitMetric(response, VOICEMAIL_ACTION.DELETE, messageId);
|
|
173
|
+
log.log(`Successfully deleted voicemail: messageId=${messageId}, statusCode=${response.statusCode}`, {
|
|
174
|
+
file: VOICEMAIL_FILE,
|
|
175
|
+
method: METHODS.DELETE_VOICEMAIL,
|
|
176
|
+
});
|
|
94
177
|
return response;
|
|
95
178
|
}
|
|
96
179
|
async getVMTranscript(messageId) {
|
|
180
|
+
log.info(`${METHOD_START_MESSAGE} with: messageId=${messageId}`, {
|
|
181
|
+
file: VOICEMAIL_FILE,
|
|
182
|
+
method: METHODS.GET_VM_TRANSCRIPT,
|
|
183
|
+
});
|
|
97
184
|
const response = await this.backendConnector.getVMTranscript(messageId);
|
|
98
185
|
if (response !== null) {
|
|
99
186
|
this.submitMetric(response, VOICEMAIL_ACTION.TRANSCRIPT, messageId);
|
|
187
|
+
log.log(`Successfully retrieved voicemail transcript: messageId=${messageId}, statusCode=${response.statusCode}`, {
|
|
188
|
+
file: VOICEMAIL_FILE,
|
|
189
|
+
method: METHODS.GET_VM_TRANSCRIPT,
|
|
190
|
+
});
|
|
100
191
|
}
|
|
101
192
|
return response;
|
|
102
193
|
}
|
|
103
194
|
resolveContact(callingPartyInfo) {
|
|
104
|
-
|
|
195
|
+
log.info(METHOD_START_MESSAGE, {
|
|
196
|
+
file: VOICEMAIL_FILE,
|
|
197
|
+
method: METHODS.RESOLVE_CONTACT,
|
|
198
|
+
});
|
|
199
|
+
const response = this.backendConnector.resolveContact(callingPartyInfo);
|
|
200
|
+
log.log('Contact resolution completed successfully', {
|
|
201
|
+
file: VOICEMAIL_FILE,
|
|
202
|
+
method: METHODS.RESOLVE_CONTACT,
|
|
203
|
+
});
|
|
204
|
+
return response;
|
|
105
205
|
}
|
|
106
206
|
getSDKConnector() {
|
|
107
207
|
return this.sdkConnector;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import SDKConnector from '../SDKConnector';
|
|
2
|
-
import { RAW_REQUEST, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE, TRANSCRIPT, USER, XML_TYPE, BW_XSI_ENDPOINT_VERSION, WEBEX_CALLING_CONNECTOR_FILE, } from '../common/constants';
|
|
3
|
-
import { serviceErrorCodeHandler, getXsiActionEndpoint, getSortedVoicemailList, resolveContact, storeVoicemailList, fetchVoicemailList, } from '../common/Utils';
|
|
2
|
+
import { RAW_REQUEST, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE, TRANSCRIPT, USER, XML_TYPE, BW_XSI_ENDPOINT_VERSION, WEBEX_CALLING_CONNECTOR_FILE, METHOD_START_MESSAGE, } from '../common/constants';
|
|
3
|
+
import { serviceErrorCodeHandler, getXsiActionEndpoint, getSortedVoicemailList, resolveContact, storeVoicemailList, fetchVoicemailList, uploadLogs, } from '../common/Utils';
|
|
4
4
|
import { CALLING_BACKEND, HTTP_METHODS, SORT, } from '../common/types';
|
|
5
5
|
import log from '../Logger';
|
|
6
|
-
import { JSON_FORMAT, MARK_AS_READ, MARK_AS_UNREAD, MESSAGE_MEDIA_CONTENT, TRANSCRIPT_CONTENT, VOICE_MESSAGING_MESSAGES, NO_VOICEMAIL_MSG, NO_VOICEMAIL_STATUS_CODE, RADIX_RAND, PREFIX, TRANSCRIPT_STATUS, MESSAGE_SUMMARY, CALLS, SUMMARY, NEW_MESSAGES, NEW_URGENT_MESSAGES, OLD_URGENT_MESSAGES, OLD_MESSAGES, } from './constants';
|
|
6
|
+
import { JSON_FORMAT, MARK_AS_READ, MARK_AS_UNREAD, MESSAGE_MEDIA_CONTENT, TRANSCRIPT_CONTENT, VOICE_MESSAGING_MESSAGES, NO_VOICEMAIL_MSG, NO_VOICEMAIL_STATUS_CODE, RADIX_RAND, PREFIX, TRANSCRIPT_STATUS, MESSAGE_SUMMARY, CALLS, SUMMARY, NEW_MESSAGES, NEW_URGENT_MESSAGES, OLD_URGENT_MESSAGES, OLD_MESSAGES, METHODS, } from './constants';
|
|
7
7
|
export class WxCallBackendConnector {
|
|
8
8
|
xsiEndpoint;
|
|
9
9
|
userId;
|
|
@@ -11,6 +11,7 @@ export class WxCallBackendConnector {
|
|
|
11
11
|
sdkConnector;
|
|
12
12
|
xsiVoiceMessageURI;
|
|
13
13
|
webex;
|
|
14
|
+
authHeaders = null;
|
|
14
15
|
constructor(webex, logger) {
|
|
15
16
|
this.sdkConnector = SDKConnector;
|
|
16
17
|
if (!this.sdkConnector.getWebex()) {
|
|
@@ -21,12 +22,13 @@ export class WxCallBackendConnector {
|
|
|
21
22
|
this.userId = this.webex.internal.device.userId;
|
|
22
23
|
log.setLogger(logger.level, WEBEX_CALLING_CONNECTOR_FILE);
|
|
23
24
|
}
|
|
24
|
-
init() {
|
|
25
|
+
async init() {
|
|
26
|
+
this.authHeaders = await this.getAuthHeaders();
|
|
25
27
|
const loggerContext = {
|
|
26
28
|
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
27
|
-
method:
|
|
29
|
+
method: METHODS.INIT,
|
|
28
30
|
};
|
|
29
|
-
log.info(
|
|
31
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
30
32
|
const response = this.setXsiVoiceMessageURI();
|
|
31
33
|
return response;
|
|
32
34
|
}
|
|
@@ -37,10 +39,11 @@ export class WxCallBackendConnector {
|
|
|
37
39
|
let responseDetails;
|
|
38
40
|
const loggerContext = {
|
|
39
41
|
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
40
|
-
method:
|
|
42
|
+
method: METHODS.SET_XSI_VOICE_MESSAGE_URI,
|
|
41
43
|
};
|
|
44
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
42
45
|
this.xsiEndpoint = await getXsiActionEndpoint(this.webex, loggerContext, CALLING_BACKEND.WXC);
|
|
43
|
-
log.
|
|
46
|
+
log.log(`XsiEndpoint is ${this.xsiEndpoint}`, loggerContext);
|
|
44
47
|
if (this.userId) {
|
|
45
48
|
this.xsiVoiceMessageURI = `${this.xsiEndpoint}/${BW_XSI_ENDPOINT_VERSION}/${USER}/${this.userId}/${VOICE_MESSAGING_MESSAGES}`;
|
|
46
49
|
responseDetails = {
|
|
@@ -54,9 +57,9 @@ export class WxCallBackendConnector {
|
|
|
54
57
|
async getVoicemailList(offset, offsetLimit, sort, refresh) {
|
|
55
58
|
const loggerContext = {
|
|
56
59
|
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
57
|
-
method:
|
|
60
|
+
method: METHODS.GET_VOICEMAIL_LIST,
|
|
58
61
|
};
|
|
59
|
-
log.info(
|
|
62
|
+
log.info(`${METHOD_START_MESSAGE} with Offset: ${offset} Offset limit: ${offsetLimit} Sort type:${sort}`, loggerContext);
|
|
60
63
|
let messageinfo;
|
|
61
64
|
if (refresh) {
|
|
62
65
|
const urlXsi = `${this.xsiVoiceMessageURI}${JSON_FORMAT}`;
|
|
@@ -65,6 +68,7 @@ export class WxCallBackendConnector {
|
|
|
65
68
|
const response = await this.webex.request({
|
|
66
69
|
uri: `${urlXsi}`,
|
|
67
70
|
method: HTTP_METHODS.GET,
|
|
71
|
+
headers: { ...this.authHeaders },
|
|
68
72
|
});
|
|
69
73
|
const voicemailListResponse = response.body;
|
|
70
74
|
if (Object.keys(voicemailListResponse?.VoiceMessagingMessages?.messageInfoList).length === 0) {
|
|
@@ -82,6 +86,9 @@ export class WxCallBackendConnector {
|
|
|
82
86
|
}
|
|
83
87
|
catch (err) {
|
|
84
88
|
const errorInfo = err;
|
|
89
|
+
const extendedError = new Error(`Failed to get voicemail list: ${err}`);
|
|
90
|
+
log.error(extendedError, loggerContext);
|
|
91
|
+
await uploadLogs();
|
|
85
92
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
86
93
|
return errorStatus;
|
|
87
94
|
}
|
|
@@ -94,18 +101,21 @@ export class WxCallBackendConnector {
|
|
|
94
101
|
},
|
|
95
102
|
message: moreVMAvailable ? SUCCESS_MESSAGE : NO_VOICEMAIL_MSG,
|
|
96
103
|
};
|
|
104
|
+
log.log('Successfully fetched voicemail list', loggerContext);
|
|
97
105
|
return responseDetails;
|
|
98
106
|
}
|
|
99
107
|
async getVoicemailContent(messageId) {
|
|
100
108
|
const loggerContext = {
|
|
101
109
|
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
102
|
-
method:
|
|
110
|
+
method: METHODS.GET_VOICEMAIL_CONTENT,
|
|
103
111
|
};
|
|
112
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
104
113
|
try {
|
|
105
114
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
106
115
|
const response = await this.webex.request({
|
|
107
116
|
uri: `${voicemailContentUrl}`,
|
|
108
117
|
method: HTTP_METHODS.GET,
|
|
118
|
+
headers: { ...this.authHeaders },
|
|
109
119
|
});
|
|
110
120
|
const parser = new DOMParser();
|
|
111
121
|
const xmlDOM = parser.parseFromString(response[RAW_REQUEST].response, XML_TYPE);
|
|
@@ -123,25 +133,30 @@ export class WxCallBackendConnector {
|
|
|
123
133
|
},
|
|
124
134
|
message: SUCCESS_MESSAGE,
|
|
125
135
|
};
|
|
136
|
+
log.log('Successfully fetched voicemail content', loggerContext);
|
|
126
137
|
return responseDetails;
|
|
127
138
|
}
|
|
128
139
|
catch (err) {
|
|
129
140
|
const errorInfo = err;
|
|
141
|
+
const extendedError = new Error(`Failed to get voicemail content: ${err}`);
|
|
142
|
+
log.error(extendedError, loggerContext);
|
|
143
|
+
await uploadLogs();
|
|
130
144
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
131
|
-
log.info(`Voice mail content error is ${errorStatus}`, loggerContext);
|
|
132
145
|
return errorStatus;
|
|
133
146
|
}
|
|
134
147
|
}
|
|
135
148
|
async getVoicemailSummary() {
|
|
136
149
|
const loggerContext = {
|
|
137
150
|
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
138
|
-
method:
|
|
151
|
+
method: METHODS.GET_VOICEMAIL_SUMMARY,
|
|
139
152
|
};
|
|
153
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
140
154
|
try {
|
|
141
155
|
const voicemailSummaryUrl = `${this.xsiEndpoint}/${BW_XSI_ENDPOINT_VERSION}/${USER}/${this.userId}/${CALLS}/${MESSAGE_SUMMARY}`;
|
|
142
156
|
const response = await this.webex.request({
|
|
143
157
|
uri: `${voicemailSummaryUrl}`,
|
|
144
158
|
method: HTTP_METHODS.GET,
|
|
159
|
+
headers: { ...this.authHeaders },
|
|
145
160
|
});
|
|
146
161
|
const parser = new DOMParser();
|
|
147
162
|
const xmlDOM = parser.parseFromString(response[RAW_REQUEST].response, XML_TYPE);
|
|
@@ -162,35 +177,44 @@ export class WxCallBackendConnector {
|
|
|
162
177
|
},
|
|
163
178
|
message: SUCCESS_MESSAGE,
|
|
164
179
|
};
|
|
180
|
+
log.log('Successfully fetched voicemail summary', loggerContext);
|
|
165
181
|
return responseDetails;
|
|
166
182
|
}
|
|
167
183
|
catch (err) {
|
|
168
184
|
const errorInfo = err;
|
|
185
|
+
const extendedError = new Error(`Failed to get voicemail summary: ${err}`);
|
|
186
|
+
log.error(extendedError, loggerContext);
|
|
187
|
+
await uploadLogs();
|
|
169
188
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
170
|
-
log.error(new Error(`Voicemail summary error is ${errorStatus}`), loggerContext);
|
|
171
189
|
return errorStatus;
|
|
172
190
|
}
|
|
173
191
|
}
|
|
174
192
|
async voicemailMarkAsRead(messageId) {
|
|
175
193
|
const loggerContext = {
|
|
176
194
|
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
177
|
-
method:
|
|
195
|
+
method: METHODS.VOICEMAIL_MARK_AS_READ,
|
|
178
196
|
};
|
|
197
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
179
198
|
try {
|
|
180
199
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_READ}`;
|
|
181
200
|
const response = await this.webex.request({
|
|
182
201
|
uri: voicemailContentUrl,
|
|
183
202
|
method: HTTP_METHODS.PUT,
|
|
203
|
+
headers: { ...this.authHeaders },
|
|
184
204
|
});
|
|
185
205
|
const responseDetails = {
|
|
186
206
|
statusCode: Number(response.statusCode),
|
|
187
207
|
data: {},
|
|
188
208
|
message: SUCCESS_MESSAGE,
|
|
189
209
|
};
|
|
210
|
+
log.log('Successfully marked voicemail as read', loggerContext);
|
|
190
211
|
return responseDetails;
|
|
191
212
|
}
|
|
192
213
|
catch (err) {
|
|
193
214
|
const errorInfo = err;
|
|
215
|
+
const extendedError = new Error(`Failed to mark voicemail as read: ${err}`);
|
|
216
|
+
log.error(extendedError, loggerContext);
|
|
217
|
+
await uploadLogs();
|
|
194
218
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
195
219
|
return errorStatus;
|
|
196
220
|
}
|
|
@@ -198,23 +222,29 @@ export class WxCallBackendConnector {
|
|
|
198
222
|
async voicemailMarkAsUnread(messageId) {
|
|
199
223
|
const loggerContext = {
|
|
200
224
|
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
201
|
-
method:
|
|
225
|
+
method: METHODS.VOICEMAIL_MARK_AS_UNREAD,
|
|
202
226
|
};
|
|
227
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
203
228
|
try {
|
|
204
229
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_UNREAD}`;
|
|
205
230
|
const response = await this.webex.request({
|
|
206
231
|
uri: voicemailContentUrl,
|
|
207
232
|
method: HTTP_METHODS.PUT,
|
|
233
|
+
headers: { ...this.authHeaders },
|
|
208
234
|
});
|
|
209
235
|
const responseDetails = {
|
|
210
236
|
statusCode: Number(response.statusCode),
|
|
211
237
|
data: {},
|
|
212
238
|
message: SUCCESS_MESSAGE,
|
|
213
239
|
};
|
|
240
|
+
log.log('Successfully marked voicemail as unread', loggerContext);
|
|
214
241
|
return responseDetails;
|
|
215
242
|
}
|
|
216
243
|
catch (err) {
|
|
217
244
|
const errorInfo = err;
|
|
245
|
+
const extendedError = new Error(`Failed to mark voicemail as unread: ${err}`);
|
|
246
|
+
log.error(extendedError, loggerContext);
|
|
247
|
+
await uploadLogs();
|
|
218
248
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
219
249
|
return errorStatus;
|
|
220
250
|
}
|
|
@@ -222,23 +252,29 @@ export class WxCallBackendConnector {
|
|
|
222
252
|
async deleteVoicemail(messageId) {
|
|
223
253
|
const loggerContext = {
|
|
224
254
|
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
225
|
-
method:
|
|
255
|
+
method: METHODS.DELETE_VOICEMAIL,
|
|
226
256
|
};
|
|
257
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
227
258
|
try {
|
|
228
259
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
229
260
|
const response = await this.webex.request({
|
|
230
261
|
uri: voicemailContentUrl,
|
|
231
262
|
method: HTTP_METHODS.DELETE,
|
|
263
|
+
headers: { ...this.authHeaders },
|
|
232
264
|
});
|
|
233
265
|
const responseDetails = {
|
|
234
266
|
statusCode: Number(response.statusCode),
|
|
235
267
|
data: {},
|
|
236
268
|
message: SUCCESS_MESSAGE,
|
|
237
269
|
};
|
|
270
|
+
log.log('Successfully deleted voicemail', loggerContext);
|
|
238
271
|
return responseDetails;
|
|
239
272
|
}
|
|
240
273
|
catch (err) {
|
|
241
274
|
const errorInfo = err;
|
|
275
|
+
const extendedError = new Error(`Failed to delete voicemail: ${err}`);
|
|
276
|
+
log.error(extendedError, loggerContext);
|
|
277
|
+
await uploadLogs();
|
|
242
278
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
243
279
|
return errorStatus;
|
|
244
280
|
}
|
|
@@ -246,13 +282,15 @@ export class WxCallBackendConnector {
|
|
|
246
282
|
async getVMTranscript(messageId) {
|
|
247
283
|
const loggerContext = {
|
|
248
284
|
file: WEBEX_CALLING_CONNECTOR_FILE,
|
|
249
|
-
method:
|
|
285
|
+
method: METHODS.GET_VM_TRANSCRIPT,
|
|
250
286
|
};
|
|
287
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
251
288
|
try {
|
|
252
289
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${TRANSCRIPT}`;
|
|
253
290
|
const response = await this.webex.request({
|
|
254
291
|
uri: voicemailContentUrl,
|
|
255
292
|
method: HTTP_METHODS.GET,
|
|
293
|
+
headers: { ...this.authHeaders },
|
|
256
294
|
});
|
|
257
295
|
const parser = new DOMParser();
|
|
258
296
|
const xmlDOM = parser.parseFromString(response[RAW_REQUEST].response, XML_TYPE);
|
|
@@ -265,10 +303,14 @@ export class WxCallBackendConnector {
|
|
|
265
303
|
},
|
|
266
304
|
message: status.textContent,
|
|
267
305
|
};
|
|
306
|
+
log.log('Successfully fetched voicemail transcript', loggerContext);
|
|
268
307
|
return responseDetails;
|
|
269
308
|
}
|
|
270
309
|
catch (err) {
|
|
271
310
|
const errorInfo = err;
|
|
311
|
+
const extendedError = new Error(`Failed to get voicemail transcript: ${err}`);
|
|
312
|
+
log.error(extendedError, loggerContext);
|
|
313
|
+
await uploadLogs();
|
|
272
314
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
273
315
|
return errorStatus;
|
|
274
316
|
}
|
|
@@ -276,4 +318,11 @@ export class WxCallBackendConnector {
|
|
|
276
318
|
resolveContact(callingPartyInfo) {
|
|
277
319
|
return resolveContact(callingPartyInfo);
|
|
278
320
|
}
|
|
321
|
+
async getAuthHeaders() {
|
|
322
|
+
const headers = {};
|
|
323
|
+
if (this.webex?.config?.fedramp) {
|
|
324
|
+
headers.Authorization = await this.webex.credentials.getUserToken();
|
|
325
|
+
}
|
|
326
|
+
return headers;
|
|
327
|
+
}
|
|
279
328
|
}
|
|
@@ -27,3 +27,24 @@ export const NEW_MESSAGES = 'newMessages';
|
|
|
27
27
|
export const OLD_MESSAGES = 'oldMessages';
|
|
28
28
|
export const NEW_URGENT_MESSAGES = 'newUrgentMessages';
|
|
29
29
|
export const OLD_URGENT_MESSAGES = 'oldUrgentMessages';
|
|
30
|
+
export const METHODS = {
|
|
31
|
+
INIT: 'init',
|
|
32
|
+
GET_SDK_CONNECTOR: 'getSDKConnector',
|
|
33
|
+
GET_USER_ID: 'getUserId',
|
|
34
|
+
GET_BW_TOKEN: 'getBwToken',
|
|
35
|
+
SET_XSI_VOICE_MESSAGE_URI: 'setXsiVoiceMessageURI',
|
|
36
|
+
GET_VOICEMAIL_LIST: 'getVoicemailList',
|
|
37
|
+
GET_VOICEMAIL_CONTENT: 'getVoicemailContent',
|
|
38
|
+
GET_VOICEMAIL_SUMMARY: 'getVoicemailSummary',
|
|
39
|
+
VOICEMAIL_MARK_AS_READ: 'voicemailMarkAsRead',
|
|
40
|
+
VOICEMAIL_MARK_AS_UNREAD: 'voicemailMarkAsUnread',
|
|
41
|
+
DELETE_VOICEMAIL: 'deleteVoicemail',
|
|
42
|
+
GET_VM_TRANSCRIPT: 'getVMTranscript',
|
|
43
|
+
RESOLVE_CONTACT: 'resolveContact',
|
|
44
|
+
GET_VOICEMAIL_CONTENT_UCM: 'getVoicemailContentUcm',
|
|
45
|
+
RETURN_UCM_PROMISE: 'returnUcmPromise',
|
|
46
|
+
INITIALIZE_BACKEND_CONNECTOR: 'initializeBackendConnector',
|
|
47
|
+
SUBMIT_METRIC: 'submitMetric',
|
|
48
|
+
GET_AUTH_HEADERS: 'getAuthHeaders',
|
|
49
|
+
SET_UCM_VOICE_MESSAGE_BASE_URI: 'setUcmVoiceMessageBaseURI',
|
|
50
|
+
};
|