Class: Ralyxa::RequestEntities::Request
- Inherits:
-
Object
- Object
- Ralyxa::RequestEntities::Request
- Extended by:
- Forwardable
- Defined in:
- lib/ralyxa/request_entities/request.rb
Constant Summary collapse
- INTENT_REQUEST_TYPE =
'IntentRequest'.freeze
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#initialize(original_request, user_class = Ralyxa::RequestEntities::User) ⇒ Request
constructor
A new instance of Request.
- #intent_name ⇒ Object
- #new_session? ⇒ Boolean
- #session_attribute(attribute_name) ⇒ Object
- #session_attributes ⇒ Object
- #slot_value(slot_name) ⇒ Object
Constructor Details
#initialize(original_request, user_class = Ralyxa::RequestEntities::User) ⇒ Request
Returns a new instance of Request.
18 19 20 21 22 23 24 25 |
# File 'lib/ralyxa/request_entities/request.rb', line 18 def initialize(original_request, user_class = Ralyxa::RequestEntities::User) validate_request(original_request) if Ralyxa.configuration.validate_requests? @request = JSON.parse(original_request.body.read) attempt_to_rewind_request_body(original_request) @user = user_class.build(@request) end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
16 17 18 |
# File 'lib/ralyxa/request_entities/request.rb', line 16 def request @request end |
Instance Method Details
#intent_name ⇒ Object
27 28 29 30 |
# File 'lib/ralyxa/request_entities/request.rb', line 27 def intent_name return @request['request']['type'] unless intent_request? @request['request']['intent']['name'] end |
#new_session? ⇒ Boolean
36 37 38 |
# File 'lib/ralyxa/request_entities/request.rb', line 36 def new_session? @request['session']['new'] end |
#session_attribute(attribute_name) ⇒ Object
44 45 46 |
# File 'lib/ralyxa/request_entities/request.rb', line 44 def session_attribute(attribute_name) session_attributes[attribute_name] end |
#session_attributes ⇒ Object
40 41 42 |
# File 'lib/ralyxa/request_entities/request.rb', line 40 def session_attributes @request['session']['attributes'] end |
#slot_value(slot_name) ⇒ Object
32 33 34 |
# File 'lib/ralyxa/request_entities/request.rb', line 32 def slot_value(slot_name) @request['request']['intent']['slots'][slot_name]['value'] end |