InappifyCheckoutPrice.fromMap constructor
Decodes the documented checkout price shape.
Implementation
factory InappifyCheckoutPrice.fromMap(Map<String, dynamic> map) {
final original = map['originalAmount'] ?? map['original_amount'];
final discount = map['discountAmount'] ?? map['discount_amount'];
final finalAmount = map['finalAmount'] ?? map['final_amount'];
final currency = map['currency'];
if (original is! num ||
discount is! num ||
finalAmount is! num ||
currency is! String ||
currency.isEmpty) {
throw const FormatException('Checkout price is malformed.');
}
return InappifyCheckoutPrice(
originalAmount: original,
discountAmount: discount,
finalAmount: finalAmount,
currency: currency,
);
}