fromJson static method
Returns a new PatchedTutorInvitation instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static PatchedTutorInvitation? 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 "PatchedTutorInvitation[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "PatchedTutorInvitation[$key]" has a null value in JSON.');
});
return true;
}());
return PatchedTutorInvitation(
id: mapValueOfType<int>(json, r'id'),
acceptanceChangedAt: mapDateTime(json, r'acceptance_changed_at', r''),
cancellationPeriodHours: mapValueOfType<int>(json, r'cancellation_period_hours'),
cancelledAt: mapDateTime(json, r'cancelled_at', r''),
cancelledBy: mapValueOfType<int>(json, r'cancelled_by'),
cancelledByCustomer: mapValueOfType<bool>(json, r'cancelled_by_customer'),
customer: mapValueOfType<int>(json, r'customer'),
chat: mapValueOfType<int>(json, r'chat'),
endTime: mapDateTime(json, r'end_time', r''),
hasCancellationPenalty: mapValueOfType<bool>(json, r'has_cancellation_penalty'),
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'),
location: mapValueOfType<String>(json, r'location'),
numWeeks: mapValueOfType<int>(json, r'num_weeks'),
paymentAmountInCents: mapValueOfType<int>(json, r'payment_amount_in_cents'),
startTime: mapDateTime(json, r'start_time', r''),
tutor: mapValueOfType<int>(json, r'tutor'),
subject: mapValueOfType<int>(json, r'subject'),
invitationDates: InvitationDate.listFromJson(json[r'invitation_dates']),
);
}
return null;
}