Invoiceitem.fromJson constructor

Invoiceitem.fromJson(
  1. Object? json
)

Implementation

factory Invoiceitem.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return Invoiceitem(
    amount: (map['amount'] as num).toInt(),
    currency: (map['currency'] as String),
    customer: BankAccountCustomerOrId.fromJson(map['customer']),
    date: DateTime.fromMillisecondsSinceEpoch((map['date'] as int).toInt()),
    description:
        map['description'] == null ? null : (map['description'] as String),
    discountable: (map['discountable'] as bool),
    discounts: map['discounts'] == null
        ? null
        : (map['discounts'] as List<Object?>)
            .map((el) => DiscountOrId.fromJson(el))
            .toList(),
    id: (map['id'] as String),
    invoice:
        map['invoice'] == null ? null : InvoiceOrId.fromJson(map['invoice']),
    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),
                )),
    period: InvoiceLineItemPeriod.fromJson(map['period']),
    plan: map['plan'] == null ? null : InvoiceitemPlan.fromJson(map['plan']),
    price:
        map['price'] == null ? null : InvoiceitemPrice.fromJson(map['price']),
    proration: (map['proration'] as bool),
    quantity: (map['quantity'] as num).toInt(),
    subscription: map['subscription'] == null
        ? null
        : SubscriptionOrId.fromJson(map['subscription']),
    subscriptionItem: map['subscription_item'] == null
        ? null
        : (map['subscription_item'] as String),
    taxRates: map['tax_rates'] == null
        ? null
        : (map['tax_rates'] as List<Object?>)
            .map((el) => TaxRate.fromJson(el))
            .toList(),
    testClock: map['test_clock'] == null
        ? null
        : TestHelpersTestClockOrId.fromJson(map['test_clock']),
    unitAmount: map['unit_amount'] == null
        ? null
        : (map['unit_amount'] as num).toInt(),
    unitAmountDecimal: map['unit_amount_decimal'] == null
        ? null
        : (map['unit_amount_decimal'] as String),
  );
}