Skip to content

Commit 01d52ce

Browse files
committed
Merge branch 'master' into feature/channel_access_token_v21
Conflicts: spec/line/bot/client_channel_token_spec.rb
2 parents d1812b6 + 3e7eb70 commit 01d52ce

31 files changed

+476
-58
lines changed

.github/workflows/pull_request.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Pull Request CI
2+
3+
on: [ pull_request ]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
ruby: [ '2.4', '2.5', '2.6', '2.7' ]
11+
name: Ruby v${{ matrix.ruby }}
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-ruby@v1
15+
with:
16+
ruby-version: ${{ matrix.ruby }}
17+
- run: gem install bundler
18+
- run: bundle install
19+
- run: bundle exec rubocop
20+
- run: bundle exec rspec

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,47 @@
11
# Change Log
22

3+
## [v1.16.0](https://github.com/line/line-bot-sdk-ruby/tree/v1.16.0) (2020-08-13)
4+
[Full Changelog](https://github.com/line/line-bot-sdk-ruby/compare/v1.15.0...v1.16.0)
5+
6+
**Closed issues:**
7+
8+
- The endpoint to get statistics is now available in Indonesia \(ID\) [\#194](https://github.com/line/line-bot-sdk-ruby/issues/194)
9+
10+
**Merged pull requests:**
11+
12+
- Add videoPlayComplete event and spec [\#196](https://github.com/line/line-bot-sdk-ruby/pull/196) ([ryota-sakamoto](https://github.com/ryota-sakamoto))
13+
- Add example for unsend [\#195](https://github.com/line/line-bot-sdk-ruby/pull/195) ([gom](https://github.com/gom))
14+
- Add unsend event and spec [\#193](https://github.com/line/line-bot-sdk-ruby/pull/193) ([dlackty](https://github.com/dlackty))
15+
16+
## [v1.15.0](https://github.com/line/line-bot-sdk-ruby/tree/v1.15.0) (2020-08-06)
17+
[Full Changelog](https://github.com/line/line-bot-sdk-ruby/compare/v1.14.1...v1.15.0)
18+
19+
**Implemented enhancements:**
20+
21+
- Support icon-nickname-switch [\#173](https://github.com/line/line-bot-sdk-ruby/issues/173)
22+
23+
**Closed issues:**
24+
25+
- Support Get user's language [\#181](https://github.com/line/line-bot-sdk-ruby/issues/181)
26+
- New property added to "sticker message" webhook event [\#154](https://github.com/line/line-bot-sdk-ruby/issues/154)
27+
- Support new Messaging API endpoints for friend statistics added on 10/16 [\#150](https://github.com/line/line-bot-sdk-ruby/issues/150)
28+
- Messaging API update for June 2020 [\#186](https://github.com/line/line-bot-sdk-ruby/issues/186)
29+
- Messaging API - May 2020 update [\#184](https://github.com/line/line-bot-sdk-ruby/issues/184)
30+
- Support LINE emoji in messages [\#180](https://github.com/line/line-bot-sdk-ruby/issues/180)
31+
32+
**Merged pull requests:**
33+
34+
- Release 1.15.0 [\#192](https://github.com/line/line-bot-sdk-ruby/pull/192) ([kimoto](https://github.com/kimoto))
35+
- Support X-Line-Retry-Key [\#189](https://github.com/line/line-bot-sdk-ruby/pull/189) ([kimoto](https://github.com/kimoto))
36+
- Add example for LINE emoji [\#188](https://github.com/line/line-bot-sdk-ruby/pull/188) ([kimoto](https://github.com/kimoto))
37+
- feat: endpoints for group and room informations [\#187](https://github.com/line/line-bot-sdk-ruby/pull/187) ([etrex](https://github.com/etrex))
38+
339
## [v1.14.1](https://github.com/line/line-bot-sdk-ruby/tree/v1.14.1) (2020-04-06)
440
[Full Changelog](https://github.com/line/line-bot-sdk-ruby/compare/v1.14.0...v1.14.1)
541

642
**Merged pull requests:**
743

44+
- Release 1.14.1 [\#178](https://github.com/line/line-bot-sdk-ruby/pull/178) ([kimoto](https://github.com/kimoto))
845
- Accept open-uri as create\_rich\_menu\_image's argument [\#177](https://github.com/line/line-bot-sdk-ruby/pull/177) ([yskkin](https://github.com/yskkin))
946
- Update rake requirement from ~\> 10.4 to ~\> 13.0 [\#176](https://github.com/line/line-bot-sdk-ruby/pull/176) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
1047
- Update webmock requirement from ~\> 1.24 to ~\> 3.8 [\#175](https://github.com/line/line-bot-sdk-ruby/pull/175) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
@@ -31,6 +68,7 @@
3168
- Issue template [\#147](https://github.com/line/line-bot-sdk-ruby/issues/147)
3269
- Documentation - clean up [\#146](https://github.com/line/line-bot-sdk-ruby/issues/146)
3370
- Flex 1 update [\#144](https://github.com/line/line-bot-sdk-ruby/issues/144)
71+
- Release v1.14.0 [\#171](https://github.com/line/line-bot-sdk-ruby/pull/171) ([kimoto](https://github.com/kimoto))
3472

3573
**Merged pull requests:**
3674

examples/kitchensink/app.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ def reply_content(event, messages)
7777
when Line::Bot::Event::Things
7878
reply_text(event, "[THINGS]\n#{JSON.generate(event['things'])}")
7979

80+
when Line::Bot::Event::VideoPlayComplete
81+
reply_text(event, "[VIDEOPLAYCOMPLETE]\n#{JSON.generate(event['videoPlayComplete'])}")
82+
83+
when Line::Bot::Event::Unsend
84+
handle_unsend(event)
85+
8086
else
8187
reply_text(event, "Unknown event type: #{event}")
8288
end
@@ -129,6 +135,19 @@ def handle_message(event)
129135
reply_text(event, "Bot can't use profile API without user ID")
130136
end
131137

138+
when 'emoji'
139+
reply_content(event, {
140+
type: 'text',
141+
text: 'Look at this: $ It\'s a LINE emoji!',
142+
emojis: [
143+
{
144+
index: 14,
145+
productId: '5ac1bfd5040ab15980c9b435',
146+
emojiId: '001'
147+
}
148+
]
149+
})
150+
132151
when 'buttons'
133152
reply_content(event, {
134153
type: 'template',
@@ -600,3 +619,19 @@ def handle_location(event)
600619
longitude: message['longitude']
601620
})
602621
end
622+
623+
def handle_unsend(event)
624+
source = event['source']
625+
id = case source['type']
626+
when 'user'
627+
source['userId']
628+
when 'group'
629+
source['groupId']
630+
when 'room'
631+
source['roomId']
632+
end
633+
client.push_message(id, {
634+
type: 'text',
635+
text: "[UNSEND]\nmessageId: #{event['unsend']['messageId']}"
636+
})
637+
end

lib/line/bot/api.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module Bot
1919
module API
2020
DEFAULT_ENDPOINT = "https://api.line.me/v2"
2121
DEFAULT_BLOB_ENDPOINT = "https://api-data.line.me/v2"
22+
DEFAULT_LIFF_ENDPOINT = "https://api.line.me/liff/v1"
2223

2324
DEFAULT_HEADERS = {
2425
'Content-Type' => 'application/json; charset=UTF-8',

lib/line/bot/api/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
module Line
1616
module Bot
1717
module API
18-
VERSION = "1.14.1"
18+
VERSION = "1.16.0"
1919
end
2020
end
2121
end

lib/line/bot/client.rb

Lines changed: 104 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ def blob_endpoint
6666
end
6767
end
6868

69+
def liff_endpoint
70+
@liff_endpoint ||= API::DEFAULT_LIFF_ENDPOINT
71+
end
72+
6973
# @return [Hash]
7074
def credentials
7175
{
@@ -163,15 +167,16 @@ def get_channel_access_token_key_ids_21(jwt)
163167
#
164168
# @param user_id [String] User Id
165169
# @param messages [Hash or Array] Message Objects
170+
# @param headers [Hash] HTTP Headers
166171
# @return [Net::HTTPResponse]
167-
def push_message(user_id, messages)
172+
def push_message(user_id, messages, headers: {})
168173
channel_token_required
169174

170175
messages = [messages] if messages.is_a?(Hash)
171176

172177
endpoint_path = '/bot/message/push'
173178
payload = { to: user_id, messages: messages }.to_json
174-
post(endpoint, endpoint_path, payload, credentials)
179+
post(endpoint, endpoint_path, payload, credentials.merge(headers))
175180
end
176181

177182
# Reply messages to a user using replyToken.
@@ -208,30 +213,33 @@ def reply_message(token, messages)
208213
#
209214
# @param to [Array or String] Array of userIds
210215
# @param messages [Hash or Array] Message Objects
216+
# @param headers [Hash] HTTP Headers
211217
# @return [Net::HTTPResponse]
212-
def multicast(to, messages)
218+
def multicast(to, messages, headers: {})
213219
channel_token_required
214220

215221
to = [to] if to.is_a?(String)
216222
messages = [messages] if messages.is_a?(Hash)
217223

218224
endpoint_path = '/bot/message/multicast'
219225
payload = { to: to, messages: messages }.to_json
220-
post(endpoint, endpoint_path, payload, credentials)
226+
post(endpoint, endpoint_path, payload, credentials.merge(headers))
221227
end
222228

223229
# Send messages to all friends.
224230
#
225231
# @param messages [Hash or Array] Message Objects
232+
# @param headers [Hash] HTTP Headers
233+
#
226234
# @return [Net::HTTPResponse]
227-
def broadcast(messages)
235+
def broadcast(messages, headers: {})
228236
channel_token_required
229237

230238
messages = [messages] if messages.is_a?(Hash)
231239

232240
endpoint_path = '/bot/message/broadcast'
233241
payload = { messages: messages }.to_json
234-
post(endpoint, endpoint_path, payload, credentials)
242+
post(endpoint, endpoint_path, payload, credentials.merge(headers))
235243
end
236244

237245
# Narrowcast messages to users
@@ -243,9 +251,10 @@ def broadcast(messages)
243251
# @param recipient [Hash]
244252
# @param filter [Hash]
245253
# @param limit [Hash]
254+
# @param headers [Hash] HTTP Headers
246255
#
247256
# @return [Net::HTTPResponse]
248-
def narrowcast(messages, recipient: nil, filter: nil, limit: nil)
257+
def narrowcast(messages, recipient: nil, filter: nil, limit: nil, headers: {})
249258
channel_token_required
250259

251260
messages = [messages] if messages.is_a?(Hash)
@@ -257,7 +266,7 @@ def narrowcast(messages, recipient: nil, filter: nil, limit: nil)
257266
filter: filter,
258267
limit: limit
259268
}.to_json
260-
post(endpoint, endpoint_path, payload, credentials)
269+
post(endpoint, endpoint_path, payload, credentials.merge(headers))
261270
end
262271

263272
def leave_group(group_id)
@@ -352,6 +361,42 @@ def get_room_member_ids(room_id, continuation_token = nil)
352361
get(endpoint, endpoint_path, credentials)
353362
end
354363

364+
# Gets the group ID, group name, and group icon URL of a group where the LINE Official Account is a member.
365+
#
366+
# @param group_id [String] Group's identifier
367+
#
368+
# @return [Net::HTTPResponse]
369+
def get_group_summary(group_id)
370+
channel_token_required
371+
372+
endpoint_path = "/bot/group/#{group_id}/summary"
373+
get(endpoint, endpoint_path, credentials)
374+
end
375+
376+
# Gets the user IDs of the members of a group that the bot is in.
377+
#
378+
# @param group_id [String] Group's identifier
379+
#
380+
# @return [Net::HTTPResponse]
381+
def get_group_members_count(group_id)
382+
channel_token_required
383+
384+
endpoint_path = "/bot/group/#{group_id}/members/count"
385+
get(endpoint, endpoint_path, credentials)
386+
end
387+
388+
# Gets the count of members in a room.
389+
#
390+
# @param room_id [String] Room's identifier
391+
#
392+
# @return [Net::HTTPResponse]
393+
def get_room_members_count(room_id)
394+
channel_token_required
395+
396+
endpoint_path = "/bot/room/#{room_id}/members/count"
397+
get(endpoint, endpoint_path, credentials)
398+
end
399+
355400
# Get a list of all uploaded rich menus
356401
#
357402
# @return [Net::HTTPResponse]
@@ -647,6 +692,44 @@ def get_friend_demographics
647692
get(endpoint, endpoint_path, credentials)
648693
end
649694

695+
# Gets a bot's basic information.
696+
#
697+
# @return [Net::HTTPResponse]
698+
def get_bot_info
699+
channel_token_required
700+
701+
endpoint_path = '/bot/info'
702+
get(endpoint, endpoint_path, credentials)
703+
end
704+
705+
def get_liff_apps
706+
channel_token_required
707+
708+
endpoint_path = '/apps'
709+
get(liff_endpoint, endpoint_path, credentials)
710+
end
711+
712+
def create_liff_app(app)
713+
channel_token_required
714+
715+
endpoint_path = '/apps'
716+
post(liff_endpoint, endpoint_path, app.to_json, credentials)
717+
end
718+
719+
def update_liff_app(liff_id, app)
720+
channel_token_required
721+
722+
endpoint_path = "/apps/#{liff_id}"
723+
put(liff_endpoint, endpoint_path, app.to_json, credentials)
724+
end
725+
726+
def delete_liff_app(liff_id)
727+
channel_token_required
728+
729+
endpoint_path = "/apps/#{liff_id}"
730+
delete(liff_endpoint, endpoint_path, credentials)
731+
end
732+
650733
# Fetch data, get content of specified URL.
651734
#
652735
# @param endpoint_base [String]
@@ -672,6 +755,19 @@ def post(endpoint_base, endpoint_path, payload = nil, headers = {})
672755
httpclient.post(endpoint_base + endpoint_path, payload, headers)
673756
end
674757

758+
# Put data, get content of specified URL.
759+
#
760+
# @param endpoint_base [String]
761+
# @param endpoint_path [String]
762+
# @param payload [String or NilClass]
763+
# @param headers [Hash]
764+
#
765+
# @return [Net::HTTPResponse]
766+
def put(endpoint_base, endpoint_path, payload = nil, headers = {})
767+
headers = API::DEFAULT_HEADERS.merge(headers)
768+
httpclient.put(endpoint_base + endpoint_path, payload, headers)
769+
end
770+
675771
# Delete content of specified URL.
676772
#
677773
# @param endpoint_base [String]

lib/line/bot/event.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
require 'line/bot/event/message'
2222
require 'line/bot/event/postback'
2323
require 'line/bot/event/unfollow'
24+
require 'line/bot/event/unsend'
2425
require 'line/bot/event/member_joined'
2526
require 'line/bot/event/member_left'
2627
require 'line/bot/event/things'
28+
require 'line/bot/event/video_play_complete'

lib/line/bot/event/unsend.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2016 LINE
2+
#
3+
# LINE Corporation licenses this file to you under the Apache License,
4+
# version 2.0 (the "License"); you may not use this file except in compliance
5+
# with the License. You may obtain a copy of the License at:
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
15+
module Line
16+
module Bot
17+
module Event
18+
# Event object for when the user unsends a message in a group or room.
19+
#
20+
# No replyToken is generated for this event.
21+
#
22+
# https://developers.line.biz/en/reference/messaging-api/#unsend-event
23+
class Unsend < Base
24+
end
25+
end
26+
end
27+
end

0 commit comments

Comments
 (0)