Class: WhatsAppCloudApi::Location
- Defined in:
- lib/whats_app_cloud_api/models/location.rb
Overview
Location Model.
Instance Attribute Summary collapse
-
#address ⇒ String
Address of the location.
-
#latitude ⇒ String
Latitude of the location.
-
#longitude ⇒ String
Longitude of the location.
-
#name ⇒ String
Name of the location.
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(latitude = nil, longitude = nil, name = nil, address = nil) ⇒ Location
constructor
A new instance of Location.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
Constructor Details
#initialize(latitude = nil, longitude = nil, name = nil, address = nil) ⇒ Location
Returns a new instance of Location.
51 52 53 54 55 56 57 58 59 |
# File 'lib/whats_app_cloud_api/models/location.rb', line 51 def initialize(latitude = nil, longitude = nil, name = nil, address = nil) @latitude = latitude unless latitude == SKIP @longitude = longitude unless longitude == SKIP @name = name unless name == SKIP @address = address unless address == SKIP end |
Instance Attribute Details
#address ⇒ String
Address of the location. Only displayed if name is present.
26 27 28 |
# File 'lib/whats_app_cloud_api/models/location.rb', line 26 def address @address end |
#latitude ⇒ String
Latitude of the location.
14 15 16 |
# File 'lib/whats_app_cloud_api/models/location.rb', line 14 def latitude @latitude end |
#longitude ⇒ String
Longitude of the location.
18 19 20 |
# File 'lib/whats_app_cloud_api/models/location.rb', line 18 def longitude @longitude end |
#name ⇒ String
Name of the location.
22 23 24 |
# File 'lib/whats_app_cloud_api/models/location.rb', line 22 def name @name end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/whats_app_cloud_api/models/location.rb', line 62 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. latitude = hash.key?('latitude') ? hash['latitude'] : SKIP longitude = hash.key?('longitude') ? hash['longitude'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP address = hash.key?('address') ? hash['address'] : SKIP # Create object from extracted values. Location.new(latitude, longitude, name, address) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/whats_app_cloud_api/models/location.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['latitude'] = 'latitude' @_hash['longitude'] = 'longitude' @_hash['name'] = 'name' @_hash['address'] = 'address' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
47 48 49 |
# File 'lib/whats_app_cloud_api/models/location.rb', line 47 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
39 40 41 42 43 44 |
# File 'lib/whats_app_cloud_api/models/location.rb', line 39 def optionals %w[ name address ] end |