class Coupon { final String code; final String? description; final String discountType; // fixed_cart, percent, fixed_product, percent_product final String amount; final bool isValid; final String? errorMessage; Coupon({ required this.code, this.description, required this.discountType, required this.amount, this.isValid = false, this.errorMessage, }); factory Coupon.fromJson(Map json) { return Coupon( code: json['code'] ?? '', description: json['description'], discountType: json['discount_type'] ?? 'fixed_cart', amount: json['amount'] ?? '0', isValid: json['is_valid'] ?? false, errorMessage: json['error_message'], ); } String get discountDisplay { switch (discountType) { case 'percent': case 'percent_product': return '$amount%'; case 'fixed_cart': case 'fixed_product': return '$amount €'; default: return amount; } } }