Class: WhatsAppCloudApi::Address
- Defined in:
- lib/whats_app_cloud_api/models/address.rb
Overview
Address Model.
Instance Attribute Summary collapse
-
#city ⇒ String
City name.
-
#country ⇒ String
Full country name.
-
#country_code ⇒ String
Two-letter country abbreviation.
-
#state ⇒ String
State abbreviation.
-
#street ⇒ String
Street number and name.
-
#type ⇒ PersonalInformationTypeEnum
Two-letter country abbreviation.
-
#zip ⇒ String
ZIP code.
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(street = nil, city = nil, state = nil, zip = nil, country = nil, country_code = nil, type = nil) ⇒ Address
constructor
A new instance of Address.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
Constructor Details
#initialize(street = nil, city = nil, state = nil, zip = nil, country = nil, country_code = nil, type = nil) ⇒ Address
Returns a new instance of Address.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 71 def initialize(street = nil, city = nil, state = nil, zip = nil, country = nil, country_code = nil, type = nil) @street = street unless street == SKIP @city = city unless city == SKIP @state = state unless state == SKIP @zip = zip unless zip == SKIP @country = country unless country == SKIP @country_code = country_code unless country_code == SKIP @type = type unless type == SKIP end |
Instance Attribute Details
#city ⇒ String
City name.
18 19 20 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 18 def city @city end |
#country ⇒ String
Full country name.
30 31 32 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 30 def country @country end |
#country_code ⇒ String
Two-letter country abbreviation.
34 35 36 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 34 def country_code @country_code end |
#state ⇒ String
State abbreviation.
22 23 24 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 22 def state @state end |
#street ⇒ String
Street number and name
14 15 16 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 14 def street @street end |
#type ⇒ PersonalInformationTypeEnum
Two-letter country abbreviation.
38 39 40 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 38 def type @type end |
#zip ⇒ String
ZIP code.
26 27 28 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 26 def zip @zip end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 88 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. street = hash.key?('street') ? hash['street'] : SKIP city = hash.key?('city') ? hash['city'] : SKIP state = hash.key?('state') ? hash['state'] : SKIP zip = hash.key?('zip') ? hash['zip'] : SKIP country = hash.key?('country') ? hash['country'] : SKIP country_code = hash.key?('country_code') ? hash['country_code'] : SKIP type = hash.key?('type') ? hash['type'] : SKIP # Create object from extracted values. Address.new(street, city, state, zip, country, country_code, type) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['street'] = 'street' @_hash['city'] = 'city' @_hash['state'] = 'state' @_hash['zip'] = 'zip' @_hash['country'] = 'country' @_hash['country_code'] = 'country_code' @_hash['type'] = 'type' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
67 68 69 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 67 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/whats_app_cloud_api/models/address.rb', line 54 def optionals %w[ street city state zip country country_code type ] end |