encode<V> static method

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

Implementation

static V encode<V>(
  TaxProductResourceTaxCalculationShippingCost instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount',
    instance.amount,
  );
  container.encodeInt(
    'amount_tax',
    instance.amountTax,
  );
  if (instance.shippingRate != null) {
    container.encodeString(
      'shipping_rate',
      instance.shippingRate!,
    );
  }
  TaxCalculationShippingCostTaxBehavior.encode(
    instance.taxBehavior,
    container.nestedSingleValueContainer('tax_behavior').encoder,
  );
  if (instance.taxBreakdown != null) {
    container.encodeList(
      'tax_breakdown',
      (container) => instance.taxBreakdown!
          .forEach((el) => TaxProductResourceLineItemTaxBreakdown.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  container.encodeString(
    'tax_code',
    instance.taxCode,
  );
  return container.value;
}