Sha256: 5cb12399768744fdf8449fe0e16d14e5986eac7ce94eafc15985fc1167ea5721

Contents?: true

Size: 649 Bytes

Versions: 15

Compression:

Stored size: 649 Bytes

Contents

module LinkedIn
  module FaradayMiddleware
    class LinkedinErrorResponse < Faraday::Response::Middleware
      ERRORS = {
        400 => BadRequest,
        401 => Unauthorized,
        403 => Forbidden,
        404 => NotFound,
        500 => InternalServerError
      }

      def on_complete(env)
        status = env[:status].to_i
        error = ERRORS[status] || Error

        raise error.new response_values(env) if status >= 400
      end

      def response_values(env)
        {
          request: OpenStruct.new(headers: env[:request_headers], uri: env[:url]),
          response: env[:response]
        }
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
linkedin2-0.0.16 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.15 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.14 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.13 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.12 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.11 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.10 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.9 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.8 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.7 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.6 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.5 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.4 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.3 lib/linkedin/faraday_middleware/linkedin_error_response.rb
linkedin2-0.0.2 lib/linkedin/faraday_middleware/linkedin_error_response.rb