Class: Telesign::RestClient::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/telesign/rest.rb

Overview

  • http_response - A net/http response object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ Response

Returns a new instance of Response.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/telesign/rest.rb', line 30

def initialize(http_response)
  @status_code = http_response.code
  @headers = http_response.to_hash
  @body = http_response.body
  @ok = http_response.kind_of? Net::HTTPSuccess

  begin
    @json = JSON.parse(http_response.body)
  rescue JSON::JSONError
    @json = nil
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



28
29
30
# File 'lib/telesign/rest.rb', line 28

def body
  @body
end

#headersObject

Returns the value of attribute headers.



28
29
30
# File 'lib/telesign/rest.rb', line 28

def headers
  @headers
end

#jsonObject

Returns the value of attribute json.



28
29
30
# File 'lib/telesign/rest.rb', line 28

def json
  @json
end

#okObject

Returns the value of attribute ok.



28
29
30
# File 'lib/telesign/rest.rb', line 28

def ok
  @ok
end

#status_codeObject

Returns the value of attribute status_code.



28
29
30
# File 'lib/telesign/rest.rb', line 28

def status_code
  @status_code
end