ChatProviderModel.fromJson constructor
ChatProviderModel.fromJson(
- Map map
Implementation
factory ChatProviderModel.fromJson(Map map) {
bool isChatting = map['isChatting'];
Iterable<Agent> agents =
((map['agents'] ?? []) as Iterable).map((e) => Agent.fromJson(e));
Iterable<ChatLog> logs =
((map['logs'] ?? []) as Iterable).map((e) => ChatLog.fromJson(e));
int queuePosition = map['queuePosition'] ?? -1;
String queueId = map['queueId'] ?? '-1';
CHAT_SESSION_STATUS chatSessionStatus = CHAT_SESSION_STATUS.CONFIGURING;
final mChatSessionStatus = map['chatSessionStatus'];
switch (mChatSessionStatus) {
case 'CONFIGURING':
chatSessionStatus = CHAT_SESSION_STATUS.CONFIGURING;
break;
case 'ENDED':
chatSessionStatus = CHAT_SESSION_STATUS.ENDED;
break;
case 'ENDING':
chatSessionStatus = CHAT_SESSION_STATUS.ENDING;
break;
case 'INITIALIZING':
chatSessionStatus = CHAT_SESSION_STATUS.INITIALIZING;
break;
case 'STARTED':
chatSessionStatus = CHAT_SESSION_STATUS.STARTED;
break;
}
ChatDepartment? chatDepartment = map['department'] == null
? null
: ChatDepartment.fromJson(map['department']);
return ChatProviderModel(
isChatting,
chatSessionStatus,
agents,
logs,
queuePosition,
queueId,
chatDepartment,
);
}