fromJson static method
Returns a new APIBannedUser instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static APIBannedUser? 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 "APIBannedUser[_id]" is missing from JSON.');
assert(json[r'_id'] != null, 'Required key "APIBannedUser[_id]" has a null value in JSON.');
assert(json.containsKey(r'tenantId'), 'Required key "APIBannedUser[tenantId]" is missing from JSON.');
assert(json[r'tenantId'] != null, 'Required key "APIBannedUser[tenantId]" has a null value in JSON.');
assert(json.containsKey(r'createdAt'), 'Required key "APIBannedUser[createdAt]" is missing from JSON.');
assert(json[r'createdAt'] != null, 'Required key "APIBannedUser[createdAt]" has a null value in JSON.');
assert(json.containsKey(r'bannedByUserId'), 'Required key "APIBannedUser[bannedByUserId]" is missing from JSON.');
assert(json[r'bannedByUserId'] != null, 'Required key "APIBannedUser[bannedByUserId]" has a null value in JSON.');
assert(json.containsKey(r'bannedCommentText'), 'Required key "APIBannedUser[bannedCommentText]" is missing from JSON.');
assert(json[r'bannedCommentText'] != null, 'Required key "APIBannedUser[bannedCommentText]" has a null value in JSON.');
assert(json.containsKey(r'banType'), 'Required key "APIBannedUser[banType]" is missing from JSON.');
assert(json[r'banType'] != null, 'Required key "APIBannedUser[banType]" has a null value in JSON.');
assert(json.containsKey(r'bannedUntil'), 'Required key "APIBannedUser[bannedUntil]" is missing from JSON.');
assert(json.containsKey(r'hasEmailWildcard'), 'Required key "APIBannedUser[hasEmailWildcard]" is missing from JSON.');
assert(json[r'hasEmailWildcard'] != null, 'Required key "APIBannedUser[hasEmailWildcard]" has a null value in JSON.');
return true;
}());
return APIBannedUser(
id: mapValueOfType<String>(json, r'_id')!,
tenantId: mapValueOfType<String>(json, r'tenantId')!,
userId: mapValueOfType<String>(json, r'userId'),
email: mapValueOfType<String>(json, r'email'),
username: mapValueOfType<String>(json, r'username'),
ipHash: mapValueOfType<String>(json, r'ipHash'),
createdAt: mapDateTime(json, r'createdAt', r'')!,
bannedByUserId: mapValueOfType<String>(json, r'bannedByUserId')!,
bannedCommentText: mapValueOfType<String>(json, r'bannedCommentText')!,
banType: mapValueOfType<String>(json, r'banType')!,
bannedUntil: mapDateTime(json, r'bannedUntil', r''),
hasEmailWildcard: mapValueOfType<bool>(json, r'hasEmailWildcard')!,
banReason: mapValueOfType<String>(json, r'banReason'),
);
}
return null;
}