WebhookEndpoint.fromJson constructor

WebhookEndpoint.fromJson(
  1. Object? json
)

Implementation

factory WebhookEndpoint.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return WebhookEndpoint(
    apiVersion:
        map['api_version'] == null ? null : (map['api_version'] as String),
    application:
        map['application'] == null ? null : (map['application'] as String),
    created:
        DateTime.fromMillisecondsSinceEpoch((map['created'] as int).toInt()),
    description:
        map['description'] == null ? null : (map['description'] as String),
    enabledEvents: (map['enabled_events'] as List<Object?>)
        .map((el) => (el as String))
        .toList(),
    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),
            )),
    secret: map['secret'] == null ? null : (map['secret'] as String),
    status: (map['status'] as String),
    url: (map['url'] as String),
  );
}