encode<V> static method

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

Implementation

static V encode<V>(
  SubscriptionPendingUpdate instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.billingCycleAnchor != null) {
    container.encodeDateTime(
      'billing_cycle_anchor',
      instance.billingCycleAnchor!,
    );
  }
  container.encodeDateTime(
    'expires_at',
    instance.expiresAt,
  );
  if (instance.subscriptionItems != null) {
    container.encodeList(
      'subscription_items',
      (container) =>
          instance.subscriptionItems!.forEach((el) => SubscriptionItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.trialEnd != null) {
    container.encodeDateTime(
      'trial_end',
      instance.trialEnd!,
    );
  }
  if (instance.trialFromPlan != null) {
    container.encodeBool(
      'trial_from_plan',
      instance.trialFromPlan!,
    );
  }
  return container.value;
}