fromJson static method
Returns a new LifeInsuranceOffer instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static LifeInsuranceOffer? 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'uuid'),
'Required key "LifeInsuranceOffer[uuid]" is missing from JSON.');
assert(json[r'uuid'] != null,
'Required key "LifeInsuranceOffer[uuid]" has a null value in JSON.');
assert(json.containsKey(r'partner'),
'Required key "LifeInsuranceOffer[partner]" is missing from JSON.');
assert(json[r'partner'] != null,
'Required key "LifeInsuranceOffer[partner]" has a null value in JSON.');
assert(json.containsKey(r'productType'),
'Required key "LifeInsuranceOffer[productType]" is missing from JSON.');
assert(json[r'productType'] != null,
'Required key "LifeInsuranceOffer[productType]" has a null value in JSON.');
assert(json.containsKey(r'productSubType'),
'Required key "LifeInsuranceOffer[productSubType]" is missing from JSON.');
assert(json[r'productSubType'] != null,
'Required key "LifeInsuranceOffer[productSubType]" has a null value in JSON.');
assert(json.containsKey(r'url'),
'Required key "LifeInsuranceOffer[url]" is missing from JSON.');
assert(json[r'url'] != null,
'Required key "LifeInsuranceOffer[url]" has a null value in JSON.');
assert(json.containsKey(r'details'),
'Required key "LifeInsuranceOffer[details]" is missing from JSON.');
assert(json[r'details'] != null,
'Required key "LifeInsuranceOffer[details]" has a null value in JSON.');
return true;
}());
return LifeInsuranceOffer(
uuid: mapValueOfType<String>(json, r'uuid')!,
partner: Partner.fromJson(json[r'partner'])!,
marketplace: Partner.fromJson(json[r'marketplace']),
productType: ProductType.fromJson(json[r'productType'])!,
productSubType: ProductSubType.fromJson(json[r'productSubType'])!,
url: mapValueOfType<String>(json, r'url')!,
recommendationScore: num.parse('${json[r'recommendationScore']}'),
disclaimer: mapValueOfType<String>(json, r'disclaimer'),
productSubTypeDisclaimer:
mapValueOfType<String>(json, r'productSubTypeDisclaimer'),
payout: num.parse('${json[r'payout']}'),
details: LifeInsuranceOfferDetails.fromJson(json[r'details'])!,
);
}
return null;
}