encode<V> static method
V
encode<
V>( - LineItem instance,
- Encoder<V> encoder
)
Implementation
static V encode<V>(
LineItem 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!,
);
}
container.encodeString(
'currency',
instance.currency,
);
if (instance.description != null) {
container.encodeString(
'description',
instance.description!,
);
}
if (instance.discountAmounts != null) {
container.encodeList(
'discount_amounts',
(container) => instance.discountAmounts!
.forEach((el) => DiscountsResourceDiscountAmount.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
container.encodeBool(
'discountable',
instance.discountable,
);
if (instance.discounts != null) {
container.encodeList(
'discounts',
(container) => instance.discounts!.forEach((el) => DiscountOrId.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
container.encodeString(
'id',
instance.id,
);
if (instance.invoice != null) {
container.encodeString(
'invoice',
instance.invoice!,
);
}
if (instance.invoiceItem != null) {
InvoiceitemOrId.encode(
instance.invoiceItem!,
container.nestedSingleValueContainer('invoice_item').encoder,
);
}
container.encodeBool(
'livemode',
instance.livemode,
);
container.encodeMap(
'metadata',
(container) => instance.metadata.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
container.encodeString(
'object',
'line_item',
);
InvoiceLineItemPeriod.encode(
instance.period,
container.nestedSingleValueContainer('period').encoder,
);
if (instance.plan != null) {
InvoiceitemPlan.encode(
instance.plan!,
container.nestedSingleValueContainer('plan').encoder,
);
}
if (instance.price != null) {
InvoiceitemPrice.encode(
instance.price!,
container.nestedSingleValueContainer('price').encoder,
);
}
container.encodeBool(
'proration',
instance.proration,
);
if (instance.prorationDetails != null) {
InvoicesResourceLineItemsProrationDetails.encode(
instance.prorationDetails!,
container.nestedSingleValueContainer('proration_details').encoder,
);
}
if (instance.quantity != null) {
container.encodeInt(
'quantity',
instance.quantity!,
);
}
if (instance.subscription != null) {
SubscriptionOrId.encode(
instance.subscription!,
container.nestedSingleValueContainer('subscription').encoder,
);
}
if (instance.subscriptionItem != null) {
SubscriptionItemOrId.encode(
instance.subscriptionItem!,
container.nestedSingleValueContainer('subscription_item').encoder,
);
}
if (instance.taxAmounts != null) {
container.encodeList(
'tax_amounts',
(container) =>
instance.taxAmounts!.forEach((el) => InvoiceTaxAmount.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
if (instance.taxRates != null) {
container.encodeList(
'tax_rates',
(container) => instance.taxRates!.forEach((el) => TaxRate.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
container.encodeString(
'type',
instance.type,
);
if (instance.unitAmountExcludingTax != null) {
container.encodeString(
'unit_amount_excluding_tax',
instance.unitAmountExcludingTax!,
);
}
return container.value;
}