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.



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

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.



26
27
28
# File 'lib/telesign/rest.rb', line 26

def body
  @body
end

#headersObject

Returns the value of attribute headers.



26
27
28
# File 'lib/telesign/rest.rb', line 26

def headers
  @headers
end

#jsonObject

Returns the value of attribute json.



26
27
28
# File 'lib/telesign/rest.rb', line 26

def json
  @json
end

#okObject

Returns the value of attribute ok.



26
27
28
# File 'lib/telesign/rest.rb', line 26

def ok
  @ok
end

#status_codeObject

Returns the value of attribute status_code.



26
27
28
# File 'lib/telesign/rest.rb', line 26

def status_code
  @status_code
end