encode<V> static method

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

Implementation

static V encode<V>(
  PlanTier instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.flatAmount != null) {
    container.encodeInt(
      'flat_amount',
      instance.flatAmount!,
    );
  }
  if (instance.flatAmountDecimal != null) {
    container.encodeString(
      'flat_amount_decimal',
      instance.flatAmountDecimal!,
    );
  }
  if (instance.unitAmount != null) {
    container.encodeInt(
      'unit_amount',
      instance.unitAmount!,
    );
  }
  if (instance.unitAmountDecimal != null) {
    container.encodeString(
      'unit_amount_decimal',
      instance.unitAmountDecimal!,
    );
  }
  if (instance.upTo != null) {
    container.encodeInt(
      'up_to',
      instance.upTo!,
    );
  }
  return container.value;
}