line-bot-api 1.13.0 → 1.14.0
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/README.md +4 -0
- data/lib/line/bot/api/version.rb +1 -1
- data/lib/line/bot/client.rb +82 -24
- data/lib/line/bot/event/account_link.rb +5 -0
- data/lib/line/bot/event/beacon.rb +6 -0
- data/lib/line/bot/event/follow.rb +4 -0
- data/lib/line/bot/event/join.rb +3 -0
- data/lib/line/bot/event/leave.rb +5 -0
- data/lib/line/bot/event/member_joined.rb +3 -0
- data/lib/line/bot/event/member_left.rb +5 -0
- data/lib/line/bot/event/message.rb +3 -0
- data/lib/line/bot/event/postback.rb +3 -0
- data/lib/line/bot/event/things.rb +5 -0
- data/lib/line/bot/event/unfollow.rb +5 -0
- data/lib/line/bot/httpclient.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc272a376d9eb4be79d9c92ee485737c6474f652c0873923010f5b25d1d78c1a
|
4
|
+
data.tar.gz: 4beb042559850867763cec2920ac0715877c2b2a7b5538c8a749bd226de2571e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ca96d2225493a374bc23497b075a740ff95f469d4b2b832143083c96a1d4d319482ccb1c7b4a4f6bc0dbd93774bd49a6425c3dbc0a4d552b6afa6795125061e
|
7
|
+
data.tar.gz: 1809fa4bbadda5065d2f8ec1e8d4bc7fd266c1f0014623bd4606488ba6266cc8e4321fe498edf2aa63c8f6cab3bb397094d0c2aff12c37dad9c9bd5be5dfd439
|
data/README.md
CHANGED
@@ -13,6 +13,10 @@ See the official API documentation for more information
|
|
13
13
|
- English: https://developers.line.biz/en/docs/messaging-api/overview/
|
14
14
|
- Japanese: https://developers.line.biz/ja/docs/messaging-api/overview/
|
15
15
|
|
16
|
+
Also, generated documentation by YARD is available.
|
17
|
+
|
18
|
+
- https://rubydoc.info/gems/line-bot-api
|
19
|
+
|
16
20
|
## Installation
|
17
21
|
|
18
22
|
Add this line to your application's Gemfile:
|
data/lib/line/bot/api/version.rb
CHANGED
data/lib/line/bot/client.rb
CHANGED
@@ -19,6 +19,13 @@ require 'uri'
|
|
19
19
|
|
20
20
|
module Line
|
21
21
|
module Bot
|
22
|
+
# API Client of LINE Bot SDK Ruby
|
23
|
+
#
|
24
|
+
# @client ||= Line::Bot::Client.new do |config|
|
25
|
+
# config.channel_id = ENV["LINE_CHANNEL_ID"]
|
26
|
+
# config.channel_secret = ENV["LINE_CHANNEL_SECRET"]
|
27
|
+
# config.channel_token = ENV["LINE_CHANNEL_TOKEN"]
|
28
|
+
# end
|
22
29
|
class Client
|
23
30
|
# @return [String]
|
24
31
|
attr_accessor :channel_token, :channel_id, :channel_secret, :endpoint, :blob_endpoint
|
@@ -29,10 +36,9 @@ module Line
|
|
29
36
|
# @return [Hash]
|
30
37
|
attr_accessor :http_options
|
31
38
|
|
32
|
-
# Initialize a new
|
39
|
+
# Initialize a new client.
|
33
40
|
#
|
34
41
|
# @param options [Hash]
|
35
|
-
#
|
36
42
|
# @return [Line::Bot::Client]
|
37
43
|
def initialize(options = {})
|
38
44
|
options.each do |key, value|
|
@@ -96,11 +102,10 @@ module Line
|
|
96
102
|
post(endpoint, endpoint_path, payload, headers)
|
97
103
|
end
|
98
104
|
|
99
|
-
# Push messages to
|
100
|
-
#
|
101
|
-
# @param user_id [String] User's identifiers
|
102
|
-
# @param messages [Hash or Array]
|
105
|
+
# Push messages to a user using user_id.
|
103
106
|
#
|
107
|
+
# @param user_id [String] User Id
|
108
|
+
# @param messages [Hash or Array] Message Objects
|
104
109
|
# @return [Net::HTTPResponse]
|
105
110
|
def push_message(user_id, messages)
|
106
111
|
channel_token_required
|
@@ -112,11 +117,25 @@ module Line
|
|
112
117
|
post(endpoint, endpoint_path, payload, credentials)
|
113
118
|
end
|
114
119
|
|
115
|
-
# Reply messages to
|
120
|
+
# Reply messages to a user using replyToken.
|
116
121
|
#
|
117
|
-
# @
|
118
|
-
#
|
122
|
+
# @example Send a balloon to a user.
|
123
|
+
# message = {
|
124
|
+
# type: 'text',
|
125
|
+
# text: 'Hello, World!'
|
126
|
+
# }
|
127
|
+
# client.reply_message(event['replyToken'], message)
|
128
|
+
#
|
129
|
+
# @example Send multiple balloons to a user.
|
119
130
|
#
|
131
|
+
# messages = [
|
132
|
+
# {type: 'text', text: 'Message1'},
|
133
|
+
# {type: 'text', text: 'Message2'}
|
134
|
+
# ]
|
135
|
+
# client.reply_message(event['replyToken'], messages)
|
136
|
+
#
|
137
|
+
# @param token [String] Reply Token
|
138
|
+
# @param messages [Hash or Array] Message Objects
|
120
139
|
# @return [Net::HTTPResponse]
|
121
140
|
def reply_message(token, messages)
|
122
141
|
channel_token_required
|
@@ -128,11 +147,10 @@ module Line
|
|
128
147
|
post(endpoint, endpoint_path, payload, credentials)
|
129
148
|
end
|
130
149
|
|
131
|
-
#
|
132
|
-
#
|
133
|
-
# @param to [Array or String]
|
134
|
-
# @param messages [Hash or Array]
|
150
|
+
# Send messages to multiple users using userIds.
|
135
151
|
#
|
152
|
+
# @param to [Array or String] Array of userIds
|
153
|
+
# @param messages [Hash or Array] Message Objects
|
136
154
|
# @return [Net::HTTPResponse]
|
137
155
|
def multicast(to, messages)
|
138
156
|
channel_token_required
|
@@ -145,10 +163,9 @@ module Line
|
|
145
163
|
post(endpoint, endpoint_path, payload, credentials)
|
146
164
|
end
|
147
165
|
|
148
|
-
#
|
149
|
-
#
|
150
|
-
# @param messages [Hash or Array]
|
166
|
+
# Send messages to all friends.
|
151
167
|
#
|
168
|
+
# @param messages [Hash or Array] Message Objects
|
152
169
|
# @return [Net::HTTPResponse]
|
153
170
|
def broadcast(messages)
|
154
171
|
channel_token_required
|
@@ -160,6 +177,32 @@ module Line
|
|
160
177
|
post(endpoint, endpoint_path, payload, credentials)
|
161
178
|
end
|
162
179
|
|
180
|
+
# Narrowcast messages to users
|
181
|
+
#
|
182
|
+
# API Documentation is here.
|
183
|
+
# https://developers.line.biz/en/reference/messaging-api/#send-narrowcast-message
|
184
|
+
#
|
185
|
+
# @param messages [Hash or Array]
|
186
|
+
# @param recipient [Hash]
|
187
|
+
# @param filter [Hash]
|
188
|
+
# @param limit [Hash]
|
189
|
+
#
|
190
|
+
# @return [Net::HTTPResponse]
|
191
|
+
def narrowcast(messages, recipient: nil, filter: nil, limit: nil)
|
192
|
+
channel_token_required
|
193
|
+
|
194
|
+
messages = [messages] if messages.is_a?(Hash)
|
195
|
+
|
196
|
+
endpoint_path = '/bot/message/narrowcast'
|
197
|
+
payload = {
|
198
|
+
messages: messages,
|
199
|
+
recipient: recipient,
|
200
|
+
filter: filter,
|
201
|
+
limit: limit
|
202
|
+
}.to_json
|
203
|
+
post(endpoint, endpoint_path, payload, credentials)
|
204
|
+
end
|
205
|
+
|
163
206
|
def leave_group(group_id)
|
164
207
|
channel_token_required
|
165
208
|
|
@@ -177,7 +220,6 @@ module Line
|
|
177
220
|
# Get message content.
|
178
221
|
#
|
179
222
|
# @param identifier [String] Message's identifier
|
180
|
-
#
|
181
223
|
# @return [Net::HTTPResponse]
|
182
224
|
def get_message_content(identifier)
|
183
225
|
channel_token_required
|
@@ -188,8 +230,7 @@ module Line
|
|
188
230
|
|
189
231
|
# Get an user's profile.
|
190
232
|
#
|
191
|
-
# @param user_id [String] User
|
192
|
-
#
|
233
|
+
# @param user_id [String] User Id user_id
|
193
234
|
# @return [Net::HTTPResponse]
|
194
235
|
def get_profile(user_id)
|
195
236
|
channel_token_required
|
@@ -201,7 +242,7 @@ module Line
|
|
201
242
|
# Get an user's profile of a group.
|
202
243
|
#
|
203
244
|
# @param group_id [String] Group's identifier
|
204
|
-
# @param user_id [String] User
|
245
|
+
# @param user_id [String] User Id user_id
|
205
246
|
#
|
206
247
|
# @return [Net::HTTPResponse]
|
207
248
|
def get_group_member_profile(group_id, user_id)
|
@@ -214,7 +255,7 @@ module Line
|
|
214
255
|
# Get an user's profile of a room.
|
215
256
|
#
|
216
257
|
# @param room_id [String] Room's identifier
|
217
|
-
# @param user_id [String] User
|
258
|
+
# @param user_id [String] User Id user_id
|
218
259
|
#
|
219
260
|
# @return [Net::HTTPResponse]
|
220
261
|
def get_room_member_profile(room_id, user_id)
|
@@ -241,7 +282,7 @@ module Line
|
|
241
282
|
|
242
283
|
# Get user IDs of a room
|
243
284
|
#
|
244
|
-
# @param
|
285
|
+
# @param room_id [String] Room's identifier
|
245
286
|
# @param continuation_token [String] Identifier to return next page
|
246
287
|
# (next property to be included in the response)
|
247
288
|
#
|
@@ -394,6 +435,9 @@ module Line
|
|
394
435
|
|
395
436
|
# Link a rich menu to a user
|
396
437
|
#
|
438
|
+
# If you want to link a rich menu to multiple users,
|
439
|
+
# please consider to use bulk_link_rich_menus.
|
440
|
+
#
|
397
441
|
# @param user_id [String] ID of the user
|
398
442
|
# @param rich_menu_id [String] ID of an uploaded rich menu
|
399
443
|
#
|
@@ -519,6 +563,18 @@ module Line
|
|
519
563
|
get(endpoint, endpoint_path, credentials)
|
520
564
|
end
|
521
565
|
|
566
|
+
# Returns statistics about how users interact with narrowcast messages or broadcast messages sent from your LINE Official Account.
|
567
|
+
#
|
568
|
+
# @param [String] request_id
|
569
|
+
#
|
570
|
+
# @return [Net::HTTPResponse]
|
571
|
+
def get_user_interaction_statistics(request_id)
|
572
|
+
channel_token_required
|
573
|
+
|
574
|
+
endpoint_path = "/bot/insight/message/event?requestId=#{request_id}"
|
575
|
+
get(endpoint, endpoint_path, credentials)
|
576
|
+
end
|
577
|
+
|
522
578
|
# Returns the number of followers
|
523
579
|
#
|
524
580
|
# @param [String] date (Format:yyyyMMdd, Example:20191231)
|
@@ -531,7 +587,7 @@ module Line
|
|
531
587
|
get(endpoint, endpoint_path, credentials)
|
532
588
|
end
|
533
589
|
|
534
|
-
#
|
590
|
+
# Get the demographic attributes for a bot's friends.
|
535
591
|
#
|
536
592
|
# @return [Net::HTTPResponse]
|
537
593
|
def get_friend_demographics
|
@@ -596,7 +652,9 @@ module Line
|
|
596
652
|
end
|
597
653
|
end
|
598
654
|
|
599
|
-
# Validate signature
|
655
|
+
# Validate signature of a webhook event.
|
656
|
+
#
|
657
|
+
# https://developers.line.biz/en/reference/messaging-api/#signature-validation
|
600
658
|
#
|
601
659
|
# @param content [String] Request's body
|
602
660
|
# @param channel_signature [String] Request'header 'X-LINE-Signature' # HTTP_X_LINE_SIGNATURE
|
@@ -15,11 +15,16 @@
|
|
15
15
|
module Line
|
16
16
|
module Bot
|
17
17
|
module Event
|
18
|
+
# Event object for when a user has linked his/her LINE account with a provider's service account.
|
19
|
+
#
|
20
|
+
# https://developers.line.biz/en/reference/messaging-api/#account-link-event
|
18
21
|
class AccountLink < Base
|
22
|
+
# @return [String]
|
19
23
|
def result
|
20
24
|
@src['link']['result']
|
21
25
|
end
|
22
26
|
|
27
|
+
# @return [String]
|
23
28
|
def nonce
|
24
29
|
@src['link']['nonce']
|
25
30
|
end
|
@@ -15,15 +15,21 @@
|
|
15
15
|
module Line
|
16
16
|
module Bot
|
17
17
|
module Event
|
18
|
+
# Event object for when a user enters the range of a LINE Beacon.
|
19
|
+
#
|
20
|
+
# https://developers.line.biz/en/reference/messaging-api/#beacon-event
|
18
21
|
class Beacon < Base
|
22
|
+
# @return [String]
|
19
23
|
def type
|
20
24
|
@src['beacon']['type']
|
21
25
|
end
|
22
26
|
|
27
|
+
# @return [String]
|
23
28
|
def hwid
|
24
29
|
@src['beacon']['hwid']
|
25
30
|
end
|
26
31
|
|
32
|
+
# @return [String]
|
27
33
|
def deviceMessage
|
28
34
|
[@src['beacon']['dm']].pack('H*')
|
29
35
|
end
|
@@ -15,6 +15,10 @@
|
|
15
15
|
module Line
|
16
16
|
module Bot
|
17
17
|
module Event
|
18
|
+
# Event object for when your LINE official account is added as a friend (or unblocked).
|
19
|
+
# You can reply to follow events.
|
20
|
+
#
|
21
|
+
# https://developers.line.biz/en/reference/messaging-api/#follow-event
|
18
22
|
class Follow < Base
|
19
23
|
end
|
20
24
|
end
|
data/lib/line/bot/event/join.rb
CHANGED
data/lib/line/bot/event/leave.rb
CHANGED
@@ -15,6 +15,11 @@
|
|
15
15
|
module Line
|
16
16
|
module Bot
|
17
17
|
module Event
|
18
|
+
# Event object for when a user removes your LINE official account from a group or when your LINE official account leaves a group or room.
|
19
|
+
#
|
20
|
+
# No replyToken is generated for this event.
|
21
|
+
#
|
22
|
+
# https://developers.line.biz/en/reference/messaging-api/#leave-event
|
18
23
|
class Leave < Base
|
19
24
|
end
|
20
25
|
end
|
@@ -15,6 +15,9 @@
|
|
15
15
|
module Line
|
16
16
|
module Bot
|
17
17
|
module Event
|
18
|
+
# Event object for when a user joins a group or room that the LINE official account is in.
|
19
|
+
#
|
20
|
+
# https://developers.line.biz/en/reference/messaging-api/#member-joined-event
|
18
21
|
class MemberJoined < Base
|
19
22
|
end
|
20
23
|
end
|
@@ -15,6 +15,11 @@
|
|
15
15
|
module Line
|
16
16
|
module Bot
|
17
17
|
module Event
|
18
|
+
# Event object for when a user leaves a group or room that the LINE official account is in.
|
19
|
+
#
|
20
|
+
# No replyToken is generated for this event.
|
21
|
+
#
|
22
|
+
# https://developers.line.biz/en/reference/messaging-api/#member-left-event
|
18
23
|
class MemberLeft < Base
|
19
24
|
end
|
20
25
|
end
|
@@ -26,6 +26,9 @@ module Line
|
|
26
26
|
Unsupport = 'unsupport'
|
27
27
|
end
|
28
28
|
|
29
|
+
# Webhook event object which contains the sent message.
|
30
|
+
#
|
31
|
+
# https://developers.line.biz/en/reference/messaging-api/#message-event
|
29
32
|
class Message < Base
|
30
33
|
def type
|
31
34
|
Line::Bot::Event::MessageType.const_get(@src['message']['type'].capitalize)
|
@@ -22,6 +22,11 @@ module Line
|
|
22
22
|
Unsupport = 'unsupport'
|
23
23
|
end
|
24
24
|
|
25
|
+
# LINE Things API related events.
|
26
|
+
#
|
27
|
+
# * https://developers.line.biz/en/reference/messaging-api/#device-link-event
|
28
|
+
# * https://developers.line.biz/en/reference/messaging-api/#device-unlink-event
|
29
|
+
# * https://developers.line.biz/en/reference/messaging-api/#scenario-result-event
|
25
30
|
class Things < Base
|
26
31
|
def type
|
27
32
|
Line::Bot::Event::ThingsType.const_get(Line::Bot::Util.camelize(@src['things']['type']))
|
@@ -15,6 +15,11 @@
|
|
15
15
|
module Line
|
16
16
|
module Bot
|
17
17
|
module Event
|
18
|
+
# Event object for when your LINE official account is blocked.
|
19
|
+
#
|
20
|
+
# No replyToken is generated for this event.
|
21
|
+
#
|
22
|
+
# https://developers.line.biz/en/reference/messaging-api/#unfollow-event
|
18
23
|
class Unfollow < Base
|
19
24
|
end
|
20
25
|
end
|
data/lib/line/bot/httpclient.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: line-bot-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LINE Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -119,7 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
|
-
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.7.6
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
126
|
summary: SDK of the LINE Messaging API
|