fromJson static method
Returns a new StatusSeasonRewardSchema instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static StatusSeasonRewardSchema? 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'code'),
'Required key "StatusSeasonRewardSchema[code]" is missing from JSON.');
assert(json[r'code'] != null,
'Required key "StatusSeasonRewardSchema[code]" has a null value in JSON.');
assert(json.containsKey(r'type'),
'Required key "StatusSeasonRewardSchema[type]" is missing from JSON.');
assert(json[r'type'] != null,
'Required key "StatusSeasonRewardSchema[type]" has a null value in JSON.');
assert(json.containsKey(r'description'),
'Required key "StatusSeasonRewardSchema[description]" is missing from JSON.');
assert(json[r'description'] != null,
'Required key "StatusSeasonRewardSchema[description]" has a null value in JSON.');
assert(json.containsKey(r'required_points'),
'Required key "StatusSeasonRewardSchema[required_points]" is missing from JSON.');
assert(json[r'required_points'] != null,
'Required key "StatusSeasonRewardSchema[required_points]" has a null value in JSON.');
return true;
}());
return StatusSeasonRewardSchema(
code: mapValueOfType<String>(json, r'code')!,
type: RewardType.fromJson(json[r'type'])!,
description: mapValueOfType<String>(json, r'description')!,
requiredPoints: mapValueOfType<int>(json, r'required_points')!,
quantity: mapValueOfType<int>(json, r'quantity') ?? 1,
memberRequired: mapValueOfType<bool>(json, r'member_required') ?? false,
firstOnly: mapValueOfType<bool>(json, r'first_only') ?? false,
);
}
return null;
}