Sha256: 78809d672d65bfc646c01b9d5f5137f9bdd714fa64ad725e8d43f278bab33593

Contents?: true

Size: 843 Bytes

Versions: 8

Compression:

Stored size: 843 Bytes

Contents

module Roqua
  module CoreApi
    module Sessions
      class TokenSession < AuthSession
        attr_reader :access_token

        def initialize(access_token:, **additional_arguments)
          @access_token = access_token
          super additional_arguments
        end

        def logout
          delete 'sessions/destroy'
        end

        # ping the server to check if session is still valid.
        # Will throw NoSession as usual if not.
        def ping
          get "/ping"
        end

        private

        def access_denied(response)
          if response['no_session']
            fail NoSession
          else
            fail Unauthorized
          end
        end

        def headers(_request_method, _path, _params)
          {"Authorization" => "Session #{access_token}"}
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
roqua-core-api-0.6.0 lib/roqua/core_api/sessions/token_session.rb
roqua-core-api-0.5.0 lib/roqua/core_api/sessions/token_session.rb
roqua-core-api-0.4.0 lib/roqua/core_api/sessions/token_session.rb
roqua-core-api-0.3.1 lib/roqua/core_api/sessions/token_session.rb
roqua-core-api-0.3.0 lib/roqua/core_api/sessions/token_session.rb
roqua-core-api-0.2.4 lib/roqua/core_api/sessions/token_session.rb
roqua-core-api-0.2.3 lib/roqua/core_api/sessions/token_session.rb
roqua-core-api-0.2.2 lib/roqua/core_api/sessions/token_session.rb