fromJson static method
Returns a new GetVotesForUserResponse instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static GetVotesForUserResponse? 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'status'), 'Required key "GetVotesForUserResponse[status]" is missing from JSON.');
assert(json[r'status'] != null, 'Required key "GetVotesForUserResponse[status]" has a null value in JSON.');
assert(json.containsKey(r'appliedAuthorizedVotes'), 'Required key "GetVotesForUserResponse[appliedAuthorizedVotes]" is missing from JSON.');
assert(json[r'appliedAuthorizedVotes'] != null, 'Required key "GetVotesForUserResponse[appliedAuthorizedVotes]" has a null value in JSON.');
assert(json.containsKey(r'appliedAnonymousVotes'), 'Required key "GetVotesForUserResponse[appliedAnonymousVotes]" is missing from JSON.');
assert(json[r'appliedAnonymousVotes'] != null, 'Required key "GetVotesForUserResponse[appliedAnonymousVotes]" has a null value in JSON.');
assert(json.containsKey(r'pendingVotes'), 'Required key "GetVotesForUserResponse[pendingVotes]" is missing from JSON.');
assert(json[r'pendingVotes'] != null, 'Required key "GetVotesForUserResponse[pendingVotes]" has a null value in JSON.');
return true;
}());
return GetVotesForUserResponse(
status: APIStatus.fromJson(json[r'status'])!,
appliedAuthorizedVotes: PublicVote.listFromJson(json[r'appliedAuthorizedVotes']),
appliedAnonymousVotes: PublicVote.listFromJson(json[r'appliedAnonymousVotes']),
pendingVotes: PublicVote.listFromJson(json[r'pendingVotes']),
);
}
return null;
}