encode<V> static method

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

Implementation

static V encode<V>(
  CreditNoteLineItem instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  container.encodeInt(
    'amount',
    instance.amount,
  );
  if (instance.amountExcludingTax != null) {
    container.encodeInt(
      'amount_excluding_tax',
      instance.amountExcludingTax!,
    );
  }
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  container.encodeInt(
    'discount_amount',
    instance.discountAmount,
  );
  container.encodeList(
    'discount_amounts',
    (container) => instance.discountAmounts
        .forEach((el) => DiscountsResourceDiscountAmount.encode(
              el,
              container.nestedSingleValueContainer().encoder,
            )),
  );
  container.encodeString(
    'id',
    instance.id,
  );
  if (instance.invoiceLineItem != null) {
    container.encodeString(
      'invoice_line_item',
      instance.invoiceLineItem!,
    );
  }
  container.encodeBool(
    'livemode',
    instance.livemode,
  );
  container.encodeString(
    'object',
    'credit_note_line_item',
  );
  if (instance.quantity != null) {
    container.encodeInt(
      'quantity',
      instance.quantity!,
    );
  }
  container.encodeList(
    'tax_amounts',
    (container) =>
        instance.taxAmounts.forEach((el) => CreditNoteTaxAmount.encode(
              el,
              container.nestedSingleValueContainer().encoder,
            )),
  );
  container.encodeList(
    'tax_rates',
    (container) => instance.taxRates.forEach((el) => TaxRate.encode(
          el,
          container.nestedSingleValueContainer().encoder,
        )),
  );
  container.encodeString(
    'type',
    instance.type,
  );
  if (instance.unitAmount != null) {
    container.encodeInt(
      'unit_amount',
      instance.unitAmount!,
    );
  }
  if (instance.unitAmountDecimal != null) {
    container.encodeString(
      'unit_amount_decimal',
      instance.unitAmountDecimal!,
    );
  }
  if (instance.unitAmountExcludingTax != null) {
    container.encodeString(
      'unit_amount_excluding_tax',
      instance.unitAmountExcludingTax!,
    );
  }
  return container.value;
}