Class: Whatsapp::Webhook::Contact

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

Overview

A value-level contacts[] entry — identifies the WhatsApp user tied to a notification (distinct from Message::Contacts, the inbound "share a contact card" message type, which has its own richer shape).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile_name:, wa_id:) ⇒ Contact

Returns a new instance of Contact.



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

def initialize(profile_name:, wa_id:)
  @profile_name = profile_name
  @wa_id = wa_id
end

Instance Attribute Details

#profile_nameString?

Returns:

  • (String, nil)


11
12
13
# File 'lib/ruby/whatsapp/webhook/contact.rb', line 11

def profile_name
  @profile_name
end

#wa_idString?

Returns:

  • (String, nil)


15
16
17
# File 'lib/ruby/whatsapp/webhook/contact.rb', line 15

def wa_id
  @wa_id
end

Class Method Details

.deserialize(data) ⇒ Contact

Parameters:

  • data (Hash)

    A raw contacts[] entry.

Returns:



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

def deserialize(data)
  data ||= {}

  new(
    profile_name: data.dig("profile", "name"),
    wa_id: data["wa_id"]
  )
end