InvoiceitemPlan.fromJson constructor

InvoiceitemPlan.fromJson(
  1. Object? json
)

Implementation

factory InvoiceitemPlan.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return InvoiceitemPlan(
    active: (map['active'] as bool),
    aggregateUsage: map['aggregate_usage'] == null
        ? null
        : InvoiceitemPlanAggregateUsage.fromJson(map['aggregate_usage']),
    amount: map['amount'] == null ? null : (map['amount'] as num).toInt(),
    amountDecimal: map['amount_decimal'] == null
        ? null
        : (map['amount_decimal'] as String),
    billingScheme:
        InvoiceitemPlanBillingScheme.fromJson(map['billing_scheme']),
    created:
        DateTime.fromMillisecondsSinceEpoch((map['created'] as int).toInt()),
    currency: (map['currency'] as String),
    id: (map['id'] as String),
    interval: InvoiceitemPlanInterval.fromJson(map['interval']),
    intervalCount: (map['interval_count'] as num).toInt(),
    livemode: (map['livemode'] as bool),
    metadata: map['metadata'] == null
        ? null
        : (map['metadata'] as Map).cast<String, Object?>().map((
              key,
              value,
            ) =>
                MapEntry(
                  key,
                  (value as String),
                )),
    meter: map['meter'] == null ? null : (map['meter'] as String),
    nickname: map['nickname'] == null ? null : (map['nickname'] as String),
    product: map['product'] == null
        ? null
        : InvoiceitemPlanProductOrId.fromJson(map['product']),
    tiers: map['tiers'] == null
        ? null
        : (map['tiers'] as List<Object?>)
            .map((el) => PlanTier.fromJson(el))
            .toList(),
    tiersMode: map['tiers_mode'] == null
        ? null
        : InvoiceitemPlanTiersMode.fromJson(map['tiers_mode']),
    transformUsage: map['transform_usage'] == null
        ? null
        : InvoiceitemPlanTransformUsage.fromJson(map['transform_usage']),
    trialPeriodDays: map['trial_period_days'] == null
        ? null
        : (map['trial_period_days'] as num).toInt(),
    usageType: InvoiceitemPlanUsageType.fromJson(map['usage_type']),
  );
}