Class: Bouncie::Webhook
- Inherits:
-
Object
- Object
- Bouncie::Webhook
- Defined in:
- lib/bouncie/webhook.rb
Overview
Class used for parsing webhooks into specific events.
Constant Summary collapse
- WEBHOOK_EVENTS_MAP =
{ 'connect' => Bouncie::DeviceEvents::ConnectEvent, 'disconnect' => Bouncie::DeviceEvents::DisconnectEvent, 'battery' => Bouncie::VehicleHealthEvents::BatteryEvent, 'mil' => Bouncie::VehicleHealthEvents::MilEvent, 'trip_data' => Bouncie::VehicleTripEvents::TripDataEvent, 'trip_end' => Bouncie::VehicleTripEvents::TripEndEvent, 'trip_metrics' => Bouncie::VehicleTripEvents::TripMetricsEvent, 'trip_start' => Bouncie::VehicleTripEvents::TripStartEvent }.freeze
Class Method Summary collapse
Class Method Details
.parse(data) ⇒ Object
26 27 28 29 30 |
# File 'lib/bouncie/webhook.rb', line 26 def self.parse(data) event_name = data[:event_type] || data[:eventType] || data['eventType'] || data['event_type'] event_klass = Bouncie::Webhook::WEBHOOK_EVENTS_MAP[event_name.underscore] event_klass.new(data) end |