Sha256: 404d47656b86795e66b58b9086811d625821d9322c1d5b106886c707f05d065c

Contents?: true

Size: 819 Bytes

Versions: 8

Compression:

Stored size: 819 Bytes

Contents

require 'faraday'

module PaychexFaradayMiddleWare
  class RaisePaychexHttpException < Faraday::Middleware
    def initialize(app)
      super(app)
    end

    def call(env)
      @app.call(env).on_complete do |response|
        case response.status.to_i
        when 400
          raise Paychex::BadRequest, response
        when 401
          raise Paychex::Unauthorized, response
        when 403
          raise Paychex::NoAccess, response
        when 404
          raise Paychex::NotFound, response
        when 500
          raise Paychex::InternalServerError, response
        when 502
          raise Paychex::BadGateway, response
        when 503
          raise Paychex::ServiceUnavailable, response
        when 504
          raise Paychex::GatewayTimeout, response
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
paychex-0.3.3 lib/faraday/raise_paychex_http_exception.rb
paychex-0.3.2 lib/faraday/raise_paychex_http_exception.rb
paychex-0.3.1 lib/faraday/raise_paychex_http_exception.rb
paychex-0.3.0 lib/faraday/raise_paychex_http_exception.rb
paychex-0.2.2 lib/faraday/raise_paychex_http_exception.rb
paychex-0.2.1 lib/faraday/raise_paychex_http_exception.rb
paychex-0.2.0 lib/faraday/raise_paychex_http_exception.rb
paychex-0.1.1 lib/faraday/raise_paychex_http_exception.rb