qbMessageToMap static method

Map<String, Object>? qbMessageToMap(
  1. QBMessage? qbMessage
)

Implementation

static Map<String, Object>? qbMessageToMap(QBMessage? qbMessage) {
  if (qbMessage == null) {
    return null;
  }

  Map<String, Object> messageMap = Map();

  messageMap["id"] = qbMessage.id as Object;

  List<Map<String, Object>?> attachmentMapsList = [];

  if (qbMessage.attachments != null) {
    for (QBAttachment? attachment in qbMessage.attachments as List<QBAttachment?>) {
      Map<String, Object>? attachmentMap = QBAttachmentMapper.qbAttachmentToMap(attachment);
      if (attachmentMap != null) {
        attachmentMapsList.add(attachmentMap);
      }
    }
  }

  messageMap["attachments"] = attachmentMapsList;

  if (qbMessage.properties != null) {
    messageMap["properties"] = qbMessage.properties as Object;
  }
  if (qbMessage.dateSent != null) {
    messageMap["dateSent"] = qbMessage.dateSent as Object;
  }
  if (qbMessage.senderId != null) {
    messageMap["senderId"] = qbMessage.senderId as Object;
  }
  if (qbMessage.recipientId != null) {
    messageMap["recipientId"] = qbMessage.recipientId as Object;
  }
  if (qbMessage.readIds != null) {
    messageMap["readIds"] = qbMessage.readIds as Object;
  }
  if (qbMessage.deliveredIds != null) {
    messageMap["deliveredIds"] = qbMessage.deliveredIds as Object;
  }
  if (qbMessage.dialogId != null) {
    messageMap["dialogId"] = qbMessage.dialogId as Object;
  }
  if (qbMessage.markable != null) {
    messageMap["markable"] = qbMessage.markable as Object;
  }
  if (qbMessage.delayed != null) {
    messageMap["delayed"] = qbMessage.delayed as Object;
  }
  if (qbMessage.body != null) {
    messageMap["body"] = qbMessage.body as Object;
  }

  return messageMap;
}