Files
sendico/frontend/pweb/lib/utils/payment/operation_code.dart
2026-03-04 17:43:18 +03:00

24 lines
709 B
Dart

class OperationCodePair {
final String operation;
final String action;
const OperationCodePair({required this.operation, required this.action});
}
OperationCodePair? parseOperationCodePair(String? code) {
final normalized = code?.trim().toLowerCase();
if (normalized == null || normalized.isEmpty) return null;
final parts = normalized.split('.').where((part) => part.isNotEmpty).toList();
if (parts.length >= 4 && (parts.first == 'hop' || parts.first == 'edge')) {
return OperationCodePair(operation: parts[2], action: parts[3]);
}
if (parts.length >= 2) {
return OperationCodePair(
operation: parts[parts.length - 2],
action: parts.last,
);
}
return null;
}