class Eloquant::FaradayMiddleware::Response

Public Instance Methods

handle_errors!(errors) click to toggle source
# File lib/eloquant/faraday_middleware/response.rb, line 21
def handle_errors!(errors)
  error = errors.first

  fail Eloquant::Errors::Unknown if error.nil?
  fail Eloquant::Errors.find_by_response_code(error[:code].to_i), error[:message]
end
process_response(env) click to toggle source
Calls superclass method
# File lib/eloquant/faraday_middleware/response.rb, line 10
def process_response(env)
  super

  data = env[:body]

  fail Eloquant::Errors::EmptyResponse if data.nil?
  fail Eloquant::Errors::Error, data[:error_description] if data.key?(:error)

  handle_errors!(data[:errors]) unless data.fetch(:success, true)
end