encode<V> static method

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

Implementation

static V encode<V>(
  TransferReversal instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount',
    instance.amount,
  );
  if (instance.balanceTransaction != null) {
    BalanceTransactionOrId.encode(
      instance.balanceTransaction!,
      container.nestedSingleValueContainer('balance_transaction').encoder,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  if (instance.destinationPaymentRefund != null) {
    RefundOrId.encode(
      instance.destinationPaymentRefund!,
      container
          .nestedSingleValueContainer('destination_payment_refund')
          .encoder,
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  container.encodeString(
    'object',
    'transfer_reversal',
  );
  if (instance.sourceRefund != null) {
    RefundOrId.encode(
      instance.sourceRefund!,
      container.nestedSingleValueContainer('source_refund').encoder,
    );
  }
  TransferOrId.encode(
    instance.transfer,
    container.nestedSingleValueContainer('transfer').encoder,
  );
  return container.value;
}