Class: CampactUserService::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/campact_user_service/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, session_id, session_cookie_name) ⇒ Session

Returns a new instance of Session.



5
6
7
8
9
# File 'lib/campact_user_service/session.rb', line 5

def initialize(client, session_id, session_cookie_name)
  @client = client
  @session_id = session_id
  @session_cookie_name = session_cookie_name
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/campact_user_service/session.rb', line 3

def client
  @client
end

Returns the value of attribute session_cookie_name.



3
4
5
# File 'lib/campact_user_service/session.rb', line 3

def session_cookie_name
  @session_cookie_name
end

#session_idObject (readonly)

Returns the value of attribute session_id.



3
4
5
# File 'lib/campact_user_service/session.rb', line 3

def session_id
  @session_id
end

Instance Method Details

#destroyObject



23
24
25
# File 'lib/campact_user_service/session.rb', line 23

def destroy
  client.delete_request('/v1/sessions', cookies: {session_cookie_name => session_id})
end

#external_account_idObject



11
12
13
# File 'lib/campact_user_service/session.rb', line 11

def 
  session["external_account_id"]
end

#has_hard_login_session?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/campact_user_service/session.rb', line 19

def 
  session["permission_level"] == 'full'
end

#has_soft_login_session?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/campact_user_service/session.rb', line 15

def 
  session["permission_level"] == 'limited'
end