fromJson static method
Returns a new PatchedInvitation instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static PatchedInvitation? 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 "PatchedInvitation[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "PatchedInvitation[$key]" has a null value in JSON.');
});
return true;
}());
return PatchedInvitation(
id: mapValueOfType<int>(json, r'id'),
tutor: mapValueOfType<int>(json, r'tutor'),
customer: mapValueOfType<int>(json, r'customer'),
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'),
bookings: Booking.listFromJson(json[r'bookings']),
invitationDates: InvitationDate.listFromJson(json[r'invitation_dates']),
coupon: mapValueOfType<int>(json, r'coupon'),
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'),
isCreatedByCustomer: mapValueOfType<bool>(json, r'is_created_by_customer'),
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'),
startTime: mapDateTime(json, r'start_time', r''),
endTime: mapDateTime(json, r'end_time', r''),
numWeeks: mapValueOfType<int>(json, r'num_weeks'),
cancelReason: mapValueOfType<String>(json, r'cancel_reason'),
acceptancePendingReminded: mapValueOfType<bool>(json, r'acceptance_pending_reminded'),
isTrialCall: mapValueOfType<bool>(json, r'is_trial_call'),
subject: mapValueOfType<int>(json, r'subject'),
cancelledBy: mapValueOfType<int>(json, r'cancelled_by'),
creditCard: mapValueOfType<int>(json, r'credit_card'),
);
}
return null;
}