encode<V> static method

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

Implementation

static V encode<V>(
  ConfirmationTokenCreateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.paymentMethod != null) {
    container.encodeString(
      'payment_method',
      instance.paymentMethod!,
    );
  }
  if (instance.paymentMethodData != null) {
    PaymentIntentPaymentMethodData.encode(
      instance.paymentMethodData!,
      container.nestedSingleValueContainer('payment_method_data').encoder,
    );
  }
  if (instance.returnUrl != null) {
    container.encodeString(
      'return_url',
      instance.returnUrl!,
    );
  }
  if (instance.setupFutureUsage != null) {
    SessionSetupFutureUsage.encode(
      instance.setupFutureUsage!,
      container.nestedSingleValueContainer('setup_future_usage').encoder,
    );
  }
  if (instance.shipping != null) {
    InvoiceShippingDetails.encode(
      instance.shipping!,
      container.nestedSingleValueContainer('shipping').encoder,
    );
  }
  return container.value;
}