Class: Delphix::WebResponse

Inherits:
Object
  • Object
show all
Includes:
Utils, Net::HTTPHeader
Defined in:
lib/delphix/web_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#request_id, #utc_httpdate

Constructor Details

#initialize(response) ⇒ WebResponse

Returns a new instance of WebResponse.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/delphix/web_response.rb', line 50

def initialize(response)
  @code = response.code
  @headers = response.headers
  @raw_body = response
  @body = @raw_body
  @cookies = response.cookies

  Delphix.last_response = {
    code: response.code,
    headers: response.headers,
    body: JSON.parse(response.body),
    cookies: response.cookies,
    description: response.description
  }.recursively_normalize_keys

  begin
    @body = JSON.parse(@raw_body)
  rescue Exception
  end
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



40
41
42
# File 'lib/delphix/web_response.rb', line 40

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



31
32
33
# File 'lib/delphix/web_response.rb', line 31

def code
  @code
end

#cookiesObject (readonly)

Returns the value of attribute cookies.



48
49
50
# File 'lib/delphix/web_response.rb', line 48

def cookies
  @cookies
end

#headersObject (readonly)

Returns the value of attribute headers.



44
45
46
# File 'lib/delphix/web_response.rb', line 44

def headers
  @headers
end

#method#raw_body (readonly)

The current session cookies.

Returns:



35
# File 'lib/delphix/web_response.rb', line 35

attr_reader :raw_body

#raw_bodyObject (readonly)

Returns the value of attribute raw_body.



35
36
37
# File 'lib/delphix/web_response.rb', line 35

def raw_body
  @raw_body
end