class Hphones::Response
Represents an API response
Constants
- RESPONSE_TYPE_JSON
- RESPONSE_TYPE_PATH
- RESPONSE_TYPE_STATUS
- STATUS_OK
Attributes
http_response[R]
request[R]
Public Class Methods
new(request, http_response)
click to toggle source
# File lib/hphones/response.rb, line 17 def initialize(request, http_response) @http_response = http_response @request = request end
Public Instance Methods
data()
click to toggle source
# File lib/hphones/response.rb, line 22 def data @data ||= parse_data http_response.body end
Private Instance Methods
parse_data(body)
click to toggle source
# File lib/hphones/response.rb, line 30 def parse_data(body) case request.response_type when RESPONSE_TYPE_JSON parse_json body when RESPONSE_TYPE_STATUS parse_status body when RESPONSE_TYPE_PATH parse_path body end end
parse_json(body)
click to toggle source
# File lib/hphones/response.rb, line 41 def parse_json(body) JSON.parse body end
parse_path(body)
click to toggle source
# File lib/hphones/response.rb, line 54 def parse_path(body) body end
parse_status(body)
click to toggle source
# File lib/hphones/response.rb, line 45 def parse_status(body) case body when STATUS_OK true else false end end