@zohoim/client-sdk 1.0.0-poc95 → 1.0.0-poc96
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { validateSchema } from '../../../core/utils';
|
|
2
|
-
import { MessageDirection, MessageStatus, MessageTypes, MessageMeta } from '../../enum';
|
|
2
|
+
import { MessageDirection, MessageStatus, MessageTypes, MessageMeta, MetaSystemMessageType } from '../../enum';
|
|
3
3
|
import { MessageSchema } from '../../schema';
|
|
4
4
|
import { Actor } from '../Actor';
|
|
5
5
|
import { Attachment } from '../Attachment';
|
|
@@ -75,25 +75,50 @@ export default class Message {
|
|
|
75
75
|
return type === MessageTypes.ACTION;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
static getMetaValue() {
|
|
79
|
+
let meta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
80
|
+
let key = arguments.length > 1 ? arguments[1] : undefined;
|
|
81
|
+
|
|
82
|
+
if (Array.isArray(meta) && meta.length > 0) {
|
|
83
|
+
const item = meta.find(item => item.name === key);
|
|
84
|
+
return item ? item.value : '';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return '';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static getSystemMessageValue(meta) {
|
|
91
|
+
return Message.getMetaValue(meta, MessageMeta.SYSTEM_MESSAGE_TYPE);
|
|
92
|
+
}
|
|
93
|
+
|
|
78
94
|
static isSystemMessage(meta) {
|
|
79
|
-
const systemMessageType = Message.
|
|
95
|
+
const systemMessageType = Message.getSystemMessageValue(meta);
|
|
80
96
|
return !!systemMessageType;
|
|
81
97
|
}
|
|
82
98
|
|
|
83
|
-
static isHapinessRating(
|
|
84
|
-
|
|
99
|
+
static isHapinessRating(meta) {
|
|
100
|
+
const messageType = Message.getSystemMessageValue(meta);
|
|
101
|
+
return messageType === MetaSystemMessageType.CX_HAPPINESS_SURVEY;
|
|
85
102
|
}
|
|
86
103
|
|
|
87
|
-
static isWelcomeMessage(
|
|
88
|
-
|
|
104
|
+
static isWelcomeMessage(meta) {
|
|
105
|
+
const messageType = Message.getSystemMessageValue(meta);
|
|
106
|
+
return messageType === MetaSystemMessageType.WELCOMEMSG;
|
|
89
107
|
}
|
|
90
108
|
|
|
91
|
-
static isWorkflowMessage(
|
|
92
|
-
|
|
109
|
+
static isWorkflowMessage(meta) {
|
|
110
|
+
const messageType = Message.getSystemMessageValue(meta);
|
|
111
|
+
return messageType === MetaSystemMessageType.WORKFLOW_MESSAGE;
|
|
93
112
|
}
|
|
94
113
|
|
|
95
|
-
static isWorkflowNotification(
|
|
96
|
-
|
|
114
|
+
static isWorkflowNotification(meta) {
|
|
115
|
+
const messageType = Message.getSystemMessageValue(meta);
|
|
116
|
+
return messageType === MetaSystemMessageType.WORKFLOW_NOTIFICATION;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static isUnsupportedFile(meta) {
|
|
120
|
+
const messageType = Message.getSystemMessageValue(meta);
|
|
121
|
+
return messageType === MetaSystemMessageType.UN_SUPPORTED_FILE;
|
|
97
122
|
}
|
|
98
123
|
|
|
99
124
|
static isFailed(status) {
|
|
@@ -104,18 +129,6 @@ export default class Message {
|
|
|
104
129
|
return !!systemMsgType;
|
|
105
130
|
}
|
|
106
131
|
|
|
107
|
-
static getMetaValue() {
|
|
108
|
-
let meta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
109
|
-
let key = arguments.length > 1 ? arguments[1] : undefined;
|
|
110
|
-
|
|
111
|
-
if (Array.isArray(meta) && meta.length > 0) {
|
|
112
|
-
const item = meta.find(item => item.name === key);
|
|
113
|
-
return item ? item.value : '';
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return '';
|
|
117
|
-
}
|
|
118
|
-
|
|
119
132
|
toJSON() {
|
|
120
133
|
return { ...this.data
|
|
121
134
|
};
|
|
@@ -6,10 +6,6 @@ const MessageTypes = {
|
|
|
6
6
|
LAYOUT: 'LAYOUT',
|
|
7
7
|
EXTERNAL_INFO: 'EXTERNAL_INFO',
|
|
8
8
|
TEMPLATE: 'TEMPLATE',
|
|
9
|
-
ACTION: 'ACTION'
|
|
10
|
-
WELCOMEMSG: 'WELCOMEMSG',
|
|
11
|
-
WORKFLOW_MESSAGE: 'WORKFLOW_MESSAGE',
|
|
12
|
-
WORKFLOW_NOTIFICATION: 'WORKFLOW_NOTIFICATION',
|
|
13
|
-
CX_HAPPINESS_SURVEY: 'CX_HAPPINESS_SURVEY'
|
|
9
|
+
ACTION: 'ACTION'
|
|
14
10
|
};
|
|
15
11
|
export default MessageTypes;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const MetaSystemMessageType = {
|
|
2
|
+
WELCOMEMSG: 'WELCOMEMSG',
|
|
3
|
+
WORKFLOW_MESSAGE: 'WORKFLOW_MESSAGE',
|
|
4
|
+
WORKFLOW_NOTIFICATION: 'WORKFLOW_NOTIFICATION',
|
|
5
|
+
CX_HAPPINESS_SURVEY: 'CX_HAPPINESS_SURVEY',
|
|
6
|
+
UN_SUPPORTED_FILE: 'UN_SUPPORTED_FILE'
|
|
7
|
+
};
|
|
8
|
+
export default MetaSystemMessageType;
|
|
@@ -9,4 +9,5 @@ import InfoSessionStatus from './InfoSessionStatus';
|
|
|
9
9
|
import InfoAction from './InfoAction';
|
|
10
10
|
import ActionSubType from './ActionSubType';
|
|
11
11
|
import InfoTargetType from './InfoTargetType';
|
|
12
|
-
|
|
12
|
+
import MetaSystemMessageType from './MetaSystemMessageType';
|
|
13
|
+
export { MessageTypes, MessageStatus, MessageDirection, MessageContentType, MessageMeta, ActionType, ActionSubType, ExternalInfoAction, InfoSessionStatus, InfoAction, InfoTargetType, MetaSystemMessageType };
|