import 'package:decimal/decimal.dart';

/// 可用余额 - POST uc/asset/wallet/{coinName}
class WithdrawBalance {
  final String memberId;
  final Decimal balance;
  final Decimal frozenBalance;
  final Decimal withdrawableBalance;
  final Decimal transferableBalance;

  WithdrawBalance({
    this.memberId = '',
    Decimal? balance,
    Decimal? frozenBalance,
    Decimal? withdrawableBalance,
    Decimal? transferableBalance,
  })  : balance = balance ?? Decimal.zero,
        frozenBalance = frozenBalance ?? Decimal.zero,
        withdrawableBalance = withdrawableBalance ?? Decimal.zero,
        transferableBalance = transferableBalance ?? Decimal.zero;

  factory WithdrawBalance.fromJson(Map<String, dynamic> json) {
    return WithdrawBalance(
      memberId: json['memberId']?.toString() ?? '',
      balance: Decimal.tryParse(json['balance']?.toString() ?? ''),
      frozenBalance: Decimal.tryParse(json['frozenBalance']?.toString() ?? ''),
      withdrawableBalance: Decimal.tryParse(json['withdrawableBalance']?.toString() ?? ''),
      transferableBalance: Decimal.tryParse(json['transferableBalance']?.toString() ?? ''),
    );
  }
}
