encode<V> static method

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

Implementation

static V encode<V>(
  SubscriptionSchedule instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.application != null) {
    BillingPortalConfigurationApplicationOrId.encode(
      instance.application!,
      container.nestedSingleValueContainer('application').encoder,
    );
  }
  if (instance.canceledAt != null) {
    container.encodeDateTime(
      'canceled_at',
      instance.canceledAt!,
    );
  }
  if (instance.completedAt != null) {
    container.encodeDateTime(
      'completed_at',
      instance.completedAt!,
    );
  }
  container.encodeDateTime(
    'created',
    instance.created,
  );
  if (instance.currentPhase != null) {
    SubscriptionScheduleCurrentPhase.encode(
      instance.currentPhase!,
      container.nestedSingleValueContainer('current_phase').encoder,
    );
  }
  BankAccountCustomerOrId.encode(
    instance.customer,
    container.nestedSingleValueContainer('customer').encoder,
  );
  SubscriptionSchedulesResourceDefaultSettings.encode(
    instance.defaultSettings,
    container.nestedSingleValueContainer('default_settings').encoder,
  );
  container.encodeString(
    'end_behavior',
    instance.endBehavior,
  );
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  container.encodeString(
    'object',
    'subscription_schedule',
  );
  container.encodeList(
    'phases',
    (container) => instance.phases
        .forEach((el) => SubscriptionSchedulePhaseConfiguration.encode(
              el,
              container.nestedSingleValueContainer().encoder,
            )),
  );
  if (instance.releasedAt != null) {
    container.encodeDateTime(
      'released_at',
      instance.releasedAt!,
    );
  }
  if (instance.releasedSubscription != null) {
    container.encodeString(
      'released_subscription',
      instance.releasedSubscription!,
    );
  }
  container.encodeString(
    'status',
    instance.status,
  );
  if (instance.subscription != null) {
    SubscriptionOrId.encode(
      instance.subscription!,
      container.nestedSingleValueContainer('subscription').encoder,
    );
  }
  if (instance.testClock != null) {
    TestHelpersTestClockOrId.encode(
      instance.testClock!,
      container.nestedSingleValueContainer('test_clock').encoder,
    );
  }
  return container.value;
}