Files
efrilmandClaude Opus 5.5 f5e3075205 EnakPoint & EnakCoin wallet, PIN, outlet, order, community, reward
- Wallet EnakPoint & EnakCoin: beranda, riwayat, saldo kedaluwarsa, kode
  bayar, tukar EnakCoin, transfer
- PIN (buat, ganti, lupa), outlet, riwayat order, game spin
- Halaman community, webview, coming soon, dan ikon menu beranda baru
- Redesign Reward Saya: kartu tiket, filter chip, detail kode + QR
- Hapus customer point loader, menu, dan checkout lama
- Base URL ke enaklo-pos-api.altru.id

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 01:43:22 +07:00

55 lines
1.9 KiB
Dart

part of '../wallet.dart';
@freezed
sealed class WalletFailure with _$WalletFailure {
const WalletFailure._();
/// Gagal di level transport (jaringan, timeout, parsing).
const factory WalletFailure.serverError(ApiFailure failure) = _ServerError;
const factory WalletFailure.unexpectedError() = _UnexpectedError;
const factory WalletFailure.unauthorized() = _Unauthorized;
/// `303`, `310`: request tidak lengkap / salah format.
const factory WalletFailure.invalidRequest() = _InvalidRequest;
/// `304`: ditolak aturan bisnis. [cause] berbahasa Inggris, jangan ditampilkan
/// mentah ke customer.
const factory WalletFailure.rejected(String cause) = _Rejected;
/// `404`.
const factory WalletFailure.notFound() = _NotFound;
/// `429`: minta OTP terlalu cepat.
const factory WalletFailure.tooManyRequests(int retryAfterSeconds) =
_TooManyRequests;
/// `900`.
const factory WalletFailure.internalError() = _InternalError;
const factory WalletFailure.pinNotSet() = _PinNotSet;
const factory WalletFailure.pinInvalid(int? remainingAttempts) = _PinInvalid;
const factory WalletFailure.pinLocked(DateTime? lockedUntil) = _PinLocked;
const factory WalletFailure.transferBlocked(DateTime? transferBlockedUntil) =
_TransferBlocked;
bool get isPinError => maybeMap(
pinNotSet: (_) => true,
pinInvalid: (_) => true,
pinLocked: (_) => true,
transferBlocked: (_) => true,
orElse: () => false,
);
/// Request mungkin tidak sampai / jawaban tidak diterima, sehingga hasilnya
/// tidak diketahui. Hanya pada kondisi ini `Idempotency-Key` dipakai ulang.
bool get isNetworkError => maybeMap(
serverError: (value) => value.failure.maybeMap(
connectionError: (_) => true,
connectionTimeout: (_) => true,
serverError: (e) => e.statusCode == 0,
orElse: () => false,
),
orElse: () => false,
);
}