Sha256: 0ae0e3faec1e0c3ff755f78da73c05a905c994944f42712c1ed976255c47ffd7
Contents?: true
Size: 1.8 KB
Versions: 3
Compression:
Stored size: 1.8 KB
Contents
require_relative './output_speech' require_relative './reprompt' require_relative './directives' module Ralyxa module ResponseEntities class Response def initialize(output_speech, reprompt, session_attributes, end_session, start_over, card, directives) @output_speech = output_speech @reprompt = reprompt @session_attributes = session_attributes @end_session = end_session @start_over = start_over @card = card @directives = directives end def to_h {}.tap do |response| add_version(response) add_session_attributes(response) add_response(response) end end def self.as_hash(output_speech: false, reprompt: false, session_attributes: {}, end_session: false, start_over: false, card: false, directives: false) new(output_speech, reprompt, session_attributes, end_session, start_over, card, directives).to_h end private attr_reader :response def add_version(response) response[:version] = '1.0' end def add_session_attributes(response) return response[:sessionAttributes] = {} if @start_over response[:sessionAttributes] = @session_attributes unless @session_attributes.empty? end def add_response(response) response[:response] = {}.tap do |response_object| response_object[:outputSpeech] = @output_speech if @output_speech response_object[:reprompt] = @reprompt if @reprompt response_object[:card] = @card if @card response_object[:directives] = @directives if @directives response_object[:shouldEndSession] = @end_session end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
ralyxa-lambda-1.9.0 | lib/ralyxa/response_entities/response.rb |
ralyxa-lambda-1.8.0 | lib/ralyxa/response_entities/response.rb |
ralyxa-1.8.0 | lib/ralyxa/response_entities/response.rb |