encode<V> static method

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

Implementation

static V encode<V>(
  SourceTransaction instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.achCreditTransfer != null) {
    SourceTransactionAchCreditTransferData.encode(
      instance.achCreditTransfer!,
      container.nestedSingleValueContainer('ach_credit_transfer').encoder,
    );
  }
  container.encodeInt(
    'amount',
    instance.amount,
  );
  if (instance.chfCreditTransfer != null) {
    SourceTransactionChfCreditTransferData.encode(
      instance.chfCreditTransfer!,
      container.nestedSingleValueContainer('chf_credit_transfer').encoder,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  if (instance.gbpCreditTransfer != null) {
    SourceTransactionGbpCreditTransferData.encode(
      instance.gbpCreditTransfer!,
      container.nestedSingleValueContainer('gbp_credit_transfer').encoder,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeString(
    'object',
    'source_transaction',
  );
  if (instance.paperCheck != null) {
    SourceTransactionPaperCheckData.encode(
      instance.paperCheck!,
      container.nestedSingleValueContainer('paper_check').encoder,
    );
  }
  if (instance.sepaCreditTransfer != null) {
    SourceTransactionSepaCreditTransferData.encode(
      instance.sepaCreditTransfer!,
      container.nestedSingleValueContainer('sepa_credit_transfer').encoder,
    );
  }
  container.encodeString(
    'source',
    instance.source,
  );
  container.encodeString(
    'status',
    instance.status,
  );
  container.encodeString(
    'type',
    instance.type,
  );
  return container.value;
}