Sha256: db7ba2998c5e91f33cb32398caaa32f1d29196054261aacab710c74a709730b0

Contents?: true

Size: 810 Bytes

Versions: 3

Compression:

Stored size: 810 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
          {"Authorization" => "Session #{access_token}"}
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
roqua-core-api-0.2.1 lib/roqua/core_api/sessions/token_session.rb
roqua-core-api-0.2.0 lib/roqua/core_api/sessions/token_session.rb
roqua-core-api-0.1.1 lib/roqua/core_api/sessions/token_session.rb