92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/infobase/base.rb', line 92
def self.handle_response(response, request, result)
case response.code
when 200..299
json = Oj.load(response)
if json[singular_name]
new(json[singular_name])
else
json[plural_name] = json[plural_name].collect { |hash| new(hash) }
json
end
when 400
raise RestClient::BadRequest, response
when 500
raise RestClient::InternalServerError, response
else
puts response.inspect
puts request.inspect
raise result.inspect
end
end
|