Class: WalmartApIs::Address
- Defined in:
- lib/walmart_ap_is/models/address.rb
Overview
Specific details to identify a place.
Instance Attribute Summary collapse
-
#address_line1 ⇒ String
Street address information.
-
#address_line2 ⇒ String
Additional street address information.
-
#city ⇒ String
The city.
-
#company_name ⇒ String
The name of the business.
-
#country_code ⇒ String
The country code in two-character ISO 3166-1 alpha-2 format.
-
#district_or_county ⇒ String
The district or county.
-
#email ⇒ String
The email address.
-
#name ⇒ String
The name of the individual who is the primary contact.
-
#phone_number ⇒ String
The phone number.
-
#postal_code ⇒ String
The postal code.
-
#state_or_province_code ⇒ String
The state or province 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.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(address_line1:, city:, country_code:, name:, postal_code:, address_line2: SKIP, company_name: SKIP, district_or_county: SKIP, email: SKIP, phone_number: SKIP, state_or_province_code: SKIP, additional_properties: nil) ⇒ Address
constructor
A new instance of Address.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(address_line1:, city:, country_code:, name:, postal_code:, address_line2: SKIP, company_name: SKIP, district_or_county: SKIP, email: SKIP, phone_number: SKIP, state_or_province_code: SKIP, additional_properties: nil) ⇒ Address
Returns a new instance of Address.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/walmart_ap_is/models/address.rb', line 90 def initialize(address_line1:, city:, country_code:, name:, postal_code:, address_line2: SKIP, company_name: SKIP, district_or_county: SKIP, email: SKIP, phone_number: SKIP, state_or_province_code: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @address_line1 = address_line1 @address_line2 = address_line2 unless address_line2 == SKIP @city = city @company_name = company_name unless company_name == SKIP @country_code = country_code @district_or_county = district_or_county unless district_or_county == SKIP @email = email unless email == SKIP @name = name @phone_number = phone_number unless phone_number == SKIP @postal_code = postal_code @state_or_province_code = state_or_province_code unless state_or_province_code == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#address_line1 ⇒ String
Street address information.
14 15 16 |
# File 'lib/walmart_ap_is/models/address.rb', line 14 def address_line1 @address_line1 end |
#address_line2 ⇒ String
Additional street address information.
18 19 20 |
# File 'lib/walmart_ap_is/models/address.rb', line 18 def address_line2 @address_line2 end |
#city ⇒ String
The city.
22 23 24 |
# File 'lib/walmart_ap_is/models/address.rb', line 22 def city @city end |
#company_name ⇒ String
The name of the business.
26 27 28 |
# File 'lib/walmart_ap_is/models/address.rb', line 26 def company_name @company_name end |
#country_code ⇒ String
The country code in two-character ISO 3166-1 alpha-2 format.
30 31 32 |
# File 'lib/walmart_ap_is/models/address.rb', line 30 def country_code @country_code end |
#district_or_county ⇒ String
The district or county.
34 35 36 |
# File 'lib/walmart_ap_is/models/address.rb', line 34 def district_or_county @district_or_county end |
#email ⇒ String
The email address.
38 39 40 |
# File 'lib/walmart_ap_is/models/address.rb', line 38 def email @email end |
#name ⇒ String
The name of the individual who is the primary contact.
42 43 44 |
# File 'lib/walmart_ap_is/models/address.rb', line 42 def name @name end |
#phone_number ⇒ String
The phone number.
46 47 48 |
# File 'lib/walmart_ap_is/models/address.rb', line 46 def phone_number @phone_number end |
#postal_code ⇒ String
The postal code.
50 51 52 |
# File 'lib/walmart_ap_is/models/address.rb', line 50 def postal_code @postal_code end |
#state_or_province_code ⇒ String
The state or province code.
54 55 56 |
# File 'lib/walmart_ap_is/models/address.rb', line 54 def state_or_province_code @state_or_province_code end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/walmart_ap_is/models/address.rb', line 112 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. address_line1 = hash.key?('addressLine1') ? hash['addressLine1'] : nil city = hash.key?('city') ? hash['city'] : nil country_code = hash.key?('countryCode') ? hash['countryCode'] : nil name = hash.key?('name') ? hash['name'] : nil postal_code = hash.key?('postalCode') ? hash['postalCode'] : nil address_line2 = hash.key?('addressLine2') ? hash['addressLine2'] : SKIP company_name = hash.key?('companyName') ? hash['companyName'] : SKIP district_or_county = hash.key?('districtOrCounty') ? hash['districtOrCounty'] : SKIP email = hash.key?('email') ? hash['email'] : SKIP phone_number = hash.key?('phoneNumber') ? hash['phoneNumber'] : SKIP state_or_province_code = hash.key?('stateOrProvinceCode') ? hash['stateOrProvinceCode'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. Address.new(address_line1: address_line1, city: city, country_code: country_code, name: name, postal_code: postal_code, address_line2: address_line2, company_name: company_name, district_or_county: district_or_county, email: email, phone_number: phone_number, state_or_province_code: state_or_province_code, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/walmart_ap_is/models/address.rb', line 57 def self.names @_hash = {} if @_hash.nil? @_hash['address_line1'] = 'addressLine1' @_hash['address_line2'] = 'addressLine2' @_hash['city'] = 'city' @_hash['company_name'] = 'companyName' @_hash['country_code'] = 'countryCode' @_hash['district_or_county'] = 'districtOrCounty' @_hash['email'] = 'email' @_hash['name'] = 'name' @_hash['phone_number'] = 'phoneNumber' @_hash['postal_code'] = 'postalCode' @_hash['state_or_province_code'] = 'stateOrProvinceCode' @_hash end |
.nullables ⇒ Object
An array for nullable fields
86 87 88 |
# File 'lib/walmart_ap_is/models/address.rb', line 86 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/walmart_ap_is/models/address.rb', line 74 def self.optionals %w[ address_line2 company_name district_or_county email phone_number state_or_province_code ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
163 164 165 166 167 168 169 170 171 172 |
# File 'lib/walmart_ap_is/models/address.rb', line 163 def inspect class_name = self.class.name.split('::').last "<#{class_name} address_line1: #{@address_line1.inspect}, address_line2:"\ " #{@address_line2.inspect}, city: #{@city.inspect}, company_name: #{@company_name.inspect},"\ " country_code: #{@country_code.inspect}, district_or_county:"\ " #{@district_or_county.inspect}, email: #{@email.inspect}, name: #{@name.inspect},"\ " phone_number: #{@phone_number.inspect}, postal_code: #{@postal_code.inspect},"\ " state_or_province_code: #{@state_or_province_code.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
153 154 155 156 157 158 159 160 |
# File 'lib/walmart_ap_is/models/address.rb', line 153 def to_s class_name = self.class.name.split('::').last "<#{class_name} address_line1: #{@address_line1}, address_line2: #{@address_line2}, city:"\ " #{@city}, company_name: #{@company_name}, country_code: #{@country_code},"\ " district_or_county: #{@district_or_county}, email: #{@email}, name: #{@name},"\ " phone_number: #{@phone_number}, postal_code: #{@postal_code}, state_or_province_code:"\ " #{@state_or_province_code}, additional_properties: #{@additional_properties}>" end |