import 'package:json_annotation/json_annotation.dart'; import 'package:pshared/data/dto/payment/payment_quote.dart'; part 'payment.g.dart'; @JsonSerializable() class PaymentDTO { final String? paymentRef; final String? idempotencyKey; final String? state; final String? failureCode; final String? failureReason; final PaymentQuoteDTO? lastQuote; final Map? metadata; final String? createdAt; const PaymentDTO({ this.paymentRef, this.idempotencyKey, this.state, this.failureCode, this.failureReason, this.lastQuote, this.metadata, this.createdAt, }); factory PaymentDTO.fromJson(Map json) => _$PaymentDTOFromJson(_normalizeJson(json)); Map toJson() => _$PaymentDTOToJson(this); static Map _normalizeJson(Map json) { if (json.containsKey('metadata') || !json.containsKey('meta')) { return json; } final normalized = Map.from(json); normalized['metadata'] = normalized['meta']; return normalized; } }