Method: XingApi::ResponseHandler#handle

Defined in:
lib/xing_api/response_handler.rb

#handle(response) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/xing_api/response_handler.rb', line 16

def handle(response)
  return {} if response.code.to_i == 204

  unless (200..299).cover?(response.code.to_i)
    raise_failed_response!(response)
  end

  JSON.parse(response.body.to_s, symbolize_names: true)
rescue JSON::ParserError
  {}
end