Method: MultiInfo::API::Response.parse

Defined in:
lib/multiinfo/api/response.rb

.parse(response_arr) ⇒ Object

Returns the HTTP response body data as a hash.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/multiinfo/api/response.rb', line 9

def parse(response_arr)
  return { :status => 'OK' } if API.test_mode
  command, http_response = response_arr
  response_rows = http_response.split(/\r\n|\n/)
  response_status, response_body = response_rows[0], response_rows[1..-1]
  if response_status.to_i < 0 
    raise MultiInfo::API::Error.new(response_status, response_body.first)
  else
    response_hash(command, response_body).merge({:status => response_status})
  end
end