encode<V> static method

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

Implementation

static V encode<V>(
  TreasuryInboundTransfer 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.failureDetails != null) {
    TreasuryInboundTransferFailureDetails.encode(
      instance.failureDetails!,
      container.nestedSingleValueContainer('failure_details').encoder,
    );
  }
  container.encodeString(
    'financial_account',
    instance.financialAccount,
  );
  if (instance.hostedRegulatoryReceiptUrl != null) {
    container.encodeString(
      'hosted_regulatory_receipt_url',
      instance.hostedRegulatoryReceiptUrl!,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows.encode(
    instance.linkedFlows,
    container.nestedSingleValueContainer('linked_flows').encoder,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeMap(
    'metadata',
    (container) => instance.metadata.forEach((
      key,
      value,
    ) =>
        container.encodeString(
          key,
          value,
        )),
  );
  container.encodeString(
    'object',
    'treasury.inbound_transfer',
  );
  container.encodeString(
    'origin_payment_method',
    instance.originPaymentMethod,
  );
  if (instance.originPaymentMethodDetails != null) {
    InboundTransfers.encode(
      instance.originPaymentMethodDetails!,
      container
          .nestedSingleValueContainer('origin_payment_method_details')
          .encoder,
    );
  }
  if (instance.returned != null) {
    container.encodeBool(
      'returned',
      instance.returned!,
    );
  }
  container.encodeString(
    'statement_descriptor',
    instance.statementDescriptor,
  );
  container.encodeString(
    'status',
    instance.status,
  );
  TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions
      .encode(
    instance.statusTransitions,
    container.nestedSingleValueContainer('status_transitions').encoder,
  );
  if (instance.transaction != null) {
    TreasuryTransactionOrId.encode(
      instance.transaction!,
      container.nestedSingleValueContainer('transaction').encoder,
    );
  }
  return container.value;
}