CreditNoteLineItem.fromJson constructor
CreditNoteLineItem.fromJson(
- Object? json
Implementation
factory CreditNoteLineItem.fromJson(Object? json) {
final map = (json as Map).cast<String, Object?>();
return CreditNoteLineItem(
amount: (map['amount'] as num).toInt(),
amountExcludingTax: map['amount_excluding_tax'] == null
? null
: (map['amount_excluding_tax'] as num).toInt(),
description:
map['description'] == null ? null : (map['description'] as String),
discountAmount: (map['discount_amount'] as num).toInt(),
discountAmounts: (map['discount_amounts'] as List<Object?>)
.map((el) => DiscountsResourceDiscountAmount.fromJson(el))
.toList(),
id: (map['id'] as String),
invoiceLineItem: map['invoice_line_item'] == null
? null
: (map['invoice_line_item'] as String),
livemode: (map['livemode'] as bool),
quantity:
map['quantity'] == null ? null : (map['quantity'] as num).toInt(),
taxAmounts: (map['tax_amounts'] as List<Object?>)
.map((el) => CreditNoteTaxAmount.fromJson(el))
.toList(),
taxRates: (map['tax_rates'] as List<Object?>)
.map((el) => TaxRate.fromJson(el))
.toList(),
type: CreditNoteLineItemType.fromJson(map['type']),
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),
unitAmountExcludingTax: map['unit_amount_excluding_tax'] == null
? null
: (map['unit_amount_excluding_tax'] as String),
);
}