module ChgkRating::Request
Public Instance Methods
get(path, params = {})
click to toggle source
# File lib/chgk_rating/request.rb, line 5 def get(path, params = {}) respond perform_get(path, params) end
Private Instance Methods
perform_get(path, params)
click to toggle source
# File lib/chgk_rating/request.rb, line 11 def perform_get(path, params) connection.get do |req| req.url path req.params = params end end
respond(response)
click to toggle source
# File lib/chgk_rating/request.rb, line 18 def respond(response) begin body = MultiJson.load response.body raise MultiJson::ParseError if body.respond_to?(:has_key?) && body.has_key?('error') body rescue MultiJson::ParseError respond_with_error response.status, response.body end end
respond_with_error(code, body)
click to toggle source
# File lib/chgk_rating/request.rb, line 28 def respond_with_error(code, body) fail ChgkRating::Error::ERRORS[code].from_response(body) end