encode<V> static method

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

Implementation

static V encode<V>(
  InvoicesResourceShippingCost instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount_subtotal',
    instance.amountSubtotal,
  );
  container.encodeInt(
    'amount_tax',
    instance.amountTax,
  );
  container.encodeInt(
    'amount_total',
    instance.amountTotal,
  );
  if (instance.shippingRate != null) {
    ShippingRateOrId.encode(
      instance.shippingRate!,
      container.nestedSingleValueContainer('shipping_rate').encoder,
    );
  }
  if (instance.taxes != null) {
    container.encodeList(
      'taxes',
      (container) =>
          instance.taxes!.forEach((el) => LineItemsTaxAmount.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  return container.value;
}