class CircleCi::Response
Response
class is used to get access to raw HTTP request info
Attributes
body[R]
Public Class Methods
new(resp)
click to toggle source
Initializing response object to be returned from API calls, used internally.
@private
# File lib/circleci/response.rb, line 21 def initialize(resp) @resp = resp @body = parsed_body end
Public Instance Methods
success?()
click to toggle source
Convenience method to determine if request was successfull or not @return [Boolean]
# File lib/circleci/response.rb, line 30 def success? case @resp.code.to_i when (200..299) then true else false end end
Private Instance Methods
parsed_body()
click to toggle source
Attempts to parse the response as JSON. Will rescue and return original if unable to parse.
@return [Hash,Array,String] A parsed JSON object or the original response body
# File lib/circleci/response.rb, line 45 def parsed_body JSON.parse @resp.body rescue JSON::ParserError @resp.body end