encode<V> static method

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

Implementation

static V encode<V>(
  SubscriptionSchedulePhasesItem instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.addInvoiceItems != null) {
    container.encodeList(
      'add_invoice_items',
      (container) => instance.addInvoiceItems!
          .forEach((el) => SubscriptionScheduleAddInvoiceItemsItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  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.billingCycleAnchor != null) {
    SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor.encode(
      instance.billingCycleAnchor!,
      container.nestedSingleValueContainer('billing_cycle_anchor').encoder,
    );
  }
  if (instance.billingThresholds != null) {
    SubscriptionScheduleBillingThresholds.encode(
      instance.billingThresholds!,
      container.nestedSingleValueContainer('billing_thresholds').encoder,
    );
  }
  if (instance.collectionMethod != null) {
    InvoiceCollectionMethod.encode(
      instance.collectionMethod!,
      container.nestedSingleValueContainer('collection_method').encoder,
    );
  }
  if (instance.coupon != null) {
    container.encodeString(
      'coupon',
      instance.coupon!,
    );
  }
  if (instance.currency != null) {
    container.encodeString(
      'currency',
      instance.currency!,
    );
  }
  if (instance.defaultPaymentMethod != null) {
    container.encodeString(
      'default_payment_method',
      instance.defaultPaymentMethod!,
    );
  }
  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.endDate != null) {
    container.encodeDateTime(
      'end_date',
      instance.endDate!,
    );
  }
  if (instance.invoiceSettings != null) {
    SubscriptionScheduleInvoiceSettings.encode(
      instance.invoiceSettings!,
      container.nestedSingleValueContainer('invoice_settings').encoder,
    );
  }
  container.encodeList(
    'items',
    (container) =>
        instance.items.forEach((el) => SubscriptionScheduleItemsItem.encode(
              el,
              container.nestedSingleValueContainer().encoder,
            )),
  );
  if (instance.iterations != null) {
    container.encodeInt(
      'iterations',
      instance.iterations!,
    );
  }
  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.prorationBehavior != null) {
    PortalSubscriptionCancelProrationBehavior.encode(
      instance.prorationBehavior!,
      container.nestedSingleValueContainer('proration_behavior').encoder,
    );
  }
  if (instance.transferData != null) {
    SessionTransferData.encode(
      instance.transferData!,
      container.nestedSingleValueContainer('transfer_data').encoder,
    );
  }
  if (instance.trial != null) {
    container.encodeBool(
      'trial',
      instance.trial!,
    );
  }
  if (instance.trialEnd != null) {
    container.encodeDateTime(
      'trial_end',
      instance.trialEnd!,
    );
  }
  return container.value;
}