@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.
@@ -21,7 +21,7 @@ export default class Actor {
21
21
  return type === ActorType.BOT;
22
22
  }
23
23
 
24
- static isSystemMessage(type) {
24
+ static isSystem(type) {
25
25
  return type === ActorType.SYSTEM;
26
26
  }
27
27
 
@@ -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 isSystemMessage(message) {
79
- return !!message;
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 isHapinessRating(systemMessageType) {
83
- return systemMessageType === MessageTypes.CX_HAPPINESS_SURVEY;
90
+ static getSystemMessageValue(meta) {
91
+ return Message.getMetaValue(meta, MessageMeta.SYSTEM_MESSAGE_TYPE);
84
92
  }
85
93
 
86
- static isWelcomeMessage(systemMessageType) {
87
- return systemMessageType === MessageTypes.WELCOMEMSG;
94
+ static isSystemMessage(meta) {
95
+ const systemMessageType = Message.getSystemMessageValue(meta);
96
+ return !!systemMessageType;
88
97
  }
89
98
 
90
- static isWorkflowMessage(systemMessageType) {
91
- return systemMessageType === MessageTypes.WORKFLOW_MESSAGE;
99
+ static isHapinessRating(meta) {
100
+ const messageType = Message.getSystemMessageValue(meta);
101
+ return messageType === MetaSystemMessageType.CX_HAPPINESS_SURVEY;
92
102
  }
93
103
 
94
- static isWorkflowNotification(systemMessageType) {
95
- return systemMessageType === MessageTypes.WORKFLOW_NOTIFICATION;
104
+ static isWelcomeMessage(meta) {
105
+ const messageType = Message.getSystemMessageValue(meta);
106
+ return messageType === MetaSystemMessageType.WELCOMEMSG;
96
107
  }
97
108
 
98
- static isFailed(status) {
99
- return status === MessageStatus.FAILED;
109
+ static isWorkflowMessage(meta) {
110
+ const messageType = Message.getSystemMessageValue(meta);
111
+ return messageType === MetaSystemMessageType.WORKFLOW_MESSAGE;
100
112
  }
101
113
 
102
- static isAutoSent(systemMsgType) {
103
- return !!systemMsgType;
114
+ static isWorkflowNotification(meta) {
115
+ const messageType = Message.getSystemMessageValue(meta);
116
+ return messageType === MetaSystemMessageType.WORKFLOW_NOTIFICATION;
104
117
  }
105
118
 
106
- static getMetaValue() {
107
- let meta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
108
- let key = arguments.length > 1 ? arguments[1] : undefined;
119
+ static isUnsupportedFile(meta) {
120
+ const messageType = Message.getSystemMessageValue(meta);
121
+ return messageType === MetaSystemMessageType.UN_SUPPORTED_FILE;
122
+ }
109
123
 
110
- if (Array.isArray(meta) && meta.length > 0) {
111
- const item = meta.find(item => item.name === key);
112
- return item ? item.value : '';
113
- }
124
+ static isFailed(status) {
125
+ return status === MessageStatus.FAILED;
126
+ }
114
127
 
115
- return '';
128
+ static isAutoSent(systemMsgType) {
129
+ return !!systemMsgType;
116
130
  }
117
131
 
118
132
  toJSON() {
@@ -40,7 +40,7 @@ export default class Session {
40
40
  return sessionStatus === SessionStatus.ON_PROGRESS;
41
41
  }
42
42
 
43
- static isHold(sessionStatus) {
43
+ static isOnHold(sessionStatus) {
44
44
  return sessionStatus === SessionStatus.ON_HOLD;
45
45
  }
46
46
 
@@ -0,0 +1,4 @@
1
+ const MessageMeta = {
2
+ SYSTEM_MESSAGE_TYPE: 'SYSTEM_MESSAGE_TYPE'
3
+ };
4
+ export default MessageMeta;
@@ -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
- export { MessageTypes, MessageStatus, MessageDirection, MessageContentType, ActionType, ActionSubType, ExternalInfoAction, InfoSessionStatus, InfoAction, InfoTargetType };
12
+ import MetaSystemMessageType from './MetaSystemMessageType';
13
+ export { MessageTypes, MessageStatus, MessageDirection, MessageContentType, MessageMeta, ActionType, ActionSubType, ExternalInfoAction, InfoSessionStatus, InfoAction, InfoTargetType, MetaSystemMessageType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohoim/client-sdk",
3
- "version": "1.0.0-poc94",
3
+ "version": "1.0.0-poc96",
4
4
  "description": "To have the client sdk for the IM",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",