Class: SocketLabs::InjectionApi::Core::HttpResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/socketlabs/injectionapi/core/http_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ HttpResponse

Returns a new instance of HttpResponse.



12
13
14
15
16
# File 'lib/socketlabs/injectionapi/core/http_response.rb', line 12

def initialize(response)
  @status_code = response.code
  @body = response.body
  @headers = response.to_hash
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



9
10
11
# File 'lib/socketlabs/injectionapi/core/http_response.rb', line 9

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



10
11
12
# File 'lib/socketlabs/injectionapi/core/http_response.rb', line 10

def headers
  @headers
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



8
9
10
# File 'lib/socketlabs/injectionapi/core/http_response.rb', line 8

def status_code
  @status_code
end

Instance Method Details

#to_hashObject

Returns the body as a hash



19
20
21
# File 'lib/socketlabs/injectionapi/core/http_response.rb', line 19

def to_hash
  @parsed_body ||= JSON.parse(@body, symbolize_names: true)
end