fromJson static method
Returns a new OrderItemCancellationPreview instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static OrderItemCancellationPreview? 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'penaltyAmount'), 'Required key "OrderItemCancellationPreview[penaltyAmount]" is missing from JSON.');
assert(json[r'penaltyAmount'] != null, 'Required key "OrderItemCancellationPreview[penaltyAmount]" has a null value in JSON.');
assert(json.containsKey(r'refundAmount'), 'Required key "OrderItemCancellationPreview[refundAmount]" is missing from JSON.');
assert(json[r'refundAmount'] != null, 'Required key "OrderItemCancellationPreview[refundAmount]" has a null value in JSON.');
assert(json.containsKey(r'isRefundable'), 'Required key "OrderItemCancellationPreview[isRefundable]" is missing from JSON.');
assert(json[r'isRefundable'] != null, 'Required key "OrderItemCancellationPreview[isRefundable]" has a null value in JSON.');
return true;
}());
return OrderItemCancellationPreview(
penaltyAmount: Money.fromJson(json[r'penaltyAmount'])!,
cancellationFee: Money.fromJson(json[r'cancellationFee']),
refundAmount: Money.fromJson(json[r'refundAmount'])!,
isRefundable: mapValueOfType<bool>(json, r'isRefundable')!,
appliedPenalties: CancellationPenalty.listFromJson(json[r'appliedPenalties']),
effectiveCancellationDate: mapDateTime(json, r'effectiveCancellationDate', r''),
checkInDate: mapDateTime(json, r'checkInDate', r''),
);
}
return null;
}