Class: WhatsAppCloudApi::PhoneObject

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/whats_app_cloud_api/models/phone_object.rb

Overview

PhoneObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

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

#phoneString

Automatically populated with the wa_id value as a formatted phone number.

Returns:

  • (String)


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

def phone
  @phone
end

#typePhoneTypeEnum

WhatsApp ID.

Returns:



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

def type
  @type
end

#wa_idString

WhatsApp ID.

Returns:

  • (String)


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

.namesObject

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

#nullablesObject

An array for nullable fields



43
44
45
# File 'lib/whats_app_cloud_api/models/phone_object.rb', line 43

def nullables
  []
end

#optionalsObject

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