encode<V> static method
V
encode<
V>( - Customer instance,
- Encoder<V> encoder
)
override
Implementation
static V encode<V>(
Customer instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
if (instance.address != null) {
Address.encode(
instance.address!,
container.nestedSingleValueContainer('address').encoder,
);
}
if (instance.balance != null) {
container.encodeInt(
'balance',
instance.balance!,
);
}
if (instance.cashBalance != null) {
CashBalance.encode(
instance.cashBalance!,
container.nestedSingleValueContainer('cash_balance').encoder,
);
}
container.encodeDateTime(
'created',
instance.created,
);
if (instance.currency != null) {
container.encodeString(
'currency',
instance.currency!,
);
}
if (instance.defaultSource != null) {
PaymentSourceOrId.encode(
instance.defaultSource!,
container.nestedSingleValueContainer('default_source').encoder,
);
}
if (instance.delinquent != null) {
container.encodeBool(
'delinquent',
instance.delinquent!,
);
}
if (instance.description != null) {
container.encodeString(
'description',
instance.description!,
);
}
if (instance.discount != null) {
CustomerDiscount.encode(
instance.discount!,
container.nestedSingleValueContainer('discount').encoder,
);
}
if (instance.email != null) {
container.encodeString(
'email',
instance.email!,
);
}
container.encodeString(
'id',
instance.id,
);
if (instance.invoiceCreditBalance != null) {
container.encodeMap(
'invoice_credit_balance',
(container) => instance.invoiceCreditBalance!.forEach((
key,
value,
) =>
container.encodeInt(
key,
value,
)),
);
}
if (instance.invoicePrefix != null) {
container.encodeString(
'invoice_prefix',
instance.invoicePrefix!,
);
}
if (instance.invoiceSettings != null) {
InvoiceSettingCustomerSetting.encode(
instance.invoiceSettings!,
container.nestedSingleValueContainer('invoice_settings').encoder,
);
}
container.encodeBool(
'livemode',
instance.livemode,
);
if (instance.metadata != null) {
container.encodeMap(
'metadata',
(container) => instance.metadata!.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
}
if (instance.name != null) {
container.encodeString(
'name',
instance.name!,
);
}
if (instance.nextInvoiceSequence != null) {
container.encodeInt(
'next_invoice_sequence',
instance.nextInvoiceSequence!,
);
}
container.encodeString(
'object',
'customer',
);
if (instance.phone != null) {
container.encodeString(
'phone',
instance.phone!,
);
}
if (instance.preferredLocales != null) {
container.encodeList(
'preferred_locales',
(container) => instance.preferredLocales!
.forEach((el) => container.encodeString(el)),
);
}
if (instance.shipping != null) {
ChargeShipping.encode(
instance.shipping!,
container.nestedSingleValueContainer('shipping').encoder,
);
}
if (instance.sources != null) {
CustomerSources.encode(
instance.sources!,
container.nestedSingleValueContainer('sources').encoder,
);
}
if (instance.subscriptions != null) {
CustomerSubscriptions.encode(
instance.subscriptions!,
container.nestedSingleValueContainer('subscriptions').encoder,
);
}
if (instance.tax != null) {
CustomerTax.encode(
instance.tax!,
container.nestedSingleValueContainer('tax').encoder,
);
}
if (instance.taxExempt != null) {
CheckoutSessionCustomerDetailsTaxExempt.encode(
instance.taxExempt!,
container.nestedSingleValueContainer('tax_exempt').encoder,
);
}
if (instance.taxIds != null) {
CustomerTaxIds.encode(
instance.taxIds!,
container.nestedSingleValueContainer('tax_ids').encoder,
);
}
if (instance.testClock != null) {
TestHelpersTestClockOrId.encode(
instance.testClock!,
container.nestedSingleValueContainer('test_clock').encoder,
);
}
return container.value;
}