Charge.fromJson constructor

Charge.fromJson(
  1. Object? json
)

Implementation

factory Charge.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return Charge(
    amount: (map['amount'] as num).toInt(),
    amountCaptured: (map['amount_captured'] as num).toInt(),
    amountRefunded: (map['amount_refunded'] as num).toInt(),
    application: map['application'] == null
        ? null
        : ApplicationOrId.fromJson(map['application']),
    applicationFee: map['application_fee'] == null
        ? null
        : ApplicationFeeOrId.fromJson(map['application_fee']),
    applicationFeeAmount: map['application_fee_amount'] == null
        ? null
        : (map['application_fee_amount'] as num).toInt(),
    authorizationCode: map['authorization_code'] == null
        ? null
        : (map['authorization_code'] as String),
    balanceTransaction: map['balance_transaction'] == null
        ? null
        : BalanceTransactionOrId.fromJson(map['balance_transaction']),
    billingDetails: BillingDetails.fromJson(map['billing_details']),
    calculatedStatementDescriptor:
        map['calculated_statement_descriptor'] == null
            ? null
            : (map['calculated_statement_descriptor'] as String),
    captured: (map['captured'] as bool),
    created:
        DateTime.fromMillisecondsSinceEpoch((map['created'] as int).toInt()),
    currency: (map['currency'] as String),
    customer: map['customer'] == null
        ? null
        : BankAccountCustomerOrId.fromJson(map['customer']),
    description:
        map['description'] == null ? null : (map['description'] as String),
    disputed: (map['disputed'] as bool),
    failureBalanceTransaction: map['failure_balance_transaction'] == null
        ? null
        : BalanceTransactionOrId.fromJson(map['failure_balance_transaction']),
    failureCode:
        map['failure_code'] == null ? null : (map['failure_code'] as String),
    failureMessage: map['failure_message'] == null
        ? null
        : (map['failure_message'] as String),
    fraudDetails: map['fraud_details'] == null
        ? null
        : ChargeFraudDetails.fromJson(map['fraud_details']),
    id: (map['id'] as String),
    invoice:
        map['invoice'] == null ? null : InvoiceOrId.fromJson(map['invoice']),
    level3: map['level3'] == null ? null : Level3.fromJson(map['level3']),
    livemode: (map['livemode'] as bool),
    metadata: (map['metadata'] as Map).cast<String, Object?>().map((
          key,
          value,
        ) =>
            MapEntry(
              key,
              (value as String),
            )),
    onBehalfOf: map['on_behalf_of'] == null
        ? null
        : AccountOrId.fromJson(map['on_behalf_of']),
    outcome: map['outcome'] == null
        ? null
        : ChargeOutcome.fromJson(map['outcome']),
    paid: (map['paid'] as bool),
    paymentIntent: map['payment_intent'] == null
        ? null
        : PaymentIntentOrId.fromJson(map['payment_intent']),
    paymentMethod: map['payment_method'] == null
        ? null
        : (map['payment_method'] as String),
    paymentMethodDetails: map['payment_method_details'] == null
        ? null
        : ChargePaymentMethodDetails.fromJson(map['payment_method_details']),
    radarOptions: map['radar_options'] == null
        ? null
        : RadarRadarOptions.fromJson(map['radar_options']),
    receiptEmail: map['receipt_email'] == null
        ? null
        : (map['receipt_email'] as String),
    receiptNumber: map['receipt_number'] == null
        ? null
        : (map['receipt_number'] as String),
    receiptUrl:
        map['receipt_url'] == null ? null : (map['receipt_url'] as String),
    refunded: (map['refunded'] as bool),
    refunds: map['refunds'] == null
        ? null
        : ChargeRefunds.fromJson(map['refunds']),
    review: map['review'] == null ? null : ReviewOrId.fromJson(map['review']),
    shipping: map['shipping'] == null
        ? null
        : ChargeShipping.fromJson(map['shipping']),
    source:
        map['source'] == null ? null : ChargeSource.fromJson(map['source']),
    sourceTransfer: map['source_transfer'] == null
        ? null
        : TransferOrId.fromJson(map['source_transfer']),
    statementDescriptor: map['statement_descriptor'] == null
        ? null
        : (map['statement_descriptor'] as String),
    statementDescriptorSuffix: map['statement_descriptor_suffix'] == null
        ? null
        : (map['statement_descriptor_suffix'] as String),
    status:
        BankConnectionsResourceBalanceRefreshStatus.fromJson(map['status']),
    transfer: map['transfer'] == null
        ? null
        : TransferOrId.fromJson(map['transfer']),
    transferData: map['transfer_data'] == null
        ? null
        : ChargeTransferData.fromJson(map['transfer_data']),
    transferGroup: map['transfer_group'] == null
        ? null
        : (map['transfer_group'] as String),
  );
}