encode<V> static method

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

Implementation

static V encode<V>(
  CheckoutSession instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.afterExpiration != null) {
    CheckoutSessionAfterExpiration.encode(
      instance.afterExpiration!,
      container.nestedSingleValueContainer('after_expiration').encoder,
    );
  }
  if (instance.allowPromotionCodes != null) {
    container.encodeBool(
      'allow_promotion_codes',
      instance.allowPromotionCodes!,
    );
  }
  if (instance.amountSubtotal != null) {
    container.encodeInt(
      'amount_subtotal',
      instance.amountSubtotal!,
    );
  }
  if (instance.amountTotal != null) {
    container.encodeInt(
      'amount_total',
      instance.amountTotal!,
    );
  }
  PaymentPagesCheckoutSessionAutomaticTax.encode(
    instance.automaticTax,
    container.nestedSingleValueContainer('automatic_tax').encoder,
  );
  if (instance.billingAddressCollection != null) {
    container.encodeString(
      'billing_address_collection',
      instance.billingAddressCollection!,
    );
  }
  if (instance.cancelUrl != null) {
    container.encodeString(
      'cancel_url',
      instance.cancelUrl!,
    );
  }
  if (instance.clientReferenceId != null) {
    container.encodeString(
      'client_reference_id',
      instance.clientReferenceId!,
    );
  }
  if (instance.clientSecret != null) {
    container.encodeString(
      'client_secret',
      instance.clientSecret!,
    );
  }
  if (instance.consent != null) {
    CheckoutSessionConsent.encode(
      instance.consent!,
      container.nestedSingleValueContainer('consent').encoder,
    );
  }
  if (instance.consentCollection != null) {
    CheckoutSessionConsentCollection.encode(
      instance.consentCollection!,
      container.nestedSingleValueContainer('consent_collection').encoder,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  if (instance.currency != null) {
    container.encodeString(
      'currency',
      instance.currency!,
    );
  }
  if (instance.currencyConversion != null) {
    CheckoutSessionCurrencyConversion.encode(
      instance.currencyConversion!,
      container.nestedSingleValueContainer('currency_conversion').encoder,
    );
  }
  container.encodeList(
    'custom_fields',
    (container) => instance.customFields
        .forEach((el) => PaymentPagesCheckoutSessionCustomFields.encode(
              el,
              container.nestedSingleValueContainer().encoder,
            )),
  );
  PaymentPagesCheckoutSessionCustomText.encode(
    instance.customText,
    container.nestedSingleValueContainer('custom_text').encoder,
  );
  if (instance.customer != null) {
    BankAccountCustomerOrId.encode(
      instance.customer!,
      container.nestedSingleValueContainer('customer').encoder,
    );
  }
  if (instance.customerCreation != null) {
    container.encodeString(
      'customer_creation',
      instance.customerCreation!,
    );
  }
  if (instance.customerDetails != null) {
    CheckoutSessionCustomerDetails.encode(
      instance.customerDetails!,
      container.nestedSingleValueContainer('customer_details').encoder,
    );
  }
  if (instance.customerEmail != null) {
    container.encodeString(
      'customer_email',
      instance.customerEmail!,
    );
  }
  container.encodeDateTime(
    'expires_at',
    instance.expiresAt,
  );
  container.encodeString(
    'id',
    instance.id,
  );
  if (instance.invoice != null) {
    InvoiceOrId.encode(
      instance.invoice!,
      container.nestedSingleValueContainer('invoice').encoder,
    );
  }
  if (instance.invoiceCreation != null) {
    CheckoutSessionInvoiceCreation.encode(
      instance.invoiceCreation!,
      container.nestedSingleValueContainer('invoice_creation').encoder,
    );
  }
  if (instance.lineItems != null) {
    CheckoutSessionLineItems.encode(
      instance.lineItems!,
      container.nestedSingleValueContainer('line_items').encoder,
    );
  }
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  if (instance.locale != null) {
    container.encodeString(
      'locale',
      instance.locale!,
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  container.encodeString(
    'mode',
    instance.mode,
  );
  container.encodeString(
    'object',
    'checkout.session',
  );
  if (instance.paymentIntent != null) {
    PaymentIntentOrId.encode(
      instance.paymentIntent!,
      container.nestedSingleValueContainer('payment_intent').encoder,
    );
  }
  if (instance.paymentLink != null) {
    PaymentLinkOrId.encode(
      instance.paymentLink!,
      container.nestedSingleValueContainer('payment_link').encoder,
    );
  }
  if (instance.paymentMethodCollection != null) {
    CheckoutSessionCustomerCreation.encode(
      instance.paymentMethodCollection!,
      container
          .nestedSingleValueContainer('payment_method_collection')
          .encoder,
    );
  }
  if (instance.paymentMethodConfigurationDetails != null) {
    CheckoutSessionPaymentMethodConfigurationDetails.encode(
      instance.paymentMethodConfigurationDetails!,
      container
          .nestedSingleValueContainer('payment_method_configuration_details')
          .encoder,
    );
  }
  if (instance.paymentMethodOptions != null) {
    CheckoutSessionPaymentMethodOptions.encode(
      instance.paymentMethodOptions!,
      container.nestedSingleValueContainer('payment_method_options').encoder,
    );
  }
  container.encodeList(
    'payment_method_types',
    (container) => instance.paymentMethodTypes
        .forEach((el) => container.encodeString(el)),
  );
  container.encodeString(
    'payment_status',
    instance.paymentStatus,
  );
  if (instance.phoneNumberCollection != null) {
    PaymentPagesCheckoutSessionPhoneNumberCollection.encode(
      instance.phoneNumberCollection!,
      container.nestedSingleValueContainer('phone_number_collection').encoder,
    );
  }
  if (instance.recoveredFrom != null) {
    container.encodeString(
      'recovered_from',
      instance.recoveredFrom!,
    );
  }
  if (instance.redirectOnCompletion != null) {
    container.encodeString(
      'redirect_on_completion',
      instance.redirectOnCompletion!,
    );
  }
  if (instance.returnUrl != null) {
    container.encodeString(
      'return_url',
      instance.returnUrl!,
    );
  }
  if (instance.setupIntent != null) {
    SetupIntentOrId.encode(
      instance.setupIntent!,
      container.nestedSingleValueContainer('setup_intent').encoder,
    );
  }
  if (instance.shippingAddressCollection != null) {
    CheckoutSessionShippingAddressCollection.encode(
      instance.shippingAddressCollection!,
      container
          .nestedSingleValueContainer('shipping_address_collection')
          .encoder,
    );
  }
  if (instance.shippingCost != null) {
    CheckoutSessionShippingCost.encode(
      instance.shippingCost!,
      container.nestedSingleValueContainer('shipping_cost').encoder,
    );
  }
  if (instance.shippingDetails != null) {
    ChargeShipping.encode(
      instance.shippingDetails!,
      container.nestedSingleValueContainer('shipping_details').encoder,
    );
  }
  container.encodeList(
    'shipping_options',
    (container) => instance.shippingOptions
        .forEach((el) => PaymentPagesCheckoutSessionShippingOption.encode(
              el,
              container.nestedSingleValueContainer().encoder,
            )),
  );
  if (instance.status != null) {
    container.encodeString(
      'status',
      instance.status!,
    );
  }
  if (instance.submitType != null) {
    container.encodeString(
      'submit_type',
      instance.submitType!,
    );
  }
  if (instance.subscription != null) {
    SubscriptionOrId.encode(
      instance.subscription!,
      container.nestedSingleValueContainer('subscription').encoder,
    );
  }
  if (instance.successUrl != null) {
    container.encodeString(
      'success_url',
      instance.successUrl!,
    );
  }
  if (instance.taxIdCollection != null) {
    PaymentPagesCheckoutSessionTaxIdCollection.encode(
      instance.taxIdCollection!,
      container.nestedSingleValueContainer('tax_id_collection').encoder,
    );
  }
  if (instance.totalDetails != null) {
    CheckoutSessionTotalDetails.encode(
      instance.totalDetails!,
      container.nestedSingleValueContainer('total_details').encoder,
    );
  }
  if (instance.uiMode != null) {
    container.encodeString(
      'ui_mode',
      instance.uiMode!,
    );
  }
  if (instance.url != null) {
    container.encodeString(
      'url',
      instance.url!,
    );
  }
  return container.value;
}