encode<V> static method

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

Implementation

static V encode<V>(
  BillingPortalConfigurationUpdateOptionsFeaturesSubscriptionUpdate instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.defaultAllowedUpdates != null) {
    container.encodeList(
      'default_allowed_updates',
      (container) => instance.defaultAllowedUpdates!.forEach(
          (el) => PortalSubscriptionUpdateDefaultAllowedUpdatesItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.enabled != null) {
    container.encodeBool(
      'enabled',
      instance.enabled!,
    );
  }
  if (instance.products != null) {
    container.encodeList(
      'products',
      (container) => instance.products!
          .forEach((el) => PortalSubscriptionUpdateProduct.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.prorationBehavior != null) {
    PortalSubscriptionCancelProrationBehavior.encode(
      instance.prorationBehavior!,
      container.nestedSingleValueContainer('proration_behavior').encoder,
    );
  }
  return container.value;
}