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