encode<V> static method

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

Implementation

static V encode<V>(
  SetupIntentCreateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.attachToSelf != null) {
    container.encodeBool(
      'attach_to_self',
      instance.attachToSelf!,
    );
  }
  if (instance.automaticPaymentMethods != null) {
    PaymentFlowsAutomaticPaymentMethodsPaymentIntent.encode(
      instance.automaticPaymentMethods!,
      container
          .nestedSingleValueContainer('automatic_payment_methods')
          .encoder,
    );
  }
  if (instance.confirm != null) {
    container.encodeBool(
      'confirm',
      instance.confirm!,
    );
  }
  if (instance.confirmationToken != null) {
    container.encodeString(
      'confirmation_token',
      instance.confirmationToken!,
    );
  }
  if (instance.customer != null) {
    container.encodeString(
      'customer',
      instance.customer!,
    );
  }
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.flowDirections != null) {
    container.encodeList(
      'flow_directions',
      (container) => instance.flowDirections!
          .forEach((el) => SetupAttemptFlowDirectionsItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.mandateData != null) {
    PaymentIntentMandateData.encode(
      instance.mandateData!,
      container.nestedSingleValueContainer('mandate_data').encoder,
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.onBehalfOf != null) {
    container.encodeString(
      'on_behalf_of',
      instance.onBehalfOf!,
    );
  }
  if (instance.paymentMethod != null) {
    container.encodeString(
      'payment_method',
      instance.paymentMethod!,
    );
  }
  if (instance.paymentMethodConfiguration != null) {
    container.encodeString(
      'payment_method_configuration',
      instance.paymentMethodConfiguration!,
    );
  }
  if (instance.paymentMethodData != null) {
    PaymentIntentPaymentMethodData.encode(
      instance.paymentMethodData!,
      container.nestedSingleValueContainer('payment_method_data').encoder,
    );
  }
  if (instance.paymentMethodOptions != null) {
    SetupIntentCreateOptionsPaymentMethodOptions.encode(
      instance.paymentMethodOptions!,
      container.nestedSingleValueContainer('payment_method_options').encoder,
    );
  }
  if (instance.paymentMethodTypes != null) {
    container.encodeList(
      'payment_method_types',
      (container) => instance.paymentMethodTypes!
          .forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.returnUrl != null) {
    container.encodeString(
      'return_url',
      instance.returnUrl!,
    );
  }
  if (instance.singleUse != null) {
    MandateSingleUse.encode(
      instance.singleUse!,
      container.nestedSingleValueContainer('single_use').encoder,
    );
  }
  if (instance.usage != null) {
    SessionSetupFutureUsage.encode(
      instance.usage!,
      container.nestedSingleValueContainer('usage').encoder,
    );
  }
  if (instance.useStripeSdk != null) {
    container.encodeBool(
      'use_stripe_sdk',
      instance.useStripeSdk!,
    );
  }
  return container.value;
}