Class: AlexaRubykit::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/alexa_rubykit/request.rb

Overview

Echo can send 3 types of requests

  • LaunchRequest: The start of the app.

  • IntentRequest: The intent of the app.

  • SessionEndedRequest: Session has ended.

Direct Known Subclasses

IntentRequest, LaunchRequest, SessionEndedRequest

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_request) ⇒ Request

Returns a new instance of Request.

Raises:

  • (ArgumentError)

12
13
14
15
16
17
18
19
20
21
# File 'lib/alexa_rubykit/request.rb', line 12

def initialize(json_request)
  @request_id = json_request['request']['requestId']
  raise ArgumentError, 'Request ID should exist on all Requests' if @request_id.nil?
  @version = json_request['version']
  @locale = json_request['request']['locale']
  @json   = json_request

  # TODO: We probably need better session handling.
  @session = AlexaRubykit::Session.new(json_request['session'])
end

Instance Attribute Details

#jsonObject

global


9
10
11
# File 'lib/alexa_rubykit/request.rb', line 9

def json
  @json
end

#localeObject

on request


10
11
12
# File 'lib/alexa_rubykit/request.rb', line 10

def locale
  @locale
end

#request_idObject

on request


10
11
12
# File 'lib/alexa_rubykit/request.rb', line 10

def request_id
  @request_id
end

#sessionObject

global


9
10
11
# File 'lib/alexa_rubykit/request.rb', line 9

def session
  @session
end

#typeObject

global


9
10
11
# File 'lib/alexa_rubykit/request.rb', line 9

def type
  @type
end

#versionObject

global


9
10
11
# File 'lib/alexa_rubykit/request.rb', line 9

def version
  @version
end