32 lines
1.0 KiB
Dart
32 lines
1.0 KiB
Dart
import 'package:pshared/data/dto/payment/payment.dart';
|
|
import 'package:pshared/data/mapper/payment/quote.dart';
|
|
import 'package:pshared/models/payment/payment.dart';
|
|
import 'package:pshared/models/payment/state.dart';
|
|
|
|
extension PaymentDTOMapper on PaymentDTO {
|
|
Payment toDomain() => Payment(
|
|
paymentRef: paymentRef,
|
|
idempotencyKey: idempotencyKey,
|
|
state: state,
|
|
orchestrationState: paymentOrchestrationStateFromValue(state),
|
|
failureCode: failureCode,
|
|
failureReason: failureReason,
|
|
lastQuote: lastQuote?.toDomain(),
|
|
metadata: metadata,
|
|
createdAt: createdAt == null ? null : DateTime.tryParse(createdAt!),
|
|
);
|
|
}
|
|
|
|
extension PaymentMapper on Payment {
|
|
PaymentDTO toDTO() => PaymentDTO(
|
|
paymentRef: paymentRef,
|
|
idempotencyKey: idempotencyKey,
|
|
state: state ?? paymentOrchestrationStateToValue(orchestrationState),
|
|
failureCode: failureCode,
|
|
failureReason: failureReason,
|
|
lastQuote: lastQuote?.toDTO(),
|
|
metadata: metadata,
|
|
createdAt: createdAt?.toUtc().toIso8601String(),
|
|
);
|
|
}
|