class CountryModel {
  final bool? status;
  final List<CountryData>? countriesData;
  final List<StateData>? statesData;

  CountryModel({
    this.status,
    this.countriesData,
    this.statesData,
  });

  factory CountryModel.fromJson(Map<String, dynamic> json) {
    return CountryModel(
      status: json['status'],
      countriesData: json['countries_data'] != null
          ? List<CountryData>.from(
              json['countries_data'].map((x) => CountryData.fromJson(x)))
          : [],
      statesData: json['states_data'] != null
          ? List<StateData>.from(
              json['states_data'].map((x) => StateData.fromJson(x)))
          : [],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'status': status,
      'countries_data': countriesData?.map((x) => x.toJson()).toList(),
      'states_data': statesData?.map((x) => x.toJson()).toList(),
    };
  }
}

class CountryData {
  final int? id;
  final String? countryCode;
  final String? countryName;
  final int? active;
  final dynamic createdBy;
  final dynamic updatedBy;
  final String? createdAt;
  final String? updatedAt;

  CountryData({
    this.id,
    this.countryCode,
    this.countryName,
    this.active,
    this.createdBy,
    this.updatedBy,
    this.createdAt,
    this.updatedAt,
  });

  factory CountryData.fromJson(Map<String, dynamic> json) {
    return CountryData(
      id: json['id'],
      countryCode: json['country_code'],
      countryName: json['country_name'],
      active: json['active'],
      createdBy: json['created_by'],
      updatedBy: json['updated_by'],
      createdAt: json['created_at'],
      updatedAt: json['updated_at'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'country_code': countryCode,
      'country_name': countryName,
      'active': active,
      'created_by': createdBy,
      'updated_by': updatedBy,
      'created_at': createdAt,
      'updated_at': updatedAt,
    };
  }
}

class StateData {
  final int? id;
  final String? stateName;
  final int? active;
  final int? countryId;
  final dynamic createdBy;
  final dynamic updatedBy;
  final String? createdAt;
  final String? updatedAt;

  StateData({
    this.id,
    this.stateName,
    this.active,
    this.countryId,
    this.createdBy,
    this.updatedBy,
    this.createdAt,
    this.updatedAt,
  });

  factory StateData.fromJson(Map<String, dynamic> json) {
    return StateData(
      id: json['id'],
      stateName: json['state_name'],
      active: json['active'],
      countryId: json['country_id'],
      createdBy: json['created_by'],
      updatedBy: json['updated_by'],
      createdAt: json['created_at'],
      updatedAt: json['updated_at'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'state_name': stateName,
      'active': active,
      'country_id': countryId,
      'created_by': createdBy,
      'updated_by': updatedBy,
      'created_at': createdAt,
      'updated_at': updatedAt,
    };
  }
}
