InvoiceCreateOptions.fromJson constructor
InvoiceCreateOptions.fromJson(
- Object? json
Implementation
factory InvoiceCreateOptions.fromJson(Object? json) {
final map = (json as Map).cast<String, Object?>();
return InvoiceCreateOptions(
accountTaxIds: map['account_tax_ids'] == null
? null
: (map['account_tax_ids'] as List<Object?>)
.map((el) => (el as String))
.toList(),
applicationFeeAmount: map['application_fee_amount'] == null
? null
: (map['application_fee_amount'] as num).toInt(),
autoAdvance:
map['auto_advance'] == null ? null : (map['auto_advance'] as bool),
automaticTax: map['automatic_tax'] == null
? null
: SessionAutomaticTax.fromJson(map['automatic_tax']),
collectionMethod: map['collection_method'] == null
? null
: InvoiceCollectionMethod.fromJson(map['collection_method']),
currency: map['currency'] == null ? null : (map['currency'] as String),
customFields: map['custom_fields'] == null
? null
: (map['custom_fields'] as List<Object?>)
.map((el) => InvoiceSettingCustomField.fromJson(el))
.toList(),
customer: map['customer'] == null ? null : (map['customer'] as String),
daysUntilDue: map['days_until_due'] == null
? null
: (map['days_until_due'] as num).toInt(),
defaultPaymentMethod: map['default_payment_method'] == null
? null
: (map['default_payment_method'] as String),
defaultSource: map['default_source'] == null
? null
: (map['default_source'] as String),
defaultTaxRates: map['default_tax_rates'] == null
? null
: (map['default_tax_rates'] as List<Object?>)
.map((el) => (el as String))
.toList(),
description:
map['description'] == null ? null : (map['description'] as String),
discounts: map['discounts'] == null
? null
: (map['discounts'] as List<Object?>)
.map((el) => InvoiceItemDiscountsItem.fromJson(el))
.toList(),
dueDate: map['due_date'] == null
? null
: DateTime.fromMillisecondsSinceEpoch(
(map['due_date'] as int).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(),
footer: map['footer'] == null ? null : (map['footer'] as String),
fromInvoice: map['from_invoice'] == null
? null
: InvoiceCreateOptionsFromInvoice.fromJson(map['from_invoice']),
issuer: map['issuer'] == null
? null
: SessionLiability.fromJson(map['issuer']),
metadata: map['metadata'] == null
? null
: (map['metadata'] as Map).cast<String, Object?>().map((
key,
value,
) =>
MapEntry(
key,
(value as String),
)),
number: map['number'] == null ? null : (map['number'] as String),
onBehalfOf:
map['on_behalf_of'] == null ? null : (map['on_behalf_of'] as String),
paymentSettings: map['payment_settings'] == null
? null
: InvoicePaymentSettings.fromJson(map['payment_settings']),
pendingInvoiceItemsBehavior: map['pending_invoice_items_behavior'] == null
? null
: InvoicePendingInvoiceItemsBehavior.fromJson(
map['pending_invoice_items_behavior']),
rendering: map['rendering'] == null
? null
: InvoiceCreateOptionsRendering.fromJson(map['rendering']),
renderingOptions: map['rendering_options'] == null
? null
: SessionRenderingOptions.fromJson(map['rendering_options']),
shippingCost: map['shipping_cost'] == null
? null
: SessionShippingOptionsItem.fromJson(map['shipping_cost']),
shippingDetails: map['shipping_details'] == null
? null
: InvoiceShippingDetails.fromJson(map['shipping_details']),
statementDescriptor: map['statement_descriptor'] == null
? null
: (map['statement_descriptor'] as String),
subscription:
map['subscription'] == null ? null : (map['subscription'] as String),
transferData: map['transfer_data'] == null
? null
: ChargeCreateOptionsTransferData.fromJson(map['transfer_data']),
);
}