encode<V> static method

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

Implementation

static V encode<V>(
  InvoiceLineItemUpdateOptions instance,
  Encoder<V> encoder,
) {
  final container = encoder.container<String>();
  if (instance.amount != null) {
    container.encodeInt(
      'amount',
      instance.amount!,
    );
  }
  if (instance.description != null) {
    container.encodeString(
      'description',
      instance.description!,
    );
  }
  if (instance.discountable != null) {
    container.encodeBool(
      'discountable',
      instance.discountable!,
    );
  }
  if (instance.discounts != null) {
    container.encodeList(
      'discounts',
      (container) =>
          instance.discounts!.forEach((el) => InvoiceItemDiscountsItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.expand != null) {
    container.encodeList(
      'expand',
      (container) =>
          instance.expand!.forEach((el) => container.encodeString(el)),
    );
  }
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  if (instance.period != null) {
    InvoiceLineItemPeriod.encode(
      instance.period!,
      container.nestedSingleValueContainer('period').encoder,
    );
  }
  if (instance.price != null) {
    container.encodeString(
      'price',
      instance.price!,
    );
  }
  if (instance.priceData != null) {
    InvoiceLineItemPriceData.encode(
      instance.priceData!,
      container.nestedSingleValueContainer('price_data').encoder,
    );
  }
  if (instance.quantity != null) {
    container.encodeInt(
      'quantity',
      instance.quantity!,
    );
  }
  if (instance.taxAmounts != null) {
    container.encodeList(
      'tax_amounts',
      (container) => instance.taxAmounts!
          .forEach((el) => InvoiceLineItemTaxAmountsItem.encode(
                el,
                container.nestedSingleValueContainer().encoder,
              )),
    );
  }
  if (instance.taxRates != null) {
    container.encodeList(
      'tax_rates',
      (container) =>
          instance.taxRates!.forEach((el) => container.encodeString(el)),
    );
  }
  return container.value;
}