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
27
# File 'lib/xing_api/response_handler.rb', line 16

def handle(response)
  return Response.new('{}', response.to_hash) if response.code.to_i == 204

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

  Response.new(
    response.body.to_s,
    response.to_hash
  )
end