peach-ruby 0.3.0 → 0.5.0
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/README.md +34 -3
- data/lib/peach/stream/response.rb +15 -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: 1c436683fd63ce4146bae46abd33f6a3b526763827e0346fc078047f45ceb83a
|
4
|
+
data.tar.gz: 510884541687f39b105f3f99ddd5c1dd58a9749b730462b40ab2f46082f92e50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e89f352088cd473f27aea558b6f9ffbab323cc5995de4466ee9982b407a82e1c3266243776a96b731879c7b5b8169e94b99ac7d5e87e1d0979e6031c1fdfa214
|
7
|
+
data.tar.gz: 623041f06dd194ac1a18b067ae49165a8c81453bdf91f5684480161ad04f5f8f1e90728684107309c487563ebace0aa1fb998462bc1e01ceafebecafd0ea14aa
|
data/README.md
CHANGED
@@ -45,10 +45,41 @@ Peach::TemplateMessage.deliver('wat_1234abcd', { foo: 'bar' }, contact)
|
|
45
45
|
|
46
46
|
## Development
|
47
47
|
|
48
|
-
|
48
|
+
### Install dependencies
|
49
49
|
|
50
|
-
|
50
|
+
```bash
|
51
|
+
bin/setup
|
52
|
+
```
|
53
|
+
|
54
|
+
### Run tests
|
55
|
+
|
56
|
+
```bash
|
57
|
+
bundle exec rake spec
|
58
|
+
```
|
59
|
+
|
60
|
+
### Use the interactive prompt
|
61
|
+
|
62
|
+
```bash
|
63
|
+
bin/console
|
64
|
+
```
|
65
|
+
|
66
|
+
### Install gem locally
|
67
|
+
|
68
|
+
```bash
|
69
|
+
bundle exec rake install
|
70
|
+
```
|
71
|
+
|
72
|
+
### Release a new version
|
73
|
+
|
74
|
+
We use the [rubygems/release-gem@v1](https://github.com/rubygems/release-gem) action, which creates the tags and pushes the `.gem` file to [rubygems.org](https://rubygems.org) for us.
|
75
|
+
|
76
|
+
What we need to do then is:
|
77
|
+
1. Update version number in `version.rb`
|
78
|
+
2. Run `bundle install` to update `Gemfile.lock` with the new gem version
|
79
|
+
3. Add and commit changes and create a Pull Request
|
80
|
+
|
81
|
+
The GitHub Action then should ideally take care of the rest.
|
51
82
|
|
52
83
|
## Contributing
|
53
84
|
|
54
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
85
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/trypeach-io/peach-ruby.
|
@@ -42,6 +42,12 @@ module Peach
|
|
42
42
|
{ prompt: prompt }
|
43
43
|
end
|
44
44
|
|
45
|
+
def send_template_message(system_name, data: {})
|
46
|
+
template_message = { system_name: system_name }
|
47
|
+
template_message[:data] = data unless data.empty?
|
48
|
+
{ template_message: template_message }
|
49
|
+
end
|
50
|
+
|
45
51
|
def handoff(user_id: nil, group_id: nil, text: nil)
|
46
52
|
handoff = {}
|
47
53
|
handoff[:message] = { text: text } if text
|
@@ -95,8 +101,8 @@ module Peach
|
|
95
101
|
def validate_prompt(prompt)
|
96
102
|
validate_key(prompt)
|
97
103
|
validate_data(prompt)
|
98
|
-
validate_button(prompt)
|
99
|
-
validate_options(prompt)
|
104
|
+
validate_button(prompt)
|
105
|
+
validate_options(prompt)
|
100
106
|
end
|
101
107
|
|
102
108
|
def validate_key(prompt)
|
@@ -110,11 +116,15 @@ module Peach
|
|
110
116
|
end
|
111
117
|
|
112
118
|
def validate_button(prompt)
|
119
|
+
return unless prompt.key?(:button)
|
120
|
+
|
113
121
|
raise Peach::BadResponseError, 'Field `prompt.button` is not a String' unless prompt[:button].is_a?(String)
|
114
122
|
raise Peach::BadResponseError, 'Field `prompt.button` is empty' if prompt[:button].empty?
|
115
123
|
end
|
116
124
|
|
117
125
|
def validate_options(prompt)
|
126
|
+
return unless prompt.key?(:options)
|
127
|
+
|
118
128
|
raise Peach::BadResponseError, 'Field `prompt.options` is not an Array' unless prompt[:options].is_a?(Array)
|
119
129
|
|
120
130
|
validate_each_option(prompt)
|
@@ -123,7 +133,7 @@ module Peach
|
|
123
133
|
def validate_each_option(prompt)
|
124
134
|
prompt[:options].each_with_index do |option, idx|
|
125
135
|
validate_option_is_hash(option, idx)
|
126
|
-
validate_option_title(option, idx)
|
136
|
+
# validate_option_title(option, idx)
|
127
137
|
validate_option_value_or_values(prompt, option, idx)
|
128
138
|
end
|
129
139
|
end
|
@@ -144,7 +154,7 @@ module Peach
|
|
144
154
|
if prompt.key?(:button)
|
145
155
|
validate_option_values(option, idx)
|
146
156
|
else
|
147
|
-
validate_option_value(option, idx)
|
157
|
+
# validate_option_value(option, idx)
|
148
158
|
end
|
149
159
|
end
|
150
160
|
|
@@ -160,7 +170,7 @@ module Peach
|
|
160
170
|
end
|
161
171
|
|
162
172
|
validate_values_are_array(option, idx)
|
163
|
-
validate_each_value(option, idx)
|
173
|
+
# validate_each_value(option, idx)
|
164
174
|
end
|
165
175
|
|
166
176
|
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.5.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-
|
11
|
+
date: 2024-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debug
|