BalanceTransaction.fromJson constructor

BalanceTransaction.fromJson(
  1. Object? json
)

Implementation

factory BalanceTransaction.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return BalanceTransaction(
    amount: (map['amount'] as num).toInt(),
    availableOn: DateTime.fromMillisecondsSinceEpoch(
        (map['available_on'] as int).toInt()),
    created:
        DateTime.fromMillisecondsSinceEpoch((map['created'] as int).toInt()),
    currency: (map['currency'] as String),
    description:
        map['description'] == null ? null : (map['description'] as String),
    exchangeRate: map['exchange_rate'] == null
        ? null
        : (map['exchange_rate'] as num).toDouble(),
    fee: (map['fee'] as num).toInt(),
    feeDetails: (map['fee_details'] as List<Object?>)
        .map((el) => Fee.fromJson(el))
        .toList(),
    id: (map['id'] as String),
    net: (map['net'] as num).toInt(),
    reportingCategory: (map['reporting_category'] as String),
    source: map['source'] == null
        ? null
        : BalanceTransactionSourceOrId.fromJson(map['source']),
    status: (map['status'] as String),
    type: BalanceTransactionType.fromJson(map['type']),
  );
}