google_assistant 0.0.4 → 0.0.5
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/lib/google_assistant.rb +14 -0
- data/lib/google_assistant/argument.rb +11 -0
- data/lib/google_assistant/conversation.rb +45 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b154ca654d07f2cd12c6f443bbf7046ef54d1f3
|
4
|
+
data.tar.gz: dbc77bed224fd5bd86dd95c829ee0b885f1c97fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f80e5e558716bc7b6a5c51d7fcbf66f4a56e07965f7a7a66dc02c9fe766d789a2aacb0c269e76c8c347fe3bb1b72c0a2c66efb42494820e5976d321f97e95fab
|
7
|
+
data.tar.gz: 8cb7380fe2917dfd782a39c2b16e7e97413f46d88e9f9cfcf1af8978f767d7023930c6a1d12163065c463ae48a0521f6500927da6187963e63b280ea8d1dcf4a
|
data/lib/google_assistant.rb
CHANGED
@@ -25,6 +25,16 @@ class GoogleAssistant
|
|
25
25
|
@_intent ||= Intent.new(intent_string)
|
26
26
|
end
|
27
27
|
|
28
|
+
def arguments
|
29
|
+
@_arguments ||= inputs[0]["arguments"].map do |argument|
|
30
|
+
Argument.new(argument)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def conversation
|
35
|
+
@_conversation ||= Conversation.new(conversation_params)
|
36
|
+
end
|
37
|
+
|
28
38
|
def tell(message)
|
29
39
|
final_response = { speech_response: {} }
|
30
40
|
|
@@ -158,6 +168,10 @@ class GoogleAssistant
|
|
158
168
|
inputs[0]["intent"] || handle_error("Missing intent from request body")
|
159
169
|
end
|
160
170
|
|
171
|
+
def conversation_params
|
172
|
+
params["conversation"] || {}
|
173
|
+
end
|
174
|
+
|
161
175
|
def handle_error(message)
|
162
176
|
raise message
|
163
177
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GoogleAssistant
|
4
|
+
class Conversation
|
5
|
+
class Type
|
6
|
+
TYPE_UNSPECIFIED = 0
|
7
|
+
NEW = 1
|
8
|
+
ACTIVE = 2
|
9
|
+
EXPIRED = 3
|
10
|
+
ARCHIVED = 4
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :id, :type, :token
|
14
|
+
|
15
|
+
def initialize(opts)
|
16
|
+
@id = opts["conversation_id"]
|
17
|
+
@type = opts["type"]
|
18
|
+
@token = parse_token(opts["conversation_token"])
|
19
|
+
end
|
20
|
+
|
21
|
+
def data
|
22
|
+
if token.is_a?(Hash)
|
23
|
+
token["data"]
|
24
|
+
else
|
25
|
+
token
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def state
|
30
|
+
if token.is_a?(Hash)
|
31
|
+
token["state"]
|
32
|
+
else
|
33
|
+
token
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def parse_token(token)
|
40
|
+
JSON.parse(token)
|
41
|
+
rescue JSON::ParserError, TypeError
|
42
|
+
token
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_assistant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Milam
|
@@ -17,6 +17,8 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/google_assistant.rb
|
20
|
+
- lib/google_assistant/argument.rb
|
21
|
+
- lib/google_assistant/conversation.rb
|
20
22
|
- lib/google_assistant/intent.rb
|
21
23
|
homepage: https://github.com/armilam/google-assistant-ruby
|
22
24
|
licenses:
|