encode<V> static method

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

Implementation

static V encode<V>(
  PaymentLinkUpdateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.active != null) {
    container.encodeBool(
      'active',
      instance.active!,
    );
  }
  if (instance.afterCompletion != null) {
    PaymentLinkAfterCompletion.encode(
      instance.afterCompletion!,
      container.nestedSingleValueContainer('after_completion').encoder,
    );
  }
  if (instance.allowPromotionCodes != null) {
    container.encodeBool(
      'allow_promotion_codes',
      instance.allowPromotionCodes!,
    );
  }
  if (instance.automaticTax != null) {
    SessionAutomaticTax.encode(
      instance.automaticTax!,
      container.nestedSingleValueContainer('automatic_tax').encoder,
    );
  }
  if (instance.billingAddressCollection != null) {
    PaymentLinkBillingAddressCollection.encode(
      instance.billingAddressCollection!,
      container
          .nestedSingleValueContainer('billing_address_collection')
          .encoder,
    );
  }
  if (instance.customFields != null) {
    container.encodeList(
      'custom_fields',
      (container) => instance.customFields!
          .forEach((el) => SessionCustomFieldsItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.customText != null) {
    SessionCustomText.encode(
      instance.customText!,
      container.nestedSingleValueContainer('custom_text').encoder,
    );
  }
  if (instance.customerCreation != null) {
    PaymentLinkCustomerCreation.encode(
      instance.customerCreation!,
      container.nestedSingleValueContainer('customer_creation').encoder,
    );
  }
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.inactiveMessage != null) {
    container.encodeString(
      'inactive_message',
      instance.inactiveMessage!,
    );
  }
  if (instance.invoiceCreation != null) {
    PaymentLinkCreateOptionsInvoiceCreation.encode(
      instance.invoiceCreation!,
      container.nestedSingleValueContainer('invoice_creation').encoder,
    );
  }
  if (instance.lineItems != null) {
    container.encodeList(
      'line_items',
      (container) => instance.lineItems!
          .forEach((el) => PaymentLinkUpdateOptionsLineItemsItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.paymentIntentData != null) {
    PaymentLinkUpdateOptionsPaymentIntentData.encode(
      instance.paymentIntentData!,
      container.nestedSingleValueContainer('payment_intent_data').encoder,
    );
  }
  if (instance.paymentMethodCollection != null) {
    PaymentLinkCustomerCreation.encode(
      instance.paymentMethodCollection!,
      container
          .nestedSingleValueContainer('payment_method_collection')
          .encoder,
    );
  }
  if (instance.paymentMethodTypes != null) {
    container.encodeList(
      'payment_method_types',
      (container) => instance.paymentMethodTypes!
          .forEach((el) => PaymentLinkPaymentMethodTypesItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.restrictions != null) {
    PaymentLinkCreateOptionsRestrictions.encode(
      instance.restrictions!,
      container.nestedSingleValueContainer('restrictions').encoder,
    );
  }
  if (instance.shippingAddressCollection != null) {
    PaymentPagesCheckoutSessionShippingAddressCollection.encode(
      instance.shippingAddressCollection!,
      container
          .nestedSingleValueContainer('shipping_address_collection')
          .encoder,
    );
  }
  if (instance.subscriptionData != null) {
    PaymentLinkUpdateOptionsSubscriptionData.encode(
      instance.subscriptionData!,
      container.nestedSingleValueContainer('subscription_data').encoder,
    );
  }
  return container.value;
}