CustomerBalanceTransaction.fromJson constructor

CustomerBalanceTransaction.fromJson(
  1. Object? json
)

Implementation

factory CustomerBalanceTransaction.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return CustomerBalanceTransaction(
    amount: (map['amount'] as num).toInt(),
    created:
        DateTime.fromMillisecondsSinceEpoch((map['created'] as int).toInt()),
    creditNote: map['credit_note'] == null
        ? null
        : CreditNoteOrId.fromJson(map['credit_note']),
    currency: (map['currency'] as String),
    customer: CustomerOrId.fromJson(map['customer']),
    description:
        map['description'] == null ? null : (map['description'] as String),
    endingBalance: (map['ending_balance'] as num).toInt(),
    id: (map['id'] as String),
    invoice:
        map['invoice'] == null ? null : InvoiceOrId.fromJson(map['invoice']),
    livemode: (map['livemode'] as bool),
    metadata: map['metadata'] == null
        ? null
        : (map['metadata'] as Map).cast<String, Object?>().map((
              key,
              value,
            ) =>
                MapEntry(
                  key,
                  (value as String),
                )),
    type: CustomerBalanceTransactionType.fromJson(map['type']),
  );
}