mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-03 12:24:19 +01:00
CW-1139-Migrate-CakePay-mobile-to-use-the-new-backend-APIs (#2416)
* migrate to new backend API * hide value_type filter * Improve vendor card parsing * Update country.dart * Update lib/cake_pay/src/models/cake_pay_card.dart Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * Update lib/cake_pay/src/models/cake_pay_card.dart Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * address review comments * fix min limit value * Update lib/view_model/cake_pay/cake_pay_buy_card_view_model.dart Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * refactor denomination handling and min value logic --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
+13
-18
@@ -10,6 +10,9 @@ class Country extends EnumerableItem<String> with Serializable<String> {
|
||||
|
||||
static List<Country> get all => _all.values.toList();
|
||||
|
||||
static List<Country> get allForCakePay => _all.values
|
||||
.where((element) => element.countryCode != 'EU' && element.countryCode != 'AQ').toList();
|
||||
|
||||
static const afghanistan = Country(code: 'afg', countryCode: 'AF', fullName: "Afghanistan");
|
||||
static const andorra = Country(code: 'and', countryCode: 'AD', fullName: "Andorra");
|
||||
static const angola = Country(code: 'ago', countryCode: 'AO', fullName: "Angola");
|
||||
@@ -352,30 +355,22 @@ class Country extends EnumerableItem<String> with Serializable<String> {
|
||||
'Curaçao': "Curacao",
|
||||
};
|
||||
|
||||
static String normalizeName(String name) {
|
||||
final key = name.trim();
|
||||
return _cakePayNames[key] ?? key;
|
||||
}
|
||||
|
||||
static Country deserialize({required String raw}) => _all[raw]!;
|
||||
|
||||
static final Map<String, Country> countryByName = {
|
||||
for (var country in _all.values) country.fullName: country,
|
||||
};
|
||||
|
||||
static Country? fromCakePayName(String name) {
|
||||
final normalizedName = _cakePayNames[name] ?? name;
|
||||
return countryByName[normalizedName];
|
||||
}
|
||||
|
||||
static String getCakePayName(Country country) {
|
||||
return _cakePayNames.entries
|
||||
.firstWhere(
|
||||
(entry) => entry.value == country.fullName,
|
||||
orElse: () => MapEntry(country.fullName, country.fullName),
|
||||
)
|
||||
.key;
|
||||
}
|
||||
|
||||
static Country? fromCode(String countryCode) {
|
||||
return _all.values.firstWhereOrNull((element) => element.raw == countryCode.toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
static Country? fromCountryCode(String countryCode) {
|
||||
return _all.values.firstWhereOrNull((element) => element.countryCode == countryCode.toUpperCase());
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => other is Country && other.raw == raw;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user