Class: Whatsapp::Webhook::SmbMessageEchoes

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

Overview

Messages sent via the WhatsApp Business App or a linked device, echoed back so a Cloud API integration stays in sync with what the business itself sent.

Best-effort schema: Meta's public docs describe this field in one line with no published JSON example, but do state these mirror the standard inbound messages shape — hence reusing Message.deserialize here. The exact key name (message_echoes) is a best-effort guess; validate against a real payload before relying on it 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(messaging_product:, metadata:, message_echoes:) ⇒ SmbMessageEchoes

Returns a new instance of SmbMessageEchoes.



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

def initialize(messaging_product:, metadata:, message_echoes:)
  @messaging_product = messaging_product
  @metadata = 
  @message_echoes = message_echoes
end

Instance Attribute Details

#message_echoesArray<Message::Base>

Returns:



25
26
27
# File 'lib/ruby/whatsapp/webhook/smb_message_echoes.rb', line 25

def message_echoes
  @message_echoes
end

#messaging_productString?

Returns:

  • (String, nil)


17
18
19
# File 'lib/ruby/whatsapp/webhook/smb_message_echoes.rb', line 17

def messaging_product
  @messaging_product
end

#metadataMetadata?

Returns:



21
22
23
# File 'lib/ruby/whatsapp/webhook/smb_message_echoes.rb', line 21

def 
  @metadata
end

Class Method Details

.deserialize(data) ⇒ SmbMessageEchoes

Parameters:

  • data (Hash)

    The raw value hash.

Returns:



36
37
38
39
40
41
42
43
44
# File 'lib/ruby/whatsapp/webhook/smb_message_echoes.rb', line 36

def deserialize(data)
  data ||= {}

  new(
    messaging_product: data["messaging_product"],
    metadata: data["metadata"] ? Metadata.deserialize(data["metadata"]) : nil,
    message_echoes: Array(data["message_echoes"]).map { |echo_data| Message.deserialize(echo_data) }
  )
end