QuoteUpdateOptions.fromJson constructor

QuoteUpdateOptions.fromJson(
  1. Object? json
)

Implementation

factory QuoteUpdateOptions.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return QuoteUpdateOptions(
    applicationFeeAmount: map['application_fee_amount'] == null
        ? null
        : (map['application_fee_amount'] as num).toInt(),
    applicationFeePercent: map['application_fee_percent'] == null
        ? null
        : (map['application_fee_percent'] as num).toDouble(),
    automaticTax: map['automatic_tax'] == null
        ? null
        : SessionAutomaticTax.fromJson(map['automatic_tax']),
    collectionMethod: map['collection_method'] == null
        ? null
        : InvoiceCollectionMethod.fromJson(map['collection_method']),
    customer: map['customer'] == null ? null : (map['customer'] 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(),
    expand: map['expand'] == null
        ? null
        : (map['expand'] as List<Object?>)
            .map((el) => (el as String))
            .toList(),
    expiresAt: map['expires_at'] == null
        ? null
        : DateTime.fromMillisecondsSinceEpoch(
            (map['expires_at'] as int).toInt()),
    footer: map['footer'] == null ? null : (map['footer'] as String),
    header: map['header'] == null ? null : (map['header'] as String),
    invoiceSettings: map['invoice_settings'] == null
        ? null
        : QuoteInvoiceSettings.fromJson(map['invoice_settings']),
    lineItems: map['line_items'] == null
        ? null
        : (map['line_items'] as List<Object?>)
            .map((el) => QuoteUpdateOptionsLineItemsItem.fromJson(el))
            .toList(),
    metadata: map['metadata'] == null
        ? null
        : (map['metadata'] as Map).cast<String, Object?>().map((
              key,
              value,
            ) =>
                MapEntry(
                  key,
                  (value as String),
                )),
    onBehalfOf:
        map['on_behalf_of'] == null ? null : (map['on_behalf_of'] as String),
    subscriptionData: map['subscription_data'] == null
        ? null
        : QuoteUpdateOptionsSubscriptionData.fromJson(
            map['subscription_data']),
    transferData: map['transfer_data'] == null
        ? null
        : QuoteCreateOptionsTransferData.fromJson(map['transfer_data']),
  );
}