encode<V> static method

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

Implementation

static V encode<V>(
  PaymentLinkCreateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  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.applicationFeeAmount != null) {
    container.encodeInt(
      'application_fee_amount',
      instance.applicationFeeAmount!,
    );
  }
  if (instance.applicationFeePercent != null) {
    container.encodeDouble(
      'application_fee_percent',
      instance.applicationFeePercent!,
    );
  }
  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.consentCollection != null) {
    SessionConsentCollection.encode(
      instance.consentCollection!,
      container.nestedSingleValueContainer('consent_collection').encoder,
    );
  }
  if (instance.currency != null) {
    container.encodeString(
      'currency',
      instance.currency!,
    );
  }
  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,
    );
  }
  container.encodeList(
    'line_items',
    (container) =>
        instance.lineItems.forEach((el) => PaymentLinkLineItemsItem.encode(
              el,
              container.nestedSingleValueContainer().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.paymentIntentData != null) {
    PaymentLinkCreateOptionsPaymentIntentData.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.phoneNumberCollection != null) {
    PortalSubscriptionPause.encode(
      instance.phoneNumberCollection!,
      container.nestedSingleValueContainer('phone_number_collection').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.shippingOptions != null) {
    container.encodeList(
      'shipping_options',
      (container) => instance.shippingOptions!
          .forEach((el) => CreditNoteShippingCost.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.submitType != null) {
    PaymentLinkSubmitType.encode(
      instance.submitType!,
      container.nestedSingleValueContainer('submit_type').encoder,
    );
  }
  if (instance.subscriptionData != null) {
    PaymentLinkCreateOptionsSubscriptionData.encode(
      instance.subscriptionData!,
      container.nestedSingleValueContainer('subscription_data').encoder,
    );
  }
  if (instance.taxIdCollection != null) {
    PortalSubscriptionPause.encode(
      instance.taxIdCollection!,
      container.nestedSingleValueContainer('tax_id_collection').encoder,
    );
  }
  if (instance.transferData != null) {
    ChargeCreateOptionsTransferData.encode(
      instance.transferData!,
      container.nestedSingleValueContainer('transfer_data').encoder,
    );
  }
  return container.value;
}