Class: AlexaRuby::Alexa

Inherits:
Object
  • Object
show all
Defined in:
lib/alexa_ruby/alexa.rb

Overview

Main processing class, parses request from Amazon Alexa and initialize new response object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, opts) ⇒ Alexa

Initialize new Alexa assistant

Parameters:

  • request (Hash)

    request from Amazon Alexa web service

  • opts (Hash)

    additional options: :disable_validations [Boolean] disables request validation if true

Raises:

  • (ArgumentError)

12
13
14
15
16
17
18
19
20
# File 'lib/alexa_ruby/alexa.rb', line 12

def initialize(request, opts)
  @req = request
  @opts = opts
  invalid_request_exception if invalid_request?
  @request = define_request
  raise ArgumentError, 'Unknown type of Alexa request' if @request.nil?
  @request.valid? if ssl_check?
  @response = Response.new(@request.type, @request.version)
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request


5
6
7
# File 'lib/alexa_ruby/alexa.rb', line 5

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response


5
6
7
# File 'lib/alexa_ruby/alexa.rb', line 5

def response
  @response
end