import '../competitions/competitions.dart';

class ItemsMatches {
  String? sId;
  String? competitionId;
  String? name;
  String? isCup;
  String? logo;
  bool? favourite;
  List<Matches>? matches;

  ItemsMatches(
      {this.sId,
        this.competitionId,
        this.name,
        this.isCup,
        this.logo,
        this.favourite,
        this.matches});

  ItemsMatches.fromJson(Map<String, dynamic> json) {
    sId = json['_id'];
    competitionId = json['competitionId'];
    name = json['name'];
    isCup = json['isCup'];
    logo = json['logo'];
    favourite = json['favourite'];
    if (json['matches'] != null) {
      matches = <Matches>[];
      json['matches'].forEach((v) {
        matches!.add(new Matches.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['_id'] = sId;
    data['competitionId'] = competitionId;
    data['name'] = name;
    data['isCup'] = isCup;
    data['logo'] = logo;
    data['favourite'] = favourite;
    if (matches != null) {
      data['matches'] = matches!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}


class Matches {
  String? sId;
  String? matchId;
  String? competitionId;
  ItemsCompetitions? competition;
  String? groupId;
  String? homeName;
  String? homeId;
  Home? home;
  String? location;
  String? round;
  String? leagueId;
  String? awayId;
  Home? away;
  String? date;
  String? time;
  String? awayName;
  bool? displayFixtureLineup;
  bool? isSendLineupNoti;
  String? createdAt;
  String? updatedAt;
  String? status;
  bool? favourite;
  int? iV;
  String ? etScore;
  String ? ftScore;
  String ? htScore;
  String ? lastChanged;
  String ? matchTime;
  String ? psScore;
  String ? score;
  String ? realResultId;

  Matches(
      {this.sId,
        this.matchId,
        this.competitionId,
        this.competition,
        this.groupId,
        this.homeName,
        this.homeId,
        this.home,
        this.location,
        this.round,
        this.leagueId,
        this.awayId,
        this.away,
        this.status,
        this.favourite,
        this.date,
        this.time,
        this.awayName,
        this.displayFixtureLineup,
        this.isSendLineupNoti,
        this.createdAt,
        this.updatedAt,
        this.etScore,
        this.ftScore,
        this.htScore,
        this.lastChanged,
        this.matchTime,
        this.psScore,
        this.score,
        this.realResultId,
        this.iV});

  Matches.fromJson(Map<String, dynamic> json) {
    sId = json['_id'];
    etScore = json['etScore'];
    ftScore = json['ftScore'];
    htScore = json['htScore'];
    lastChanged = json['lastChanged'];
    matchTime = json['matchTime'];
    psScore = json['psScore'];
    score = json['score'];
    realResultId = json['realResultId'];
    matchId = json['matchId'];
    competitionId = json['competitionId'];
    competition = json['competition'] != null
        ? ItemsCompetitions.fromJson(json['competition'])
        : null;
    groupId = json['groupId'];
    homeName = json['homeName'];
    homeId = json['homeId'];
    home = json['home'] != null ? Home.fromJson(json['home']) : null;
    location = json['location'];
    round = json['round'];
    leagueId = json['leagueId'];
    awayId = json['awayId'];
    away = json['away'] != null ? Home.fromJson(json['away']) : null;
    date = json['date'];
    time = json['time'];
    awayName = json['awayName'];
    displayFixtureLineup = json['displayFixtureLineup'];
    isSendLineupNoti = json['isSendLineupNoti'];
    createdAt = json['createdAt'];
    status = json['status'];
    favourite = json['favourite'];
    updatedAt = json['updatedAt'];
    iV = json['__v'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['_id'] = sId;
    data['etScore'] = etScore;
    data['ftScore'] = ftScore;
    data['htScore'] = htScore;
    data['lastChanged'] = lastChanged;
    data['matchTime'] = matchTime;
    data['psScore'] = psScore;
    data['score'] = score;
    data['realResultId'] = realResultId;
    data['matchId'] = matchId;
    data['competitionId'] = competitionId;
    if (competition != null) {
      data['competition'] = competition!.toJson();
    }
    data['groupId'] = groupId;
    data['homeName'] = homeName;
    data['homeId'] = homeId;
    if (home != null) {
      data['home'] = home!.toJson();
    }
    data['location'] = location;
    data['round'] = round;
    data['leagueId'] = leagueId;
    data['awayId'] = awayId;
    if (away != null) {
      data['away'] = away!.toJson();
    }
    data['date'] = date;
    data['time'] = time;
    data['awayName'] = awayName;
    data['displayFixtureLineup'] = displayFixtureLineup;
    data['isSendLineupNoti'] = isSendLineupNoti;
    data['createdAt'] = createdAt;
    data['favourite'] = favourite;
    data['status'] = status;
    data['updatedAt'] = updatedAt;
    data['__v'] = iV;
    return data;
  }
}


class Home {
  String? sId;
  String? teamId;
  String? name;
  String? logo;
  String? stadium;
  bool ? favourite;

  Home({this.sId, this.teamId,
    this.name,
    this.logo,
    this.stadium,
    this.favourite});

  Home.fromJson(Map<String, dynamic> json) {
    sId = json['_id'];
    favourite = json['favourite'];
    teamId = json['teamId'];
    name = json['name'];
    stadium = json['stadium'];
    logo = json['logo'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    data['_id'] = sId;
    data['favourite'] = favourite;
    data['teamId'] = teamId;
    data['name'] = name;
    data['stadium'] = stadium;
    data['logo'] = logo;
    return data;
  }
}