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.



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

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.



93
94
95
# File 'lib/spark_api/authentication/api_auth.rb', line 93

def auth_token
  @auth_token
end

#expiresObject

Returns the value of attribute expires.



93
94
95
# File 'lib/spark_api/authentication/api_auth.rb', line 93

def expires
  @expires
end

#rolesObject

Returns the value of attribute roles.



93
94
95
# File 'lib/spark_api/authentication/api_auth.rb', line 93

def roles
  @roles
end

Instance Method Details

#expired?Boolean

Is the user session token expired?

Returns:

  • (Boolean)


100
101
102
# File 'lib/spark_api/authentication/api_auth.rb', line 100

def expired?
  DateTime.now > @expires
end