InvoiceUpdateOptions.fromJson constructor

InvoiceUpdateOptions.fromJson(
  1. Object? json
)

Implementation

factory InvoiceUpdateOptions.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return InvoiceUpdateOptions(
    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']),
    customFields: map['custom_fields'] == null
        ? null
        : (map['custom_fields'] as List<Object?>)
            .map((el) => InvoiceSettingCustomField.fromJson(el))
            .toList(),
    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),
    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']),
    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),
    transferData: map['transfer_data'] == null
        ? null
        : ChargeCreateOptionsTransferData.fromJson(map['transfer_data']),
  );
}