viberroo 0.3.4 → 0.3.6
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/viberroo/bot.rb +25 -1
- data/lib/viberroo/response.rb +12 -0
- data/lib/viberroo/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: c569eed07cf0475903f3c9a5777dc953cd0acde17b0e7a4c4da83f8fbe6d9432
|
4
|
+
data.tar.gz: 055dc6395d9aba734402ad5055288581576b7fccf55d844862a1da916ef844a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d55b1a657492018e73c48aa2d662a46e2bf94576c491507b0783b94fd8ab47c4e55b8f3223722f70601a6afa9bd7c6d3b5c9cd465e05f8c651326e8925b890e7
|
7
|
+
data.tar.gz: 1c43468c37ff74c91c471615f75b3c00a9e78fe68d80ea771afc475cb7a3272bedd5876801355541fc8718fb1464e3bef28a75a74ca35ae0513e7bfc322ae968
|
data/lib/viberroo/bot.rb
CHANGED
@@ -141,7 +141,12 @@ module Viberroo
|
|
141
141
|
# @see https://developers.viber.com/docs/api/rest-bot-api/#keyboards
|
142
142
|
#
|
143
143
|
def send_message(message, keyboard: {})
|
144
|
-
request(
|
144
|
+
request(
|
145
|
+
URL::MESSAGE,
|
146
|
+
{ receiver: @response.user_id }.merge(message, keyboard).tap do |hash|
|
147
|
+
hash.merge!(min_api_version_hash(keyboard)) unless hash[:min_api_version]
|
148
|
+
end
|
149
|
+
)
|
145
150
|
end
|
146
151
|
|
147
152
|
# @deprecated Use {#send_message} instead.
|
@@ -249,5 +254,24 @@ module Viberroo
|
|
249
254
|
def caller_name
|
250
255
|
caller[1][/`.*'/][1..-2]
|
251
256
|
end
|
257
|
+
|
258
|
+
##
|
259
|
+
# @!visibility private
|
260
|
+
#
|
261
|
+
# @note Iterates each keyboard input to identify the maximum required :min_api_version param.
|
262
|
+
#
|
263
|
+
# @return [Hash || Empty Hash]
|
264
|
+
#
|
265
|
+
def min_api_version_hash(keyboard)
|
266
|
+
buttons_array = keyboard.dig(:keyboard, :Buttons)
|
267
|
+
|
268
|
+
return {} unless buttons_array
|
269
|
+
|
270
|
+
min_api_version = buttons_array.map { |btn| btn[:min_api_version] }.compact.max
|
271
|
+
|
272
|
+
return {} unless min_api_version
|
273
|
+
|
274
|
+
{ min_api_version: min_api_version }
|
275
|
+
end
|
252
276
|
end
|
253
277
|
end
|
data/lib/viberroo/response.rb
CHANGED
@@ -16,7 +16,15 @@ module Viberroo
|
|
16
16
|
# skip_before_action :verify_authenticity_token
|
17
17
|
#
|
18
18
|
# def callback
|
19
|
+
# # For example, params contain the following:
|
20
|
+
# # { foo: { bar: { baz: :boo }}}
|
19
21
|
# @response = Viberroo::Response.new(params.permit!)
|
22
|
+
# # Those can be accessed through params:
|
23
|
+
# puts @response.params.foo
|
24
|
+
# # Or directly:
|
25
|
+
# puts @response.foo
|
26
|
+
# puts @response.foo.bar
|
27
|
+
# puts @response.foo.bar.baz
|
20
28
|
# @bot = Viberroo::Bot.new(response: @response)
|
21
29
|
#
|
22
30
|
# head :ok
|
@@ -47,5 +55,9 @@ module Viberroo
|
|
47
55
|
@params.dig(:user, :id)
|
48
56
|
end
|
49
57
|
end
|
58
|
+
|
59
|
+
def method_missing(method)
|
60
|
+
params.public_send(method)
|
61
|
+
end
|
50
62
|
end
|
51
63
|
end
|
data/lib/viberroo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viberroo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Viktor Habchak
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
requirements: []
|
59
|
-
rubygems_version: 3.3.
|
59
|
+
rubygems_version: 3.3.26
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Viber bot for Ruby / Rails.
|