import 'dart:convert';

Identification identificationFromJson(String str) => Identification.fromJson(json.decode(str));

String identificationToJson(Identification data) => json.encode(data.toJson());

class Identification {
    Identification({
        required this.id,
        required this.agency,
        required this.issuedAt,
        this.dateIssued,
        this.expirationDate,
        required this.asPdfReference,
        required this.identificationNumber,
    });

    int? id;
    Agency? agency;
    IssuedAt? issuedAt;
    DateTime? dateIssued;
    DateTime? expirationDate;
    bool? asPdfReference;
    String? identificationNumber;

    factory Identification.fromJson(Map<String, dynamic> json) => Identification(
        id: json["id"],
        agency:json["agency"] == null? null: Agency.fromJson(json["agency"]),
        issuedAt: json["issued_at"] == null? null:IssuedAt.fromJson(json["issued_at"]),
        dateIssued:json["date_issued"]==null?null:DateTime.parse(json["date_issued"]),
        expirationDate:json["expiration_date"]==null?null:DateTime.parse(json["expiration_date"]),
        asPdfReference: json["as_pdf_reference"],
        identificationNumber: json["identification_number"],
    );

    Map<String, dynamic> toJson() => {
        "id": id,
        "agency": agency!.toJson(),
        "issued_at": issuedAt!.toJson(),
        "date_issued": dateIssued,
        "expiration_date": expirationDate,
        "as_pdf_reference": asPdfReference,
        "identification_number": identificationNumber,
    };
}

class Agency {
    Agency({
        required this.id,
        required this.name,
        required this.category,
        required this.privateEntity,
    });

    int? id;
    String? name;
    Category? category;
    bool? privateEntity;

    factory Agency.fromJson(Map<String, dynamic> json) => Agency(
        id: json["id"],
        name: json["name"],
        category: json["category"] == null? null: Category.fromJson(json["category"]),
        privateEntity: json["private_entity"],
    );

    Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
        "category": category!.toJson(),
        "private_entity": privateEntity,
    };
}

class Category {
    Category({
        required this.id,
        required this.name,
        required this.industryClass,
    });

    int? id;
    String? name;
    IndustryClass? industryClass;

    factory Category.fromJson(Map<String, dynamic> json) => Category(
        id: json["id"],
        name: json["name"],
        industryClass:json['industry_class'] == null? null:  IndustryClass.fromJson(json["industry_class"]),
    );

    Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
        "industry_class": industryClass!.toJson(),
    };
}

class IndustryClass {
    IndustryClass({
        required this.id,
        required this.name,
        this.description,
    });

    int? id;
    String? name;
    String? description;

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

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

class IssuedAt {
    IssuedAt({
        required this.id,
        this.issuedAtClass,
        required this.country,
        this.barangay,
        required this.addressCategory,
        required this.cityMunicipality,
    });

    int? id;
    dynamic issuedAtClass;
    Country? country;
    dynamic barangay;
    AddressCategory? addressCategory;
    CityMunicipality? cityMunicipality;

    factory IssuedAt.fromJson(Map<String, dynamic> json) => IssuedAt(
        id: json["id"],
        issuedAtClass: json["class"],
        country: json['country'] == null? null: Country.fromJson(json["country"]),
        barangay: 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": issuedAtClass,
        "country": country!.toJson(),
        "barangay": barangay,
        "address_category": addressCategory!.toJson(),
        "city_municipality": cityMunicipality!.toJson(),
    };
}

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

    int? id;
    String? name;
    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 CityMunicipality {
    CityMunicipality({
        required this.code,
        required this.zipcode,
        required this.province,
        required this.psgcCode,
        required this.description,
    });

    String? code;
    String? zipcode;
    Province? province;
    String? psgcCode;
    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,
    });

    String? code;
    Region? region;
    String? psgcCode;
    String? shortname;
    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,
    });

    int? code;
    String? psgcCode;
    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,
    });

    int? id;
    String? code;
    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,
    };
}
