encode<V> static method

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

Implementation

static V encode<V>(
  SubscriptionScheduleConfigurationItem instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.billingThresholds != null) {
    SubscriptionItemBillingThresholds.encode(
      instance.billingThresholds!,
      container.nestedSingleValueContainer('billing_thresholds').encoder,
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  SubscriptionScheduleConfigurationItemPlanOrId.encode(
    instance.plan,
    container.nestedSingleValueContainer('plan').encoder,
  );
  SubscriptionScheduleAddInvoiceItemPriceOrId.encode(
    instance.price,
    container.nestedSingleValueContainer('price').encoder,
  );
  if (instance.quantity != null) {
    container.encodeInt(
      'quantity',
      instance.quantity!,
    );
  }
  if (instance.taxRates != null) {
    container.encodeList(
      'tax_rates',
      (container) => instance.taxRates!.forEach((el) => TaxRate.encode(
            el,
            container.nestedSingleValueContainer().encoder,
          )),
    );
  }
  return container.value;
}