encode<V> static method

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

Implementation

static V encode<V>(
  PlanCreateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.active != null) {
    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!,
    );
  }
  if (instance.billingScheme != null) {
    InvoiceitemPlanBillingScheme.encode(
      instance.billingScheme!,
      container.nestedSingleValueContainer('billing_scheme').encoder,
    );
  }
  container.encodeString(
    'currency',
    instance.currency,
  );
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.id != null) {
    container.encodeString(
      'id',
      instance.id!,
    );
  }
  InvoiceitemPlanInterval.encode(
    instance.interval,
    container.nestedSingleValueContainer('interval').encoder,
  );
  if (instance.intervalCount != null) {
    container.encodeInt(
      'interval_count',
      instance.intervalCount!,
    );
  }
  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!,
    );
  }
  if (instance.product != null) {
    PlanProduct.encode(
      instance.product!,
      container.nestedSingleValueContainer('product').encoder,
    );
  }
  if (instance.tiers != null) {
    container.encodeList(
      'tiers',
      (container) => instance.tiers!.forEach((el) => PlanTiersItem.encode(
            el,
            container.nestedSingleValueContainer().encoder,
          )),
    );
  }
  if (instance.tiersMode != null) {
    container.encodeString(
      'tiers_mode',
      instance.tiersMode!,
    );
  }
  if (instance.transformUsage != null) {
    TransformUsage.encode(
      instance.transformUsage!,
      container.nestedSingleValueContainer('transform_usage').encoder,
    );
  }
  if (instance.trialPeriodDays != null) {
    container.encodeInt(
      'trial_period_days',
      instance.trialPeriodDays!,
    );
  }
  if (instance.usageType != null) {
    InvoiceitemPlanUsageType.encode(
      instance.usageType!,
      container.nestedSingleValueContainer('usage_type').encoder,
    );
  }
  return container.value;
}