Orchestrator refactoring + planned amounts
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:pshared/data/dto/money.dart';
|
||||
|
||||
part 'operation.g.dart';
|
||||
|
||||
@@ -10,6 +11,7 @@ class PaymentOperationDTO {
|
||||
final String? code;
|
||||
final String? state;
|
||||
final String? label;
|
||||
final PaymentOperationMoneyDTO? money;
|
||||
final String? failureCode;
|
||||
final String? failureReason;
|
||||
final String? startedAt;
|
||||
@@ -22,6 +24,7 @@ class PaymentOperationDTO {
|
||||
this.code,
|
||||
this.state,
|
||||
this.label,
|
||||
this.money,
|
||||
this.failureCode,
|
||||
this.failureReason,
|
||||
this.startedAt,
|
||||
@@ -32,3 +35,29 @@ class PaymentOperationDTO {
|
||||
_$PaymentOperationDTOFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$PaymentOperationDTOToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class PaymentOperationMoneyDTO {
|
||||
final PaymentOperationMoneySnapshotDTO? planned;
|
||||
final PaymentOperationMoneySnapshotDTO? executed;
|
||||
|
||||
const PaymentOperationMoneyDTO({this.planned, this.executed});
|
||||
|
||||
factory PaymentOperationMoneyDTO.fromJson(Map<String, dynamic> json) =>
|
||||
_$PaymentOperationMoneyDTOFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$PaymentOperationMoneyDTOToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class PaymentOperationMoneySnapshotDTO {
|
||||
final MoneyDTO? amount;
|
||||
final MoneyDTO? convertedAmount;
|
||||
|
||||
const PaymentOperationMoneySnapshotDTO({this.amount, this.convertedAmount});
|
||||
|
||||
factory PaymentOperationMoneySnapshotDTO.fromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$PaymentOperationMoneySnapshotDTOFromJson(json);
|
||||
Map<String, dynamic> toJson() =>
|
||||
_$PaymentOperationMoneySnapshotDTOToJson(this);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:pshared/data/dto/payment/operation.dart';
|
||||
import 'package:pshared/data/mapper/money.dart';
|
||||
import 'package:pshared/models/payment/execution_operation.dart';
|
||||
|
||||
|
||||
extension PaymentOperationDTOMapper on PaymentOperationDTO {
|
||||
PaymentExecutionOperation toDomain() => PaymentExecutionOperation(
|
||||
stepRef: stepRef,
|
||||
@@ -10,6 +10,7 @@ extension PaymentOperationDTOMapper on PaymentOperationDTO {
|
||||
code: code,
|
||||
state: state,
|
||||
label: label,
|
||||
money: money?.toDomain(),
|
||||
failureCode: failureCode,
|
||||
failureReason: failureReason,
|
||||
startedAt: _parseDateTime(startedAt),
|
||||
@@ -25,6 +26,7 @@ extension PaymentExecutionOperationMapper on PaymentExecutionOperation {
|
||||
code: code,
|
||||
state: state,
|
||||
label: label,
|
||||
money: money?.toDTO(),
|
||||
failureCode: failureCode,
|
||||
failureReason: failureReason,
|
||||
startedAt: startedAt?.toUtc().toIso8601String(),
|
||||
@@ -32,6 +34,38 @@ extension PaymentExecutionOperationMapper on PaymentExecutionOperation {
|
||||
);
|
||||
}
|
||||
|
||||
extension PaymentOperationMoneyDTOMapper on PaymentOperationMoneyDTO {
|
||||
PaymentExecutionOperationMoney toDomain() => PaymentExecutionOperationMoney(
|
||||
planned: planned?.toDomain(),
|
||||
executed: executed?.toDomain(),
|
||||
);
|
||||
}
|
||||
|
||||
extension PaymentExecutionOperationMoneyMapper
|
||||
on PaymentExecutionOperationMoney {
|
||||
PaymentOperationMoneyDTO toDTO() => PaymentOperationMoneyDTO(
|
||||
planned: planned?.toDTO(),
|
||||
executed: executed?.toDTO(),
|
||||
);
|
||||
}
|
||||
|
||||
extension PaymentOperationMoneySnapshotDTOMapper
|
||||
on PaymentOperationMoneySnapshotDTO {
|
||||
PaymentExecutionOperationMoneySnapshot toDomain() =>
|
||||
PaymentExecutionOperationMoneySnapshot(
|
||||
amount: amount?.toDomain(),
|
||||
convertedAmount: convertedAmount?.toDomain(),
|
||||
);
|
||||
}
|
||||
|
||||
extension PaymentExecutionOperationMoneySnapshotMapper
|
||||
on PaymentExecutionOperationMoneySnapshot {
|
||||
PaymentOperationMoneySnapshotDTO toDTO() => PaymentOperationMoneySnapshotDTO(
|
||||
amount: amount?.toDTO(),
|
||||
convertedAmount: convertedAmount?.toDTO(),
|
||||
);
|
||||
}
|
||||
|
||||
DateTime? _parseDateTime(String? value) {
|
||||
final normalized = value?.trim();
|
||||
if (normalized == null || normalized.isEmpty) return null;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:pshared/models/money.dart';
|
||||
|
||||
class PaymentExecutionOperation {
|
||||
final String? stepRef;
|
||||
final String? operationRef;
|
||||
@@ -5,6 +7,7 @@ class PaymentExecutionOperation {
|
||||
final String? code;
|
||||
final String? state;
|
||||
final String? label;
|
||||
final PaymentExecutionOperationMoney? money;
|
||||
final String? failureCode;
|
||||
final String? failureReason;
|
||||
final DateTime? startedAt;
|
||||
@@ -17,9 +20,30 @@ class PaymentExecutionOperation {
|
||||
required this.code,
|
||||
required this.state,
|
||||
required this.label,
|
||||
required this.money,
|
||||
required this.failureCode,
|
||||
required this.failureReason,
|
||||
required this.startedAt,
|
||||
required this.completedAt,
|
||||
});
|
||||
}
|
||||
|
||||
class PaymentExecutionOperationMoney {
|
||||
final PaymentExecutionOperationMoneySnapshot? planned;
|
||||
final PaymentExecutionOperationMoneySnapshot? executed;
|
||||
|
||||
const PaymentExecutionOperationMoney({
|
||||
required this.planned,
|
||||
required this.executed,
|
||||
});
|
||||
}
|
||||
|
||||
class PaymentExecutionOperationMoneySnapshot {
|
||||
final Money? amount;
|
||||
final Money? convertedAmount;
|
||||
|
||||
const PaymentExecutionOperationMoneySnapshot({
|
||||
required this.amount,
|
||||
required this.convertedAmount,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user