class EventModel {
  List<Events>? events;

  EventModel({this.events});

  EventModel.fromJson(Map<String, dynamic> json) {
    if (json['events'] != null) {
      events = <Events>[];
      json['events'].forEach((v) {
        events!.add(Events.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (events != null) {
      data['events'] = events!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Events {
  int? id;
  String? title;
  String? description;
  String? subtitle;
  String? awards;
  String? image;
  String? startAt;
  String? endAt;
  bool? isOpen;
  int? totalParticipants;
  int? totalReceivedWorks;
  List<Winners>? winners;

  Events(
      {this.id,
      this.title,
      this.description,
      this.subtitle,
      this.awards,
      this.image,
      this.startAt,
      this.endAt,
      this.isOpen,
      this.totalParticipants,
      this.totalReceivedWorks,
      this.winners});

  Events.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    title = json['title'];
    description = json['description'];
    subtitle = json['subtitle'];
    awards = json['awards'];
    image = json['image'];
    startAt = json['start_at'];
    endAt = json['end_at'];
    isOpen = json['is_open'];
    totalParticipants = json['total_participants'];
    totalReceivedWorks = json['total_received_works'];
    if (json['winners'] != null) {
      winners = <Winners>[];
      json['winners'].forEach((v) {
        winners!.add(Winners.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['title'] = title;
    data['description'] = description;
    data['subtitle'] = subtitle;
    data['awards'] = awards;
    data['image'] = image;
    data['start_at'] = startAt;
    data['end_at'] = endAt;
    data['is_open'] = isOpen;
    data['total_participants'] = totalParticipants;
    data['total_received_works'] = totalReceivedWorks;
    if (winners != null) {
      data['winners'] = winners!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Winners {
  int? rank;
  String? username;

  Winners({this.rank, this.username});

  Winners.fromJson(Map<String, dynamic> json) {
    rank = json['rank'];
    username = json['username'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['rank'] = rank;
    data['username'] = username;
    return data;
  }
}
