Class: Whatsapp::Webhook::Message::Contacts::Phone

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/whatsapp/webhook/message/contacts/phone.rb

Overview

A phone number entry within an inbound contact card.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(phone:, type: nil, wa_id: nil) ⇒ Phone

Returns a new instance of Phone.



21
22
23
24
25
# File 'lib/ruby/whatsapp/webhook/message/contacts/phone.rb', line 21

def initialize(phone:, type: nil, wa_id: nil)
  @phone = phone
  @type = type
  @wa_id = wa_id
end

Instance Attribute Details

#phoneString?

Returns:

  • (String, nil)


11
12
13
# File 'lib/ruby/whatsapp/webhook/message/contacts/phone.rb', line 11

def phone
  @phone
end

#typeString?

Returns:

  • (String, nil)


15
16
17
# File 'lib/ruby/whatsapp/webhook/message/contacts/phone.rb', line 15

def type
  @type
end

#wa_idString?

Returns:

  • (String, nil)


19
20
21
# File 'lib/ruby/whatsapp/webhook/message/contacts/phone.rb', line 19

def wa_id
  @wa_id
end

Class Method Details

.deserialize(data) ⇒ Phone

Parameters:

  • data (Hash)

    A raw phones[] entry.

Returns:



30
31
32
33
34
# File 'lib/ruby/whatsapp/webhook/message/contacts/phone.rb', line 30

def deserialize(data)
  data ||= {}

  new(phone: data["phone"], type: data["type"], wa_id: data["wa_id"])
end