Module: Ravelry::Utils::Request

Extended by:
Request
Included in:
Request
Defined in:
lib/ravelry/utils/request.rb

Instance Method Summary collapse

Instance Method Details

#get(url, key, params = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ravelry/utils/request.rb', line 6

def get(url, key, params={})
  request = Typhoeus::Request.get(
    "https://api.ravelry.com/#{url}",
    userpwd: "#{Ravelry.configuration.access_key}:#{Ravelry.configuration.personal_key}",
    params: params
  )

  data = JSON.parse(request.response_body, {symbolize_names: true})
  return data[key] if key
  return data
end