fromJsonRobotQuery static method
Message
fromJsonRobotQuery(
- dynamic json
)
Implementation
static Message fromJsonRobotQuery(dynamic json) {
//
// String? content = json['content'];
List<Answer> robotQaList = [];
if (json['type'] == BytedeskConstants.MESSAGE_TYPE_ROBOT) {
robotQaList = json['answers'] == null
? []
: (json['answers'] as List<dynamic>)
.map((item) => Answer.fromJson(item))
.toList();
// for (var i = 0; i < robotQaList.length; i++) {
// Answer answer = robotQaList[i];
// content += '\n\n' + answer.aid + ':' + answer.question;
// }
}
//
return Message(
mid: json['mid'],
// topic: json['thread']['topic'],
content: json['content'],
imageUrl: json['imageUrl'],
voiceUrl: json['voiceUrl'],
fileUrl: json['fileUrl'],
videoUrl: json['videoOrShortUrl'],
nickname: json['user']['nickname'],
avatar: json['user']['avatar'],
type: json['type'],
timestamp: json['createdAt'],
status: 'stored',
isSend: 0,
currentUid: SpUtil.getString(BytedeskConstants.uid),
client: json['client'],
// thread: Thread.fromVisitorJson(json['thread']),
user: User.fromJson(json['user']),
answers: robotQaList,
answersJson: json['answers'].toString());
}