fromJson static method

PatchedtutorSerialCourse? fromJson(
  1. dynamic value
)

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

Implementation

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

    return PatchedtutorSerialCourse(
      id: mapValueOfType<int>(json, r'id'),
      startDate: mapDateTime(json, r'start_date', r''),
      endDate: mapDateTime(json, r'end_date', r''),
      subject: mapValueOfType<String>(json, r'subject'),
      level: mapValueOfType<int>(json, r'level'),
      numWeeks: mapValueOfType<int>(json, r'num_weeks'),
      maxSeats: mapValueOfType<int>(json, r'max_seats'),
      weeklyPriceCents: mapValueOfType<int>(json, r'weekly_price_cents'),
      courseName: mapValueOfType<String>(json, r'course_name'),
      description: mapValueOfType<String>(json, r'description'),
      image: mapValueOfType<String>(json, r'image'),
      status: mapValueOfType<String>(json, r'status'),
      customerCount: mapValueOfType<String>(json, r'customer_count'),
      customers: mapValueOfType<String>(json, r'customers'),
      tutor: mapValueOfType<int>(json, r'tutor'),
      courses: mapValueOfType<String>(json, r'courses'),
      timeZone: mapValueOfType<String>(json, r'time_zone'),
      publishStatus: mapValueOfType<bool>(json, r'publish_status'),
      canEnroll: mapValueOfType<String>(json, r'can_enroll'),
    );
  }
  return null;
}