fromJson static method
Returns a new TutorBooking instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static TutorBooking? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "TutorBooking[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "TutorBooking[$key]" has a null value in JSON.');
});
return true;
}());
return TutorBooking(
id: mapValueOfType<int>(json, r'id'),
tutor: User.fromJson(json[r'tutor']),
customer: User.fromJson(json[r'customer']),
tutorFeedback: TutorFeedback.fromJson(json[r'tutor_feedback']),
customerFeedback: CustomerFeedback.fromJson(json[r'customer_feedback']),
chat: mapValueOfType<int>(json, r'chat'),
cancellationPeriodHours: mapValueOfType<String>(json, r'cancellation_period_hours'),
hasCancellationPenalty: mapValueOfType<bool>(json, r'has_cancellation_penalty'),
paymentHoldsAt: mapDateTime(json, r'payment_holds_at', r''),
paymentAmountInCents: mapValueOfType<int>(json, r'payment_amount_in_cents'),
feedbackId: mapValueOfType<String>(json, r'feedback_id'),
subject: SimpleSubjectLevel.fromJson(json[r'subject']),
created: mapDateTime(json, r'created', r''),
modified: mapDateTime(json, r'modified', r''),
deletedAt: mapDateTime(json, r'deleted_at', r''),
isTutorPaid: mapValueOfType<bool>(json, r'is_tutor_paid'),
isAcceptedByCustomer: mapValueOfType<bool>(json, r'is_accepted_by_customer'),
isAcceptedByTutor: mapValueOfType<bool>(json, r'is_accepted_by_tutor'),
isRejectedByCustomer: mapValueOfType<bool>(json, r'is_rejected_by_customer'),
isRejectedByTutor: mapValueOfType<bool>(json, r'is_rejected_by_tutor'),
location: mapValueOfType<String>(json, r'location'),
acceptanceChangedAt: mapDateTime(json, r'acceptance_changed_at', r''),
cancelledAt: mapDateTime(json, r'cancelled_at', r''),
cancelledByCustomer: mapValueOfType<bool>(json, r'cancelled_by_customer'),
confirmedAt: mapDateTime(json, r'confirmed_at', r''),
confirmedStatus: ConfirmedStatusEnum.fromJson(json[r'confirmed_status']),
customerFeedbackStatus: CustomerFeedbackStatusEnum.fromJson(json[r'customer_feedback_status']),
customerFeedbackNotes: mapValueOfType<String>(json, r'customer_feedback_notes'),
customerFeedbackCreatedAt: mapDateTime(json, r'customer_feedback_created_at', r''),
customerFeedbackRating: mapValueOfType<int>(json, r'customer_feedback_rating'),
customerFeedbackExcellent: mapValueOfType<bool>(json, r'customer_feedback_excellent'),
tutorFeedbackNotes: mapValueOfType<String>(json, r'tutor_feedback_notes'),
tutorFeedbackCreatedAt: mapDateTime(json, r'tutor_feedback_created_at', r''),
tutorFeedbackRating: mapValueOfType<int>(json, r'tutor_feedback_rating'),
showCustomerFeedbackOnSite: mapValueOfType<bool>(json, r'show_customer_feedback_on_site'),
startTime: mapDateTime(json, r'start_time', r'')!,
endTime: mapDateTime(json, r'end_time', r'')!,
customerToken: mapValueOfType<String>(json, r'customer_token'),
tutorToken: mapValueOfType<String>(json, r'tutor_token'),
feedbackRequired: mapValueOfType<bool>(json, r'feedback_required'),
isTrialCall: mapValueOfType<bool>(json, r'is_trial_call'),
finishedNotificationsSent: mapValueOfType<bool>(json, r'finished_notifications_sent'),
reconfirmingNotificationsSent: mapValueOfType<bool>(json, r'reconfirming_notifications_sent'),
cancelReason: mapValueOfType<String>(json, r'cancel_reason'),
isCustomerRead: mapValueOfType<bool>(json, r'is_customer_read'),
isTutorRead: mapValueOfType<bool>(json, r'is_tutor_read'),
rescheduleCountByCustomer: mapValueOfType<int>(json, r'reschedule_count_by_customer'),
rescheduleCountByTutor: mapValueOfType<int>(json, r'reschedule_count_by_tutor'),
invitation: mapValueOfType<int>(json, r'invitation'),
cancelledBy: mapValueOfType<int>(json, r'cancelled_by'),
zoomMeeting: mapValueOfType<int>(json, r'zoom_meeting'),
);
}
return null;
}