Class: UspsApi::AddressesAddress
- Defined in:
- lib/usps_api/models/addresses_address.rb
Overview
Address fields standard to all locations.
Instance Attribute Summary collapse
-
#city_abbreviation ⇒ String
This is the abbreviation of the city name for the address.
-
#secondary_address ⇒ String
The secondary unit designator, such as apartment(APT) or suite(STE) number, defining the exact location of the address within a building.
-
#street_address ⇒ String
The number of a building along with the name of the road or street on which it is located.
-
#street_address_abbreviation ⇒ String
This is the abbreviation of the primary street address line for the address.
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(street_address: SKIP, street_address_abbreviation: SKIP, secondary_address: SKIP, city_abbreviation: SKIP, additional_properties: nil) ⇒ AddressesAddress
constructor
A new instance of AddressesAddress.
-
#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(street_address: SKIP, street_address_abbreviation: SKIP, secondary_address: SKIP, city_abbreviation: SKIP, additional_properties: nil) ⇒ AddressesAddress
Returns a new instance of AddressesAddress.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/usps_api/models/addresses_address.rb', line 58 def initialize(street_address: SKIP, street_address_abbreviation: SKIP, secondary_address: SKIP, city_abbreviation: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @street_address = street_address unless street_address == SKIP unless street_address_abbreviation == SKIP @street_address_abbreviation = street_address_abbreviation end @secondary_address = secondary_address unless secondary_address == SKIP @city_abbreviation = city_abbreviation unless city_abbreviation == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#city_abbreviation ⇒ String
This is the abbreviation of the city name for the address.
31 32 33 |
# File 'lib/usps_api/models/addresses_address.rb', line 31 def city_abbreviation @city_abbreviation end |
#secondary_address ⇒ String
The secondary unit designator, such as apartment(APT) or suite(STE) number, defining the exact location of the address within a building. For more information please see [Postal Explorer](pe.usps.com/text/pub28/28c2_003.htm).
27 28 29 |
# File 'lib/usps_api/models/addresses_address.rb', line 27 def secondary_address @secondary_address end |
#street_address ⇒ String
The number of a building along with the name of the road or street on which it is located.
15 16 17 |
# File 'lib/usps_api/models/addresses_address.rb', line 15 def street_address @street_address end |
#street_address_abbreviation ⇒ String
This is the abbreviation of the primary street address line for the address.
20 21 22 |
# File 'lib/usps_api/models/addresses_address.rb', line 20 def street_address_abbreviation @street_address_abbreviation end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/usps_api/models/addresses_address.rb', line 75 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. street_address = hash.key?('streetAddress') ? hash['streetAddress'] : SKIP street_address_abbreviation = hash.key?('streetAddressAbbreviation') ? hash['streetAddressAbbreviation'] : SKIP secondary_address = hash.key?('secondaryAddress') ? hash['secondaryAddress'] : SKIP city_abbreviation = hash.key?('cityAbbreviation') ? hash['cityAbbreviation'] : 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. AddressesAddress.new(street_address: street_address, street_address_abbreviation: street_address_abbreviation, secondary_address: secondary_address, city_abbreviation: city_abbreviation, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
34 35 36 37 38 39 40 41 |
# File 'lib/usps_api/models/addresses_address.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['street_address'] = 'streetAddress' @_hash['street_address_abbreviation'] = 'streetAddressAbbreviation' @_hash['secondary_address'] = 'secondaryAddress' @_hash['city_abbreviation'] = 'cityAbbreviation' @_hash end |
.nullables ⇒ Object
An array for nullable fields
54 55 56 |
# File 'lib/usps_api/models/addresses_address.rb', line 54 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 47 48 49 50 51 |
# File 'lib/usps_api/models/addresses_address.rb', line 44 def self.optionals %w[ street_address street_address_abbreviation secondary_address city_abbreviation ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
112 113 114 115 116 117 118 |
# File 'lib/usps_api/models/addresses_address.rb', line 112 def inspect class_name = self.class.name.split('::').last "<#{class_name} street_address: #{@street_address.inspect}, street_address_abbreviation:"\ " #{@street_address_abbreviation.inspect}, secondary_address: #{@secondary_address.inspect},"\ " city_abbreviation: #{@city_abbreviation.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
103 104 105 106 107 108 109 |
# File 'lib/usps_api/models/addresses_address.rb', line 103 def to_s class_name = self.class.name.split('::').last "<#{class_name} street_address: #{@street_address}, street_address_abbreviation:"\ " #{@street_address_abbreviation}, secondary_address: #{@secondary_address},"\ " city_abbreviation: #{@city_abbreviation}, additional_properties:"\ " #{@additional_properties}>" end |