encode<V> static method
V
encode<
V>( - Quote instance,
- Encoder<V> encoder
)
override
Implementation
static V encode<V>(
Quote instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
container.encodeInt(
'amount_subtotal',
instance.amountSubtotal,
);
container.encodeInt(
'amount_total',
instance.amountTotal,
);
if (instance.application != null) {
BillingPortalConfigurationApplicationOrId.encode(
instance.application!,
container.nestedSingleValueContainer('application').encoder,
);
}
if (instance.applicationFeeAmount != null) {
container.encodeInt(
'application_fee_amount',
instance.applicationFeeAmount!,
);
}
if (instance.applicationFeePercent != null) {
container.encodeDouble(
'application_fee_percent',
instance.applicationFeePercent!,
);
}
QuotesResourceAutomaticTax.encode(
instance.automaticTax,
container.nestedSingleValueContainer('automatic_tax').encoder,
);
InvoiceCollectionMethod.encode(
instance.collectionMethod,
container.nestedSingleValueContainer('collection_method').encoder,
);
QuotesResourceComputed.encode(
instance.computed,
container.nestedSingleValueContainer('computed').encoder,
);
container.encodeDateTime(
'created',
instance.created,
);
if (instance.currency != null) {
container.encodeString(
'currency',
instance.currency!,
);
}
if (instance.customer != null) {
BankAccountCustomerOrId.encode(
instance.customer!,
container.nestedSingleValueContainer('customer').encoder,
);
}
if (instance.defaultTaxRates != null) {
container.encodeList(
'default_tax_rates',
(container) =>
instance.defaultTaxRates!.forEach((el) => TaxRateOrId.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
if (instance.description != null) {
container.encodeString(
'description',
instance.description!,
);
}
container.encodeList(
'discounts',
(container) => instance.discounts.forEach((el) => DiscountOrId.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
container.encodeDateTime(
'expires_at',
instance.expiresAt,
);
if (instance.footer != null) {
container.encodeString(
'footer',
instance.footer!,
);
}
if (instance.fromQuote != null) {
QuoteFromQuote.encode(
instance.fromQuote!,
container.nestedSingleValueContainer('from_quote').encoder,
);
}
if (instance.header != null) {
container.encodeString(
'header',
instance.header!,
);
}
container.encodeString(
'id',
instance.id,
);
if (instance.invoice != null) {
QuoteInvoiceOrId.encode(
instance.invoice!,
container.nestedSingleValueContainer('invoice').encoder,
);
}
InvoiceSettingQuoteSetting.encode(
instance.invoiceSettings,
container.nestedSingleValueContainer('invoice_settings').encoder,
);
if (instance.lineItems != null) {
CheckoutSessionLineItems.encode(
instance.lineItems!,
container.nestedSingleValueContainer('line_items').encoder,
);
}
container.encodeBool(
'livemode',
instance.livemode,
);
container.encodeMap(
'metadata',
(container) => instance.metadata.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
if (instance.number != null) {
container.encodeString(
'number',
instance.number!,
);
}
container.encodeString(
'object',
'quote',
);
if (instance.onBehalfOf != null) {
AccountOrId.encode(
instance.onBehalfOf!,
container.nestedSingleValueContainer('on_behalf_of').encoder,
);
}
container.encodeString(
'status',
instance.status,
);
QuotesResourceStatusTransitions.encode(
instance.statusTransitions,
container.nestedSingleValueContainer('status_transitions').encoder,
);
if (instance.subscription != null) {
SubscriptionOrId.encode(
instance.subscription!,
container.nestedSingleValueContainer('subscription').encoder,
);
}
QuotesResourceSubscriptionDataSubscriptionData.encode(
instance.subscriptionData,
container.nestedSingleValueContainer('subscription_data').encoder,
);
if (instance.subscriptionSchedule != null) {
SubscriptionScheduleOrId.encode(
instance.subscriptionSchedule!,
container.nestedSingleValueContainer('subscription_schedule').encoder,
);
}
if (instance.testClock != null) {
TestHelpersTestClockOrId.encode(
instance.testClock!,
container.nestedSingleValueContainer('test_clock').encoder,
);
}
QuotesResourceTotalDetails.encode(
instance.totalDetails,
container.nestedSingleValueContainer('total_details').encoder,
);
if (instance.transferData != null) {
QuoteTransferData.encode(
instance.transferData!,
container.nestedSingleValueContainer('transfer_data').encoder,
);
}
return container.value;
}