Class: AlexaRuby::Context

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

Overview

Amazon Alexa request context - application, user and device info

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Context

Initialize new Context object

Parameters:

  • context (Hash)

    request context parameters

Raises:

  • (ArgumentError)

    if application ID, or user ID, or device ID are nil


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

def initialize(context)
  @app_id = get_app_id(context[:System][:application])
  raise ArgumentError, 'Missing application ID' unless @app_id

  @user = load_user(context[:System][:user])
  @device = load_device(context[:System][:device])
  @api_endpoint = context[:System][:apiEndpoint]
  @audio_state = load_audio_state(context[:AudioPlayer])
end

Instance Attribute Details

#api_endpointObject (readonly)

Returns the value of attribute api_endpoint


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

def api_endpoint
  @api_endpoint
end

#app_idObject (readonly)

Returns the value of attribute app_id


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

def app_id
  @app_id
end

#audio_stateObject (readonly)

Returns the value of attribute audio_state


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

def audio_state
  @audio_state
end

#deviceObject (readonly)

Returns the value of attribute device


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

def device
  @device
end

#userObject (readonly)

Returns the value of attribute user


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

def user
  @user
end