Class: UspsApi::ScanFormsDomesticAddress
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::ScanFormsDomesticAddress
- Defined in:
- lib/usps_api/models/scan_forms_domestic_address.rb
Overview
Address fields for US locations
Instance Attribute Summary collapse
-
#city ⇒ String
This is the city name of the address.
-
#city_abbreviation ⇒ String
This is the abbreviation of 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.
-
#state ⇒ String
This is two-character state code of the address.
-
#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 street address line for the address.
-
#urbanization ⇒ String
An area, sector, or residential development within a geographic area (typically used for addresses in Puerto Rico).
-
#zip_code ⇒ String
This is the 5-digit ZIP code.
-
#zip_plus4 ⇒ String
This is the ZIP+4 extension.
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, city: SKIP, state: SKIP, zip_code: SKIP, zip_plus4: SKIP, urbanization: SKIP, additional_properties: nil) ⇒ ScanFormsDomesticAddress
constructor
A new instance of ScanFormsDomesticAddress.
-
#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, city: SKIP, state: SKIP, zip_code: SKIP, zip_plus4: SKIP, urbanization: SKIP, additional_properties: nil) ⇒ ScanFormsDomesticAddress
Returns a new instance of ScanFormsDomesticAddress.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 88 def initialize(street_address: SKIP, street_address_abbreviation: SKIP, secondary_address: SKIP, city_abbreviation: SKIP, city: SKIP, state: SKIP, zip_code: SKIP, zip_plus4: SKIP, urbanization: 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 @city = city unless city == SKIP @state = state unless state == SKIP @zip_code = zip_code unless zip_code == SKIP @zip_plus4 = zip_plus4 unless zip_plus4 == SKIP @urbanization = urbanization unless urbanization == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#city ⇒ String
This is the city name of the address.
34 35 36 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 34 def city @city end |
#city_abbreviation ⇒ String
This is the abbreviation of city name for the address.
30 31 32 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 30 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).
26 27 28 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 26 def secondary_address @secondary_address end |
#state ⇒ String
This is two-character state code of the address.
38 39 40 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 38 def state @state 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/scan_forms_domestic_address.rb', line 15 def street_address @street_address end |
#street_address_abbreviation ⇒ String
This is the abbreviation of street address line for the address.
19 20 21 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 19 def street_address_abbreviation @street_address_abbreviation end |
#urbanization ⇒ String
An area, sector, or residential development within a geographic area (typically used for addresses in Puerto Rico)
51 52 53 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 51 def urbanization @urbanization end |
#zip_code ⇒ String
This is the 5-digit ZIP code.
42 43 44 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 42 def zip_code @zip_code end |
#zip_plus4 ⇒ String
This is the ZIP+4 extension.
46 47 48 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 46 def zip_plus4 @zip_plus4 end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
111 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 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 111 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 city = hash.key?('city') ? hash['city'] : SKIP state = hash.key?('state') ? hash['state'] : SKIP zip_code = hash.key?('ZIPCode') ? hash['ZIPCode'] : SKIP zip_plus4 = hash.key?('ZIPPlus4') ? hash['ZIPPlus4'] : SKIP urbanization = hash.key?('urbanization') ? hash['urbanization'] : 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. ScanFormsDomesticAddress.new(street_address: street_address, street_address_abbreviation: street_address_abbreviation, secondary_address: secondary_address, city_abbreviation: city_abbreviation, city: city, state: state, zip_code: zip_code, zip_plus4: zip_plus4, urbanization: urbanization, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 54 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['city'] = 'city' @_hash['state'] = 'state' @_hash['zip_code'] = 'ZIPCode' @_hash['zip_plus4'] = 'ZIPPlus4' @_hash['urbanization'] = 'urbanization' @_hash end |
.nullables ⇒ Object
An array for nullable fields
84 85 86 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 84 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 69 def self.optionals %w[ street_address street_address_abbreviation secondary_address city_abbreviation city state zip_code zip_plus4 urbanization ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
159 160 161 162 163 164 165 166 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 159 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}, city: #{@city.inspect}, state:"\ " #{@state.inspect}, zip_code: #{@zip_code.inspect}, zip_plus4: #{@zip_plus4.inspect},"\ " urbanization: #{@urbanization.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
149 150 151 152 153 154 155 156 |
# File 'lib/usps_api/models/scan_forms_domestic_address.rb', line 149 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}, city: #{@city}, state: #{@state}, zip_code:"\ " #{@zip_code}, zip_plus4: #{@zip_plus4}, urbanization: #{@urbanization},"\ " additional_properties: #{@additional_properties}>" end |