CreditNoteCreateOptions.fromJson constructor
CreditNoteCreateOptions.fromJson(
- Object? json
Implementation
factory CreditNoteCreateOptions.fromJson(Object? json) {
final map = (json as Map).cast<String, Object?>();
return CreditNoteCreateOptions(
amount: map['amount'] == null ? null : (map['amount'] as num).toInt(),
creditAmount: map['credit_amount'] == null
? null
: (map['credit_amount'] as num).toInt(),
effectiveAt: map['effective_at'] == null
? null
: DateTime.fromMillisecondsSinceEpoch(
(map['effective_at'] as int).toInt()),
expand: map['expand'] == null
? null
: (map['expand'] as List<Object?>)
.map((el) => (el as String))
.toList(),
invoice: (map['invoice'] as String),
lines: map['lines'] == null
? null
: (map['lines'] as List<Object?>)
.map((el) => CreditNoteLinesItem.fromJson(el))
.toList(),
memo: map['memo'] == null ? null : (map['memo'] as String),
metadata: map['metadata'] == null
? null
: (map['metadata'] as Map).cast<String, Object?>().map((
key,
value,
) =>
MapEntry(
key,
(value as String),
)),
outOfBandAmount: map['out_of_band_amount'] == null
? null
: (map['out_of_band_amount'] as num).toInt(),
reason: map['reason'] == null
? null
: CreditNoteCreateOptionsReason.fromJson(map['reason']),
refund: map['refund'] == null ? null : (map['refund'] as String),
refundAmount: map['refund_amount'] == null
? null
: (map['refund_amount'] as num).toInt(),
shippingCost: map['shipping_cost'] == null
? null
: CreditNoteShippingCost.fromJson(map['shipping_cost']),
);
}