encode<V> static method

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

Implementation

static V encode<V>(
  SubscriptionScheduleUpdateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.defaultSettings != null) {
    SubscriptionScheduleDefaultSettings.encode(
      instance.defaultSettings!,
      container.nestedSingleValueContainer('default_settings').encoder,
    );
  }
  if (instance.endBehavior != null) {
    SubscriptionScheduleEndBehavior.encode(
      instance.endBehavior!,
      container.nestedSingleValueContainer('end_behavior').encoder,
    );
  }
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.phases != null) {
    container.encodeList(
      'phases',
      (container) => instance.phases!
          .forEach((el) => SubscriptionScheduleUpdateOptionsPhasesItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.prorationBehavior != null) {
    PortalSubscriptionCancelProrationBehavior.encode(
      instance.prorationBehavior!,
      container.nestedSingleValueContainer('proration_behavior').encoder,
    );
  }
  return container.value;
}