fromJson static method
Returns a new Subscription instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Subscription? 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 "Subscription[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "Subscription[$key]" has a null value in JSON.');
});
return true;
}());
return Subscription(
id: mapValueOfType<String>(json, r'id')!,
organizationId: mapValueOfType<String>(json, r'organizationId')!,
productId: mapValueOfType<String>(json, r'productId')!,
totalSeats: mapValueOfType<int>(json, r'totalSeats')!,
seatsUsed: mapValueOfType<int>(json, r'seatsUsed')!,
status: SubscriptionStatusEnum.fromJson(json[r'status'])!,
startDate: mapValueOfType<String>(json, r'startDate')!,
endDate: mapValueOfType<String>(json, r'endDate'),
pricePerSeat: mapValueOfType<String>(json, r'pricePerSeat'),
billingCycle: mapValueOfType<String>(json, r'billingCycle'),
providerType: mapValueOfType<String>(json, r'providerType'),
providerSubscriptionId: mapValueOfType<String>(json, r'providerSubscriptionId'),
providerPlanId: mapValueOfType<String>(json, r'providerPlanId'),
paymentStatus: mapValueOfType<String>(json, r'paymentStatus'),
nextBillingDate: mapValueOfType<String>(json, r'nextBillingDate'),
lastPaymentDate: mapValueOfType<String>(json, r'lastPaymentDate'),
paypalSubscriptionId: mapValueOfType<String>(json, r'paypalSubscriptionId'),
paypalPlanId: mapValueOfType<String>(json, r'paypalPlanId'),
metadata: UserMetadata.fromJson(json[r'metadata']),
createdAt: mapValueOfType<String>(json, r'createdAt'),
updatedAt: mapValueOfType<String>(json, r'updatedAt'),
);
}
return null;
}