Class: VpsbClient::Api::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/vpsb_client/api/response.rb

Defined Under Namespace

Classes: HttpError, NotAuthenticated

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(curl_response) ⇒ Response

Returns a new instance of Response.

Raises:



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_strObject (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

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/vpsb_client/api/response.rb', line 6

def code
  @code
end

#content_typeObject (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_responseObject



20
21
22
# File 'lib/vpsb_client/api/response.rb', line 20

def parsed_response
  @parsed_response ||= JSON.parse(@body_str)
end