Class: Sunwatch::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sunwatch/client.rb

Constant Summary collapse

EPA_UV_URI =
'http://iaspub.epa.gov/enviro/efservice/getEnvirofactsUV'

Class Method Summary collapse

Class Method Details

.uv_info_for(opts) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/sunwatch/client.rb', line 9

def self.uv_info_for(opts)
  url = build_url(opts)
  response = HTTParty.get(url)
  raise_unavailable_error if response.code != 200
  build_response(JSON.parse(response.body))
rescue HTTParty::Error => e
  raise_unavailable_error(e.message)
end