encode<V> static method
Implementation
static V encode<V>(
SubscriptionSchedulePhaseConfiguration instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
container.encodeList(
'add_invoice_items',
(container) => instance.addInvoiceItems
.forEach((el) => SubscriptionScheduleAddInvoiceItem.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
if (instance.applicationFeePercent != null) {
container.encodeDouble(
'application_fee_percent',
instance.applicationFeePercent!,
);
}
if (instance.automaticTax != null) {
SchedulesPhaseAutomaticTax.encode(
instance.automaticTax!,
container.nestedSingleValueContainer('automatic_tax').encoder,
);
}
if (instance.billingCycleAnchor != null) {
container.encodeString(
'billing_cycle_anchor',
instance.billingCycleAnchor!,
);
}
if (instance.billingThresholds != null) {
SubscriptionBillingThresholds.encode(
instance.billingThresholds!,
container.nestedSingleValueContainer('billing_thresholds').encoder,
);
}
if (instance.collectionMethod != null) {
container.encodeString(
'collection_method',
instance.collectionMethod!,
);
}
if (instance.coupon != null) {
SubscriptionSchedulePhaseConfigurationCouponOrId.encode(
instance.coupon!,
container.nestedSingleValueContainer('coupon').encoder,
);
}
container.encodeString(
'currency',
instance.currency,
);
if (instance.defaultPaymentMethod != null) {
PaymentMethodOrId.encode(
instance.defaultPaymentMethod!,
container.nestedSingleValueContainer('default_payment_method').encoder,
);
}
if (instance.defaultTaxRates != null) {
container.encodeList(
'default_tax_rates',
(container) => instance.defaultTaxRates!.forEach((el) => TaxRate.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
if (instance.description != null) {
container.encodeString(
'description',
instance.description!,
);
}
container.encodeDateTime(
'end_date',
instance.endDate,
);
if (instance.invoiceSettings != null) {
InvoiceSettingSubscriptionSchedulePhaseSetting.encode(
instance.invoiceSettings!,
container.nestedSingleValueContainer('invoice_settings').encoder,
);
}
container.encodeList(
'items',
(container) => instance.items
.forEach((el) => SubscriptionScheduleConfigurationItem.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
if (instance.metadata != null) {
container.encodeMap(
'metadata',
(container) => instance.metadata!.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
}
if (instance.onBehalfOf != null) {
AccountOrId.encode(
instance.onBehalfOf!,
container.nestedSingleValueContainer('on_behalf_of').encoder,
);
}
PortalSubscriptionCancelProrationBehavior.encode(
instance.prorationBehavior,
container.nestedSingleValueContainer('proration_behavior').encoder,
);
container.encodeDateTime(
'start_date',
instance.startDate,
);
if (instance.transferData != null) {
SubscriptionTransferData.encode(
instance.transferData!,
container.nestedSingleValueContainer('transfer_data').encoder,
);
}
if (instance.trialEnd != null) {
container.encodeDateTime(
'trial_end',
instance.trialEnd!,
);
}
return container.value;
}