fromJson static method

PatchedTutorReview? fromJson(
  1. dynamic value
)

Returns a new PatchedTutorReview instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static PatchedTutorReview? 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 "PatchedTutorReview[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "PatchedTutorReview[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return PatchedTutorReview(
      id: mapValueOfType<int>(json, r'id'),
      customer: User.fromJson(json[r'customer']),
      tutor: User.fromJson(json[r'tutor']),
      showCustomerFeedbackOnSite: mapValueOfType<bool>(json, r'show_customer_feedback_on_site'),
      subject: SimpleSubjectLevel.fromJson(json[r'subject']),
      customerFeedbackNotes: mapValueOfType<String>(json, r'customer_feedback_notes'),
      customerFeedbackStatus: CustomerFeedbackStatusEnum.fromJson(json[r'customer_feedback_status']),
      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'),
    );
  }
  return null;
}