class Contact {
  final int id;
  final String username;
  final String name;
  final String surname;
  final String? lastMessage;
  final String? avatarUrl;
  final DateTime? lastMessageTime;
  final bool isOnline;
  final int unreadCount;

  Contact({
    required this.id,
    required this.username,
    required this.name,
    required this.surname,  
    this.lastMessage,
    this.avatarUrl,
    this.lastMessageTime,
    this.isOnline = false,
    this.unreadCount = 0,
  });

  factory Contact.fromJson(Map<String, dynamic> json) {
    return Contact(
      id: json['id'],
      username: json['username'] ?? 'Unknown',
      name: json['name'] ?? 'Unknown',
      surname: json['surname'] ?? 'Unknown',
      // Другие поля можно добавить позже
    );
  }
}