fromJson static method
Returns a new PubSubVote instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static PubSubVote? 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 "PubSubVote[_id]" is missing from JSON.');
assert(json[r'_id'] != null, 'Required key "PubSubVote[_id]" has a null value in JSON.');
assert(json.containsKey(r'tenantId'), 'Required key "PubSubVote[tenantId]" is missing from JSON.');
assert(json[r'tenantId'] != null, 'Required key "PubSubVote[tenantId]" has a null value in JSON.');
assert(json.containsKey(r'urlId'), 'Required key "PubSubVote[urlId]" is missing from JSON.');
assert(json[r'urlId'] != null, 'Required key "PubSubVote[urlId]" has a null value in JSON.');
assert(json.containsKey(r'urlIdRaw'), 'Required key "PubSubVote[urlIdRaw]" is missing from JSON.');
assert(json[r'urlIdRaw'] != null, 'Required key "PubSubVote[urlIdRaw]" has a null value in JSON.');
assert(json.containsKey(r'commentId'), 'Required key "PubSubVote[commentId]" is missing from JSON.');
assert(json[r'commentId'] != null, 'Required key "PubSubVote[commentId]" has a null value in JSON.');
assert(json.containsKey(r'direction'), 'Required key "PubSubVote[direction]" is missing from JSON.');
assert(json[r'direction'] != null, 'Required key "PubSubVote[direction]" has a null value in JSON.');
assert(json.containsKey(r'createdAt'), 'Required key "PubSubVote[createdAt]" is missing from JSON.');
assert(json[r'createdAt'] != null, 'Required key "PubSubVote[createdAt]" has a null value in JSON.');
assert(json.containsKey(r'verificationId'), 'Required key "PubSubVote[verificationId]" is missing from JSON.');
return true;
}());
return PubSubVote(
id: mapValueOfType<String>(json, r'_id')!,
tenantId: mapValueOfType<String>(json, r'tenantId')!,
urlId: mapValueOfType<String>(json, r'urlId')!,
urlIdRaw: mapValueOfType<String>(json, r'urlIdRaw')!,
commentId: mapValueOfType<String>(json, r'commentId')!,
userId: mapValueOfType<String>(json, r'userId'),
direction: mapValueOfType<int>(json, r'direction')!,
createdAt: mapValueOfType<int>(json, r'createdAt')!,
verificationId: mapValueOfType<String>(json, r'verificationId'),
);
}
return null;
}