Sha256: aeb3adb8a28fc91c4732e0c05eeb1b65ada575fccd125c6166cd4cd2909bc943

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 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

1 entries across 1 versions & 1 rubygems

Version Path
roqua-core-api-0.7.0 lib/roqua/core_api/sessions/token_session.rb