Class: Util::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/bs2_api/util/response.rb

Class Method Summary collapse

Class Method Details

.parse_error(res) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bs2_api/util/response.rb', line 4

def parse_error res
  hash    = JSON.parse(res.body)
  message = "#{res.code}: "

  if hash.is_a?(Array)
    message << hash[0]["descricao"]
  elsif hash.key?("error_description")
    message << hash["error_description"]
  else 
    message << hash.to_s
  end

  message
end