// class AnnouncementModel {
//   List<Announcement>? announcements;
//   int? totalAnnouncements;
//
//   AnnouncementModel({this.announcements, this.totalAnnouncements});
//
//   // Factory constructor to create an instance from a JSON map
//   factory AnnouncementModel.fromJson(Map<String, dynamic> json) {
//     return AnnouncementModel(
//       announcements: json['announcements'] != null
//           ? List<Announcement>.from(json['announcements'].map((item) => Announcement.fromJson(item)))
//           : null,
//       totalAnnouncements: json['totalAnnouncements']?.toString() != null
//           ? int.tryParse(json['totalAnnouncements'].toString())
//           : 1,
//     );
//   }
//
//   // Method to convert an instance to a JSON map
//   Map<String, dynamic> toJson() {
//     return {
//       'announcements': announcements?.map((item) => item.toJson()).toList(),
//       'totalAnnouncements': totalAnnouncements,
//     };
//   }
//
//   // Overriding the toString() method for debugging purposes
//   @override
//   String toString() {
//     return 'AnnouncementModel(announcements: $announcements, totalAnnouncements: $totalAnnouncements)';
//   }
// }

class AnnouncementModel {
  String? id;
  List<String>? sentTo;
  String? message;
  String? createdAt;
  String? updatedAt;
  String? uniqueId;
  int? version;

  AnnouncementModel({
    this.id,
    this.sentTo,
    this.message,
    this.createdAt,
    this.updatedAt,
    this.uniqueId,
    this.version,
  });

  // Factory constructor to create an instance from a JSON map
  factory AnnouncementModel.fromJson(Map<String, dynamic> json) {
    return AnnouncementModel(
      id: json['_id']?.toString(),
      sentTo: json['sentTo'] != null ? List<String>.from(json['sentTo']) : null,
      message: json['message']?.toString(),
      createdAt: json['createdAt']?.toString(),
      updatedAt: json['updatedAt']?.toString(),
      uniqueId: json['uniqueId']?.toString(),
      version: json['__v']?.toString() != null ? int.tryParse(json['__v'].toString()) : null,
    );
  }

  // Method to convert an instance to a JSON map
  Map<String, dynamic> toJson() {
    return {
      '_id': id,
      'sentTo': sentTo,
      'message': message,
      'createdAt': createdAt,
      'updatedAt': updatedAt,
      'uniqueId': uniqueId,
      '__v': version,
    };
  }

  // Overriding the toString() method for debugging purposes
  @override
  String toString() {
    return 'Announcement(id: $id, sentTo: $sentTo, message: $message, createdAt: $createdAt, updatedAt: $updatedAt, uniqueId: $uniqueId, version: $version)';
  }
}
