Class: UspsApi::Facility
- Defined in:
- lib/usps_api/models/facility.rb
Overview
This is USPS® facility information.
Instance Attribute Summary collapse
-
#city ⇒ String
City Name.
-
#city_abbreviation ⇒ String
City Name Abbreviation.
-
#closes ⇒ FacilityClosureTimes
The time that the facility closes for each day, including holidays.
-
#facility_name ⇒ String
This is the facility’s name.
-
#facility_type ⇒ FacilityType
This is the type of facility at the location.
-
#secondary_address ⇒ String
Suite or apartment number.
-
#state ⇒ String
2-letter USPS state abbreviation.
-
#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
Primary address line abbreviations.
-
#urbanization ⇒ String
An area, sector, or residential development within a geographic area (typically used for addresses in Puerto Rico).
-
#zip_code ⇒ String
5-digit ZIP code.
-
#zip_plus4 ⇒ String
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, facility_name: SKIP, facility_type: SKIP, closes: SKIP) ⇒ Facility
constructor
A new instance of Facility.
-
#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, facility_name: SKIP, facility_type: SKIP, closes: SKIP) ⇒ Facility
Returns a new instance of Facility.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/usps_api/models/facility.rb', line 103 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, facility_name: SKIP, facility_type: SKIP, closes: SKIP) @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 @facility_name = facility_name unless facility_name == SKIP @facility_type = facility_type unless facility_type == SKIP @closes = closes unless closes == SKIP end |
Instance Attribute Details
#city ⇒ String
City Name.
31 32 33 |
# File 'lib/usps_api/models/facility.rb', line 31 def city @city end |
#city_abbreviation ⇒ String
City Name Abbreviation.
27 28 29 |
# File 'lib/usps_api/models/facility.rb', line 27 def city_abbreviation @city_abbreviation end |
#closes ⇒ FacilityClosureTimes
The time that the facility closes for each day, including holidays.
60 61 62 |
# File 'lib/usps_api/models/facility.rb', line 60 def closes @closes end |
#facility_name ⇒ String
This is the facility’s name.
52 53 54 |
# File 'lib/usps_api/models/facility.rb', line 52 def facility_name @facility_name end |
#facility_type ⇒ FacilityType
This is the type of facility at the location.
56 57 58 |
# File 'lib/usps_api/models/facility.rb', line 56 def facility_type @facility_type end |
#secondary_address ⇒ String
Suite or apartment number.
23 24 25 |
# File 'lib/usps_api/models/facility.rb', line 23 def secondary_address @secondary_address end |
#state ⇒ String
2-letter USPS state abbreviation.
35 36 37 |
# File 'lib/usps_api/models/facility.rb', line 35 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/facility.rb', line 15 def street_address @street_address end |
#street_address_abbreviation ⇒ String
Primary address line abbreviations.
19 20 21 |
# File 'lib/usps_api/models/facility.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).
48 49 50 |
# File 'lib/usps_api/models/facility.rb', line 48 def urbanization @urbanization end |
#zip_code ⇒ String
5-digit ZIP code.
39 40 41 |
# File 'lib/usps_api/models/facility.rb', line 39 def zip_code @zip_code end |
#zip_plus4 ⇒ String
ZIP+4 extension.
43 44 45 |
# File 'lib/usps_api/models/facility.rb', line 43 def zip_plus4 @zip_plus4 end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 151 152 153 154 155 156 157 158 159 |
# File 'lib/usps_api/models/facility.rb', line 126 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 facility_name = hash.key?('facilityName') ? hash['facilityName'] : SKIP facility_type = hash.key?('facilityType') ? hash['facilityType'] : SKIP closes = FacilityClosureTimes.from_hash(hash['closes']) if hash['closes'] # Create object from extracted values. Facility.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, facility_name: facility_name, facility_type: facility_type, closes: closes) end |
.names ⇒ Object
A mapping from model property names to API property names.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/usps_api/models/facility.rb', line 63 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['facility_name'] = 'facilityName' @_hash['facility_type'] = 'facilityType' @_hash['closes'] = 'closes' @_hash end |
.nullables ⇒ Object
An array for nullable fields
99 100 101 |
# File 'lib/usps_api/models/facility.rb', line 99 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/usps_api/models/facility.rb', line 81 def self.optionals %w[ street_address street_address_abbreviation secondary_address city_abbreviation city state zip_code zip_plus4 urbanization facility_name facility_type closes ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
172 173 174 175 176 177 178 179 180 |
# File 'lib/usps_api/models/facility.rb', line 172 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}, facility_name: #{@facility_name.inspect},"\ " facility_type: #{@facility_type.inspect}, closes: #{@closes.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
162 163 164 165 166 167 168 169 |
# File 'lib/usps_api/models/facility.rb', line 162 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}, facility_name:"\ " #{@facility_name}, facility_type: #{@facility_type}, closes: #{@closes}>" end |