fromJson static method
Returns a new SerialCourseCustomer instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static SerialCourseCustomer? 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 "SerialCourseCustomer[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "SerialCourseCustomer[$key]" has a null value in JSON.');
});
return true;
}());
return SerialCourseCustomer(
id: mapValueOfType<int>(json, r'id'),
name: mapValueOfType<String>(json, r'name'),
feedbackId: mapValueOfType<String>(json, r'feedback_id'),
created: mapDateTime(json, r'created', r''),
modified: mapDateTime(json, r'modified', r''),
deletedAt: mapDateTime(json, r'deleted_at', r''),
numWeeks: mapValueOfType<int>(json, r'num_weeks')!,
startDate: mapDateTime(json, r'start_date', r'')!,
endDate: mapDateTime(json, r'end_date', r'')!,
weeklyPriceCents: mapValueOfType<int>(json, r'weekly_price_cents')!,
timeZone: mapValueOfType<String>(json, r'time_zone'),
stripeCheckoutSessionId: mapValueOfType<String>(json, r'stripe_checkout_session_id'),
stripeSubscriptionScheduledId: mapValueOfType<String>(json, r'stripe_subscription_scheduled_id'),
stripeSubscriptionId: mapValueOfType<String>(json, r'stripe_subscription_id'),
cancelAt: mapDateTime(json, r'cancel_at', r''),
canceledAt: mapDateTime(json, r'canceled_at', r''),
cancelAtPeriodEnd: mapValueOfType<bool>(json, r'cancel_at_period_end'),
subscriptionStatus: SubscriptionStatusEnum.fromJson(json[r'subscription_status'])!,
serialCourse: mapValueOfType<int>(json, r'serial_course'),
customer: mapValueOfType<int>(json, r'customer'),
chat: mapValueOfType<int>(json, r'chat'),
);
}
return null;
}