Module: ActionAlexa::RequestPayload::Request
- Included in:
- AlexaRequest
- Defined in:
- lib/action_alexa/request_payload/request.rb
Overview
Request component of the JSON blob from the Alexa request TO the application. This module contains utility methods to access the attributes
Instance Method Summary collapse
- #intent_name ⇒ Object
- #link_result_should_be_returned? ⇒ Boolean
- #locale ⇒ Object
-
#request_id ⇒ Object
For logging purposes when reaching out to Amazon.
- #slot(slot_type) ⇒ Object
- #slot?(slot_type) ⇒ Boolean
- #slots ⇒ Object
- #slots? ⇒ Boolean
- #timestamp ⇒ Object
- #type ⇒ Object
Instance Method Details
#intent_name ⇒ Object
12 13 14 15 16 17 |
# File 'lib/action_alexa/request_payload/request.rb', line 12 def intent_name return type unless type == 'IntentRequest' full_intent_name = request_payload['intent']['name'] full_intent_name.split(/\./).last.gsub(/Intent$/, '') end |
#link_result_should_be_returned? ⇒ Boolean
32 33 34 35 36 |
# File 'lib/action_alexa/request_payload/request.rb', line 32 def link_result_should_be_returned? key = 'shouldLinkResultBeReturned' request_payload.key?(key) && request_payload[key] end |
#locale ⇒ Object
28 29 30 |
# File 'lib/action_alexa/request_payload/request.rb', line 28 def locale request_payload['locale'] end |
#request_id ⇒ Object
For logging purposes when reaching out to Amazon
20 21 22 |
# File 'lib/action_alexa/request_payload/request.rb', line 20 def request_id request_payload['requestId'] end |
#slot(slot_type) ⇒ Object
46 47 48 49 50 |
# File 'lib/action_alexa/request_payload/request.rb', line 46 def slot(slot_type) return nil unless slots? slots[slot_type] end |
#slot?(slot_type) ⇒ Boolean
42 43 44 |
# File 'lib/action_alexa/request_payload/request.rb', line 42 def slot?(slot_type) slots? && !slot(slot_type).nil? end |
#slots ⇒ Object
52 53 54 |
# File 'lib/action_alexa/request_payload/request.rb', line 52 def slots request_payload['intent']['slots'] end |
#slots? ⇒ Boolean
38 39 40 |
# File 'lib/action_alexa/request_payload/request.rb', line 38 def slots? !slots.nil? end |
#timestamp ⇒ Object
24 25 26 |
# File 'lib/action_alexa/request_payload/request.rb', line 24 def request_payload['timestamp'] end |
#type ⇒ Object
8 9 10 |
# File 'lib/action_alexa/request_payload/request.rb', line 8 def type request_payload['type'] end |