encode<V> static method

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

Implementation

static V encode<V>(
  TaxTransactionLineItem 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,
  );
  if (instance.metadata != null) {
    container.encodeMap(
      'metadata',
      (container) => instance.metadata!.forEach((
        key,
        value,
      ) =>
          container.encodeString(
            key,
            value,
          )),
    );
  }
  container.encodeString(
    'object',
    'tax.transaction_line_item',
  );
  if (instance.product != null) {
    container.encodeString(
      'product',
      instance.product!,
    );
  }
  container.encodeInt(
    'quantity',
    instance.quantity,
  );
  container.encodeString(
    'reference',
    instance.reference,
  );
  if (instance.reversal != null) {
    TaxTransactionLineItemReversal.encode(
      instance.reversal!,
      container.nestedSingleValueContainer('reversal').encoder,
    );
  }
  TaxCalculationShippingCostTaxBehavior.encode(
    instance.taxBehavior,
    container.nestedSingleValueContainer('tax_behavior').encoder,
  );
  container.encodeString(
    'tax_code',
    instance.taxCode,
  );
  TaxTransactionType.encode(
    instance.type,
    container.nestedSingleValueContainer('type').encoder,
  );
  return container.value;
}