fromJson static method
Returns a new LoanOffer instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static LoanOffer? 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 "LoanOffer[uuid]" is missing from JSON.');
assert(json[r'uuid'] != null,
'Required key "LoanOffer[uuid]" has a null value in JSON.');
assert(json.containsKey(r'productType'),
'Required key "LoanOffer[productType]" is missing from JSON.');
assert(json[r'productType'] != null,
'Required key "LoanOffer[productType]" has a null value in JSON.');
assert(json.containsKey(r'productSubType'),
'Required key "LoanOffer[productSubType]" is missing from JSON.');
assert(json[r'productSubType'] != null,
'Required key "LoanOffer[productSubType]" has a null value in JSON.');
assert(json.containsKey(r'originator'),
'Required key "LoanOffer[originator]" is missing from JSON.');
assert(json[r'originator'] != null,
'Required key "LoanOffer[originator]" has a null value in JSON.');
assert(json.containsKey(r'preQualified'),
'Required key "LoanOffer[preQualified]" is missing from JSON.');
assert(json[r'preQualified'] != null,
'Required key "LoanOffer[preQualified]" has a null value in JSON.');
assert(json.containsKey(r'preApproved'),
'Required key "LoanOffer[preApproved]" is missing from JSON.');
assert(json[r'preApproved'] != null,
'Required key "LoanOffer[preApproved]" has a null value in JSON.');
assert(json.containsKey(r'secured'),
'Required key "LoanOffer[secured]" is missing from JSON.');
assert(json[r'secured'] != null,
'Required key "LoanOffer[secured]" has a null value in JSON.');
assert(json.containsKey(r'coApplicant'),
'Required key "LoanOffer[coApplicant]" is missing from JSON.');
assert(json[r'coApplicant'] != null,
'Required key "LoanOffer[coApplicant]" has a null value in JSON.');
assert(json.containsKey(r'sponsored'),
'Required key "LoanOffer[sponsored]" is missing from JSON.');
assert(json[r'sponsored'] != null,
'Required key "LoanOffer[sponsored]" has a null value in JSON.');
assert(json.containsKey(r'maxAmount'),
'Required key "LoanOffer[maxAmount]" is missing from JSON.');
assert(json[r'maxAmount'] != null,
'Required key "LoanOffer[maxAmount]" has a null value in JSON.');
assert(json.containsKey(r'aprType'),
'Required key "LoanOffer[aprType]" is missing from JSON.');
assert(json[r'aprType'] != null,
'Required key "LoanOffer[aprType]" has a null value in JSON.');
assert(json.containsKey(r'allowPrepayment'),
'Required key "LoanOffer[allowPrepayment]" is missing from JSON.');
assert(json[r'allowPrepayment'] != null,
'Required key "LoanOffer[allowPrepayment]" has a null value in JSON.');
return true;
}());
return LoanOffer(
uuid: mapValueOfType<String>(json, r'uuid')!,
productType: ProductType.fromJson(json[r'productType'])!,
productSubType: ProductSubType.fromJson(json[r'productSubType'])!,
productSubTypeDisclaimer:
mapValueOfType<String>(json, r'productSubTypeDisclaimer'),
url: mapValueOfType<String>(json, r'url'),
originator: Originator.fromJson(json[r'originator'])!,
originatorId: mapValueOfType<String>(json, r'originatorId'),
preQualified: mapValueOfType<bool>(json, r'preQualified')!,
preApproved: mapValueOfType<bool>(json, r'preApproved')!,
secured: mapValueOfType<bool>(json, r'secured')!,
coApplicant: mapValueOfType<bool>(json, r'coApplicant')!,
sponsored: mapValueOfType<bool>(json, r'sponsored')!,
maxAmount: mapValueOfType<int>(json, r'maxAmount')!,
minAmount: mapValueOfType<int>(json, r'minAmount'),
termLength: mapValueOfType<int>(json, r'termLength'),
termUnit: TermUnit.fromJson(json[r'termUnit']),
displayTermUnit: mapValueOfType<String>(json, r'displayTermUnit'),
termDescription: mapValueOfType<String>(json, r'termDescription'),
maxApr:
json[r'maxApr'] == null ? null : num.parse('${json[r'maxApr']}'),
minApr:
json[r'minApr'] == null ? null : num.parse('${json[r'minApr']}'),
meanApr:
json[r'meanApr'] == null ? null : num.parse('${json[r'meanApr']}'),
aprType: AprType.fromJson(json[r'aprType'])!,
aprDescription: mapValueOfType<String>(json, r'aprDescription'),
feeRate:
json[r'feeRate'] == null ? null : num.parse('${json[r'feeRate']}'),
maxFeeRate: json[r'maxFeeRate'] == null
? null
: num.parse('${json[r'maxFeeRate']}'),
minFeeRate: json[r'minFeeRate'] == null
? null
: num.parse('${json[r'minFeeRate']}'),
feeFixed: json[r'feeFixed'] == null
? null
: num.parse('${json[r'feeFixed']}'),
maxFeeFixed: json[r'maxFeeFixed'] == null
? null
: num.parse('${json[r'maxFeeFixed']}'),
minFeeFixed: json[r'minFeeFixed'] == null
? null
: num.parse('${json[r'minFeeFixed']}'),
allowPrepayment: mapValueOfType<bool>(json, r'allowPrepayment')!,
prepaymentFee: json[r'prepaymentFee'] == null
? null
: num.parse('${json[r'prepaymentFee']}'),
monthlyPayment: json[r'monthlyPayment'] == null
? null
: num.parse('${json[r'monthlyPayment']}'),
maxMonthlyPayment: json[r'maxMonthlyPayment'] == null
? null
: num.parse('${json[r'maxMonthlyPayment']}'),
minMonthlyPayment: json[r'minMonthlyPayment'] == null
? null
: num.parse('${json[r'minMonthlyPayment']}'),
monthlyPaymentDescription:
mapValueOfType<String>(json, r'monthlyPaymentDescription'),
meanMonthlyPayment: json[r'meanMonthlyPayment'] == null
? null
: num.parse('${json[r'meanMonthlyPayment']}'),
maxTotalPayment: json[r'maxTotalPayment'] == null
? null
: num.parse('${json[r'maxTotalPayment']}'),
minTotalPayment: json[r'minTotalPayment'] == null
? null
: num.parse('${json[r'minTotalPayment']}'),
meanTotalPayment: json[r'meanTotalPayment'] == null
? null
: num.parse('${json[r'meanTotalPayment']}'),
recommendationScore: json[r'recommendationScore'] == null
? null
: num.parse('${json[r'recommendationScore']}'),
payout:
json[r'payout'] == null ? null : num.parse('${json[r'payout']}'),
conversionProbability: num.parse('${json[r'conversionProbability']}'),
terms: mapValueOfType<String>(json, r'terms'),
amountPrefix: mapValueOfType<String>(json, r'amountPrefix'),
);
}
return null;
}