fromJson static method
Returns a new APIAuditLog instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static APIAuditLog? 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(() {
assert(json.containsKey(r'_id'), 'Required key "APIAuditLog[_id]" is missing from JSON.');
assert(json[r'_id'] != null, 'Required key "APIAuditLog[_id]" has a null value in JSON.');
assert(json.containsKey(r'resourceName'), 'Required key "APIAuditLog[resourceName]" is missing from JSON.');
assert(json[r'resourceName'] != null, 'Required key "APIAuditLog[resourceName]" has a null value in JSON.');
assert(json.containsKey(r'crudType'), 'Required key "APIAuditLog[crudType]" is missing from JSON.');
assert(json[r'crudType'] != null, 'Required key "APIAuditLog[crudType]" has a null value in JSON.');
return true;
}());
return APIAuditLog(
id: mapValueOfType<String>(json, r'_id')!,
userId: mapValueOfType<String>(json, r'userId'),
username: mapValueOfType<String>(json, r'username'),
resourceName: mapValueOfType<String>(json, r'resourceName')!,
crudType: APIAuditLogCrudTypeEnum.fromJson(json[r'crudType'])!,
from: APIAuditLogFromEnum.fromJson(json[r'from']),
url: mapValueOfType<String>(json, r'url'),
ip: mapValueOfType<String>(json, r'ip'),
when_: mapDateTime(json, r'when', r''),
description: mapValueOfType<String>(json, r'description'),
serverStartDate: mapDateTime(json, r'serverStartDate', r''),
objectDetails: mapCastOfType<String, Object>(json, r'objectDetails'),
);
}
return null;
}