Class: WhatsAppCloudApi::Name

Inherits:
BaseModel show all
Defined in:
lib/whats_app_cloud_api/models/name.rb

Overview

Name Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

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

Returns a new instance of Name.


64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/whats_app_cloud_api/models/name.rb', line 64

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

Instance Attribute Details

#first_nameString

Full name, as it normally appears.

Returns:

  • (String)

18
19
20
# File 'lib/whats_app_cloud_api/models/name.rb', line 18

def first_name
  @first_name
end

#formatted_nameString

Full name, as it normally appears.

Returns:

  • (String)

14
15
16
# File 'lib/whats_app_cloud_api/models/name.rb', line 14

def formatted_name
  @formatted_name
end

#last_nameString

Full name, as it normally appears.

Returns:

  • (String)

22
23
24
# File 'lib/whats_app_cloud_api/models/name.rb', line 22

def last_name
  @last_name
end

#middle_nameString

Full name, as it normally appears.

Returns:

  • (String)

26
27
28
# File 'lib/whats_app_cloud_api/models/name.rb', line 26

def middle_name
  @middle_name
end

#prefixString

Full name, as it normally appears.

Returns:

  • (String)

34
35
36
# File 'lib/whats_app_cloud_api/models/name.rb', line 34

def prefix
  @prefix
end

#suffixString

Full name, as it normally appears.

Returns:

  • (String)

30
31
32
# File 'lib/whats_app_cloud_api/models/name.rb', line 30

def suffix
  @suffix
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/whats_app_cloud_api/models/name.rb', line 79

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  formatted_name =
    hash.key?('formatted_name') ? hash['formatted_name'] : SKIP
  first_name = hash.key?('first_name') ? hash['first_name'] : SKIP
  last_name = hash.key?('last_name') ? hash['last_name'] : SKIP
  middle_name = hash.key?('middle_name') ? hash['middle_name'] : SKIP
  suffix = hash.key?('suffix') ? hash['suffix'] : SKIP
  prefix = hash.key?('prefix') ? hash['prefix'] : SKIP

  # Create object from extracted values.
  Name.new(formatted_name,
           first_name,
           last_name,
           middle_name,
           suffix,
           prefix)
end

.namesObject

A mapping from model property names to API property names.


37
38
39
40
41
42
43
44
45
46
# File 'lib/whats_app_cloud_api/models/name.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['formatted_name'] = 'formatted_name'
  @_hash['first_name'] = 'first_name'
  @_hash['last_name'] = 'last_name'
  @_hash['middle_name'] = 'middle_name'
  @_hash['suffix'] = 'suffix'
  @_hash['prefix'] = 'prefix'
  @_hash
end

Instance Method Details

#nullablesObject

An array for nullable fields


60
61
62
# File 'lib/whats_app_cloud_api/models/name.rb', line 60

def nullables
  []
end

#optionalsObject

An array for optional fields


49
50
51
52
53
54
55
56
57
# File 'lib/whats_app_cloud_api/models/name.rb', line 49

def optionals
  %w[
    first_name
    last_name
    middle_name
    suffix
    prefix
  ]
end