toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  return {
    'id': id,
    if (groupId != null) 'group_id': groupId,
    if (senderId != null) 'sender_id': senderId,
    'message_content': messageContent,
    'created_at': createdAt?.toIso8601String(),
    if (updatedAt != null) 'updated_at': updatedAt?.toIso8601String(),
    if (sender != null) 'sender': sender?.toJson(),
    'read_info': readInfo.map((e) => e.toJson()).toList(),
    'delivery_info': deliveryInfo.map((e) => e.toJson()).toList(),
    'overall_status': overallStatus,
    'attachments': attachments.map((e) => e.toJson()).toList(),
    'reactions': reactions,
    if (replyTo != null) 'reply_to': replyTo?.toJson(),
    'mentions': mentions,
    if (messageId != null) 'message_id': messageId,
    if (content != null) 'content': content,
    if (lastMessage != null) 'last_message': lastMessage?.toJson(),
  };
}