viberroo 0.3.2 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d57993081fac92ff1ebeb1b7ae2da6a269e63d5fdb311f139798e8e4868cf072
4
- data.tar.gz: '0990bb91aad353fe640c1b4e491fdec405a42a3c3676fe2e3c8bf6bb78dfce9c'
3
+ metadata.gz: 905efb8d9509ef00211a87556c9601b8979eacd02a6cf1bb32d10f019ee34183
4
+ data.tar.gz: b906e7b223f3e88c5a4796475e352961081734e041c804d0d15a209bc8ef4cce
5
5
  SHA512:
6
- metadata.gz: 9b79c7790edd6f836a8a4acd5b5b3bfa10dba7dc4cbecf64ab61131fd9a913a940d1d21331f4a1d6d98e1f58e9d03be60caa5264d7c03c5382a6b4939b026ec3
7
- data.tar.gz: 9720b62c4fb5f76d42893763ecac41a9cdf5f1d3dc74022ff886d85fb75480e988e673d6c5261aedc83bf0157d3c40a852cbcce692b29dec2d4dcce5d264f0f8
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:, token: nil)
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
- send_name: send_name, send_photo: send_photo)
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
- request(URL::MESSAGE,
145
- { receiver: @response&.user_id }.merge(message).merge(keyboard))
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] message **Required**. List of user ids.
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
- attr_accessor :auth_token
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
- attr_accessor :parse_response_body
50
+ attr_accessor :parse_response_body
51
51
 
52
52
  def initialize
53
53
  @auth_token = nil
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Viberroo
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '0.3.5'.freeze
3
3
  end
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.2
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.0.3
59
+ rubygems_version: 3.3.7
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: Viber bot for Ruby / Rails.