Class: Whatsapp::Webhook::Message::Contacts::Name

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

Overview

The name component of an inbound contact card.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formatted_name:, first_name: nil, last_name: nil, middle_name: nil, prefix: nil, suffix: nil) ⇒ Name

Returns a new instance of Name.



33
34
35
36
37
38
39
40
# File 'lib/ruby/whatsapp/webhook/message/contacts/name.rb', line 33

def initialize(formatted_name:, first_name: nil, last_name: nil, middle_name: nil, prefix: nil, suffix: nil)
  @formatted_name = formatted_name
  @first_name = first_name
  @last_name = last_name
  @middle_name = middle_name
  @prefix = prefix
  @suffix = suffix
end

Instance Attribute Details

#first_nameString?

Returns:

  • (String, nil)


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

def first_name
  @first_name
end

#formatted_nameString?

Returns:

  • (String, nil)


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

def formatted_name
  @formatted_name
end

#last_nameString?

Returns:

  • (String, nil)


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

def last_name
  @last_name
end

#middle_nameString?

Returns:

  • (String, nil)


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

def middle_name
  @middle_name
end

#prefixString?

Returns:

  • (String, nil)


27
28
29
# File 'lib/ruby/whatsapp/webhook/message/contacts/name.rb', line 27

def prefix
  @prefix
end

#suffixString?

Returns:

  • (String, nil)


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

def suffix
  @suffix
end

Class Method Details

.deserialize(data) ⇒ Name

Parameters:

  • data (Hash)

    The raw name hash.

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ruby/whatsapp/webhook/message/contacts/name.rb', line 45

def deserialize(data)
  data ||= {}

  new(
    formatted_name: data["formatted_name"],
    first_name: data["first_name"],
    last_name: data["last_name"],
    middle_name: data["middle_name"],
    prefix: data["prefix"],
    suffix: data["suffix"]
  )
end