61 lines
1.7 KiB
Dart
61 lines
1.7 KiB
Dart
class PaymentOperationDTO {
|
|
final String? stepRef;
|
|
final String? operationRef;
|
|
final String? gateway;
|
|
final String? code;
|
|
final String? state;
|
|
final String? label;
|
|
final String? failureCode;
|
|
final String? failureReason;
|
|
final String? startedAt;
|
|
final String? completedAt;
|
|
|
|
const PaymentOperationDTO({
|
|
this.stepRef,
|
|
this.operationRef,
|
|
this.gateway,
|
|
this.code,
|
|
this.state,
|
|
this.label,
|
|
this.failureCode,
|
|
this.failureReason,
|
|
this.startedAt,
|
|
this.completedAt,
|
|
});
|
|
|
|
factory PaymentOperationDTO.fromJson(Map<String, dynamic> json) =>
|
|
PaymentOperationDTO(
|
|
stepRef: _asString(json['stepRef'] ?? json['step_ref']),
|
|
operationRef: _asString(json['operationRef'] ?? json['operation_ref']),
|
|
gateway: _asString(json['gateway']),
|
|
code: _asString(json['code']),
|
|
state: _asString(json['state']),
|
|
label: _asString(json['label']),
|
|
failureCode: _asString(json['failureCode'] ?? json['failure_code']),
|
|
failureReason: _asString(
|
|
json['failureReason'] ?? json['failure_reason'],
|
|
),
|
|
startedAt: _asString(json['startedAt'] ?? json['started_at']),
|
|
completedAt: _asString(json['completedAt'] ?? json['completed_at']),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => <String, dynamic>{
|
|
'stepRef': stepRef,
|
|
'operationRef': operationRef,
|
|
'gateway': gateway,
|
|
'code': code,
|
|
'state': state,
|
|
'label': label,
|
|
'failureCode': failureCode,
|
|
'failureReason': failureReason,
|
|
'startedAt': startedAt,
|
|
'completedAt': completedAt,
|
|
};
|
|
}
|
|
|
|
String? _asString(Object? value) {
|
|
final text = value?.toString().trim();
|
|
if (text == null || text.isEmpty) return null;
|
|
return text;
|
|
}
|