Class: Whatsapp::Webhook::AutomaticEvents

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/whatsapp/webhook/automatic_events.rb

Overview

Purchase or lead event detection from Click to WhatsApp ad conversations.

Best-effort schema: Meta's public docs describe this field in one line with no published JSON example; event_data's nested shape isn't confidently typeable from that description alone, so it's kept as a raw hash rather than guessing further. Validate against a real payload before relying on this in production. Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/webhooks/overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_type:, message_id:, event_data:) ⇒ AutomaticEvents

Returns a new instance of AutomaticEvents.



26
27
28
29
30
# File 'lib/ruby/whatsapp/webhook/automatic_events.rb', line 26

def initialize(event_type:, message_id:, event_data:)
  @event_type = event_type
  @message_id = message_id
  @event_data = event_data
end

Instance Attribute Details

#event_dataHash

Returns:

  • (Hash)


24
25
26
# File 'lib/ruby/whatsapp/webhook/automatic_events.rb', line 24

def event_data
  @event_data
end

#event_typeString?

Returns e.g. "purchase", "lead".

Returns:

  • (String, nil)

    e.g. "purchase", "lead".



16
17
18
# File 'lib/ruby/whatsapp/webhook/automatic_events.rb', line 16

def event_type
  @event_type
end

#message_idString?

Returns:

  • (String, nil)


20
21
22
# File 'lib/ruby/whatsapp/webhook/automatic_events.rb', line 20

def message_id
  @message_id
end

Class Method Details

.deserialize(data) ⇒ AutomaticEvents

Parameters:

  • data (Hash)

    The raw value hash.

Returns:



35
36
37
38
39
# File 'lib/ruby/whatsapp/webhook/automatic_events.rb', line 35

def deserialize(data)
  data ||= {}

  new(event_type: data["event_type"], message_id: data["message_id"], event_data: data["event_data"] || {})
end