encode<V> static method

V encode<V>(
  1. TreasuryOutboundTransfer instance,
  2. Encoder<V> encoder
)

Implementation

static V encode<V>(
  TreasuryOutboundTransfer instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount',
    instance.amount,
  );
  container.encodeBool(
    'cancelable',
    instance.cancelable,
  );
  container.encodeDateTime(
    'created',
    instance.created,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  if (instance.destinationPaymentMethod != null) {
    container.encodeString(
      'destination_payment_method',
      instance.destinationPaymentMethod!,
    );
  }
  OutboundTransfersPaymentMethodDetails.encode(
    instance.destinationPaymentMethodDetails,
    container
        .nestedSingleValueContainer('destination_payment_method_details')
        .encoder,
  );
  container.encodeDateTime(
    'expected_arrival_date',
    instance.expectedArrivalDate,
  );
  container.encodeString(
    'financial_account',
    instance.financialAccount,
  );
  if (instance.hostedRegulatoryReceiptUrl != null) {
    container.encodeString(
      'hosted_regulatory_receipt_url',
      instance.hostedRegulatoryReceiptUrl!,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeMap(
    'metadata',
    (container) => instance.metadata.forEach((
      key,
      value,
    ) =>
        container.encodeString(
          key,
          value,
        )),
  );
  container.encodeString(
    'object',
    'treasury.outbound_transfer',
  );
  if (instance.returnedDetails != null) {
    TreasuryOutboundPaymentReturnedDetails.encode(
      instance.returnedDetails!,
      container.nestedSingleValueContainer('returned_details').encoder,
    );
  }
  container.encodeString(
    'statement_descriptor',
    instance.statementDescriptor,
  );
  TreasuryOutboundPaymentStatus.encode(
    instance.status,
    container.nestedSingleValueContainer('status').encoder,
  );
  TreasuryOutboundTransfersResourceStatusTransitions.encode(
    instance.statusTransitions,
    container.nestedSingleValueContainer('status_transitions').encoder,
  );
  TreasuryTransactionOrId.encode(
    instance.transaction,
    container.nestedSingleValueContainer('transaction').encoder,
  );
  return container.value;
}