fromJson static method
Returns a new RateLimitWindowSchema instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static RateLimitWindowSchema? 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'limit'),
'Required key "RateLimitWindowSchema[limit]" is missing from JSON.');
assert(json[r'limit'] != null,
'Required key "RateLimitWindowSchema[limit]" has a null value in JSON.');
assert(json.containsKey(r'remaining'),
'Required key "RateLimitWindowSchema[remaining]" is missing from JSON.');
assert(json[r'remaining'] != null,
'Required key "RateLimitWindowSchema[remaining]" has a null value in JSON.');
assert(json.containsKey(r'reset'),
'Required key "RateLimitWindowSchema[reset]" is missing from JSON.');
assert(json[r'reset'] != null,
'Required key "RateLimitWindowSchema[reset]" has a null value in JSON.');
return true;
}());
return RateLimitWindowSchema(
limit: mapValueOfType<int>(json, r'limit')!,
remaining: mapValueOfType<int>(json, r'remaining')!,
reset: mapDateTime(json, r'reset', r'')!,
);
}
return null;
}