toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  final Map<String, dynamic> data = new Map<String, dynamic>();
  data.putIfNotNull("from", from);
  data.putIfNotNull("to", to);
  data.putIfNotNull("body", body.toJson());
  data.putIfNotNull("attributes", attributes);
  data.putIfNotNull(
      "direction", this.direction == MessageDirection.SEND ? 'send' : 'rec');
  data.putIfNotNull("hasRead", hasRead);
  data.putIfNotNull("hasReadAck", hasReadAck);
  data.putIfNotNull("hasDeliverAck", hasDeliverAck);
  data.putIfNotNull("needGroupAck", needGroupAck);
  data.putIfNotNull("msgId", msgId);
  data.putIfNotNull("conversationId", this.conversationId ?? this.to);
  data.putIfNotNull("chatType", chatTypeToInt(chatType));
  data.putIfNotNull("localTime", localTime);
  data.putIfNotNull("serverTime", serverTime);
  data.putIfNotNull("status", messageStatusToInt(this.status));
  data.putIfNotNull("isThread", isChatThreadMessage);
  data.putIfNotNull('isContentReplaced', isContentReplaced);
  if (_priority != null) {
    data.putIfNotNull("chatroomMessagePriority", _priority!.index);
  }
  data.putIfNotNull('deliverOnlineOnly', deliverOnlineOnly);
  if (receiverList != null) {
    data.putIfNotNull('receiverList', receiverList);
  }

  return data;
}