@webex/calling 3.8.0 → 3.8.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.
- 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 +53 -24
- 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 +2 -2
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +359 -297
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +561 -163
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- 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.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 +103 -64
- 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/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 +3 -1
- 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/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 +12 -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
|
@@ -11,10 +11,58 @@ class MetricManager {
|
|
|
11
11
|
this.webex = webex;
|
|
12
12
|
this.serviceIndicator = indicator;
|
|
13
13
|
}
|
|
14
|
+
submitUploadLogsMetric(name, action, type, trackingId, feedbackId, correlationId, stack, callId) {
|
|
15
|
+
let data;
|
|
16
|
+
switch (name) {
|
|
17
|
+
case METRIC_EVENT.UPLOAD_LOGS_SUCCESS: {
|
|
18
|
+
data = {
|
|
19
|
+
tags: {
|
|
20
|
+
action,
|
|
21
|
+
device_id: this.deviceInfo?.device?.deviceId,
|
|
22
|
+
service_indicator: this.serviceIndicator,
|
|
23
|
+
},
|
|
24
|
+
fields: {
|
|
25
|
+
device_url: this.deviceInfo?.device?.clientDeviceUri,
|
|
26
|
+
mobius_url: this.deviceInfo?.device?.uri,
|
|
27
|
+
calling_sdk_version: process.env.CALLING_SDK_VERSION || VERSION,
|
|
28
|
+
correlation_id: correlationId,
|
|
29
|
+
tracking_id: trackingId,
|
|
30
|
+
feedback_id: feedbackId,
|
|
31
|
+
call_id: callId,
|
|
32
|
+
},
|
|
33
|
+
type,
|
|
34
|
+
};
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case METRIC_EVENT.UPLOAD_LOGS_FAILED: {
|
|
38
|
+
data = {
|
|
39
|
+
tags: {
|
|
40
|
+
action,
|
|
41
|
+
device_id: this.deviceInfo?.device?.deviceId,
|
|
42
|
+
service_indicator: this.serviceIndicator,
|
|
43
|
+
},
|
|
44
|
+
fields: {
|
|
45
|
+
device_url: this.deviceInfo?.device?.clientDeviceUri,
|
|
46
|
+
mobius_url: this.deviceInfo?.device?.uri,
|
|
47
|
+
calling_sdk_version: process.env.CALLING_SDK_VERSION || VERSION,
|
|
48
|
+
correlation_id: correlationId,
|
|
49
|
+
tracking_id: trackingId,
|
|
50
|
+
feedback_id: feedbackId,
|
|
51
|
+
error: stack,
|
|
52
|
+
call_id: callId,
|
|
53
|
+
},
|
|
54
|
+
type,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (data) {
|
|
59
|
+
this.webex.internal.metrics.submitClientMetrics(name, data);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
14
62
|
setDeviceInfo(deviceInfo) {
|
|
15
63
|
this.deviceInfo = deviceInfo;
|
|
16
64
|
}
|
|
17
|
-
submitRegistrationMetric(name, metricAction, type, clientError) {
|
|
65
|
+
submitRegistrationMetric(name, metricAction, type, caller, serverType, trackingId, keepaliveCount, clientError) {
|
|
18
66
|
let data;
|
|
19
67
|
switch (name) {
|
|
20
68
|
case METRIC_EVENT.REGISTRATION: {
|
|
@@ -28,6 +76,9 @@ class MetricManager {
|
|
|
28
76
|
device_url: this.deviceInfo?.device?.clientDeviceUri,
|
|
29
77
|
mobius_url: this.deviceInfo?.device?.uri,
|
|
30
78
|
calling_sdk_version: process.env.CALLING_SDK_VERSION || VERSION,
|
|
79
|
+
reg_source: caller,
|
|
80
|
+
server_type: serverType,
|
|
81
|
+
trackingId,
|
|
31
82
|
},
|
|
32
83
|
type,
|
|
33
84
|
};
|
|
@@ -45,6 +96,10 @@ class MetricManager {
|
|
|
45
96
|
device_url: this.deviceInfo?.device?.clientDeviceUri,
|
|
46
97
|
mobius_url: this.deviceInfo?.device?.uri,
|
|
47
98
|
calling_sdk_version: process.env.CALLING_SDK_VERSION || VERSION,
|
|
99
|
+
reg_source: caller,
|
|
100
|
+
server_type: serverType,
|
|
101
|
+
trackingId,
|
|
102
|
+
keepalive_count: keepaliveCount,
|
|
48
103
|
error: clientError.getError().message,
|
|
49
104
|
error_type: clientError.getError().type,
|
|
50
105
|
},
|
|
@@ -256,7 +311,7 @@ class MetricManager {
|
|
|
256
311
|
}
|
|
257
312
|
}
|
|
258
313
|
export const getMetricManager = (webex, indicator) => {
|
|
259
|
-
if (!metricManager) {
|
|
314
|
+
if (!metricManager && webex) {
|
|
260
315
|
metricManager = new MetricManager(webex, indicator);
|
|
261
316
|
}
|
|
262
317
|
return metricManager;
|
|
@@ -15,6 +15,8 @@ export var METRIC_EVENT;
|
|
|
15
15
|
METRIC_EVENT["REGISTRATION_ERROR"] = "web-calling-sdk-registration-error";
|
|
16
16
|
METRIC_EVENT["VOICEMAIL"] = "web-calling-sdk-voicemail";
|
|
17
17
|
METRIC_EVENT["VOICEMAIL_ERROR"] = "web-calling-sdk-voicemail-error";
|
|
18
|
+
METRIC_EVENT["UPLOAD_LOGS_SUCCESS"] = "web-calling-sdk-upload-logs-success";
|
|
19
|
+
METRIC_EVENT["UPLOAD_LOGS_FAILED"] = "web-calling-sdk-upload-logs-failed";
|
|
18
20
|
})(METRIC_EVENT || (METRIC_EVENT = {}));
|
|
19
21
|
export var REG_ACTION;
|
|
20
22
|
(function (REG_ACTION) {
|
|
@@ -37,3 +39,4 @@ export var VOICEMAIL_ACTION;
|
|
|
37
39
|
VOICEMAIL_ACTION["DELETE"] = "delete";
|
|
38
40
|
VOICEMAIL_ACTION["TRANSCRIPT"] = "transcript";
|
|
39
41
|
})(VOICEMAIL_ACTION || (VOICEMAIL_ACTION = {}));
|
|
42
|
+
export const UPLOAD_LOGS_ACTION = 'upload_logs';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ERROR_CODE } from '../Errors/types';
|
|
2
2
|
import SDKConnector from '../SDKConnector';
|
|
3
|
-
import { BASE64, BEARER, BINARY, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE, OBJECT, TOKEN, USER, XML_TYPE, BW_XSI_ENDPOINT_VERSION, } from '../common/constants';
|
|
4
|
-
import { serviceErrorCodeHandler, getXsiActionEndpoint, getSortedVoicemailList, storeVoicemailList, fetchVoicemailList, } from '../common/Utils';
|
|
3
|
+
import { BASE64, BEARER, BINARY, SUCCESS_MESSAGE, SUCCESS_STATUS_CODE, OBJECT, TOKEN, USER, XML_TYPE, BW_XSI_ENDPOINT_VERSION, METHOD_START_MESSAGE, } from '../common/constants';
|
|
4
|
+
import { serviceErrorCodeHandler, getXsiActionEndpoint, getSortedVoicemailList, storeVoicemailList, fetchVoicemailList, uploadLogs, } from '../common/Utils';
|
|
5
5
|
import { CALLING_BACKEND, HTTP_METHODS, SORT, } from '../common/types';
|
|
6
6
|
import log from '../Logger';
|
|
7
|
-
import { BROADWORKS_VOICEMAIL_FILE, BW_TOKEN_FETCH_ENDPOINT, JSON_FORMAT, MARK_AS_READ, MARK_AS_UNREAD, MESSAGE_MEDIA_CONTENT, VOICE_MESSAGING_MESSAGES, NO_VOICEMAIL_MSG, NO_VOICEMAIL_STATUS_CODE, RADIX_RAND, PREFIX, } from './constants';
|
|
7
|
+
import { BROADWORKS_VOICEMAIL_FILE, BW_TOKEN_FETCH_ENDPOINT, JSON_FORMAT, MARK_AS_READ, MARK_AS_UNREAD, MESSAGE_MEDIA_CONTENT, VOICE_MESSAGING_MESSAGES, NO_VOICEMAIL_MSG, NO_VOICEMAIL_STATUS_CODE, RADIX_RAND, PREFIX, METHODS, } from './constants';
|
|
8
8
|
export class BroadworksBackendConnector {
|
|
9
9
|
bwtoken;
|
|
10
10
|
userId;
|
|
@@ -26,10 +26,11 @@ export class BroadworksBackendConnector {
|
|
|
26
26
|
init() {
|
|
27
27
|
const loggerContext = {
|
|
28
28
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
29
|
-
method:
|
|
29
|
+
method: METHODS.INIT,
|
|
30
30
|
};
|
|
31
|
-
log.info(
|
|
31
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
32
32
|
const response = this.setXsiVoiceMessageURI();
|
|
33
|
+
log.log('Successfully initialized Broadworks voicemail connector', loggerContext);
|
|
33
34
|
return response;
|
|
34
35
|
}
|
|
35
36
|
getSDKConnector() {
|
|
@@ -38,8 +39,9 @@ export class BroadworksBackendConnector {
|
|
|
38
39
|
async getUserId() {
|
|
39
40
|
const loggerContext = {
|
|
40
41
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
41
|
-
method:
|
|
42
|
+
method: METHODS.GET_USER_ID,
|
|
42
43
|
};
|
|
44
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
43
45
|
try {
|
|
44
46
|
await this.getBwToken();
|
|
45
47
|
if (this.bwtoken && this.bwtoken.split('.').length > 1) {
|
|
@@ -54,10 +56,18 @@ export class BroadworksBackendConnector {
|
|
|
54
56
|
const errorInfo = {
|
|
55
57
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
56
58
|
};
|
|
59
|
+
const extendedError = new Error(`Failed to get userId: ${err}`);
|
|
60
|
+
log.error(extendedError, loggerContext);
|
|
61
|
+
await uploadLogs();
|
|
57
62
|
return serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
async getBwToken() {
|
|
66
|
+
const loggerContext = {
|
|
67
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
68
|
+
method: METHODS.GET_BW_TOKEN,
|
|
69
|
+
};
|
|
70
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
61
71
|
try {
|
|
62
72
|
const bwTokenResponse = await this.webex.request({
|
|
63
73
|
uri: `${this.webex.internal.services._serviceUrls.broadworksIdpProxy}${BW_TOKEN_FETCH_ENDPOINT}`,
|
|
@@ -65,16 +75,23 @@ export class BroadworksBackendConnector {
|
|
|
65
75
|
});
|
|
66
76
|
const response = bwTokenResponse.body;
|
|
67
77
|
this.bwtoken = response[TOKEN][BEARER];
|
|
78
|
+
log.log('Successfully fetched Broadworks token', loggerContext);
|
|
68
79
|
}
|
|
69
80
|
catch (err) {
|
|
70
|
-
|
|
81
|
+
const extendedError = new Error(`Broadworks token exception: ${err}`);
|
|
82
|
+
log.error(extendedError, {
|
|
83
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
84
|
+
method: METHODS.GET_BW_TOKEN,
|
|
85
|
+
});
|
|
86
|
+
await uploadLogs();
|
|
71
87
|
}
|
|
72
88
|
}
|
|
73
89
|
async setXsiVoiceMessageURI() {
|
|
74
90
|
const loggerContext = {
|
|
75
91
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
76
|
-
method:
|
|
92
|
+
method: METHODS.SET_XSI_VOICE_MESSAGE_URI,
|
|
77
93
|
};
|
|
94
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
78
95
|
let userIdResponse = await this.getUserId();
|
|
79
96
|
this.xsiEndpoint = await getXsiActionEndpoint(this.webex, loggerContext, CALLING_BACKEND.BWRKS);
|
|
80
97
|
this.xsiAccessToken = `${BEARER} ${this.bwtoken}`;
|
|
@@ -87,14 +104,15 @@ export class BroadworksBackendConnector {
|
|
|
87
104
|
message: SUCCESS_MESSAGE,
|
|
88
105
|
};
|
|
89
106
|
}
|
|
107
|
+
log.log('Successfully set XSI voice message URI', loggerContext);
|
|
90
108
|
return userIdResponse;
|
|
91
109
|
}
|
|
92
110
|
async getVoicemailList(offset, offsetLimit, sort, refresh) {
|
|
93
111
|
const loggerContext = {
|
|
94
112
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
95
|
-
method:
|
|
113
|
+
method: METHODS.GET_VOICEMAIL_LIST,
|
|
96
114
|
};
|
|
97
|
-
log.info(
|
|
115
|
+
log.info(`${METHOD_START_MESSAGE} with offset: ${offset}, offsetLimit: ${offsetLimit}, sort type: ${sort}`, loggerContext);
|
|
98
116
|
const urlXsi = `${this.xsiVoiceMessageURI}${JSON_FORMAT}`;
|
|
99
117
|
let messageinfo;
|
|
100
118
|
const sortParam = Object.values(SORT).includes(sort) ? sort : SORT.DEFAULT;
|
|
@@ -127,11 +145,15 @@ export class BroadworksBackendConnector {
|
|
|
127
145
|
const errorInfo = {
|
|
128
146
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
129
147
|
};
|
|
148
|
+
const extendedError = new Error(`Failed to get voicemail list: ${err}`);
|
|
149
|
+
log.error(extendedError, loggerContext);
|
|
150
|
+
await uploadLogs();
|
|
130
151
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
131
152
|
return errorStatus;
|
|
132
153
|
}
|
|
133
154
|
}
|
|
134
155
|
const { messages, moreVMAvailable } = fetchVoicemailList(this.context, offset, offsetLimit, loggerContext);
|
|
156
|
+
log.log(`Successfully fetched voicemail list with ${messages.length} messages`, loggerContext);
|
|
135
157
|
const responseDetails = {
|
|
136
158
|
statusCode: moreVMAvailable ? SUCCESS_STATUS_CODE : NO_VOICEMAIL_STATUS_CODE,
|
|
137
159
|
data: {
|
|
@@ -144,8 +166,9 @@ export class BroadworksBackendConnector {
|
|
|
144
166
|
async getVoicemailContent(messageId) {
|
|
145
167
|
const loggerContext = {
|
|
146
168
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
147
|
-
method:
|
|
169
|
+
method: METHODS.GET_VOICEMAIL_CONTENT,
|
|
148
170
|
};
|
|
171
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
149
172
|
try {
|
|
150
173
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
151
174
|
const response = await fetch(`${voicemailContentUrl}`, {
|
|
@@ -163,7 +186,8 @@ export class BroadworksBackendConnector {
|
|
|
163
186
|
const mediaDetails = xmlDOM.getElementsByTagName(MESSAGE_MEDIA_CONTENT)[0];
|
|
164
187
|
const mediaType = mediaDetails.childNodes[1]?.textContent;
|
|
165
188
|
const mediaContent = mediaDetails.childNodes[2]?.textContent;
|
|
166
|
-
log.info(`Media type is
|
|
189
|
+
log.info(`Media type is ${mediaType}`, loggerContext);
|
|
190
|
+
log.log(`Successfully fetched voicemail content for message ID: ${messageId}`, loggerContext);
|
|
167
191
|
const responseDetails = {
|
|
168
192
|
statusCode: response?.status,
|
|
169
193
|
data: {
|
|
@@ -180,6 +204,9 @@ export class BroadworksBackendConnector {
|
|
|
180
204
|
const errorInfo = {
|
|
181
205
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
182
206
|
};
|
|
207
|
+
const extendedError = new Error(`Failed to get voicemail content: ${err}`);
|
|
208
|
+
log.error(extendedError, loggerContext);
|
|
209
|
+
await uploadLogs();
|
|
183
210
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
184
211
|
return errorStatus;
|
|
185
212
|
}
|
|
@@ -190,8 +217,9 @@ export class BroadworksBackendConnector {
|
|
|
190
217
|
async voicemailMarkAsRead(messageId) {
|
|
191
218
|
const loggerContext = {
|
|
192
219
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
193
|
-
method:
|
|
220
|
+
method: METHODS.VOICEMAIL_MARK_AS_READ,
|
|
194
221
|
};
|
|
222
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
195
223
|
try {
|
|
196
224
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_READ}`;
|
|
197
225
|
const response = await fetch(voicemailContentUrl, {
|
|
@@ -203,6 +231,7 @@ export class BroadworksBackendConnector {
|
|
|
203
231
|
if (!response.ok) {
|
|
204
232
|
throw new Error(`${response.status}`);
|
|
205
233
|
}
|
|
234
|
+
log.log(`Successfully marked voicemail with ID ${messageId} as read`, loggerContext);
|
|
206
235
|
const responseDetails = {
|
|
207
236
|
statusCode: response.status,
|
|
208
237
|
data: {},
|
|
@@ -214,6 +243,9 @@ export class BroadworksBackendConnector {
|
|
|
214
243
|
const errorInfo = {
|
|
215
244
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
216
245
|
};
|
|
246
|
+
const extendedError = new Error(`Failed to mark voicemail as read: ${err}`);
|
|
247
|
+
log.error(extendedError, loggerContext);
|
|
248
|
+
await uploadLogs();
|
|
217
249
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
218
250
|
return errorStatus;
|
|
219
251
|
}
|
|
@@ -221,8 +253,9 @@ export class BroadworksBackendConnector {
|
|
|
221
253
|
async voicemailMarkAsUnread(messageId) {
|
|
222
254
|
const loggerContext = {
|
|
223
255
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
224
|
-
method:
|
|
256
|
+
method: METHODS.VOICEMAIL_MARK_AS_UNREAD,
|
|
225
257
|
};
|
|
258
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
226
259
|
try {
|
|
227
260
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}/${MARK_AS_UNREAD}`;
|
|
228
261
|
const response = await fetch(voicemailContentUrl, {
|
|
@@ -234,6 +267,7 @@ export class BroadworksBackendConnector {
|
|
|
234
267
|
if (!response.ok) {
|
|
235
268
|
throw new Error(`${response.status}`);
|
|
236
269
|
}
|
|
270
|
+
log.log(`Successfully marked voicemail with ID ${messageId} as unread`, loggerContext);
|
|
237
271
|
const responseDetails = {
|
|
238
272
|
statusCode: response.status,
|
|
239
273
|
data: {},
|
|
@@ -245,6 +279,9 @@ export class BroadworksBackendConnector {
|
|
|
245
279
|
const errorInfo = {
|
|
246
280
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
247
281
|
};
|
|
282
|
+
const extendedError = new Error(`Failed to mark voicemail as unread: ${err}`);
|
|
283
|
+
log.error(extendedError, loggerContext);
|
|
284
|
+
await uploadLogs();
|
|
248
285
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
249
286
|
return errorStatus;
|
|
250
287
|
}
|
|
@@ -252,8 +289,9 @@ export class BroadworksBackendConnector {
|
|
|
252
289
|
async deleteVoicemail(messageId) {
|
|
253
290
|
const loggerContext = {
|
|
254
291
|
file: BROADWORKS_VOICEMAIL_FILE,
|
|
255
|
-
method:
|
|
292
|
+
method: METHODS.DELETE_VOICEMAIL,
|
|
256
293
|
};
|
|
294
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
257
295
|
try {
|
|
258
296
|
const voicemailContentUrl = `${this.xsiEndpoint}${messageId}`;
|
|
259
297
|
const response = await fetch(voicemailContentUrl, {
|
|
@@ -265,6 +303,7 @@ export class BroadworksBackendConnector {
|
|
|
265
303
|
if (!response.ok) {
|
|
266
304
|
throw new Error(`${response.status}`);
|
|
267
305
|
}
|
|
306
|
+
log.log(`Successfully deleted voicemail with ID ${messageId}`, loggerContext);
|
|
268
307
|
const responseDetails = {
|
|
269
308
|
statusCode: response.status,
|
|
270
309
|
data: {},
|
|
@@ -276,16 +315,26 @@ export class BroadworksBackendConnector {
|
|
|
276
315
|
const errorInfo = {
|
|
277
316
|
statusCode: err instanceof Error ? Number(err.message) : '',
|
|
278
317
|
};
|
|
318
|
+
const extendedError = new Error(`Failed to delete voicemail: ${err}`);
|
|
319
|
+
log.error(extendedError, loggerContext);
|
|
320
|
+
await uploadLogs();
|
|
279
321
|
const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
|
|
280
322
|
return errorStatus;
|
|
281
323
|
}
|
|
282
324
|
}
|
|
283
325
|
async getVMTranscript(messageId) {
|
|
284
|
-
|
|
326
|
+
const loggerContext = {
|
|
327
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
328
|
+
method: METHODS.GET_VM_TRANSCRIPT,
|
|
329
|
+
};
|
|
330
|
+
log.info(`${METHOD_START_MESSAGE} with messageId: ${messageId}`, loggerContext);
|
|
285
331
|
return Promise.resolve(null);
|
|
286
332
|
}
|
|
287
333
|
resolveContact(callingPartyInfo) {
|
|
288
|
-
log.info(
|
|
334
|
+
log.info(`${METHOD_START_MESSAGE} with Calling Party Info: ${callingPartyInfo}`, {
|
|
335
|
+
file: BROADWORKS_VOICEMAIL_FILE,
|
|
336
|
+
method: METHODS.RESOLVE_CONTACT,
|
|
337
|
+
});
|
|
289
338
|
return Promise.resolve(null);
|
|
290
339
|
}
|
|
291
340
|
}
|
|
@@ -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;
|