Add saved payout destination UX and service contracts (#54)
This commit is contained in:
1 parent
a5689876ff
commit
24af794112
49 files changed
+4687
-62
No files matched your search
@@ -0,0 +1,49 @@
|
||||
/// Local, explicit-label paste parsing. Raw pasted text is never retained.
|
||||
class BankPaste {
|
||||
BankPaste._(this.values, this.conflicts);
|
||||
final Map<String, String> values;
|
||||
final Set<String> conflicts;
|
||||
static BankPaste parse(String text) {
|
||||
final values = <String, String>{};
|
||||
final conflicts = <String>{};
|
||||
const labels = {
|
||||
'бик': 'bik',
|
||||
'bik': 'bik',
|
||||
'счет': 'account',
|
||||
'счёт': 'account',
|
||||
'номер счета': 'account',
|
||||
'номер счёта': 'account',
|
||||
'account': 'account',
|
||||
'account number': 'account',
|
||||
'имя': 'firstName',
|
||||
'first name': 'firstName',
|
||||
'фамилия': 'lastName',
|
||||
'last name': 'lastName',
|
||||
'отчество': 'patronymic',
|
||||
'patronymic': 'patronymic',
|
||||
'получатель': 'holder',
|
||||
'фио': 'holder',
|
||||
'account holder': 'holder',
|
||||
'банк': 'bank',
|
||||
'bank': 'bank',
|
||||
'корреспондентский счет': 'correspondent',
|
||||
'корреспондентский счёт': 'correspondent',
|
||||
'correspondent account': 'correspondent',
|
||||
};
|
||||
for (final line in text.split(RegExp(r'[\r\n]+'))) {
|
||||
final match = RegExp(r'^\s*([^:=]+)\s*[:=]\s*(.+?)\s*$').firstMatch(line);
|
||||
if (match == null) continue;
|
||||
final key = labels[match[1]!.trim().toLowerCase()];
|
||||
if (key == null) continue;
|
||||
var value = match[2]!.trim();
|
||||
if (['bik', 'account', 'correspondent'].contains(key))
|
||||
value = value.replaceAll(RegExp(r'\s'), '');
|
||||
if (values.containsKey(key) && values[key] != value) conflicts.add(key);
|
||||
values[key] = value;
|
||||
}
|
||||
for (final key in conflicts) {
|
||||
values.remove(key);
|
||||
}
|
||||
return BankPaste._(Map.unmodifiable(values), Set.unmodifiable(conflicts));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user