| 1 | import 'package:cake_wallet/generated/i18n.dart'; |
| 2 | import 'package:cw_core/enumerable_item.dart'; |
| 3 | |
| 4 | class FiatApiMode extends EnumerableItem<int> with Serializable<int> { |
| 5 | const FiatApiMode({required String title, required int raw}) : super(title: title, raw: raw); |
| 6 | |
| 7 | static const all = [FiatApiMode.enabled, FiatApiMode.torOnly, FiatApiMode.disabled]; |
| 8 | |
| 9 | static const enabled = FiatApiMode(raw: 0, title: 'Enabled'); |
| 10 | static const torOnly = FiatApiMode(raw: 1, title: 'Tor only'); |
| 11 | static const disabled = FiatApiMode(raw: 2, title: 'Disabled'); |
| 12 | |
| 13 | static FiatApiMode deserialize({required int raw}) { |
| 14 | switch (raw) { |
| 15 | case 0: |
| 16 | return enabled; |
| 17 | case 1: |
| 18 | return torOnly; |
| 19 | case 2: |
| 20 | return disabled; |
| 21 | default: |
| 22 | throw Exception('Unexpected token: $raw for FiatApiMode deserialize'); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | @override |
| 27 | String toString() { |
| 28 | switch (this) { |
| 29 | case FiatApiMode.enabled: |
| 30 | return S.current.enabled; |
| 31 | case FiatApiMode.torOnly: |
| 32 | return S.current.tor_only; |
| 33 | case FiatApiMode.disabled: |
| 34 | return S.current.disabled; |
| 35 | default: |
| 36 | return ''; |
| 37 | } |
| 38 | } |
| 39 | } |