SubscriptionItemCreateOptions.fromJson constructor

SubscriptionItemCreateOptions.fromJson(
  1. Object? json
)

Implementation

factory SubscriptionItemCreateOptions.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return SubscriptionItemCreateOptions(
    billingThresholds: map['billing_thresholds'] == null
        ? null
        : UpcomingSubscriptionItemsItemBillingThresholds.fromJson(
            map['billing_thresholds']),
    expand: map['expand'] == null
        ? null
        : (map['expand'] as List<Object?>)
            .map((el) => (el as String))
            .toList(),
    metadata: map['metadata'] == null
        ? null
        : (map['metadata'] as Map).cast<String, Object?>().map((
              key,
              value,
            ) =>
                MapEntry(
                  key,
                  (value as String),
                )),
    paymentBehavior: map['payment_behavior'] == null
        ? null
        : SubscriptionItemPaymentBehavior.fromJson(map['payment_behavior']),
    plan: map['plan'] == null ? null : (map['plan'] as String),
    price: map['price'] == null ? null : (map['price'] as String),
    priceData: map['price_data'] == null
        ? null
        : UpcomingSubscriptionItemsItemPriceData.fromJson(map['price_data']),
    prorationBehavior: map['proration_behavior'] == null
        ? null
        : PortalSubscriptionCancelProrationBehavior.fromJson(
            map['proration_behavior']),
    prorationDate: map['proration_date'] == null
        ? null
        : DateTime.fromMillisecondsSinceEpoch(
            (map['proration_date'] as int).toInt()),
    quantity:
        map['quantity'] == null ? null : (map['quantity'] as num).toInt(),
    subscription: (map['subscription'] as String),
    taxRates: map['tax_rates'] == null
        ? null
        : (map['tax_rates'] as List<Object?>)
            .map((el) => (el as String))
            .toList(),
  );
}