Sha256: 01567d3d985b38dac16763301997cbbb5a4ec105afc0a4758a0bf1cac4b1f8fa

Contents?: true

Size: 596 Bytes

Versions: 2

Compression:

Stored size: 596 Bytes

Contents

module Lifen
  class UserAuthenticatedClient < Client

    def initialize(token)
      @token = token
    end

    attr_reader :token

    private

      def handle_status!(response)
        super(response)

        case response.status
        when 400
          raise InvalidParamsError, "Invalid params"
        when 401
          raise UnauthorizedError, "Token is not valid"
        when 403
          raise Error, "Action is forbidden"
        end

      end

      def bearer
        token.value
      end

      def before_request
        token.refresh_once_if_needed
      end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lifen-1.0.1 lib/lifen/user_authenticated_client.rb
lifen-1.0.0 lib/lifen/user_authenticated_client.rb