TreasuryOutboundPayment.fromJson constructor

TreasuryOutboundPayment.fromJson(
  1. Object? json
)

Implementation

factory TreasuryOutboundPayment.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return TreasuryOutboundPayment(
    amount: (map['amount'] as num).toInt(),
    cancelable: (map['cancelable'] as bool),
    created:
        DateTime.fromMillisecondsSinceEpoch((map['created'] as int).toInt()),
    currency: (map['currency'] as String),
    customer: map['customer'] == null ? null : (map['customer'] as String),
    description:
        map['description'] == null ? null : (map['description'] as String),
    destinationPaymentMethod: map['destination_payment_method'] == null
        ? null
        : (map['destination_payment_method'] as String),
    destinationPaymentMethodDetails:
        map['destination_payment_method_details'] == null
            ? null
            : OutboundPaymentsPaymentMethodDetails.fromJson(
                map['destination_payment_method_details']),
    endUserDetails: map['end_user_details'] == null
        ? null
        : TreasuryOutboundPaymentEndUserDetails.fromJson(
            map['end_user_details']),
    expectedArrivalDate: DateTime.fromMillisecondsSinceEpoch(
        (map['expected_arrival_date'] as int).toInt()),
    financialAccount: (map['financial_account'] as String),
    hostedRegulatoryReceiptUrl: map['hosted_regulatory_receipt_url'] == null
        ? null
        : (map['hosted_regulatory_receipt_url'] as String),
    id: (map['id'] as String),
    livemode: (map['livemode'] as bool),
    metadata: (map['metadata'] as Map).cast<String, Object?>().map((
          key,
          value,
        ) =>
            MapEntry(
              key,
              (value as String),
            )),
    returnedDetails: map['returned_details'] == null
        ? null
        : TreasuryOutboundPaymentReturnedDetails.fromJson(
            map['returned_details']),
    statementDescriptor: (map['statement_descriptor'] as String),
    status: TreasuryOutboundPaymentStatus.fromJson(map['status']),
    statusTransitions:
        TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions
            .fromJson(map['status_transitions']),
    transaction: TreasuryTransactionOrId.fromJson(map['transaction']),
  );
}