Class: AlexaRuby::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/alexa_ruby/request/base_request/session.rb

Overview

Amazon Alexa user session

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Session

Initialize new Session

Parameters:

  • session (Hash)

    session parameters

Raises:

  • (ArgumentError)

    if user session data is absent



11
12
13
14
15
16
17
18
19
# File 'lib/alexa_ruby/request/base_request/session.rb', line 11

def initialize(session)
  @session = session
  raise ArgumentError, 'Empty user session' if invalid_session?

  @state = @session[:new] ? :new : :old
  @id = @session[:sessionId]
  @attributes = @session[:attributes] || {}
  @user = load_user unless @session[:user].nil?
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/alexa_ruby/request/base_request/session.rb', line 4

def attributes
  @attributes
end

#end_reasonObject

Returns the value of attribute end_reason.



4
5
6
# File 'lib/alexa_ruby/request/base_request/session.rb', line 4

def end_reason
  @end_reason
end

#errorObject

Returns the value of attribute error.



4
5
6
# File 'lib/alexa_ruby/request/base_request/session.rb', line 4

def error
  @error
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/alexa_ruby/request/base_request/session.rb', line 4

def id
  @id
end

#stateObject

Returns the value of attribute state.



5
6
7
# File 'lib/alexa_ruby/request/base_request/session.rb', line 5

def state
  @state
end

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'lib/alexa_ruby/request/base_request/session.rb', line 4

def user
  @user
end