import 'package:betting/data/model/res/matches/matches.dart';
import 'package:betting/data/model/res/schedule/schedule_model.dart';

class InforTeam {
  Matches? match;
  H2h? h2h;

  InforTeam({this.match, this.h2h});

  InforTeam.fromJson(Map<String, dynamic> json) {
    match = json['match'] != null ? Matches.fromJson(json['match']) : null;
    h2h = json['h2h'] != null ? H2h.fromJson(json['h2h']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    if (match != null) {
      data['match'] = match!.toJson();
    }
    if (h2h != null) {
      data['h2h'] = h2h!.toJson();
    }
    return data;
  }
}



class Home {
  String? sId;
  String? teamId;
  String? name;
  String ? logo;

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

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

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

class H2h {
  String? sId;
  List<String>? teamIds;
  String? competitionId;
  String? competition;
  Home? team1;
  Home? team2;
  List<String>? h2hFormTeam1;
  List<String>? h2hFormTeam2;
  List<Team1Last6>? team1Last6;
  List<Team1Last6>? team2Last6;
  List<h2hMatches>? h2h;
  String? createdAt;
  String? updatedAt;
  int? iV;


  H2h(
      {this.sId,
        this.teamIds,
        this.competitionId,
        this.competition,
        this.team1,
        this.team2,
        this.h2hFormTeam1,
        this.h2hFormTeam2,
        this.team1Last6,
        this.team2Last6,
        this.h2h,
        this.createdAt,
        this.updatedAt,
        this.iV});

  H2h.fromJson(Map<String, dynamic> json) {
    sId = json['_id'];
    teamIds = json['teamIds'].cast<String>();
    competitionId = json['competitionId'];
    competition = json['competition'];
    team1 = json['team1'] != null ? Home.fromJson(json['team1']) : null;
    team2 = json['team2'] != null ? Home.fromJson(json['team2']) : null;
    h2hFormTeam1 = json['h2hFormTeam1'].cast<String>();
    h2hFormTeam2 = json['h2hFormTeam2'].cast<String>();
    if (json['team1Last6'] != null) {
      team1Last6 = <Team1Last6>[];
      json['team1Last6'].forEach((v) {
        team1Last6!.add(Team1Last6.fromJson(v));
      });
    }
    if (json['team2Last6'] != null) {
      team2Last6 = <Team1Last6>[];
      json['team2Last6'].forEach((v) {
        team2Last6!.add(Team1Last6.fromJson(v));
      });
    }
    if (json['h2h'] != null) {
      h2h = <h2hMatches>[];
      json['h2h'].forEach((v) {
        h2h!.add(h2hMatches.fromJson(v));
      });
    }
    createdAt = json['createdAt'];
    updatedAt = json['updatedAt'];
    iV = json['__v'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    data['_id'] = sId;
    data['teamIds'] = teamIds;
    data['competitionId'] = competitionId;
    data['competition'] = competition;
    if (team1 != null) {
      data['team1'] = team1!.toJson();
    }
    if (team2 != null) {
      data['team2'] = team2!.toJson();
    }
    data['h2hFormTeam1'] = h2hFormTeam1;
    data['h2hFormTeam2'] = h2hFormTeam2;
    if (team1Last6 != null) {
      data['team1Last6'] = team1Last6!.map((v) => v.toJson()).toList();
    }
    if (team2Last6 != null) {
      data['team2Last6'] = team2Last6!.map((v) => v.toJson()).toList();
    }
    if (h2h != null) {
      data['h2h'] = h2h!.map((v) => v.toJson()).toList();
    }
    data['createdAt'] = createdAt;
    data['updatedAt'] = updatedAt;
    data['__v'] = iV;
    return data;
  }
}

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

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

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

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


class h2hMatches {
  String? id;
  String? date;
  String? homeName;
  String? awayName;
  String? score;
  String? htScore;
  String? ftScore;
  String? etScore;
  String? psScore;
  String? time;
  String? leagueId;
  String? status;
  String? added;
  String? lastChanged;
  String? homeId;
  String? awayId;
  String? competitionId;
  String? location;
  String? fixtureId;
  String? scheduled;
  String? halfTimeOutcome;
  String? fullTimeOutcome;
  String ? extraTimeOutcome;
  Home? home;
  Competition? competition;
  Home? away;
  String ? match;

  h2hMatches(
      {this.id,
        this.date,
        this.homeName,
        this.awayName,
        this.score,
        this.htScore,
        this.ftScore,
        this.etScore,
        this.psScore,
        this.time,
        this.leagueId,
        this.status,
        this.added,
        this.lastChanged,
        this.homeId,
        this.awayId,
        this.competitionId,
        this.location,
        this.fixtureId,
        this.scheduled,
        this.halfTimeOutcome,
        this.fullTimeOutcome,
        this.extraTimeOutcome,
        this.home,
        this.away,
        this.competition,
        this.match});

  h2hMatches.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    date = json['date'];
    homeName = json['homeName'];
    awayName = json['awayName'];
    score = json['score'];
    htScore = json['htScore'];
    ftScore = json['ftScore'];
    etScore = json['etScore'];
    psScore = json['ps_score'];
    time = json['time'];
    leagueId = json['leagueId'];
    status = json['status'];
    added = json['added'];
    lastChanged = json['lastChanged'];
    homeId = json['homeId'];
    awayId = json['awayId'];
    competitionId = json['competitionId'];
    location = json['location'];
    fixtureId = json['fixtureId'];
    scheduled = json['scheduled'];
    halfTimeOutcome = json['halfTimeOutcome'];
    fullTimeOutcome = json['fullTimeOutcome'];
    extraTimeOutcome = json['extraTimeOutcome'];
    home = json['home'] != null ? Home.fromJson(json['home']) : null;
    away = json['away'] != null ? Home.fromJson(json['away']) : null;
    competition = json['away'] != null ? Competition.fromJson(json['away']) : null;
    match = json['match'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    data['id'] = id;
    data['date'] = date;
    data['homeName'] = homeName;
    data['awayName'] = awayName;
    data['score'] = score;
    data['htScore'] = htScore;
    data['ftScore'] = ftScore;
    data['etScore'] = etScore;
    data['ps_score'] = psScore;
    data['time'] = time;
    data['leagueId'] = leagueId;
    data['status'] = status;
    data['added'] = added;
    data['lastChanged'] = lastChanged;
    data['homeId'] = homeId;
    data['awayId'] = awayId;
    data['competitionId'] = competitionId;
    data['location'] = location;
    data['fixtureId'] = fixtureId;
    data['scheduled'] = scheduled;
    data['halfTimeOutcome'] = halfTimeOutcome;
    data['fullTimeOutcome'] = fullTimeOutcome;
    data['extraTimeOutcome'] = extraTimeOutcome;
    if (home != null) {
      data['home'] = home!.toJson();
    }
    if (competition != null) {
      data['competition'] = competition!.toJson();
    }
    if (away != null) {
      data['away'] = away!.toJson();
    }
    data['match'] = match;
    return data;
  }
}



