@zohoim/client-sdk 1.0.0-poc94 → 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.
- package/es/domain/entities/Actor/Actor.js +1 -1
- package/es/domain/entities/Message/Message.js +37 -23
- package/es/domain/entities/Session/Session.js +1 -1
- package/es/domain/enum/message/MessageMeta.js +4 -0
- package/es/domain/enum/message/MessageType.js +1 -5
- package/es/domain/enum/message/MetaSystemMessageType.js +8 -0
- package/es/domain/enum/message/index.js +3 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { validateSchema } from '../../../core/utils';
|
|
2
|
-
import { MessageDirection, MessageStatus, MessageTypes } 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,44 +75,58 @@ export default class Message {
|
|
|
75
75
|
return type === MessageTypes.ACTION;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
static
|
|
79
|
-
|
|
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 '';
|
|
80
88
|
}
|
|
81
89
|
|
|
82
|
-
static
|
|
83
|
-
return
|
|
90
|
+
static getSystemMessageValue(meta) {
|
|
91
|
+
return Message.getMetaValue(meta, MessageMeta.SYSTEM_MESSAGE_TYPE);
|
|
84
92
|
}
|
|
85
93
|
|
|
86
|
-
static
|
|
87
|
-
|
|
94
|
+
static isSystemMessage(meta) {
|
|
95
|
+
const systemMessageType = Message.getSystemMessageValue(meta);
|
|
96
|
+
return !!systemMessageType;
|
|
88
97
|
}
|
|
89
98
|
|
|
90
|
-
static
|
|
91
|
-
|
|
99
|
+
static isHapinessRating(meta) {
|
|
100
|
+
const messageType = Message.getSystemMessageValue(meta);
|
|
101
|
+
return messageType === MetaSystemMessageType.CX_HAPPINESS_SURVEY;
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
static
|
|
95
|
-
|
|
104
|
+
static isWelcomeMessage(meta) {
|
|
105
|
+
const messageType = Message.getSystemMessageValue(meta);
|
|
106
|
+
return messageType === MetaSystemMessageType.WELCOMEMSG;
|
|
96
107
|
}
|
|
97
108
|
|
|
98
|
-
static
|
|
99
|
-
|
|
109
|
+
static isWorkflowMessage(meta) {
|
|
110
|
+
const messageType = Message.getSystemMessageValue(meta);
|
|
111
|
+
return messageType === MetaSystemMessageType.WORKFLOW_MESSAGE;
|
|
100
112
|
}
|
|
101
113
|
|
|
102
|
-
static
|
|
103
|
-
|
|
114
|
+
static isWorkflowNotification(meta) {
|
|
115
|
+
const messageType = Message.getSystemMessageValue(meta);
|
|
116
|
+
return messageType === MetaSystemMessageType.WORKFLOW_NOTIFICATION;
|
|
104
117
|
}
|
|
105
118
|
|
|
106
|
-
static
|
|
107
|
-
|
|
108
|
-
|
|
119
|
+
static isUnsupportedFile(meta) {
|
|
120
|
+
const messageType = Message.getSystemMessageValue(meta);
|
|
121
|
+
return messageType === MetaSystemMessageType.UN_SUPPORTED_FILE;
|
|
122
|
+
}
|
|
109
123
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
124
|
+
static isFailed(status) {
|
|
125
|
+
return status === MessageStatus.FAILED;
|
|
126
|
+
}
|
|
114
127
|
|
|
115
|
-
|
|
128
|
+
static isAutoSent(systemMsgType) {
|
|
129
|
+
return !!systemMsgType;
|
|
116
130
|
}
|
|
117
131
|
|
|
118
132
|
toJSON() {
|
|
@@ -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;
|
|
@@ -2,10 +2,12 @@ import MessageTypes from './MessageType';
|
|
|
2
2
|
import MessageStatus from './MessageStatus';
|
|
3
3
|
import MessageDirection from './MessageDirection';
|
|
4
4
|
import MessageContentType from './MessageContentType';
|
|
5
|
+
import MessageMeta from './MessageMeta';
|
|
5
6
|
import ActionType from './ActionType';
|
|
6
7
|
import ExternalInfoAction from './ExternalInfoAction';
|
|
7
8
|
import InfoSessionStatus from './InfoSessionStatus';
|
|
8
9
|
import InfoAction from './InfoAction';
|
|
9
10
|
import ActionSubType from './ActionSubType';
|
|
10
11
|
import InfoTargetType from './InfoTargetType';
|
|
11
|
-
|
|
12
|
+
import MetaSystemMessageType from './MetaSystemMessageType';
|
|
13
|
+
export { MessageTypes, MessageStatus, MessageDirection, MessageContentType, MessageMeta, ActionType, ActionSubType, ExternalInfoAction, InfoSessionStatus, InfoAction, InfoTargetType, MetaSystemMessageType };
|