Files
sendico/frontend/pshared/lib/data/mapper/payment/operation.dart
2026-03-04 17:43:18 +03:00

38 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,
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,
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);
}