Class: USPS::Request::CityAndStateLookup
- Defined in:
- lib/usps/request/city_and_state_lookup.rb
Overview
All the address information APIs are essentially identical
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(*zip_codes) ⇒ CityAndStateLookup
constructor
Given a list of zip codes, looks up what city and state they are associated with.
Methods inherited from Base
#api, config, #response_for, #secure?, #send!
Constructor Details
#initialize(*zip_codes) ⇒ CityAndStateLookup
Given a list of zip codes, looks up what city and state they are associated with.
The USPS api is only capable of handling at most 5 zip codes per request.
14 15 16 17 18 19 20 |
# File 'lib/usps/request/city_and_state_lookup.rb', line 14 def initialize(*zip_codes) @zip_codes = zip_codes.flatten if(@zip_codes.size > 5) raise ArgumentError, 'at most 5 lookups can be performed per request' end end |
Instance Method Details
#build ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/usps/request/city_and_state_lookup.rb', line 22 def build super do |builder| @zip_codes.each_with_index do |zip, i| builder.tag!('ZipCode', :ID => i) do builder.tag!('Zip5', zip) end end end end |