lib/chatrix/matrix.rb
# Parses a HTTParty Response object and returns it if it was successful.
#
# @param response [HTTParty::Response] The response object to parse.
# @return [HTTParty::Response] The same response object that was passed
#   in, if the request was successful.
#
# @raise [RequestError] If a `400` response code was returned from the
#   request.
# @raise [AuthenticationError] If a `401` response code was returned
#   from the request.
# @raise [ForbiddenError] If a `403` response code was returned from the
#   request.
# @raise [NotFoundError] If a `404` response code was returned from the
#   request.
# @raise [RateLimitError] If a `429` response code was returned from the
#   request.
# @raise [ApiError] If an unknown response code was returned from the
#   request.
Parses a HTTParty Response object and returns it if it was successful.
Parses a HTTParty Response object and returns it if it was successful .
def parse_response(response)
      case response.code
      when 200 
        response
      else
        handler = ERROR_HANDLERS[response.code]
        raise handler.first.new(response.parsed_response), handler.last
      end
    end
def parse_response ( response ) case response . code when 200 response else handler = ERROR_HANDLERS [ response . code ] raise handler . first . new ( response . parsed_response ) , handler . last end end
Parses a HTTParty Response object and returns it if it was successful.
Parses a HTTParty Response object and returns it if it was successful .
# OK
The same response object that was passed in, if the request was successful.
The same response object that was passed in if the request was successful .
HTTParty::Response
[RequestError] If a `400` response code was returned from the request.
[ RequestError ] If a ` 400 ` response code was returned from the request .
[AuthenticationError] If a `401` response code was returned from the request.
[ AuthenticationError ] If a ` 401 ` response code was returned from the request .
[ForbiddenError] If a `403` response code was returned from the request.
[ ForbiddenError ] If a ` 403 ` response code was returned from the request .
[NotFoundError] If a `404` response code was returned from the request.
[ NotFoundError ] If a ` 404 ` response code was returned from the request .
[RateLimitError] If a `429` response code was returned from the request.
[ RateLimitError ] If a ` 429 ` response code was returned from the request .
[ApiError] If an unknown response code was returned from the request.
[ ApiError ] If an unknown response code was returned from the request .
response
The response object to parse.
The response object to parse .