Files
sendico/frontend/pweb/lib/services/wallets.dart
2025-11-25 08:20:09 +03:00

49 lines
1.3 KiB
Dart

import 'package:pweb/models/currency.dart';
import 'package:pweb/models/wallet.dart';
abstract class WalletsService {
Future<List<Wallet>> getWallets();
Future<List<Wallet>> updateWallet();
Future<List<Wallet>> createWallet();
Future<List<Wallet>> deleteWallet();
Future<Wallet> getWallet(String walletRef);
}
class MockWalletsService implements WalletsService {
final List<Wallet> _wallets = [
Wallet(id: '1124', walletUserID: 'WA-12345667', name: 'Main Wallet', balance: 10000000.0, currency: Currency.rub),
Wallet(id: '2124', walletUserID: 'WA-76654321', name: 'Savings', balance: 2500.5, currency: Currency.usd),
];
@override
Future<List<Wallet>> getWallets() async {
return _wallets;
}
@override
Future<Wallet> getWallet(String walletId) async {
return _wallets.firstWhere(
(wallet) => wallet.id == walletId,
orElse: () => throw const WalletNotFoundException(),
);
}
@override
Future<List<Wallet>> updateWallet() async => [];
@override
Future<List<Wallet>> createWallet() async => [];
@override
Future<List<Wallet>> deleteWallet() async => [];
}
class WalletNotFoundException implements Exception {
const WalletNotFoundException();
@override
String toString() => 'WalletNotFoundException';
}