fromJson static method
Returns a new License instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static License? 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 "License[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "License[$key]" has a null value in JSON.');
});
return true;
}());
return License(
id: mapValueOfType<String>(json, r'id')!,
userId: mapValueOfType<String>(json, r'userId')!,
organizationId: mapValueOfType<String>(json, r'organizationId')!,
productId: mapValueOfType<String>(json, r'productId')!,
subscriptionId: mapValueOfType<String>(json, r'subscriptionId')!,
status: LicenseStatusEnum.fromJson(json[r'status'])!,
assignedBy: mapValueOfType<String>(json, r'assignedBy'),
assignedAt: mapValueOfType<String>(json, r'assignedAt'),
revokedAt: mapValueOfType<String>(json, r'revokedAt'),
revokedBy: mapValueOfType<String>(json, r'revokedBy'),
metadata: UserMetadata.fromJson(json[r'metadata']),
createdAt: mapValueOfType<String>(json, r'createdAt'),
updatedAt: mapValueOfType<String>(json, r'updatedAt'),
);
}
return null;
}