encode<V> static method

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

Implementation

static V encode<V>(
  CalculationShippingCost instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.amount != null) {
    container.encodeInt(
      'amount',
      instance.amount!,
    );
  }
  if (instance.shippingRate != null) {
    container.encodeString(
      'shipping_rate',
      instance.shippingRate!,
    );
  }
  if (instance.taxBehavior != null) {
    TaxCalculationShippingCostTaxBehavior.encode(
      instance.taxBehavior!,
      container.nestedSingleValueContainer('tax_behavior').encoder,
    );
  }
  if (instance.taxCode != null) {
    container.encodeString(
      'tax_code',
      instance.taxCode!,
    );
  }
  return container.value;
}