39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
import 'package:pshared/data/dto/payment/operation.dart';
|
|
import 'package:pshared/models/payment/execution_operation.dart';
|
|
|
|
extension PaymentOperationDTOMapper on PaymentOperationDTO {
|
|
PaymentExecutionOperation toDomain() => PaymentExecutionOperation(
|
|
stepRef: stepRef,
|
|
operationRef: operationRef,
|
|
gateway: gateway,
|
|
code: code,
|
|
state: state,
|
|
label: label,
|
|
failureCode: failureCode,
|
|
failureReason: failureReason,
|
|
startedAt: _parseDateTime(startedAt),
|
|
completedAt: _parseDateTime(completedAt),
|
|
);
|
|
}
|
|
|
|
extension PaymentExecutionOperationMapper on PaymentExecutionOperation {
|
|
PaymentOperationDTO toDTO() => PaymentOperationDTO(
|
|
stepRef: stepRef,
|
|
operationRef: operationRef,
|
|
gateway: gateway,
|
|
code: code,
|
|
state: state,
|
|
label: label,
|
|
failureCode: failureCode,
|
|
failureReason: failureReason,
|
|
startedAt: startedAt?.toUtc().toIso8601String(),
|
|
completedAt: completedAt?.toUtc().toIso8601String(),
|
|
);
|
|
}
|
|
|
|
DateTime? _parseDateTime(String? value) {
|
|
final normalized = value?.trim();
|
|
if (normalized == null || normalized.isEmpty) return null;
|
|
return DateTime.tryParse(normalized);
|
|
}
|