ShippingRate.fromJson constructor

ShippingRate.fromJson(
  1. Object? json
)

Implementation

factory ShippingRate.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return ShippingRate(
    active: (map['active'] as bool),
    created:
        DateTime.fromMillisecondsSinceEpoch((map['created'] as int).toInt()),
    deliveryEstimate: map['delivery_estimate'] == null
        ? null
        : ShippingRateDeliveryEstimate.fromJson(map['delivery_estimate']),
    displayName:
        map['display_name'] == null ? null : (map['display_name'] as String),
    fixedAmount: map['fixed_amount'] == null
        ? null
        : ShippingRateFixedAmount.fromJson(map['fixed_amount']),
    id: (map['id'] as String),
    livemode: (map['livemode'] as bool),
    metadata: (map['metadata'] as Map).cast<String, Object?>().map((
          key,
          value,
        ) =>
            MapEntry(
              key,
              (value as String),
            )),
    taxBehavior: map['tax_behavior'] == null
        ? null
        : CurrencyOptionTaxBehavior.fromJson(map['tax_behavior']),
    taxCode: map['tax_code'] == null
        ? null
        : TaxCodeOrId.fromJson(map['tax_code']),
  );
}