module AlexaToolbox
Constants
- VERSION
Public Class Methods
build_request(json_request, application_id = "")
click to toggle source
Builds a new request for Alexa, primarily for testing purposes
# File lib/alexa_toolbox/request.rb, line 52 def self.build_request(json_request, application_id = "") json_request = self.transform_keys_to_symbols(json_request) raise ArgumentError, 'Invalid Alexa Request. Missing session, request, version, or application id.' unless AlexaToolbox.valid_alexa?(json_request) Request.new(json_request,{ :application_id => application_id }) end
print_json(json)
click to toggle source
Prints a JSON object.
# File lib/alexa_toolbox.rb, line 9 def self.print_json(json) p json end
print_version()
click to toggle source
Prints the Gem version.
# File lib/alexa_toolbox.rb, line 14 def self.print_version p AlexaToolbox::VERSION end
transform_keys_to_symbols(input)
click to toggle source
Take keys of hash and transform those to a symbols
# File lib/alexa_toolbox.rb, line 24 def self.transform_keys_to_symbols(input) return input if not input.is_a?(Hash) hash = input.inject({}){|store,(key,val)| store[key.to_sym] = self.transform_keys_to_symbols(val); store} return hash end
valid_alexa?(request_json)
click to toggle source
Returns true if all the Alexa objects are set.
# File lib/alexa_toolbox.rb, line 19 def self.valid_alexa?(request_json) !request_json.nil? && !request_json[:version].nil? && !request_json[:request].nil? end