Method: Fitting::Records::Spherical::Response#to_hash

Defined in:
lib/fitting/records/spherical/response.rb

#to_hashObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fitting/records/spherical/response.rb', line 15

def to_hash
  begin
    parse_body =  JSON.parse(body)
  rescue JSON::ParserError
    parse_body = {}
  end

  if @content_type == nil || @content_type == ''
    {
      status: status,
      content_type: 'application/json',
      body: parse_body
    }
  else
    ct = @content_type.split("; ")
    {
      status: status,
      content_type: ct.first,
      body: parse_body
    }
  end
end