part of '../wallet.dart'; enum WalletCurrency { point('POINT', 'EnakPoint'), coin('COIN', 'EnakCoin'); const WalletCurrency(this.apiValue, this.label); final String apiValue; final String label; static WalletCurrency fromApi(String? value) => value == coin.apiValue ? coin : point; } const _bothCurrencies = [WalletCurrency.point, WalletCurrency.coin]; enum WalletTransactionType { earn('EARN', 'Dari belanja', _bothCurrencies), earnReversal( 'EARN_REVERSAL', 'Dibatalkan (order di-void/refund)', _bothCurrencies, ), exchangeOut('EXCHANGE_OUT', 'Ditukar ke EnakPoint', [WalletCurrency.coin]), exchangeIn('EXCHANGE_IN', 'Hasil tukar EnakCoin', [WalletCurrency.point]), transferOut('TRANSFER_OUT', 'Transfer keluar', _bothCurrencies), transferIn('TRANSFER_IN', 'Transfer masuk', _bothCurrencies), gameSpend('GAME_SPEND', 'Main game', [WalletCurrency.coin]), gameSpendRefund('GAME_SPEND_REFUND', 'Biaya main dikembalikan', [ WalletCurrency.coin, ]), gameReward('GAME_REWARD', 'Hadiah game', [WalletCurrency.coin]), rewardRedeem('REWARD_REDEEM', 'Ditukar ke voucher', [WalletCurrency.point]), rewardRedeemRefund('REWARD_REDEEM_REFUND', 'Penukaran voucher dibatalkan', [ WalletCurrency.point, ]), expire('EXPIRE', 'Kedaluwarsa', _bothCurrencies), adjustment('ADJUSTMENT', 'Koreksi', _bothCurrencies), migration('MIGRATION', 'Saldo awal', _bothCurrencies), /// Tipe baru dari backend yang belum dikenal app: tampilkan `description` /// tanpa label. unknown('', '', []); const WalletTransactionType(this.apiValue, this.label, this.currencies); final String apiValue; final String label; /// Mata uang yang bisa memiliki tipe ini. final List currencies; /// Tipe yang bisa dipilih di filter riwayat untuk tab [currency]. static List filterableFor(WalletCurrency currency) => values.where((e) => e.currencies.contains(currency)).toList(); static WalletTransactionType fromApi(String? value) => values.firstWhere((e) => e.apiValue == value, orElse: () => unknown); } enum PinOtpPurpose { setup('pin_setup'), reset('pin_reset'); const PinOtpPurpose(this.apiValue); final String apiValue; } enum VoucherType { fixedValue('FIXED_VALUE'), percentage('PERCENTAGE'), freeItem('FREE_ITEM'), merchantBenefit('MERCHANT_BENEFIT'), unknown(''); const VoucherType(this.apiValue); final String apiValue; static VoucherType fromApi(String? value) => values.firstWhere((e) => e.apiValue == value, orElse: () => unknown); } enum VoucherRedemptionStatus { completed('COMPLETED'), /// Sedang diproses penyedia luar; EnakPoint sudah terpotong. pending('PENDING'), /// Gagal; EnakPoint dikembalikan otomatis (`REWARD_REDEEM_REFUND`). failed('FAILED'), unknown(''); const VoucherRedemptionStatus(this.apiValue); final String apiValue; static VoucherRedemptionStatus fromApi(String? value) => values.firstWhere((e) => e.apiValue == value, orElse: () => unknown); }