Class: WhatsAppCloudApi::PhoneObject
- Defined in:
- lib/whats_app_cloud_api/models/phone_object.rb
Overview
PhoneObject Model.
Instance Attribute Summary collapse
-
#phone ⇒ String
Automatically populated with the wa_id value as a formatted phone number.
-
#type ⇒ PhoneTypeEnum
WhatsApp ID.
-
#wa_id ⇒ String
WhatsApp ID.
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(phone = nil, wa_id = nil, type = nil) ⇒ PhoneObject
constructor
A new instance of PhoneObject.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
Constructor Details
#initialize(phone = nil, wa_id = nil, type = nil) ⇒ PhoneObject
Returns a new instance of PhoneObject.
47 48 49 50 51 52 53 |
# File 'lib/whats_app_cloud_api/models/phone_object.rb', line 47 def initialize(phone = nil, wa_id = nil, type = nil) @phone = phone unless phone == SKIP @wa_id = wa_id unless wa_id == SKIP @type = type unless type == SKIP end |
Instance Attribute Details
#phone ⇒ String
Automatically populated with the wa_id value as a formatted phone number.
14 15 16 |
# File 'lib/whats_app_cloud_api/models/phone_object.rb', line 14 def phone @phone end |
#type ⇒ PhoneTypeEnum
WhatsApp ID.
22 23 24 |
# File 'lib/whats_app_cloud_api/models/phone_object.rb', line 22 def type @type end |
#wa_id ⇒ String
WhatsApp ID.
18 19 20 |
# File 'lib/whats_app_cloud_api/models/phone_object.rb', line 18 def wa_id @wa_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/whats_app_cloud_api/models/phone_object.rb', line 56 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. phone = hash.key?('phone') ? hash['phone'] : SKIP wa_id = hash.key?('wa_id') ? hash['wa_id'] : SKIP type = hash.key?('type') ? hash['type'] : SKIP # Create object from extracted values. PhoneObject.new(phone, wa_id, type) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 |
# File 'lib/whats_app_cloud_api/models/phone_object.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['phone'] = 'phone' @_hash['wa_id'] = 'wa_id' @_hash['type'] = 'type' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
43 44 45 |
# File 'lib/whats_app_cloud_api/models/phone_object.rb', line 43 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
34 35 36 37 38 39 40 |
# File 'lib/whats_app_cloud_api/models/phone_object.rb', line 34 def optionals %w[ phone wa_id type ] end |