encode<V> static method

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

Implementation

static V encode<V>(
  InvoiceCreateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.accountTaxIds != null) {
    container.encodeList(
      'account_tax_ids',
      (container) =>
          instance.accountTaxIds!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.applicationFeeAmount != null) {
    container.encodeInt(
      'application_fee_amount',
      instance.applicationFeeAmount!,
    );
  }
  if (instance.autoAdvance != null) {
    container.encodeBool(
      'auto_advance',
      instance.autoAdvance!,
    );
  }
  if (instance.automaticTax != null) {
    SessionAutomaticTax.encode(
      instance.automaticTax!,
      container.nestedSingleValueContainer('automatic_tax').encoder,
    );
  }
  if (instance.collectionMethod != null) {
    InvoiceCollectionMethod.encode(
      instance.collectionMethod!,
      container.nestedSingleValueContainer('collection_method').encoder,
    );
  }
  if (instance.currency != null) {
    container.encodeString(
      'currency',
      instance.currency!,
    );
  }
  if (instance.customFields != null) {
    container.encodeList(
      'custom_fields',
      (container) => instance.customFields!
          .forEach((el) => InvoiceSettingCustomField.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.customer != null) {
    container.encodeString(
      'customer',
      instance.customer!,
    );
  }
  if (instance.daysUntilDue != null) {
    container.encodeInt(
      'days_until_due',
      instance.daysUntilDue!,
    );
  }
  if (instance.defaultPaymentMethod != null) {
    container.encodeString(
      'default_payment_method',
      instance.defaultPaymentMethod!,
    );
  }
  if (instance.defaultSource != null) {
    container.encodeString(
      'default_source',
      instance.defaultSource!,
    );
  }
  if (instance.defaultTaxRates != null) {
    container.encodeList(
      'default_tax_rates',
      (container) => instance.defaultTaxRates!
          .forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  if (instance.discounts != null) {
    container.encodeList(
      'discounts',
      (container) =>
          instance.discounts!.forEach((el) => InvoiceItemDiscountsItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.dueDate != null) {
    container.encodeDateTime(
      'due_date',
      instance.dueDate!,
    );
  }
  if (instance.effectiveAt != null) {
    container.encodeDateTime(
      'effective_at',
      instance.effectiveAt!,
    );
  }
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.footer != null) {
    container.encodeString(
      'footer',
      instance.footer!,
    );
  }
  if (instance.fromInvoice != null) {
    InvoiceCreateOptionsFromInvoice.encode(
      instance.fromInvoice!,
      container.nestedSingleValueContainer('from_invoice').encoder,
    );
  }
  if (instance.issuer != null) {
    SessionLiability.encode(
      instance.issuer!,
      container.nestedSingleValueContainer('issuer').encoder,
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.number != null) {
    container.encodeString(
      'number',
      instance.number!,
    );
  }
  if (instance.onBehalfOf != null) {
    container.encodeString(
      'on_behalf_of',
      instance.onBehalfOf!,
    );
  }
  if (instance.paymentSettings != null) {
    InvoicePaymentSettings.encode(
      instance.paymentSettings!,
      container.nestedSingleValueContainer('payment_settings').encoder,
    );
  }
  if (instance.pendingInvoiceItemsBehavior != null) {
    container.encodeString(
      'pending_invoice_items_behavior',
      instance.pendingInvoiceItemsBehavior!,
    );
  }
  if (instance.rendering != null) {
    InvoiceCreateOptionsRendering.encode(
      instance.rendering!,
      container.nestedSingleValueContainer('rendering').encoder,
    );
  }
  if (instance.renderingOptions != null) {
    SessionRenderingOptions.encode(
      instance.renderingOptions!,
      container.nestedSingleValueContainer('rendering_options').encoder,
    );
  }
  if (instance.shippingCost != null) {
    SessionShippingOptionsItem.encode(
      instance.shippingCost!,
      container.nestedSingleValueContainer('shipping_cost').encoder,
    );
  }
  if (instance.shippingDetails != null) {
    InvoiceShippingDetails.encode(
      instance.shippingDetails!,
      container.nestedSingleValueContainer('shipping_details').encoder,
    );
  }
  if (instance.statementDescriptor != null) {
    container.encodeString(
      'statement_descriptor',
      instance.statementDescriptor!,
    );
  }
  if (instance.subscription != null) {
    container.encodeString(
      'subscription',
      instance.subscription!,
    );
  }
  if (instance.transferData != null) {
    ChargeCreateOptionsTransferData.encode(
      instance.transferData!,
      container.nestedSingleValueContainer('transfer_data').encoder,
    );
  }
  return container.value;
}