Class: Nomics::Client
- Inherits:
-
Object
- Object
- Nomics::Client
- Defined in:
- lib/nomics/client.rb
Instance Method Summary collapse
-
#get(path, params = {}) ⇒ Object
NOMICS_BASE_URL = “api.nomics.com”.
Instance Method Details
#get(path, params = {}) ⇒ Object
NOMICS_BASE_URL = “api.nomics.com”
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/nomics/client.rb', line 9 def get(path, params = {}) params.merge!(key: api_key) uri = URI::HTTPS.build(host: 'api.nomics.com', path: path, query: URI.encode_www_form(params)) wait_if_necessary response = Net::HTTP.get_response(uri) case response when Net::HTTPSuccess JSON.parse response.body when Net::HTTPUnauthorized raise HTTPAuthorizationError.new(response.body) when Net::HTTPServerError raise APIServerError.new(response.body) else raise UnhandledError.new(response.body) end end |