import 'last_message.dart';

class ChatRoom {
  final int id;
  final String type;
  final String updatedAt;
  int unread;
  final LastMessage lastMessage;

  ChatRoom({
    required this.id,
    required this.type,
    required this.updatedAt,
    required this.unread,
    required this.lastMessage,
  });

  factory ChatRoom.fromJson(Map<String, dynamic> json) => ChatRoom(
        id: json['id'],
        type: json['type'],
        updatedAt: json['updatedAt'],
        unread: json['unread'],
        lastMessage: LastMessage.fromJson(json['lastMessage']),
      );

  Map<String, dynamic> toJson() => {
        'id': id,
        'type': type,
        'updatedAt': updatedAt,
        'unread': unread,
        'lastMessage': lastMessage.toJson(),
      };
}
