class WssAgent::Response
Constants
- BAD_REQUEST_STATUS
- SERVER_ERROR_STATUS
- SUCCESS_STATUS
Attributes
data[R]
message[R]
response[R]
response_data[R]
status[R]
Public Class Methods
new(response)
click to toggle source
# File lib/wss_agent/response.rb, line 9 def initialize(response) @response = response if response.is_a?(Faraday::Error::ClientError) parse_error else parse_response end end
Public Instance Methods
parse_error()
click to toggle source
# File lib/wss_agent/response.rb, line 18 def parse_error @status = SERVER_ERROR_STATUS @message = response.message end
parse_response()
click to toggle source
# File lib/wss_agent/response.rb, line 23 def parse_response if response.success? begin @response_data = MultiJson.load(response.body) @status = @response_data['status'].to_i @message = @response_data['message'] rescue @status = SERVER_ERROR_STATUS @message = response.body end else @status = SERVER_ERROR_STATUS @message = response.body end end
response_success?()
click to toggle source
# File lib/wss_agent/response.rb, line 39 def response_success? if response.is_a?(Faraday::Error::ClientError) false else response.success? end end
success?()
click to toggle source
# File lib/wss_agent/response.rb, line 47 def success? response_success? && status == SUCCESS_STATUS end