import '../core/utils/safe_convert.dart'; import 'student.dart'; class Exam { final int id; final String name; final String state; final String? startDate; final String? endDate; final NamedRecord? program; final NamedRecord? academicYear; const Exam({ required this.id, required this.name, required this.state, this.startDate, this.endDate, this.program, this.academicYear, }); factory Exam.fromJson(Map json) { return Exam( id: SafeConvert.toSafeInt(json['id']), name: SafeConvert.toSafeString(json['name']), state: SafeConvert.toSafeString(json['state'], 'scheduled'), startDate: SafeConvert.toNullableString(json['start_date']), endDate: SafeConvert.toNullableString(json['end_date']), program: NamedRecord.fromNullableJson(json['program']), academicYear: NamedRecord.fromNullableJson(json['academic_year']), ); } }