class Academical::HttpClient::ResponseHandler

ResponseHandler takes care of decoding the response body into suitable type

Public Class Methods

get_body(response) click to toggle source
# File lib/academical/http_client/response_handler.rb, line 8
def self.get_body(response)
  type = response.headers["content-type"]
  body = response.body

  # Response body is in JSON
  if type.include?("json")
    body = JSON.parse body
  end

  return body
end