/// User balance for a single wallet type. /// /// Combines wallet metadata with available and locked amounts in raw units. library; import 'wallet_type_model.dart'; /// Balance snapshot for one asset, including nested wallet type details. class BalanceModel { const BalanceModel({ required this.walletType, required this.available, required this.locked, this.bonusAvailable = '0', this.testAvailable = '0', }); final WalletTypeModel walletType; /// Spendable main balance in smallest units as a string. final String available; /// Locked balance (e.g. pending withdrawals) in smallest units. final String locked; /// Bonus account available balance in smallest units. final String bonusAvailable; /// Test account available balance in smallest units. final String testAvailable; /// Parses a balance entry from the `/api/v1/balances` response. factory BalanceModel.fromJson(Map json) { final wt = json['walletType'] as Map; return BalanceModel( walletType: WalletTypeModel.fromJson(wt), available: (json['available'] ?? '0').toString(), locked: (json['locked'] ?? '0').toString(), bonusAvailable: (json['bonusAvailable'] ?? '0').toString(), testAvailable: (json['testAvailable'] ?? '0').toString(), ); } }