passo_mobile_app/lib/model/profile/eligibility.dart

122 lines
3.8 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';
2023-02-27 06:26:27 +00:00
EligibityCert eligibityFromJson(String str) =>
EligibityCert.fromJson(json.decode(str));
String eligibityToJson(EligibityCert data) => json.encode(data.toJson());
class EligibityCert {
2023-02-27 06:26:27 +00:00
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,
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;
final String? licenseNumber;
2023-02-27 06:26:27 +00:00
factory EligibityCert.fromJson(Map<String, dynamic> json) => EligibityCert(
id: json["id"],
rating: json["rating"]?.toDouble(),
2023-02-27 06:26:27 +00:00
examDate: json['exam_date'] == null
? null
: DateTime.parse(json["exam_date"]),
attachments: null,
2023-02-27 06:26:27 +00:00
eligibility: json['eligibility'] == null
? null
: Eligibility.fromJson(json["eligibility"]),
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,
2023-02-27 06:26:27 +00:00
);
2023-02-27 06:26:27 +00:00
Map<String, dynamic> toJson() => {
"id": id,
"rating": rating,
2023-02-27 06:26:27 +00:00
"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,
2023-02-27 06:26:27 +00:00
};
@override
String toString() {
return 'eligibility:${eligibility.toString()}, rating:$rating, examDate:${examDate.toString()},validydate:${validityDate.toString()}, lisence:$licenseNumber, examAddress:${examAddress.toString()}';
}
}
class ExamAddress {
2023-02-27 06:26:27 +00:00
ExamAddress({
required this.id,
required this.examAddressClass,
required this.country,
required this.barangay,
required this.addressCategory,
required this.cityMunicipality,
});
2023-02-27 06:26:27 +00:00
final int? id;
final dynamic examAddressClass;
final Country? country;
final dynamic barangay;
final AddressCategory? addressCategory;
final CityMunicipality? cityMunicipality;
2023-02-27 06:26:27 +00:00
factory ExamAddress.fromJson(Map<String, dynamic> json) => ExamAddress(
id: json["id"],
examAddressClass: json["class"],
2023-02-27 06:26:27 +00:00
country:
json["country"] == null ? null : Country.fromJson(json["country"]),
barangay: json["barangay"],
2023-02-27 06:26:27 +00:00
addressCategory: json["address_category"] == null
? null
: AddressCategory.fromJson(json["address_category"]),
cityMunicipality: json["city_municipality"] == null
? null
: CityMunicipality.fromJson(json["city_municipality"]),
);
2023-02-27 06:26:27 +00:00
Map<String, dynamic> toJson() => {
"id": id,
"class": examAddressClass,
"country": country!.toJson(),
"barangay": barangay,
"address_category": addressCategory!.toJson(),
"city_municipality": cityMunicipality!.toJson(),
2023-02-27 06:26:27 +00:00
};
2023-02-27 06:26:27 +00:00
@override
String toString() {
return 'country:${country.toString()} , address:${cityMunicipality.toString()}';
}
}