Quote.fromJson constructor

Quote.fromJson(
  1. Object? json
)

Implementation

factory Quote.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return Quote(
    amountSubtotal: (map['amount_subtotal'] as num).toInt(),
    amountTotal: (map['amount_total'] as num).toInt(),
    application: map['application'] == null
        ? null
        : BillingPortalConfigurationApplicationOrId.fromJson(
            map['application']),
    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: QuotesResourceAutomaticTax.fromJson(map['automatic_tax']),
    collectionMethod:
        InvoiceCollectionMethod.fromJson(map['collection_method']),
    computed: QuotesResourceComputed.fromJson(map['computed']),
    created:
        DateTime.fromMillisecondsSinceEpoch((map['created'] as int).toInt()),
    currency: map['currency'] == null ? null : (map['currency'] as String),
    customer: map['customer'] == null
        ? null
        : BankAccountCustomerOrId.fromJson(map['customer']),
    defaultTaxRates: map['default_tax_rates'] == null
        ? null
        : (map['default_tax_rates'] as List<Object?>)
            .map((el) => TaxRateOrId.fromJson(el))
            .toList(),
    description:
        map['description'] == null ? null : (map['description'] as String),
    discounts: (map['discounts'] as List<Object?>)
        .map((el) => DiscountOrId.fromJson(el))
        .toList(),
    expiresAt: DateTime.fromMillisecondsSinceEpoch(
        (map['expires_at'] as int).toInt()),
    footer: map['footer'] == null ? null : (map['footer'] as String),
    fromQuote: map['from_quote'] == null
        ? null
        : QuoteFromQuote.fromJson(map['from_quote']),
    header: map['header'] == null ? null : (map['header'] as String),
    id: (map['id'] as String),
    invoice: map['invoice'] == null
        ? null
        : QuoteInvoiceOrId.fromJson(map['invoice']),
    invoiceSettings:
        InvoiceSettingQuoteSetting.fromJson(map['invoice_settings']),
    lineItems: map['line_items'] == null
        ? null
        : CheckoutSessionLineItems.fromJson(map['line_items']),
    livemode: (map['livemode'] as bool),
    metadata: (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
        : AccountOrId.fromJson(map['on_behalf_of']),
    status: QuoteStatus.fromJson(map['status']),
    statusTransitions:
        QuotesResourceStatusTransitions.fromJson(map['status_transitions']),
    subscription: map['subscription'] == null
        ? null
        : SubscriptionOrId.fromJson(map['subscription']),
    subscriptionData: QuotesResourceSubscriptionDataSubscriptionData.fromJson(
        map['subscription_data']),
    subscriptionSchedule: map['subscription_schedule'] == null
        ? null
        : SubscriptionScheduleOrId.fromJson(map['subscription_schedule']),
    testClock: map['test_clock'] == null
        ? null
        : TestHelpersTestClockOrId.fromJson(map['test_clock']),
    totalDetails: QuotesResourceTotalDetails.fromJson(map['total_details']),
    transferData: map['transfer_data'] == null
        ? null
        : QuoteTransferData.fromJson(map['transfer_data']),
  );
}