Class: WhatsAppCloudApi::Name
- Defined in:
- lib/whats_app_cloud_api/models/name.rb
Overview
Name Model.
Instance Attribute Summary collapse
-
#first_name ⇒ String
Full name, as it normally appears.
-
#formatted_name ⇒ String
Full name, as it normally appears.
-
#last_name ⇒ String
Full name, as it normally appears.
-
#middle_name ⇒ String
Full name, as it normally appears.
-
#prefix ⇒ String
Full name, as it normally appears.
-
#suffix ⇒ String
Full name, as it normally appears.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(formatted_name = nil, first_name = nil, last_name = nil, middle_name = nil, suffix = nil, prefix = nil) ⇒ Name
constructor
A new instance of Name.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
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_name ⇒ String
Full name, as it normally appears.
18 19 20 |
# File 'lib/whats_app_cloud_api/models/name.rb', line 18 def first_name @first_name end |
#formatted_name ⇒ String
Full name, as it normally appears.
14 15 16 |
# File 'lib/whats_app_cloud_api/models/name.rb', line 14 def formatted_name @formatted_name end |
#last_name ⇒ String
Full name, as it normally appears.
22 23 24 |
# File 'lib/whats_app_cloud_api/models/name.rb', line 22 def last_name @last_name end |
#middle_name ⇒ String
Full name, as it normally appears.
26 27 28 |
# File 'lib/whats_app_cloud_api/models/name.rb', line 26 def middle_name @middle_name end |
#prefix ⇒ String
Full name, as it normally appears.
34 35 36 |
# File 'lib/whats_app_cloud_api/models/name.rb', line 34 def prefix @prefix end |
#suffix ⇒ String
Full name, as it normally appears.
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 |
.names ⇒ Object
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
#nullables ⇒ Object
An array for nullable fields
60 61 62 |
# File 'lib/whats_app_cloud_api/models/name.rb', line 60 def nullables [] end |
#optionals ⇒ Object
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 |