CustomerCreateOptions.fromJson constructor

CustomerCreateOptions.fromJson(
  1. Object? json
)

Implementation

factory CustomerCreateOptions.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return CustomerCreateOptions(
    address: map['address'] == null
        ? null
        : AccountSupportAddress.fromJson(map['address']),
    balance: map['balance'] == null ? null : (map['balance'] as num).toInt(),
    cashBalance: map['cash_balance'] == null
        ? null
        : CustomerCashBalance.fromJson(map['cash_balance']),
    coupon: map['coupon'] == null ? null : (map['coupon'] as String),
    description:
        map['description'] == null ? null : (map['description'] as String),
    email: map['email'] == null ? null : (map['email'] as String),
    expand: map['expand'] == null
        ? null
        : (map['expand'] as List<Object?>)
            .map((el) => (el as String))
            .toList(),
    invoicePrefix: map['invoice_prefix'] == null
        ? null
        : (map['invoice_prefix'] as String),
    invoiceSettings: map['invoice_settings'] == null
        ? null
        : CustomerInvoiceSettings.fromJson(map['invoice_settings']),
    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(),
    paymentMethod: map['payment_method'] == null
        ? null
        : (map['payment_method'] as String),
    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(),
    promotionCode: map['promotion_code'] == null
        ? null
        : (map['promotion_code'] as String),
    shipping: map['shipping'] == null
        ? null
        : CustomerShipping.fromJson(map['shipping']),
    source: map['source'] == null ? null : (map['source'] as String),
    tax: map['tax'] == null ? null : CustomerTax.fromJson(map['tax']),
    taxExempt: map['tax_exempt'] == null
        ? null
        : CustomerTaxExempt.fromJson(map['tax_exempt']),
    taxIdData: map['tax_id_data'] == null
        ? null
        : (map['tax_id_data'] as List<Object?>)
            .map((el) => CustomerTaxIdDataItem.fromJson(el))
            .toList(),
    testClock:
        map['test_clock'] == null ? null : (map['test_clock'] as String),
    validate: map['validate'] == null ? null : (map['validate'] as bool),
  );
}