class CloudmersiveValidateApiClient::NormalizeAddressResponse
Result of validating a street address
Attributes
The name of the building, house or structure if applicable, such as "Cloudmersive Building 2". This will often by null.
The city of the address.
Country of the address, if present in the address. If not included in the address it will be null.
Two-letter ISO 3166-1 country code
If the address is valid, the degrees latitude of the validated address, null otherwise
If the address is valid, the degrees longitude of the validated address, null otherwise
The postal code or zip code of the address.
The state or province of the address.
The name of the street or road of the address. For example, in the address "1600 Pennsylvania Avenue NW" the street number would be "Pennsylvania Avenue NW".
The street number or house number of the address. For example, in the address "1600 Pennsylvania Avenue NW" the street number would be "1600". This value will typically be populated for most addresses.
True if the address is valid, false otherwise
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 52 def self.attribute_map { :'valid_address' => :'ValidAddress', :'building' => :'Building', :'street_number' => :'StreetNumber', :'street' => :'Street', :'city' => :'City', :'state_or_province' => :'StateOrProvince', :'postal_code' => :'PostalCode', :'country_full_name' => :'CountryFullName', :'iso_two_letter_code' => :'ISOTwoLetterCode', :'latitude' => :'Latitude', :'longitude' => :'Longitude' } end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 87 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'ValidAddress') self.valid_address = attributes[:'ValidAddress'] end if attributes.has_key?(:'Building') self.building = attributes[:'Building'] end if attributes.has_key?(:'StreetNumber') self.street_number = attributes[:'StreetNumber'] end if attributes.has_key?(:'Street') self.street = attributes[:'Street'] end if attributes.has_key?(:'City') self.city = attributes[:'City'] end if attributes.has_key?(:'StateOrProvince') self.state_or_province = attributes[:'StateOrProvince'] end if attributes.has_key?(:'PostalCode') self.postal_code = attributes[:'PostalCode'] end if attributes.has_key?(:'CountryFullName') self.country_full_name = attributes[:'CountryFullName'] end if attributes.has_key?(:'ISOTwoLetterCode') self.iso_two_letter_code = attributes[:'ISOTwoLetterCode'] end if attributes.has_key?(:'Latitude') self.latitude = attributes[:'Latitude'] end if attributes.has_key?(:'Longitude') self.longitude = attributes[:'Longitude'] end end
Attribute type mapping.
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 69 def self.swagger_types { :'valid_address' => :'BOOLEAN', :'building' => :'String', :'street_number' => :'String', :'street' => :'String', :'city' => :'String', :'state_or_province' => :'String', :'postal_code' => :'String', :'country_full_name' => :'String', :'iso_two_letter_code' => :'String', :'latitude' => :'Float', :'longitude' => :'Float' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 153 def ==(o) return true if self.equal?(o) self.class == o.class && valid_address == o.valid_address && building == o.building && street_number == o.street_number && street == o.street && city == o.city && state_or_province == o.state_or_province && postal_code == o.postal_code && country_full_name == o.country_full_name && iso_two_letter_code == o.iso_two_letter_code && latitude == o.latitude && longitude == o.longitude end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 205 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = CloudmersiveValidateApiClient.const_get(type).new temp_model.build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 271 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 184 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
@see the `==` method @param [Object] Object to be compared
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 171 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Fixnum] Hash code
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 177 def hash [valid_address, building, street_number, street, city, state_or_province, postal_code, country_full_name, iso_two_letter_code, latitude, longitude].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 140 def list_invalid_properties invalid_properties = Array.new invalid_properties end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 257 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 245 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/cloudmersive-validate-api-client/models/normalize_address_response.rb, line 147 def valid? true end