fromJson static method
Returns a new SavingsOfferDetails instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static SavingsOfferDetails? 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'annualPercentYield'),
'Required key "SavingsOfferDetails[annualPercentYield]" is missing from JSON.');
assert(json[r'annualPercentYield'] != null,
'Required key "SavingsOfferDetails[annualPercentYield]" has a null value in JSON.');
assert(json.containsKey(r'compoundingMethod'),
'Required key "SavingsOfferDetails[compoundingMethod]" is missing from JSON.');
assert(json[r'compoundingMethod'] != null,
'Required key "SavingsOfferDetails[compoundingMethod]" has a null value in JSON.');
assert(json.containsKey(r'minimumDeposit'),
'Required key "SavingsOfferDetails[minimumDeposit]" is missing from JSON.');
assert(json[r'minimumDeposit'] != null,
'Required key "SavingsOfferDetails[minimumDeposit]" has a null value in JSON.');
assert(json.containsKey(r'monthlyFee'),
'Required key "SavingsOfferDetails[monthlyFee]" is missing from JSON.');
assert(json[r'monthlyFee'] != null,
'Required key "SavingsOfferDetails[monthlyFee]" has a null value in JSON.');
assert(json.containsKey(r'effectiveAsOf'),
'Required key "SavingsOfferDetails[effectiveAsOf]" is missing from JSON.');
assert(json[r'effectiveAsOf'] != null,
'Required key "SavingsOfferDetails[effectiveAsOf]" has a null value in JSON.');
return true;
}());
return SavingsOfferDetails(
name: mapValueOfType<String>(json, r'name'),
description: mapValueOfType<String>(json, r'description'),
details: mapValueOfType<String>(json, r'details'),
rate: num.parse('${json[r'rate']}'),
annualPercentYield: num.parse('${json[r'annualPercentYield']}'),
compoundingMethod:
CompoundingMethod.fromJson(json[r'compoundingMethod'])!,
introductoryPeriodMonths:
mapValueOfType<int>(json, r'introductoryPeriodMonths'),
introductoryRate: num.parse('${json[r'introductoryRate']}'),
minimumDeposit: num.parse('${json[r'minimumDeposit']}'),
minimumDepositWithFees: num.parse('${json[r'minimumDepositWithFees']}'),
monthlyFee: num.parse('${json[r'monthlyFee']}'),
checkWriting: mapValueOfType<bool>(json, r'checkWriting'),
effectiveAsOf: mapDateTime(json, r'effectiveAsOf', r'')!,
federalInsuranceType:
FederalInsuranceType.fromJson(json[r'federalInsuranceType']),
incentiveDetails:
IncentiveDetails.listFromJson(json[r'incentiveDetails']),
cdTermUnit: TermUnit.fromJson(json[r'cdTermUnit']),
cdTermLength: mapValueOfType<int>(json, r'cdTermLength'),
impressionTrackingPixelUrls:
json[r'impressionTrackingPixelUrls'] is Iterable
? (json[r'impressionTrackingPixelUrls'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
);
}
return null;
}