Method: Forecasting::Client#get

Defined in:
lib/forecasting/client.rb

#get(path, opts = {}) ⇒ Hash

Performs a GET request and returned the parsed JSON as a Hash.

Parameters:

  • path (String)

    path to be combined with ‘host`

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

    key/values will get passed as HTTP (GET) parameters

Returns:

  • (Hash)


199
200
201
202
203
204
205
# File 'lib/forecasting/client.rb', line 199

def get(path, opts = {})
  url = "#{host}/#{path}"
  url += "?#{opts.map {|k, v| "#{k}=#{v}"}.join("&")}" if opts.any?
  uri = URI(url)
  response = http_response(:get, uri)
  JSON.parse(response.body)
end