Class: Whatsapp::Webhook::Metadata

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

Overview

The metadata object present on most webhook value payloads, identifying which of your business phone numbers the notification is about.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(display_phone_number:, phone_number_id:) ⇒ Metadata

Returns a new instance of Metadata.



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

def initialize(display_phone_number:, phone_number_id:)
  @display_phone_number = display_phone_number
  @phone_number_id = phone_number_id
end

Instance Attribute Details

#display_phone_numberString?

Returns:

  • (String, nil)


10
11
12
# File 'lib/ruby/whatsapp/webhook/metadata.rb', line 10

def display_phone_number
  @display_phone_number
end

#phone_number_idString?

Returns:

  • (String, nil)


14
15
16
# File 'lib/ruby/whatsapp/webhook/metadata.rb', line 14

def phone_number_id
  @phone_number_id
end

Class Method Details

.deserialize(data) ⇒ Metadata

Parameters:

  • data (Hash)

    The raw metadata hash.

Returns:



24
25
26
27
28
29
30
31
# File 'lib/ruby/whatsapp/webhook/metadata.rb', line 24

def deserialize(data)
  data ||= {}

  new(
    display_phone_number: data["display_phone_number"],
    phone_number_id: data["phone_number_id"]
  )
end