mapToQBMessage static method
Implementation
static QBMessage? mapToQBMessage(Map<dynamic, dynamic>? map) {
if (map == null || map.length <= 0) {
return null;
}
QBMessage qbMessage = QBMessage();
if (map.containsKey("id")) {
qbMessage.id = map["id"] as String?;
}
if (map.containsKey("attachments")) {
List<Object?> attachmentsMapsList = map["attachments"] as List<Object?>;
List<QBAttachment?> attachmentsList = [];
for (final attachmentDynamicMap in attachmentsMapsList) {
Map<String, Object> attachmentMap =
Map<String, Object>.from(attachmentDynamicMap as Map<dynamic, dynamic>);
QBAttachment? qbAttachment = QBAttachmentMapper.mapToQBAttachment(attachmentMap);
attachmentsList.add(qbAttachment);
}
qbMessage.attachments = attachmentsList;
}
if (map.containsKey("properties")) {
LinkedHashMap<dynamic, dynamic> hashMap =
map["properties"] as LinkedHashMap<dynamic, dynamic>;
Map<String, String> propertiesMap =
hashMap.map((key, value) => MapEntry(key as String, value.toString()));
qbMessage.properties = propertiesMap;
}
if (map.containsKey("dateSent")) {
qbMessage.dateSent = map["dateSent"] as int?;
}
if (map.containsKey("senderId")) {
qbMessage.senderId = map["senderId"] as int?;
}
if (map.containsKey("recipientId")) {
qbMessage.recipientId = map["recipientId"] as int?;
}
if (map.containsKey("readIds")) {
qbMessage.readIds = List.from(map["readIds"] as Iterable<dynamic>);
}
if (map.containsKey("deliveredIds")) {
qbMessage.deliveredIds = List.from(map["deliveredIds"] as Iterable<dynamic>);
}
if (map.containsKey("dialogId")) {
qbMessage.dialogId = map["dialogId"] as String?;
}
if (map.containsKey("markable")) {
qbMessage.markable = map["markable"] as bool?;
}
if (map.containsKey("delayed")) {
qbMessage.delayed = map["delayed"] as bool?;
}
if (map.containsKey("body")) {
qbMessage.body = map["body"] as String?;
}
return qbMessage;
}