alexa_rubykit 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -3
- data/README.md +1 -0
- data/lib/alexa_rubykit/intent_request.rb +9 -9
- data/lib/alexa_rubykit/launch_request.rb +3 -6
- data/lib/alexa_rubykit/request.rb +20 -19
- data/lib/alexa_rubykit/response.rb +1 -1
- data/lib/alexa_rubykit/session.rb +6 -2
- data/lib/alexa_rubykit/session_ended_request.rb +5 -6
- data/lib/alexa_rubykit/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b7bcf9c3859a9434906cf1d1e1bb3123ec4277
|
4
|
+
data.tar.gz: e1e52a2d3116620bd2d17069f2ebb76dc4c07ddb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c20b3b2d6be9adc312f33154bf29cc6cc6c8883a19d8e00c560cf80dc27cd5fbbd5f1f9164ea2993c9bab8382c7ce783bd7a7f53b65ed0caa5ede0211263f70
|
7
|
+
data.tar.gz: d8695ccc7ea17a6884b477f2e83c7f1ba141ba672d33c4643fee71925d76f500e846fda99b1d73dff32f7c200abb8be7ac2b6f53bbc28845a9336b8c2a52dba4
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
alexa_rubykit (
|
4
|
+
alexa_rubykit (0.0.12.pre.dev)
|
5
5
|
bundler (~> 1.7)
|
6
6
|
rake (~> 10.0)
|
7
|
+
sinatra (~> 1.4)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
12
|
diff-lcs (1.2.5)
|
13
|
+
rack (1.6.1)
|
14
|
+
rack-protection (1.5.3)
|
15
|
+
rack
|
12
16
|
rake (10.4.2)
|
13
17
|
rspec (3.2.0)
|
14
18
|
rspec-core (~> 3.2.0)
|
@@ -23,11 +27,16 @@ GEM
|
|
23
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
24
28
|
rspec-support (~> 3.2.0)
|
25
29
|
rspec-support (3.2.2)
|
30
|
+
sinatra (1.4.6)
|
31
|
+
rack (~> 1.4)
|
32
|
+
rack-protection (~> 1.4)
|
33
|
+
tilt (>= 1.3, < 3)
|
34
|
+
tilt (2.0.1)
|
26
35
|
|
27
36
|
PLATFORMS
|
28
37
|
ruby
|
29
38
|
|
30
39
|
DEPENDENCIES
|
31
40
|
alexa_rubykit!
|
32
|
-
rspec (~> 3.2
|
33
|
-
rspec-mocks (~> 3.2
|
41
|
+
rspec (~> 3.2.0)
|
42
|
+
rspec-mocks (~> 3.2.0)
|
data/README.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
module AlexaRubykit
|
2
2
|
class IntentRequest < Request
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :intent, :name, :slots
|
4
4
|
|
5
5
|
# We still don't know if all of the parameters in the request are required.
|
6
6
|
# Checking for the presence of intent on an IntentRequest.
|
7
|
-
def initialize(
|
8
|
-
|
7
|
+
def initialize(json_request)
|
8
|
+
super
|
9
|
+
@intent = json_request['request']['intent']
|
10
|
+
raise ArgumentError, 'Intent should exist on an IntentRequest' if @intent.nil?
|
9
11
|
@type = 'INTENT_REQUEST'
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@name = intent['name']
|
13
|
-
@slots = intent['slots']
|
12
|
+
@name = @intent['name']
|
13
|
+
@slots = @intent['slots']
|
14
14
|
end
|
15
15
|
|
16
16
|
# Takes a Hash object.
|
@@ -37,7 +37,7 @@ module AlexaRubykit
|
|
37
37
|
|
38
38
|
# Outputs the Intent Name, request Id and slot information.
|
39
39
|
def to_s
|
40
|
-
"IntentRequest: #{
|
40
|
+
"IntentRequest: #{name} requestID: #{request_id} Slots: #{slots}"
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -54,7 +54,7 @@ module AlexaRubykit
|
|
54
54
|
|
55
55
|
# Outputs Slot name and value.
|
56
56
|
def to_s
|
57
|
-
"Slot Name: #{
|
57
|
+
"Slot Name: #{name}, Value: #{value}"
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -1,18 +1,15 @@
|
|
1
1
|
module AlexaRubykit
|
2
2
|
class LaunchRequest < Request
|
3
|
-
attr_accessor :request_id
|
4
|
-
|
5
3
|
# We still don't know if all of the parameters in the request are required.
|
6
4
|
# Checking for the presence of intent on an IntentRequest.
|
7
|
-
def initialize(
|
8
|
-
|
5
|
+
def initialize(json_request)
|
6
|
+
super
|
9
7
|
@type = 'LAUNCH_REQUEST'
|
10
|
-
@request_id = request_id
|
11
8
|
end
|
12
9
|
|
13
10
|
# Outputs the launch requestID.
|
14
11
|
def to_s
|
15
|
-
"LaunchRequest requestID: #{
|
12
|
+
"LaunchRequest requestID: #{request_id}"
|
16
13
|
end
|
17
14
|
end
|
18
15
|
end
|
@@ -6,11 +6,18 @@ module AlexaRubykit
|
|
6
6
|
class Request
|
7
7
|
require 'json'
|
8
8
|
require 'alexa_rubykit/session'
|
9
|
-
attr_accessor :version, :
|
9
|
+
attr_accessor :version, :type, :session, :json # global
|
10
|
+
attr_accessor :request_id, :locale # on request
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def initialize(json_request)
|
13
|
+
@request_id = json_request['request']['requestId']
|
14
|
+
raise ArgumentError, 'Request ID should exist on all Requests' if @request_id.nil?
|
15
|
+
@version = json_request['version']
|
16
|
+
@locale = json_request['request']['locale']
|
17
|
+
@json = json_request
|
18
|
+
|
19
|
+
# TODO: We probably need better session handling.
|
20
|
+
@session = AlexaRubykit::Session.new(json_request['session'])
|
14
21
|
end
|
15
22
|
end
|
16
23
|
|
@@ -18,29 +25,23 @@ module AlexaRubykit
|
|
18
25
|
def self.build_request(json_request)
|
19
26
|
raise ArgumentError, 'Invalid Alexa Request.' unless AlexaRubykit.valid_alexa?(json_request)
|
20
27
|
@request = nil
|
21
|
-
# TODO: We probably need better session handling.
|
22
|
-
session = AlexaRubykit::Session.new(json_request['session'])
|
23
28
|
case json_request['request']['type']
|
24
29
|
when /Launch/
|
25
|
-
@request = LaunchRequest.new(json_request
|
30
|
+
@request = LaunchRequest.new(json_request)
|
26
31
|
when /Intent/
|
27
|
-
@request = IntentRequest.new(json_request
|
32
|
+
@request = IntentRequest.new(json_request)
|
28
33
|
when /SessionEnded/
|
29
|
-
@request = SessionEndedRequest.new(json_request
|
34
|
+
@request = SessionEndedRequest.new(json_request)
|
30
35
|
else
|
31
36
|
raise ArgumentError, 'Invalid Request Type.'
|
32
37
|
end
|
33
|
-
@request.add_session(session)
|
34
38
|
@request
|
35
39
|
end
|
36
40
|
|
37
|
-
#
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
hash = value.inject({}){|memo,(k,v)| memo[k.to_sym] = Hash.transform_keys_to_symbols(v); memo}
|
43
|
-
return hash
|
44
|
-
end
|
41
|
+
# Take keys of hash and transform those to a symbols
|
42
|
+
def self.transform_keys_to_symbols(value)
|
43
|
+
return value if not value.is_a?(Hash)
|
44
|
+
hash = value.inject({}){|memo,(k,v)| memo[k.to_sym] = self.transform_keys_to_symbols(v); memo}
|
45
|
+
return hash
|
45
46
|
end
|
46
|
-
end
|
47
|
+
end
|
@@ -33,7 +33,7 @@ module AlexaRubykit
|
|
33
33
|
def add_card(type = nil, title = nil , subtitle = nil, content = nil)
|
34
34
|
# A Card must have a type which the default is Simple.
|
35
35
|
@card = Hash.new()
|
36
|
-
@card[:type] = 'Simple'
|
36
|
+
@card[:type] = type || 'Simple'
|
37
37
|
@card[:title] = title unless title.nil?
|
38
38
|
@card[:subtitle] = subtitle unless subtitle.nil?
|
39
39
|
@card[:content] = content unless content.nil?
|
@@ -12,7 +12,7 @@ module AlexaRubykit
|
|
12
12
|
|
13
13
|
# Returns whether this is a new session or not.
|
14
14
|
def new?
|
15
|
-
|
15
|
+
!!@new
|
16
16
|
end
|
17
17
|
|
18
18
|
# Returns true if a user is defined.
|
@@ -22,7 +22,11 @@ module AlexaRubykit
|
|
22
22
|
|
23
23
|
# Returns the user_id.
|
24
24
|
def user_id
|
25
|
-
@user['userId'] if
|
25
|
+
@user['userId'] if @user
|
26
|
+
end
|
27
|
+
|
28
|
+
def access_token
|
29
|
+
@user['accessToken'] if @user
|
26
30
|
end
|
27
31
|
|
28
32
|
# Check to see if attributes are present.
|
@@ -1,21 +1,20 @@
|
|
1
1
|
# Session end request class.
|
2
2
|
module AlexaRubykit
|
3
3
|
class SessionEndedRequest < Request
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :reason
|
5
5
|
|
6
6
|
# TODO: Validate the reason.
|
7
7
|
# We still don't know if all of the parameters in the request are required.
|
8
8
|
# Checking for the presence of intent on an IntentRequest.
|
9
|
-
def initialize(
|
10
|
-
|
9
|
+
def initialize(json_request)
|
10
|
+
super
|
11
11
|
@type = 'SESSION_ENDED_REQUEST'
|
12
|
-
@
|
13
|
-
@reason = reason
|
12
|
+
@reason = json_request['request']['reason']
|
14
13
|
end
|
15
14
|
|
16
15
|
# Ouputs the request_id and the reason why.
|
17
16
|
def to_s
|
18
|
-
"Session Ended for requestID: #{
|
17
|
+
"Session Ended for requestID: #{request_id} with reason #{reason}"
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alexa_rubykit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damian Finol
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.4.
|
121
|
+
rubygems_version: 2.4.6
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Alexa Ruby Kit
|