PlanCreateOptions.fromJson constructor
PlanCreateOptions.fromJson(
- Object? json
Implementation
factory PlanCreateOptions.fromJson(Object? json) {
final map = (json as Map).cast<String, Object?>();
return PlanCreateOptions(
active: map['active'] == null ? null : (map['active'] as bool),
aggregateUsage: map['aggregate_usage'] == null
? null
: PlanAggregateUsage.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: map['billing_scheme'] == null
? null
: InvoiceitemPlanBillingScheme.fromJson(map['billing_scheme']),
currency: (map['currency'] as String),
expand: map['expand'] == null
? null
: (map['expand'] as List<Object?>)
.map((el) => (el as String))
.toList(),
id: map['id'] == null ? null : (map['id'] as String),
interval: InvoiceitemPlanInterval.fromJson(map['interval']),
intervalCount: map['interval_count'] == null
? null
: (map['interval_count'] as num).toInt(),
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 : PlanProduct.fromJson(map['product']),
tiers: map['tiers'] == null
? null
: (map['tiers'] as List<Object?>)
.map((el) => PlanTiersItem.fromJson(el))
.toList(),
tiersMode: map['tiers_mode'] == null
? null
: PlanTiersMode.fromJson(map['tiers_mode']),
transformUsage: map['transform_usage'] == null
? null
: TransformUsage.fromJson(map['transform_usage']),
trialPeriodDays: map['trial_period_days'] == null
? null
: (map['trial_period_days'] as num).toInt(),
usageType: map['usage_type'] == null
? null
: InvoiceitemPlanUsageType.fromJson(map['usage_type']),
);
}