encode<V> static method

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

Implementation

static V encode<V>(
  Item instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount_discount',
    instance.amountDiscount,
  );
  container.encodeInt(
    'amount_subtotal',
    instance.amountSubtotal,
  );
  container.encodeInt(
    'amount_tax',
    instance.amountTax,
  );
  container.encodeInt(
    'amount_total',
    instance.amountTotal,
  );
  container.encodeString(
    'currency',
    instance.currency,
  );
  container.encodeString(
    'description',
    instance.description,
  );
  if (instance.discounts != null) {
    container.encodeList(
      'discounts',
      (container) =>
          instance.discounts!.forEach((el) => LineItemsDiscountAmount.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  container.encodeString(
    'id',
    instance.id,
  );
  container.encodeString(
    'object',
    'item',
  );
  if (instance.price != null) {
    InvoiceitemPrice.encode(
      instance.price!,
      container.nestedSingleValueContainer('price').encoder,
    );
  }
  if (instance.quantity != null) {
    container.encodeInt(
      'quantity',
      instance.quantity!,
    );
  }
  if (instance.taxes != null) {
    container.encodeList(
      'taxes',
      (container) =>
          instance.taxes!.forEach((el) => LineItemsTaxAmount.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  return container.value;
}