Class: SparkApi::Authentication::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/spark_api/authentication/api_auth.rb

Overview

Session class

Handle on the api user session information as return by the api session service, including roles, tokens and expiration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Session

Returns a new instance of Session.



96
97
98
99
100
# File 'lib/spark_api/authentication/api_auth.rb', line 96

def initialize(options={})
  @auth_token = options["AuthToken"]
  @expires = DateTime.parse options["Expires"]
  @roles = options["Roles"]
end

Instance Attribute Details

#auth_tokenObject

Returns the value of attribute auth_token.



95
96
97
# File 'lib/spark_api/authentication/api_auth.rb', line 95

def auth_token
  @auth_token
end

#expiresObject

Returns the value of attribute expires.



95
96
97
# File 'lib/spark_api/authentication/api_auth.rb', line 95

def expires
  @expires
end

#rolesObject

Returns the value of attribute roles.



95
96
97
# File 'lib/spark_api/authentication/api_auth.rb', line 95

def roles
  @roles
end

Instance Method Details

#expired?Boolean

Is the user session token expired?

Returns:

  • (Boolean)


102
103
104
# File 'lib/spark_api/authentication/api_auth.rb', line 102

def expired?
  DateTime.now > @expires
end