File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,10 +140,12 @@ def remove_webhook
140140 # @see https://viber.github.io/docs/tools/keyboards/#buttons-parameters
141141 # @see https://developers.viber.com/docs/api/rest-bot-api/#keyboards
142142 #
143- def send_message ( message : , keyboard : { } )
143+ def send_message ( message , keyboard : { } )
144144 request (
145145 URL ::MESSAGE ,
146- { receiver : @response . user_id } . merge ( message , keyboard , min_api_version_hash ( keyboard ) )
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
147149 )
148150 end
149151
Original file line number Diff line number Diff line change 88 let ( :bot ) { Viberroo ::Bot . new ( token : token , response : response ) }
99
1010 describe '#send_message' do
11- subject { bot . send_message ( message : message , keyboard : keyboard ) }
11+ subject { bot . send_message ( message , keyboard : keyboard ) }
1212
1313 let ( :message ) do
1414 {
4545 end
4646 end
4747
48+ context 'when keyboard contain single input with api version but min_api-version was set before' do
49+ let ( :min_api_version ) { 7 }
50+ let ( :message ) { { min_api_version : min_api_version } }
51+ let ( :button ) { Viberroo ::Input . share_phone_button ( { } ) }
52+ let ( :keyboard ) { Viberroo ::Input . keyboard ( Buttons : [ button ] ) }
53+
54+ it 'sets correct :min_api_version attr in the params root' do
55+ expect ( bot ) . to receive ( :request ) . with (
56+ Viberroo ::URL ::MESSAGE ,
57+ { receiver : response . user_id } . merge ( message , keyboard , min_api_version : min_api_version )
58+ )
59+ subject
60+ end
61+ end
62+
4863 context 'when keyboard contain multiple inputs one of which has no api versions' do
4964 let ( :button_one ) { Viberroo ::Input . share_phone_button ( { } ) }
5065 let ( :button_two ) { Viberroo ::Input . reply_button ( { } ) }
You can’t perform that action at this time.
0 commit comments