CustomerCashBalanceTransaction.fromJson constructor

CustomerCashBalanceTransaction.fromJson(
  1. Object? json
)

Implementation

factory CustomerCashBalanceTransaction.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return CustomerCashBalanceTransaction(
    adjustedForOverdraft: map['adjusted_for_overdraft'] == null
        ? null
        : CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft
            .fromJson(map['adjusted_for_overdraft']),
    appliedToPayment: map['applied_to_payment'] == null
        ? null
        : CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction
            .fromJson(map['applied_to_payment']),
    created:
        DateTime.fromMillisecondsSinceEpoch((map['created'] as int).toInt()),
    currency: (map['currency'] as String),
    customer: CustomerOrId.fromJson(map['customer']),
    endingBalance: (map['ending_balance'] as num).toInt(),
    funded: map['funded'] == null
        ? null
        : CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction
            .fromJson(map['funded']),
    id: (map['id'] as String),
    livemode: (map['livemode'] as bool),
    netAmount: (map['net_amount'] as num).toInt(),
    refundedFromPayment: map['refunded_from_payment'] == null
        ? null
        : CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction
            .fromJson(map['refunded_from_payment']),
    transferredToBalance: map['transferred_to_balance'] == null
        ? null
        : CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalance
            .fromJson(map['transferred_to_balance']),
    type: CustomerCashBalanceTransactionType.fromJson(map['type']),
    unappliedFromPayment: map['unapplied_from_payment'] == null
        ? null
        : CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction
            .fromJson(map['unapplied_from_payment']),
  );
}