StripeEvent.fromJson constructor

StripeEvent.fromJson(
  1. Object? json
)

Implementation

factory StripeEvent.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  final type = (map['type'] as String);
  final factory = $mapping[type];
  if (factory == null) {
    throw ArgumentError('Unknown type of StripeEvent: "$type"');
  }
  final data = switch (map) {
    {'data': {'object': _} && final data} => data,
    _ => throw ArgumentError('Unknown data structure for StripeEvent: $map'),
  };
  return factory(data);
}