Module: Mailtrap::EmailLogEventDetails
- Defined in:
- lib/mailtrap/email_log_event_details.rb
Overview
Type-specific event detail structs for EmailLogEvent. Use event_type to determine which details schema applies.
Defined Under Namespace
Classes: Bounce, Click, Delivery, Open, Reject, Spam, Unsubscribe
Constant Summary collapse
- DETAIL_STRUCTS =
{ 'delivery' => Delivery, 'open' => Open, 'click' => Click, 'soft_bounce' => Bounce, 'bounce' => Bounce, 'spam' => Spam, 'unsubscribe' => Unsubscribe, 'suspension' => Reject, 'reject' => Reject }.freeze
Class Method Summary collapse
-
.build(event_type, hash) ⇒ Delivery, ...
Builds the appropriate detail struct from API response.
Class Method Details
.build(event_type, hash) ⇒ Delivery, ...
Builds the appropriate detail struct from API response.
53 54 55 56 57 58 59 |
# File 'lib/mailtrap/email_log_event_details.rb', line 53 def self.build(event_type, hash) struct_class = DETAIL_STRUCTS[event_type.to_s] raise ArgumentError, "Unknown event_type: #{event_type.inspect}" unless struct_class attrs = hash.slice(*struct_class.members) struct_class.new(**attrs) end |