/// 划转记录 - POST uc/asset/transfer/list
class TransferRecord {
  final String id;
  final String memberId;
  final String unit;
  final String amount;

  /// 转出钱包类型（SPOT/SWAP/FOLLOW/EXCHANGE）
  final String source;

  /// 转入钱包类型
  final String target;

  final String createTime;

  const TransferRecord({
    this.id = '',
    this.memberId = '',
    this.unit = '',
    this.amount = '0',
    this.source = '',
    this.target = '',
    this.createTime = '',
  });

  /// 转出账户显示名
  String get sourceName => _walletName(source);

  /// 转入账户显示名
  String get targetName => _walletName(target);

  static String _walletName(String type) {
    switch (type) {
      case 'SPOT': return '资金账户';
      case 'SWAP': return '合约账户';
      case 'FOLLOW': return '跟单账户';
      case 'EXCHANGE': return '币种钱包';
      default: return type;
    }
  }

  factory TransferRecord.fromJson(Map<String, dynamic> json) {
    return TransferRecord(
      id: json['id']?.toString() ?? '',
      memberId: json['memberId']?.toString() ?? '',
      unit: json['unit']?.toString() ?? '',
      amount: json['amount']?.toString() ?? '0',
      source: json['source']?.toString() ?? '',
      target: json['target']?.toString() ?? '',
      createTime: json['createTime']?.toString() ?? '',
    );
  }
}
