Module: Usps::Api::Endpoints::CityStateLookup

Included in:
Usps::Api::Endpoints
Defined in:
lib/usps/api/endpoints/city_state_lookup.rb

Instance Method Summary collapse

Instance Method Details

#city_state_lookup(options = {}) ⇒ Object

City/State Lookup API returns the city and state corresponding to the given ZIP Code. The CityStateLookup API processes up to five lookups per request.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • city_state_lookup_request (required, Hash)

    API= CityStateLookupRequest

    • :zip_code (required, Hash) —

      • :zip5 (required, Integer) —



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/usps/api/endpoints/city_state_lookup.rb', line 15

def city_state_lookup(options = {})
	throw ArgumentError.new('Required arguments :city_state_lookup_request missing') if options[:city_state_lookup_request].nil?
	throw ArgumentError.new('Required arguments :city_state_lookup_request, :zip_code missing') if options[:city_state_lookup_request][:zip_code].nil?
	throw ArgumentError.new('Required arguments :city_state_lookup_request, :zip_code, :zip5 missing') if options[:city_state_lookup_request][:zip_code][:zip5].nil?

	request = build_request(:city_state_lookup, options)
	get('https://secure.shippingapis.com/ShippingAPI.dll', {
		API: 'CityStateLookup',
		XML: request,
	})
end