encode<V> static method

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

Implementation

static V encode<V>(
  RefundCreateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.amount != null) {
    container.encodeInt(
      'amount',
      instance.amount!,
    );
  }
  if (instance.charge != null) {
    container.encodeString(
      'charge',
      instance.charge!,
    );
  }
  if (instance.currency != null) {
    container.encodeString(
      'currency',
      instance.currency!,
    );
  }
  if (instance.customer != null) {
    container.encodeString(
      'customer',
      instance.customer!,
    );
  }
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.instructionsEmail != null) {
    container.encodeString(
      'instructions_email',
      instance.instructionsEmail!,
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.origin != null) {
    container.encodeString(
      'origin',
      'customer_balance',
    );
  }
  if (instance.paymentIntent != null) {
    container.encodeString(
      'payment_intent',
      instance.paymentIntent!,
    );
  }
  if (instance.reason != null) {
    TerminalReaderReaderResourceRefundPaymentActionReason.encode(
      instance.reason!,
      container.nestedSingleValueContainer('reason').encoder,
    );
  }
  if (instance.refundApplicationFee != null) {
    container.encodeBool(
      'refund_application_fee',
      instance.refundApplicationFee!,
    );
  }
  if (instance.reverseTransfer != null) {
    container.encodeBool(
      'reverse_transfer',
      instance.reverseTransfer!,
    );
  }
  return container.value;
}