Customer.fromJson constructor
Customer.fromJson(
- Object? json
Implementation
factory Customer.fromJson(Object? json) {
final map = (json as Map).cast<String, Object?>();
return Customer(
address: map['address'] == null ? null : Address.fromJson(map['address']),
balance: map['balance'] == null ? null : (map['balance'] as num).toInt(),
cashBalance: map['cash_balance'] == null
? null
: CashBalance.fromJson(map['cash_balance']),
created:
DateTime.fromMillisecondsSinceEpoch((map['created'] as int).toInt()),
currency: map['currency'] == null ? null : (map['currency'] as String),
defaultSource: map['default_source'] == null
? null
: PaymentSourceOrId.fromJson(map['default_source']),
delinquent:
map['delinquent'] == null ? null : (map['delinquent'] as bool),
description:
map['description'] == null ? null : (map['description'] as String),
discount: map['discount'] == null
? null
: CustomerDiscount.fromJson(map['discount']),
email: map['email'] == null ? null : (map['email'] as String),
id: (map['id'] as String),
invoiceCreditBalance: map['invoice_credit_balance'] == null
? null
: (map['invoice_credit_balance'] as Map).cast<String, Object?>().map((
key,
value,
) =>
MapEntry(
key,
(value as num).toInt(),
)),
invoicePrefix: map['invoice_prefix'] == null
? null
: (map['invoice_prefix'] as String),
invoiceSettings: map['invoice_settings'] == null
? null
: InvoiceSettingCustomerSetting.fromJson(map['invoice_settings']),
livemode: (map['livemode'] as bool),
metadata: map['metadata'] == null
? null
: (map['metadata'] as Map).cast<String, Object?>().map((
key,
value,
) =>
MapEntry(
key,
(value as String),
)),
name: map['name'] == null ? null : (map['name'] as String),
nextInvoiceSequence: map['next_invoice_sequence'] == null
? null
: (map['next_invoice_sequence'] as num).toInt(),
phone: map['phone'] == null ? null : (map['phone'] as String),
preferredLocales: map['preferred_locales'] == null
? null
: (map['preferred_locales'] as List<Object?>)
.map((el) => (el as String))
.toList(),
shipping: map['shipping'] == null
? null
: ChargeShipping.fromJson(map['shipping']),
sources: map['sources'] == null
? null
: CustomerSources.fromJson(map['sources']),
subscriptions: map['subscriptions'] == null
? null
: CustomerSubscriptions.fromJson(map['subscriptions']),
tax: map['tax'] == null ? null : CustomerTax.fromJson(map['tax']),
taxExempt: map['tax_exempt'] == null
? null
: CheckoutSessionCustomerDetailsTaxExempt.fromJson(map['tax_exempt']),
taxIds: map['tax_ids'] == null
? null
: CustomerTaxIds.fromJson(map['tax_ids']),
testClock: map['test_clock'] == null
? null
: TestHelpersTestClockOrId.fromJson(map['test_clock']),
);
}