encode<V> static method

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

Implementation

static V encode<V>(
  PriceCurrencyOptionsValue instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.customUnitAmount != null) {
    PriceCustomUnitAmount.encode(
      instance.customUnitAmount!,
      container.nestedSingleValueContainer('custom_unit_amount').encoder,
    );
  }
  if (instance.taxBehavior != null) {
    ShippingRateCurrencyOptionTaxBehavior.encode(
      instance.taxBehavior!,
      container.nestedSingleValueContainer('tax_behavior').encoder,
    );
  }
  if (instance.tiers != null) {
    container.encodeList(
      'tiers',
      (container) => instance.tiers!.forEach((el) => PlanTiersItem.encode(
            el,
            container.nestedSingleValueContainer().encoder,
          )),
    );
  }
  if (instance.unitAmount != null) {
    container.encodeInt(
      'unit_amount',
      instance.unitAmount!,
    );
  }
  if (instance.unitAmountDecimal != null) {
    container.encodeString(
      'unit_amount_decimal',
      instance.unitAmountDecimal!,
    );
  }
  return container.value;
}