line-bot-api 1.18.0 → 1.22.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/lib/line/bot/api/version.rb +1 -1
- data/lib/line/bot/api.rb +1 -0
- data/lib/line/bot/client.rb +131 -1
- data/lib/line/bot/event/base.rb +4 -0
- data/lib/line/bot/httpclient.rb +2 -4
- data/line-bot-api.gemspec +1 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a36da29494cce63f76dcb86eeb598ee138cdac97c3e8d1b9a3cd630de77f969e
|
4
|
+
data.tar.gz: e44f44089b1047692f57a95733a7fe73aa6362f45838280eedb8e14286d832ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1f110ae8342f09be0d07bc335ce8f982868d10e26b9bc3eef0c0a60b77b0c1a06dde346eab279250b0c521888978db673a50c6db17d070d1650608fc2fb080a
|
7
|
+
data.tar.gz: 7ab72e341fb0db004519df79eb2ef95e802f54da19fa90087d193c7bd493523fbb1069a70fd1c8b6be07ba7249491f1c4775fca298d8e6c4a97530ce9046279f
|
data/lib/line/bot/api/version.rb
CHANGED
data/lib/line/bot/api.rb
CHANGED
@@ -17,6 +17,7 @@ require 'line/bot/api/version'
|
|
17
17
|
module Line
|
18
18
|
module Bot
|
19
19
|
module API
|
20
|
+
DEFAULT_OAUTH_ENDPOINT = "https://api.line.me"
|
20
21
|
DEFAULT_ENDPOINT = "https://api.line.me/v2"
|
21
22
|
DEFAULT_BLOB_ENDPOINT = "https://api-data.line.me/v2"
|
22
23
|
DEFAULT_LIFF_ENDPOINT = "https://api.line.me/liff/v1"
|
data/lib/line/bot/client.rb
CHANGED
@@ -55,6 +55,10 @@ module Line
|
|
55
55
|
@endpoint ||= API::DEFAULT_ENDPOINT
|
56
56
|
end
|
57
57
|
|
58
|
+
def oauth_endpoint
|
59
|
+
@oauth_endpoint ||= API::DEFAULT_OAUTH_ENDPOINT
|
60
|
+
end
|
61
|
+
|
58
62
|
def blob_endpoint
|
59
63
|
return @blob_endpoint if @blob_endpoint
|
60
64
|
|
@@ -106,6 +110,57 @@ module Line
|
|
106
110
|
post(endpoint, endpoint_path, payload, headers)
|
107
111
|
end
|
108
112
|
|
113
|
+
# Issue channel access token v2.1
|
114
|
+
#
|
115
|
+
# @param jwt [String]
|
116
|
+
#
|
117
|
+
# @return [Net::HTTPResponse]
|
118
|
+
def issue_channel_access_token_jwt(jwt)
|
119
|
+
endpoint_path = '/oauth2/v2.1/token'
|
120
|
+
payload = URI.encode_www_form(
|
121
|
+
grant_type: 'client_credentials',
|
122
|
+
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
|
123
|
+
client_assertion: jwt
|
124
|
+
)
|
125
|
+
headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
|
126
|
+
post(oauth_endpoint, endpoint_path, payload, headers)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Revoke channel access token v2.1
|
130
|
+
#
|
131
|
+
# @param access_token [String]
|
132
|
+
#
|
133
|
+
# @return [Net::HTTPResponse]
|
134
|
+
def revoke_channel_access_token_jwt(access_token)
|
135
|
+
channel_id_required
|
136
|
+
channel_secret_required
|
137
|
+
|
138
|
+
endpoint_path = '/oauth2/v2.1/revoke'
|
139
|
+
payload = URI.encode_www_form(
|
140
|
+
client_id: channel_id,
|
141
|
+
client_secret: channel_secret,
|
142
|
+
access_token: access_token
|
143
|
+
)
|
144
|
+
headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
|
145
|
+
post(oauth_endpoint, endpoint_path, payload, headers)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Get all valid channel access token key IDs v2.1
|
149
|
+
#
|
150
|
+
# @param jwt [String]
|
151
|
+
#
|
152
|
+
# @return [Net::HTTPResponse]
|
153
|
+
def get_channel_access_token_key_ids_jwt(jwt)
|
154
|
+
payload = URI.encode_www_form(
|
155
|
+
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
|
156
|
+
client_assertion: jwt
|
157
|
+
)
|
158
|
+
endpoint_path = "/oauth2/v2.1/tokens/kid?#{payload}"
|
159
|
+
|
160
|
+
headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
|
161
|
+
get(oauth_endpoint, endpoint_path, headers)
|
162
|
+
end
|
163
|
+
|
109
164
|
# Push messages to a user using user_id.
|
110
165
|
#
|
111
166
|
# @param user_id [String] User Id
|
@@ -274,6 +329,20 @@ module Line
|
|
274
329
|
get(endpoint, endpoint_path, credentials)
|
275
330
|
end
|
276
331
|
|
332
|
+
# Get user IDs of who added your LINE Official Account as a friend
|
333
|
+
#
|
334
|
+
# @param continuation_token [String] Identifier to return next page
|
335
|
+
# (next property to be included in the response)
|
336
|
+
#
|
337
|
+
# @return [Net::HTTPResponse]
|
338
|
+
def get_follower_ids(continuation_token = nil)
|
339
|
+
channel_token_required
|
340
|
+
|
341
|
+
endpoint_path = "/bot/followers/ids"
|
342
|
+
endpoint_path += "?start=#{continuation_token}" if continuation_token
|
343
|
+
get(endpoint, endpoint_path, credentials)
|
344
|
+
end
|
345
|
+
|
277
346
|
# Get user IDs of a group
|
278
347
|
#
|
279
348
|
# @param group_id [String] Group's identifier
|
@@ -478,6 +547,66 @@ module Line
|
|
478
547
|
delete(endpoint, endpoint_path, credentials)
|
479
548
|
end
|
480
549
|
|
550
|
+
# Set rich menu alias
|
551
|
+
#
|
552
|
+
# @param rich_menu_id [String] ID of an uploaded rich menu
|
553
|
+
# @param rich_menu_alias_id [String] string of alias words rich menu
|
554
|
+
#
|
555
|
+
# @return [Net::HTTPResponse]
|
556
|
+
def set_rich_menus_alias(rich_menu_id, rich_menu_alias_id)
|
557
|
+
channel_token_required
|
558
|
+
|
559
|
+
endpoint_path = '/bot/richmenu/alias'
|
560
|
+
post(endpoint, endpoint_path, { richMenuId: rich_menu_id, richMenuAliasId: rich_menu_alias_id }.to_json, credentials)
|
561
|
+
end
|
562
|
+
|
563
|
+
# Unset rich menu alias
|
564
|
+
#
|
565
|
+
# @param rich_menu_alias_id [String] string of alias words rich menu
|
566
|
+
#
|
567
|
+
# @return [Net::HTTPResponse]
|
568
|
+
def unset_rich_menus_alias(rich_menu_alias_id)
|
569
|
+
channel_token_required
|
570
|
+
|
571
|
+
endpoint_path = "/bot/richmenu/alias/#{rich_menu_alias_id}"
|
572
|
+
delete(endpoint, endpoint_path, credentials)
|
573
|
+
end
|
574
|
+
|
575
|
+
# Update rich menu alias
|
576
|
+
#
|
577
|
+
# @param rich_menu_id [String] ID of an uploaded rich menu
|
578
|
+
# @param rich_menu_alias_id [String] string of alias words rich menu
|
579
|
+
#
|
580
|
+
# @return [Net::HTTPResponse]
|
581
|
+
def update_rich_menus_alias(rich_menu_id, rich_menu_alias_id)
|
582
|
+
channel_token_required
|
583
|
+
|
584
|
+
endpoint_path = "/bot/richmenu/alias/#{rich_menu_alias_id}"
|
585
|
+
post(endpoint, endpoint_path, { richMenuId: rich_menu_id }.to_json, credentials)
|
586
|
+
end
|
587
|
+
|
588
|
+
# Get a rich menu alias via a rich menu alias ID
|
589
|
+
#
|
590
|
+
# @param rich_menu_alias_id [String] string of alias words rich menu
|
591
|
+
#
|
592
|
+
# @return [Net::HTTPResponse]
|
593
|
+
def get_rich_menus_alias(rich_menu_alias_id)
|
594
|
+
channel_token_required
|
595
|
+
|
596
|
+
endpoint_path = "/bot/richmenu/alias/#{rich_menu_alias_id}"
|
597
|
+
get(endpoint, endpoint_path, credentials)
|
598
|
+
end
|
599
|
+
|
600
|
+
# Get a list of all uploaded rich menus alias
|
601
|
+
#
|
602
|
+
# @return [Net::HTTPResponse]
|
603
|
+
def get_rich_menus_alias_list
|
604
|
+
channel_token_required
|
605
|
+
|
606
|
+
endpoint_path = "/bot/richmenu/alias/list"
|
607
|
+
get(endpoint, endpoint_path, credentials)
|
608
|
+
end
|
609
|
+
|
481
610
|
# Link a rich menu to a user
|
482
611
|
#
|
483
612
|
# If you want to link a rich menu to multiple users,
|
@@ -940,7 +1069,7 @@ module Line
|
|
940
1069
|
def validate_signature(content, channel_signature)
|
941
1070
|
return false if !channel_signature || !channel_secret
|
942
1071
|
|
943
|
-
hash = OpenSSL::HMAC.digest(OpenSSL::Digest
|
1072
|
+
hash = OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'), channel_secret, content)
|
944
1073
|
signature = Base64.strict_encode64(hash)
|
945
1074
|
|
946
1075
|
variable_secure_compare(channel_signature, signature)
|
@@ -972,6 +1101,7 @@ module Line
|
|
972
1101
|
if file.respond_to?(:content_type)
|
973
1102
|
content_type = file.content_type
|
974
1103
|
raise ArgumentError, "invalid content type: #{content_type}" unless ['image/jpeg', 'image/png'].include?(content_type)
|
1104
|
+
|
975
1105
|
content_type
|
976
1106
|
else
|
977
1107
|
case file.path
|
data/lib/line/bot/event/base.rb
CHANGED
data/lib/line/bot/httpclient.rb
CHANGED
data/line-bot-api.gemspec
CHANGED
@@ -17,10 +17,9 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.required_ruby_version = '>= 2.
|
20
|
+
spec.required_ruby_version = '>= 2.4.0'
|
21
21
|
|
22
22
|
spec.add_development_dependency "addressable", "~> 2.3"
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.11" if RUBY_VERSION < "2.3"
|
24
23
|
spec.add_development_dependency 'rake', "~> 13.0"
|
25
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
26
25
|
spec.add_development_dependency "webmock", "~> 3.8"
|
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.22.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: 2021-
|
11
|
+
date: 2021-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -114,14 +114,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.
|
117
|
+
version: 2.4.0
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
120
|
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
|
-
rubygems_version: 3.1.
|
124
|
+
rubygems_version: 3.1.6
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: SDK of the LINE Messaging API
|