peach-ruby 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/peach/stream/request.rb +9 -3
- data/lib/peach/stream/response.rb +9 -5
- data/lib/peach/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22044ce025121dc6f98a9b9847815caff80ef0f16089368616b048f02e145d37
|
4
|
+
data.tar.gz: ead484f3c4c9427e918fe819d5d128f0c900104b8dbfa1d6a12f03942b68715e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2a7f243046a6c61cf7ef62f5ebe3d321f2b0491a3460620f3940592e99593624388e46b5513ff6297777085554030e9cedcdf61ec9720c655291fea2a07ab80
|
7
|
+
data.tar.gz: 5ba357f84e83d4d638fe3cadea472a08275b2b6d1eda30fc4b133a76dfa3edc181cfb3fb1995912c40891a3a37764650d165464ba71dc141d0e4fb7cbfa3ac08
|
data/lib/peach/stream/request.rb
CHANGED
@@ -3,11 +3,12 @@
|
|
3
3
|
module Peach
|
4
4
|
module Stream
|
5
5
|
class Request # :nodoc:
|
6
|
-
attr_reader :contact, :
|
6
|
+
attr_reader :contact, :params, :prompt, :message, :payload, :context
|
7
7
|
|
8
8
|
STREAM_TYPES = {
|
9
9
|
init: 'stream.init',
|
10
|
-
in_progress: 'stream.in_progress'
|
10
|
+
in_progress: 'stream.in_progress',
|
11
|
+
event_received: 'stream.event_received'
|
11
12
|
}.freeze
|
12
13
|
|
13
14
|
def initialize(raw_params)
|
@@ -24,6 +25,10 @@ module Peach
|
|
24
25
|
@type == STREAM_TYPES[:in_progress]
|
25
26
|
end
|
26
27
|
|
28
|
+
def event_received?
|
29
|
+
@type == STREAM_TYPES[:event_received]
|
30
|
+
end
|
31
|
+
|
27
32
|
private
|
28
33
|
|
29
34
|
def parse_params(raw_params)
|
@@ -46,9 +51,10 @@ module Peach
|
|
46
51
|
def instantiate_instance_variables_from(params)
|
47
52
|
@type = params[:type]
|
48
53
|
@contact = OpenStruct.new(params.dig(:request, :contact) || {})
|
49
|
-
@prompt = params.dig(:request, :prompt)
|
50
54
|
@params = params.dig(:request, :params) || {}
|
55
|
+
@prompt = params.dig(:request, :prompt)
|
51
56
|
@message = OpenStruct.new(params.dig(:request, :message) || {})
|
57
|
+
@payload = params.dig(:request, :payload) || {}
|
52
58
|
@context = params.dig(:request, :context) || {}
|
53
59
|
end
|
54
60
|
|
@@ -95,8 +95,8 @@ module Peach
|
|
95
95
|
def validate_prompt(prompt)
|
96
96
|
validate_key(prompt)
|
97
97
|
validate_data(prompt)
|
98
|
-
validate_button(prompt)
|
99
|
-
validate_options(prompt)
|
98
|
+
validate_button(prompt)
|
99
|
+
validate_options(prompt)
|
100
100
|
end
|
101
101
|
|
102
102
|
def validate_key(prompt)
|
@@ -110,11 +110,15 @@ module Peach
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def validate_button(prompt)
|
113
|
+
return unless prompt.key?(:button)
|
114
|
+
|
113
115
|
raise Peach::BadResponseError, 'Field `prompt.button` is not a String' unless prompt[:button].is_a?(String)
|
114
116
|
raise Peach::BadResponseError, 'Field `prompt.button` is empty' if prompt[:button].empty?
|
115
117
|
end
|
116
118
|
|
117
119
|
def validate_options(prompt)
|
120
|
+
return unless prompt.key?(:options)
|
121
|
+
|
118
122
|
raise Peach::BadResponseError, 'Field `prompt.options` is not an Array' unless prompt[:options].is_a?(Array)
|
119
123
|
|
120
124
|
validate_each_option(prompt)
|
@@ -123,7 +127,7 @@ module Peach
|
|
123
127
|
def validate_each_option(prompt)
|
124
128
|
prompt[:options].each_with_index do |option, idx|
|
125
129
|
validate_option_is_hash(option, idx)
|
126
|
-
validate_option_title(option, idx)
|
130
|
+
# validate_option_title(option, idx)
|
127
131
|
validate_option_value_or_values(prompt, option, idx)
|
128
132
|
end
|
129
133
|
end
|
@@ -144,7 +148,7 @@ module Peach
|
|
144
148
|
if prompt.key?(:button)
|
145
149
|
validate_option_values(option, idx)
|
146
150
|
else
|
147
|
-
validate_option_value(option, idx)
|
151
|
+
# validate_option_value(option, idx)
|
148
152
|
end
|
149
153
|
end
|
150
154
|
|
@@ -160,7 +164,7 @@ module Peach
|
|
160
164
|
end
|
161
165
|
|
162
166
|
validate_values_are_array(option, idx)
|
163
|
-
validate_each_value(option, idx)
|
167
|
+
# validate_each_value(option, idx)
|
164
168
|
end
|
165
169
|
|
166
170
|
def validate_values_are_array(option, idx)
|
data/lib/peach/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peach-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peach Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debug
|