Class: BetterAlexaRubyKit::Request

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

Overview

  • 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/better_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 = BetterAlexaRubyKit::Session.new(json_request['session'])
end

Instance Attribute Details

#jsonObject

global



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

def json
  @json
end

#localeObject

on request



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

def locale
  @locale
end

#request_idObject

on request



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

def request_id
  @request_id
end

#sessionObject

global



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

def session
  @session
end

#typeObject

global



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

def type
  @type
end

#versionObject

global



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

def version
  @version
end

Instance Method Details

#intent_nameObject



23
24
25
26
27
28
29
30
31
# File 'lib/better_alexa_rubykit/request.rb', line 23

def intent_name
  if type == "LAUNCH_REQUEST"
    return 'LaunchRequest'
  elsif type == 'INTENT_REQUEST'
    return name
  else
    return 'SessionEndedRequest'
  end
end