encode<V> static method
Implementation
static V encode<V>(
TaxCalculation instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
container.encodeInt(
'amount_total',
instance.amountTotal,
);
container.encodeString(
'currency',
instance.currency,
);
if (instance.customer != null) {
container.encodeString(
'customer',
instance.customer!,
);
}
TaxProductResourceCustomerDetails.encode(
instance.customerDetails,
container.nestedSingleValueContainer('customer_details').encoder,
);
if (instance.expiresAt != null) {
container.encodeDateTime(
'expires_at',
instance.expiresAt!,
);
}
if (instance.id != null) {
container.encodeString(
'id',
instance.id!,
);
}
if (instance.lineItems != null) {
TaxCalculationLineItems.encode(
instance.lineItems!,
container.nestedSingleValueContainer('line_items').encoder,
);
}
container.encodeBool(
'livemode',
instance.livemode,
);
container.encodeString(
'object',
'tax.calculation',
);
if (instance.shippingCost != null) {
TaxCalculationShippingCost.encode(
instance.shippingCost!,
container.nestedSingleValueContainer('shipping_cost').encoder,
);
}
container.encodeInt(
'tax_amount_exclusive',
instance.taxAmountExclusive,
);
container.encodeInt(
'tax_amount_inclusive',
instance.taxAmountInclusive,
);
container.encodeList(
'tax_breakdown',
(container) => instance.taxBreakdown
.forEach((el) => TaxProductResourceTaxBreakdown.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
container.encodeDateTime(
'tax_date',
instance.taxDate,
);
return container.value;
}