encode<V> static method

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

Implementation

static V encode<V>(
  InvoiceitemPlan instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeBool(
    'active',
    instance.active,
  );
  if (instance.aggregateUsage != null) {
    container.encodeString(
      'aggregate_usage',
      instance.aggregateUsage!,
    );
  }
  if (instance.amount != null) {
    container.encodeInt(
      'amount',
      instance.amount!,
    );
  }
  if (instance.amountDecimal != null) {
    container.encodeString(
      'amount_decimal',
      instance.amountDecimal!,
    );
  }
  container.encodeString(
    'billing_scheme',
    instance.billingScheme,
  );
  container.encodeDateTime(
    'created',
    instance.created,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeString(
    'interval',
    instance.interval,
  );
  container.encodeInt(
    'interval_count',
    instance.intervalCount,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.meter != null) {
    container.encodeString(
      'meter',
      instance.meter!,
    );
  }
  if (instance.nickname != null) {
    container.encodeString(
      'nickname',
      instance.nickname!,
    );
  }
  container.encodeString(
    'object',
    'plan',
  );
  if (instance.product != null) {
    InvoiceitemPlanProductOrId.encode(
      instance.product!,
      container.nestedSingleValueContainer('product').encoder,
    );
  }
  if (instance.tiers != null) {
    container.encodeList(
      'tiers',
      (container) => instance.tiers!.forEach((el) => PlanTier.encode(
            el,
            container.nestedSingleValueContainer().encoder,
          )),
    );
  }
  if (instance.tiersMode != null) {
    container.encodeString(
      'tiers_mode',
      instance.tiersMode!,
    );
  }
  if (instance.transformUsage != null) {
    InvoiceitemPlanTransformUsage.encode(
      instance.transformUsage!,
      container.nestedSingleValueContainer('transform_usage').encoder,
    );
  }
  if (instance.trialPeriodDays != null) {
    container.encodeInt(
      'trial_period_days',
      instance.trialPeriodDays!,
    );
  }
  container.encodeString(
    'usage_type',
    instance.usageType,
  );
  return container.value;
}