fromJson static method
Returns a new Assertions instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Assertions? 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 "Assertions[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "Assertions[$key]" has a null value in JSON.');
});
return true;
}());
return Assertions(
id: mapValueOfType<int>(json, r'id')!,
user: mapValueOfType<String>(json, r'user')!,
created: mapDateTime(json, r'created', r'')!,
updated: mapDateTime(json, r'updated', r'')!,
entityId: mapValueOfType<String>(json, r'entity_id')!,
credential: mapValueOfType<int>(json, r'credential')!,
metadata: mapValueOfType<Object>(json, r'metadata'),
issuedOn: mapDateTime(json, r'issued_on', r''),
revoked: mapValueOfType<bool>(json, r'revoked'),
revocationReason: mapValueOfType<String>(json, r'revocation_reason'),
expiresAt: mapDateTime(json, r'expires_at', r''),
hashed: mapValueOfType<bool>(json, r'hashed'),
salt: mapValueOfType<String>(json, r'salt'),
narrative: mapValueOfType<String>(json, r'narrative'),
acceptance: AcceptanceEnum.fromJson(json[r'acceptance']),
item: mapValueOfType<int>(json, r'item'),
);
}
return null;
}