encode<V> static method
Implementation
static V encode<V>(
SubscriptionUpdateOptions instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
if (instance.addInvoiceItems != null) {
container.encodeList(
'add_invoice_items',
(container) => instance.addInvoiceItems!
.forEach((el) => SubscriptionScheduleAddInvoiceItemsItem.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
if (instance.applicationFeePercent != null) {
container.encodeDouble(
'application_fee_percent',
instance.applicationFeePercent!,
);
}
if (instance.automaticTax != null) {
SessionAutomaticTax.encode(
instance.automaticTax!,
container.nestedSingleValueContainer('automatic_tax').encoder,
);
}
if (instance.billingCycleAnchor != null) {
container.encodeString(
'billing_cycle_anchor',
instance.billingCycleAnchor!,
);
}
if (instance.billingThresholds != null) {
SubscriptionScheduleBillingThresholds.encode(
instance.billingThresholds!,
container.nestedSingleValueContainer('billing_thresholds').encoder,
);
}
if (instance.cancelAt != null) {
container.encodeDateTime(
'cancel_at',
instance.cancelAt!,
);
}
if (instance.cancelAtPeriodEnd != null) {
container.encodeBool(
'cancel_at_period_end',
instance.cancelAtPeriodEnd!,
);
}
if (instance.cancellationDetails != null) {
SubscriptionCancellationDetails.encode(
instance.cancellationDetails!,
container.nestedSingleValueContainer('cancellation_details').encoder,
);
}
if (instance.collectionMethod != null) {
InvoiceCollectionMethod.encode(
instance.collectionMethod!,
container.nestedSingleValueContainer('collection_method').encoder,
);
}
if (instance.coupon != null) {
container.encodeString(
'coupon',
instance.coupon!,
);
}
if (instance.daysUntilDue != null) {
container.encodeInt(
'days_until_due',
instance.daysUntilDue!,
);
}
if (instance.defaultPaymentMethod != null) {
container.encodeString(
'default_payment_method',
instance.defaultPaymentMethod!,
);
}
if (instance.defaultSource != null) {
container.encodeString(
'default_source',
instance.defaultSource!,
);
}
if (instance.defaultTaxRates != null) {
container.encodeList(
'default_tax_rates',
(container) => instance.defaultTaxRates!
.forEach((el) => container.encodeString(el)),
);
}
if (instance.description != null) {
container.encodeString(
'description',
instance.description!,
);
}
if (instance.expand != null) {
container.encodeList(
'expand',
(container) =>
instance.expand!.forEach((el) => container.encodeString(el)),
);
}
if (instance.invoiceSettings != null) {
SubscriptionInvoiceSettings.encode(
instance.invoiceSettings!,
container.nestedSingleValueContainer('invoice_settings').encoder,
);
}
if (instance.items != null) {
container.encodeList(
'items',
(container) => instance.items!
.forEach((el) => UpcomingSubscriptionItemsItem.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
if (instance.metadata != null) {
container.encodeMap(
'metadata',
(container) => instance.metadata!.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
}
if (instance.offSession != null) {
container.encodeBool(
'off_session',
instance.offSession!,
);
}
if (instance.onBehalfOf != null) {
container.encodeString(
'on_behalf_of',
instance.onBehalfOf!,
);
}
if (instance.pauseCollection != null) {
SubscriptionUpdateOptionsPauseCollection.encode(
instance.pauseCollection!,
container.nestedSingleValueContainer('pause_collection').encoder,
);
}
if (instance.paymentBehavior != null) {
SubscriptionItemPaymentBehavior.encode(
instance.paymentBehavior!,
container.nestedSingleValueContainer('payment_behavior').encoder,
);
}
if (instance.paymentSettings != null) {
SubscriptionCreateOptionsPaymentSettings.encode(
instance.paymentSettings!,
container.nestedSingleValueContainer('payment_settings').encoder,
);
}
if (instance.pendingInvoiceItemInterval != null) {
SessionRecurring.encode(
instance.pendingInvoiceItemInterval!,
container
.nestedSingleValueContainer('pending_invoice_item_interval')
.encoder,
);
}
if (instance.promotionCode != null) {
container.encodeString(
'promotion_code',
instance.promotionCode!,
);
}
if (instance.prorationBehavior != null) {
PortalSubscriptionCancelProrationBehavior.encode(
instance.prorationBehavior!,
container.nestedSingleValueContainer('proration_behavior').encoder,
);
}
if (instance.prorationDate != null) {
container.encodeDateTime(
'proration_date',
instance.prorationDate!,
);
}
if (instance.transferData != null) {
SessionTransferData.encode(
instance.transferData!,
container.nestedSingleValueContainer('transfer_data').encoder,
);
}
if (instance.trialEnd != null) {
container.encodePrimitive(
'trial_end',
instance.trialEnd!,
);
}
if (instance.trialFromPlan != null) {
container.encodeBool(
'trial_from_plan',
instance.trialFromPlan!,
);
}
if (instance.trialSettings != null) {
SessionTrialSettings.encode(
instance.trialSettings!,
container.nestedSingleValueContainer('trial_settings').encoder,
);
}
return container.value;
}