// To parse this JSON data, do
//
//     final references = referencesFromJson(jsonString);
class PersonalReference {
    PersonalReference({
        required this.id,
        required this.address,
        required this.lastName,
        required this.contactNo,
        required this.firstName,
        required this.middleName,
    });

    final int? id;
    final Address? address;
    final String? lastName;
    final String? contactNo;
    final String? firstName;
    final String? middleName;

    factory PersonalReference.fromJson(Map<String, dynamic> json) => PersonalReference(
        id: json["id"],
        address: json['address'] == null?null: Address.fromJson(json["address"]),
        lastName: json["last_name"],
        contactNo: json["contact_no"],
        firstName: json["first_name"],
        middleName: json["middle_name"],
    );

    Map<String, dynamic> toJson() => {
        "id": id,
        "address": address!.toJson(),
        "last_name": lastName,
        "contact_no": contactNo,
        "first_name": firstName,
        "middle_name": middleName,
    };
}

class Address {
    Address({
        required this.id,
        required this.addressClass,
        required this.country,
        required this.barangay,
        required this.addressCategory,
        required this.cityMunicipality,
    });

    final int? id;
    final String? addressClass;
    final Country? country;
    final Barangay? barangay;
    final AddressCategory? addressCategory;
    final CityMunicipality? cityMunicipality;

    factory Address.fromJson(Map<String, dynamic> json) => Address(
        id: json["id"],
        addressClass: json["class"],
        country: json['country']== null?null: Country.fromJson(json["country"]),
        barangay:json["barangay"]== null?null: Barangay.fromJson(json["barangay"]),
        addressCategory: json["address_category"]== null? null: AddressCategory.fromJson(json["address_category"]),
        cityMunicipality: json["city_municipality"]==null?null: CityMunicipality.fromJson(json["city_municipality"]),
    );

    Map<String, dynamic> toJson() => {
        "id": id,
        "class": addressClass,
        "country": country!.toJson(),
        "barangay": barangay!.toJson(),
        "address_category": addressCategory!.toJson(),
        "city_municipality": cityMunicipality!.toJson(),
    };
}

class AddressCategory {
    AddressCategory({
        required this.id,
        required this.name,
        required this.type,
    });

    final int? id;
    final String? name;
    final String? type;

    factory AddressCategory.fromJson(Map<String, dynamic> json) => AddressCategory(
        id: json["id"],
        name: json["name"],
        type: json["type"],
    );

    Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
        "type": type,
    };
}

class Barangay {
    Barangay({
        required this.code,
        required this.description,
        required this.cityMunicipality,
    });

    final String? code;
    final String? description;
    final CityMunicipality? cityMunicipality;

    factory Barangay.fromJson(Map<String, dynamic> json) => Barangay(
        code: json["code"],
        description: json["description"],
        cityMunicipality: CityMunicipality.fromJson(json["city_municipality"]),
    );

    Map<String, dynamic> toJson() => {
        "code": code,
        "description": description,
        "city_municipality": cityMunicipality!.toJson(),
    };
}

class CityMunicipality {
    CityMunicipality({
        required this.code,
        required this.zipcode,
        required this.province,
        required this.psgcCode,
        required this.description,
    });

    final String? code;
    final String? zipcode;
    final Province? province;
    final String? psgcCode;
    final String? description;

    factory CityMunicipality.fromJson(Map<String, dynamic> json) => CityMunicipality(
        code: json["code"],
        zipcode: json["zipcode"],
        province: json["province"] == null? null : Province.fromJson(json["province"]),
        psgcCode: json["psgc_code"],
        description: json["description"],
    );

    Map<String, dynamic> toJson() => {
        "code": code,
        "zipcode": zipcode,
        "province": province!.toJson(),
        "psgc_code": psgcCode,
        "description": description,
    };
}

class Province {
    Province({
        required this.code,
        required this.region,
        required this.psgcCode,
        required this.shortname,
        required this.description,
    });

    final String? code;
    final Region? region;
    final String? psgcCode;
    final String? shortname;
    final String? description;

    factory Province.fromJson(Map<String, dynamic> json) => Province(
        code: json["code"],
        region: json["region"] == null? null : Region.fromJson(json["region"]),
        psgcCode: json["psgc_code"],
        shortname: json["shortname"],
        description: json["description"],
    );

    Map<String, dynamic> toJson() => {
        "code": code,
        "region": region!.toJson(),
        "psgc_code": psgcCode,
        "shortname": shortname,
        "description": description,
    };
}

class Region {
    Region({
        required this.code,
        required this.psgcCode,
        required this.description,
    });

    final int? code;
    final String? psgcCode;
    final String? description;

    factory Region.fromJson(Map<String, dynamic> json) => Region(
        code: json["code"],
        psgcCode: json["psgc_code"],
        description: json["description"],
    );

    Map<String, dynamic> toJson() => {
        "code": code,
        "psgc_code": psgcCode,
        "description": description,
    };
}

class Country {
    Country({
        required this.id,
        required this.code,
        required this.name,
    });

    final int? id;
    final String? code;
    final String? name;

    factory Country.fromJson(Map<String, dynamic> json) => Country(
        id: json["id"],
        code: json["code"],
        name: json["name"],
    );

    Map<String, dynamic> toJson() => {
        "id": id,
        "code": code,
        "name": name,
    };
}
