passo_mobile_app/lib/model/profile/eligibility.dart

102 lines
3.3 KiB
Dart
Raw Normal View History

// To parse this JSON data, do
//
// final eligibity = eligibityFromJson(jsonString);
import 'package:meta/meta.dart';
import 'dart:convert';
2023-02-20 07:48:24 +00:00
import 'package:unit2/model/location/region.dart';
import '../location/address_category.dart';
import '../location/city.dart';
import '../location/country.dart';
import '../utils/eligibility.dart';
EligibityCert eligibityFromJson(String str) => EligibityCert.fromJson(json.decode(str));
String eligibityToJson(EligibityCert data) => json.encode(data.toJson());
class EligibityCert {
EligibityCert({
required this.id,
required this.rating,
required this.examDate,
required this.attachments,
required this.eligibility,
required this.examAddress,
required this.validityDate,
required this.licenseNumber,
2023-02-20 07:48:24 +00:00
required this.overseas,
});
bool? overseas;
final int? id;
final double? rating;
final DateTime? examDate;
final dynamic attachments;
final Eligibility? eligibility;
final ExamAddress? examAddress;
final DateTime? validityDate;
2023-02-09 08:48:19 +00:00
final String? licenseNumber;
factory EligibityCert.fromJson(Map<String, dynamic> json) => EligibityCert(
id: json["id"],
rating: json["rating"]?.toDouble(),
examDate: json['exam_date'] == null? null: DateTime.parse(json["exam_date"]),
attachments: null,
eligibility: json['eligibility'] == null?null: Eligibility.fromJson(json["eligibility"]),
2023-02-16 07:10:54 +00:00
examAddress: json['exam_address'] == null? null: ExamAddress.fromJson(json["exam_address"]),
validityDate: json["validity_date"],
licenseNumber: json["license_number"],
2023-02-20 07:48:24 +00:00
overseas: null,
);
Map<String, dynamic> toJson() => {
"id": id,
"rating": rating,
"exam_date": "${examDate!.year.toString().padLeft(4, '0')}-${examDate!.month.toString().padLeft(2, '0')}-${examDate!.day.toString().padLeft(2, '0')}",
"attachments": attachments,
"eligibility": eligibility!.toJson(),
"exam_address": examAddress!.toJson(),
"validity_date": validityDate,
"license_number": licenseNumber,
};
}
class ExamAddress {
ExamAddress({
required this.id,
required this.examAddressClass,
required this.country,
required this.barangay,
required this.addressCategory,
required this.cityMunicipality,
});
final int? id;
final dynamic examAddressClass;
final Country? country;
final dynamic barangay;
final AddressCategory? addressCategory;
final CityMunicipality? cityMunicipality;
factory ExamAddress.fromJson(Map<String, dynamic> json) => ExamAddress(
id: json["id"],
examAddressClass: 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": examAddressClass,
"country": country!.toJson(),
"barangay": barangay,
"address_category": addressCategory!.toJson(),
"city_municipality": cityMunicipality!.toJson(),
};
}