Class: VpsbClient::Api::Response
- Inherits:
-
Object
- Object
- VpsbClient::Api::Response
- Defined in:
- lib/vpsb_client/api/response.rb
Defined Under Namespace
Classes: HttpError, NotAuthenticated
Instance Attribute Summary collapse
-
#body_str ⇒ Object
readonly
Returns the value of attribute body_str.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
Instance Method Summary collapse
-
#initialize(curl_response) ⇒ Response
constructor
A new instance of Response.
- #parsed_response ⇒ Object
Constructor Details
#initialize(curl_response) ⇒ Response
Returns a new instance of Response.
11 12 13 14 15 16 17 18 |
# File 'lib/vpsb_client/api/response.rb', line 11 def initialize(curl_response) @code = curl_response.response_code raise NotAuthenticated, "code=#{@code}" if @code == 401 raise HttpError, "code=#{@code}" unless success? @body_str = curl_response.body_str @content_type = curl_response.content_type end |
Instance Attribute Details
#body_str ⇒ Object (readonly)
Returns the value of attribute body_str.
6 7 8 |
# File 'lib/vpsb_client/api/response.rb', line 6 def body_str @body_str end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/vpsb_client/api/response.rb', line 6 def code @code end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
6 7 8 |
# File 'lib/vpsb_client/api/response.rb', line 6 def content_type @content_type end |
Instance Method Details
#parsed_response ⇒ Object
20 21 22 |
# File 'lib/vpsb_client/api/response.rb', line 20 def parsed_response @parsed_response ||= JSON.parse(@body_str) end |