Method: Postcodeapi.get_street

Defined in:
lib/postcodeapi.rb

.get_street(zipcode) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/postcodeapi.rb', line 13

def self.get_street(zipcode)
  # Format the zipcode
  zipcode = format_zipcode(zipcode)
  # Perform request
  response = RestClient.get "#{@api_url}/#{zipcode}", {:content_type => :json, :accept => :json, :'Api-Key' => @api_key}
  # Return openstruct output
  res = JSON.parse(response.to_str,{symbolize_names: true})
  OpenStruct.new res[:resource]
end