viberroo 0.3.2 → 0.3.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/viberroo/bot.rb +14 -7
- data/lib/viberroo/configuration.rb +3 -3
- data/lib/viberroo/response.rb +12 -0
- data/lib/viberroo/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 905efb8d9509ef00211a87556c9601b8979eacd02a6cf1bb32d10f019ee34183
|
4
|
+
data.tar.gz: b906e7b223f3e88c5a4796475e352961081734e041c804d0d15a209bc8ef4cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 550a5477946d9eed9487035dce6a50c4f358b059bdc6dc476e4e8d4691795b353f596881acd621d09be25c5d170c1a5ff1a9531f20ad369e3e612fe736a1aa29
|
7
|
+
data.tar.gz: 1d074d1c78124566a8cc6d81d52c696e0d9fdd00db297b762b4e6af3e456ec7a82ee230961db98e786e1245146e6fc675c91d618b45b278e781e93df833dc302
|
data/lib/viberroo/bot.rb
CHANGED
@@ -28,7 +28,7 @@ module Viberroo
|
|
28
28
|
# @see Configuration
|
29
29
|
# @see https://developers.viber.com/docs/api/rest-bot-api/#authentication-token
|
30
30
|
#
|
31
|
-
def initialize(response
|
31
|
+
def initialize(response: Response.new({}), token: nil)
|
32
32
|
Viberroo.configure
|
33
33
|
|
34
34
|
@headers = {
|
@@ -65,7 +65,7 @@ module Viberroo
|
|
65
65
|
#
|
66
66
|
def set_webhook(url:, event_types: nil, send_name: nil, send_photo: nil)
|
67
67
|
request(URL::WEBHOOK, url: url, event_types: event_types,
|
68
|
-
|
68
|
+
send_name: send_name, send_photo: send_photo)
|
69
69
|
end
|
70
70
|
|
71
71
|
##
|
@@ -140,9 +140,18 @@ module Viberroo
|
|
140
140
|
# @see https://viber.github.io/docs/tools/keyboards/#buttons-parameters
|
141
141
|
# @see https://developers.viber.com/docs/api/rest-bot-api/#keyboards
|
142
142
|
#
|
143
|
+
def send_message(message, keyboard: {})
|
144
|
+
request(URL::MESSAGE, { receiver: @response.user_id }.merge(message, keyboard))
|
145
|
+
end
|
146
|
+
|
147
|
+
# @deprecated Use {#send_message} instead.
|
143
148
|
def send(message:, keyboard: {})
|
144
|
-
|
145
|
-
|
149
|
+
Viberroo.config.logger.info(<<~WARNING)
|
150
|
+
DEPRECATION WARNING: Bot#send method is going to be removed in the next
|
151
|
+
minor release. Use Bot#send_message instead.
|
152
|
+
WARNING
|
153
|
+
|
154
|
+
send_message(message, keyboard: keyboard)
|
146
155
|
end
|
147
156
|
|
148
157
|
##
|
@@ -204,7 +213,7 @@ module Viberroo
|
|
204
213
|
# @example
|
205
214
|
# response = @bot.get_online(ids: ViberSubscriber.sample(100).pluck(:viber_id))
|
206
215
|
#
|
207
|
-
# @param [Array]
|
216
|
+
# @param [Array] ids **Required**. List of user ids.
|
208
217
|
#
|
209
218
|
# @return [Net::HTTPResponse || Hash]
|
210
219
|
#
|
@@ -227,8 +236,6 @@ module Viberroo
|
|
227
236
|
http.request(request)
|
228
237
|
end
|
229
238
|
|
230
|
-
Viberroo.config.logger&.info("##{caller_name} -- #{response.body}")
|
231
|
-
|
232
239
|
Viberroo.config.parse_response_body ? JSON.parse(response.body) : response
|
233
240
|
end
|
234
241
|
|
@@ -39,15 +39,15 @@ module Viberroo
|
|
39
39
|
# @return [String]
|
40
40
|
#
|
41
41
|
# @see Bot#set_webhook
|
42
|
-
|
43
|
-
|
42
|
+
attr_accessor :auth_token
|
43
|
+
|
44
44
|
##
|
45
45
|
# Specifies whether to parse response body of Bot requests.
|
46
46
|
#
|
47
47
|
# @return [true || false]
|
48
48
|
#
|
49
49
|
# @see Bot
|
50
|
-
|
50
|
+
attr_accessor :parse_response_body
|
51
51
|
|
52
52
|
def initialize
|
53
53
|
@auth_token = nil
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Viktor Habchak
|
@@ -47,7 +47,7 @@ require_paths:
|
|
47
47
|
- lib
|
48
48
|
required_ruby_version: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
|
-
- - "
|
50
|
+
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '2.3'
|
53
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -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.
|
59
|
+
rubygems_version: 3.3.7
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Viber bot for Ruby / Rails.
|