encode<V> static method

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

Implementation

static V encode<V>(
  TaxCalculationLineItem instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount',
    instance.amount,
  );
  container.encodeInt(
    'amount_tax',
    instance.amountTax,
  );
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeString(
    'object',
    'tax.calculation_line_item',
  );
  if (instance.product != null) {
    container.encodeString(
      'product',
      instance.product!,
    );
  }
  container.encodeInt(
    'quantity',
    instance.quantity,
  );
  if (instance.reference != null) {
    container.encodeString(
      'reference',
      instance.reference!,
    );
  }
  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;
}