encode<V> static method
Implementation
static V encode<V>(
CustomerCreateOptions instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
if (instance.address != null) {
AccountSupportAddress.encode(
instance.address!,
container.nestedSingleValueContainer('address').encoder,
);
}
if (instance.balance != null) {
container.encodeInt(
'balance',
instance.balance!,
);
}
if (instance.cashBalance != null) {
CustomerCashBalance.encode(
instance.cashBalance!,
container.nestedSingleValueContainer('cash_balance').encoder,
);
}
if (instance.coupon != null) {
container.encodeString(
'coupon',
instance.coupon!,
);
}
if (instance.description != null) {
container.encodeString(
'description',
instance.description!,
);
}
if (instance.email != null) {
container.encodeString(
'email',
instance.email!,
);
}
if (instance.expand != null) {
container.encodeList(
'expand',
(container) =>
instance.expand!.forEach((el) => container.encodeString(el)),
);
}
if (instance.invoicePrefix != null) {
container.encodeString(
'invoice_prefix',
instance.invoicePrefix!,
);
}
if (instance.invoiceSettings != null) {
CustomerInvoiceSettings.encode(
instance.invoiceSettings!,
container.nestedSingleValueContainer('invoice_settings').encoder,
);
}
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!,
);
}
if (instance.paymentMethod != null) {
container.encodeString(
'payment_method',
instance.paymentMethod!,
);
}
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.promotionCode != null) {
container.encodeString(
'promotion_code',
instance.promotionCode!,
);
}
if (instance.shipping != null) {
CustomerShipping.encode(
instance.shipping!,
container.nestedSingleValueContainer('shipping').encoder,
);
}
if (instance.source != null) {
container.encodeString(
'source',
instance.source!,
);
}
if (instance.tax != null) {
CustomerTax.encode(
instance.tax!,
container.nestedSingleValueContainer('tax').encoder,
);
}
if (instance.taxExempt != null) {
container.encodeString(
'tax_exempt',
instance.taxExempt!,
);
}
if (instance.taxIdData != null) {
container.encodeList(
'tax_id_data',
(container) =>
instance.taxIdData!.forEach((el) => CustomerTaxIdDataItem.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
if (instance.testClock != null) {
container.encodeString(
'test_clock',
instance.testClock!,
);
}
if (instance.validate != null) {
container.encodeBool(
'validate',
instance.validate!,
);
}
return container.value;
}