InappifyCheckout.fromMap constructor
Decodes checkout state while accepting documented camel-case aliases.
Implementation
factory InappifyCheckout.fromMap(Map<String, dynamic> map) {
final id = map['id'] ?? map['checkoutId'] ?? map['checkout_id'];
final status = map['status'] ?? map['checkoutStatus'];
final expiresAt = map['expiresAt'] ?? map['expires_at'];
if (id is! String || id.isEmpty || status is! String || status.isEmpty) {
throw const FormatException(
'Checkout id and status must be non-empty strings.',
);
}
if (expiresAt != null && expiresAt is! String) {
throw const FormatException('Checkout expiresAt must be a string.');
}
return InappifyCheckout(
id: id,
status: status,
expiresAt: expiresAt as String?,
);
}