line-bot-api 1.17.0 → 1.21.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.rb +1 -0
- data/lib/line/bot/api/version.rb +1 -1
- data/lib/line/bot/client.rb +142 -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 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c7c212cf7261c341fbd02845a3f678aa8d2eadd302a5fef4bb4e574a4013062
|
4
|
+
data.tar.gz: b87face2a4aacc3245a678c6cf21099702ca352c26e42ed3377e98565dceaf1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 860c6649dcb835b6f495fefd96b27b98cd2501fc5b3c93479b7cd10a65fd396e4008f86d6cd6fe74dc3cba8f9fd3392f20ee2151d6345087e7ab216124e12ab6
|
7
|
+
data.tar.gz: 18f79d5e93ec212165d4855e60060f8fc5b9c91e9b6f804e0469f4d18215565f0141ff17b6dfcf0fed35eefd6d289ce7fa4d15c138b345d0d2047fe3d7f6c807
|
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/api/version.rb
CHANGED
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,63 @@ 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
|
+
channel_id_required
|
120
|
+
channel_secret_required
|
121
|
+
|
122
|
+
endpoint_path = '/oauth2/v2.1/token'
|
123
|
+
payload = URI.encode_www_form(
|
124
|
+
grant_type: 'client_credentials',
|
125
|
+
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
|
126
|
+
client_assertion: jwt
|
127
|
+
)
|
128
|
+
headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
|
129
|
+
post(oauth_endpoint, endpoint_path, payload, headers)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Revoke channel access token v2.1
|
133
|
+
#
|
134
|
+
# @param access_token [String]
|
135
|
+
#
|
136
|
+
# @return [Net::HTTPResponse]
|
137
|
+
def revoke_channel_access_token_jwt(access_token)
|
138
|
+
channel_id_required
|
139
|
+
channel_secret_required
|
140
|
+
|
141
|
+
endpoint_path = '/oauth2/v2.1/revoke'
|
142
|
+
payload = URI.encode_www_form(
|
143
|
+
client_id: channel_id,
|
144
|
+
client_secret: channel_secret,
|
145
|
+
access_token: access_token
|
146
|
+
)
|
147
|
+
headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
|
148
|
+
post(oauth_endpoint, endpoint_path, payload, headers)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Get all valid channel access token key IDs v2.1
|
152
|
+
#
|
153
|
+
# @param jwt [String]
|
154
|
+
#
|
155
|
+
# @return [Net::HTTPResponse]
|
156
|
+
def get_channel_access_token_key_ids_jwt(jwt)
|
157
|
+
channel_id_required
|
158
|
+
channel_secret_required
|
159
|
+
|
160
|
+
payload = URI.encode_www_form(
|
161
|
+
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
|
162
|
+
client_assertion: jwt
|
163
|
+
)
|
164
|
+
endpoint_path = "/oauth2/v2.1/tokens/kid?#{payload}"
|
165
|
+
|
166
|
+
headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
|
167
|
+
get(oauth_endpoint, endpoint_path, headers)
|
168
|
+
end
|
169
|
+
|
109
170
|
# Push messages to a user using user_id.
|
110
171
|
#
|
111
172
|
# @param user_id [String] User Id
|
@@ -274,6 +335,20 @@ module Line
|
|
274
335
|
get(endpoint, endpoint_path, credentials)
|
275
336
|
end
|
276
337
|
|
338
|
+
# Get user IDs of who added your LINE Official Account as a friend
|
339
|
+
#
|
340
|
+
# @param continuation_token [String] Identifier to return next page
|
341
|
+
# (next property to be included in the response)
|
342
|
+
#
|
343
|
+
# @return [Net::HTTPResponse]
|
344
|
+
def get_follower_ids(continuation_token = nil)
|
345
|
+
channel_token_required
|
346
|
+
|
347
|
+
endpoint_path = "/bot/followers/ids"
|
348
|
+
endpoint_path += "?start=#{continuation_token}" if continuation_token
|
349
|
+
get(endpoint, endpoint_path, credentials)
|
350
|
+
end
|
351
|
+
|
277
352
|
# Get user IDs of a group
|
278
353
|
#
|
279
354
|
# @param group_id [String] Group's identifier
|
@@ -478,6 +553,31 @@ module Line
|
|
478
553
|
delete(endpoint, endpoint_path, credentials)
|
479
554
|
end
|
480
555
|
|
556
|
+
# Set rich menu alias
|
557
|
+
#
|
558
|
+
# @param rich_menu_id [String] ID of an uploaded rich menu
|
559
|
+
# @param rich_menu_alias_id [String] string of alias words rich menu
|
560
|
+
#
|
561
|
+
# @return [Net::HTTPResponse]
|
562
|
+
def set_rich_menus_alias(rich_menu_id, rich_menu_alias_id)
|
563
|
+
channel_token_required
|
564
|
+
|
565
|
+
endpoint_path = '/bot/richmenu/alias'
|
566
|
+
post(endpoint, endpoint_path, { richMenuId: rich_menu_id, richMenuAliasId: rich_menu_alias_id }.to_json, credentials)
|
567
|
+
end
|
568
|
+
|
569
|
+
# Unset rich menu alias
|
570
|
+
#
|
571
|
+
# @param rich_menu_alias_id [String] string of alias words rich menu
|
572
|
+
#
|
573
|
+
# @return [Net::HTTPResponse]
|
574
|
+
def unset_rich_menus_alias(rich_menu_alias_id)
|
575
|
+
channel_token_required
|
576
|
+
|
577
|
+
endpoint_path = "/bot/richmenu/alias/#{rich_menu_alias_id}"
|
578
|
+
delete(endpoint, endpoint_path, credentials)
|
579
|
+
end
|
580
|
+
|
481
581
|
# Link a rich menu to a user
|
482
582
|
#
|
483
583
|
# If you want to link a rich menu to multiple users,
|
@@ -645,6 +745,46 @@ module Line
|
|
645
745
|
get(endpoint, endpoint_path, credentials)
|
646
746
|
end
|
647
747
|
|
748
|
+
# Gets information on a webhook endpoint.
|
749
|
+
#
|
750
|
+
# @return [Net::HTTPResponse]
|
751
|
+
def get_webhook_endpoint
|
752
|
+
channel_token_required
|
753
|
+
|
754
|
+
endpoint_path = '/bot/channel/webhook/endpoint'
|
755
|
+
get(endpoint, endpoint_path, credentials)
|
756
|
+
end
|
757
|
+
|
758
|
+
# Sets the webhook endpoint URL.
|
759
|
+
#
|
760
|
+
# @param webhook_endpoint [String]
|
761
|
+
#
|
762
|
+
# @return [Net::HTTPResponse]
|
763
|
+
def set_webhook_endpoint(webhook_endpoint)
|
764
|
+
channel_token_required
|
765
|
+
|
766
|
+
endpoint_path = '/bot/channel/webhook/endpoint'
|
767
|
+
body = {endpoint: webhook_endpoint}
|
768
|
+
put(endpoint, endpoint_path, body.to_json, credentials)
|
769
|
+
end
|
770
|
+
|
771
|
+
# Checks if the configured webhook endpoint can receive a test webhook event.
|
772
|
+
#
|
773
|
+
# @param webhook_endpoint [String] options
|
774
|
+
#
|
775
|
+
# @return [Net::HTTPResponse]
|
776
|
+
def test_webhook_endpoint(webhook_endpoint = nil)
|
777
|
+
channel_token_required
|
778
|
+
|
779
|
+
endpoint_path = '/bot/channel/webhook/test'
|
780
|
+
body = if webhook_endpoint.nil?
|
781
|
+
{}
|
782
|
+
else
|
783
|
+
{endpoint: webhook_endpoint}
|
784
|
+
end
|
785
|
+
post(endpoint, endpoint_path, body.to_json, credentials)
|
786
|
+
end
|
787
|
+
|
648
788
|
def get_liff_apps
|
649
789
|
channel_token_required
|
650
790
|
|
@@ -900,7 +1040,7 @@ module Line
|
|
900
1040
|
def validate_signature(content, channel_signature)
|
901
1041
|
return false if !channel_signature || !channel_secret
|
902
1042
|
|
903
|
-
hash = OpenSSL::HMAC.digest(OpenSSL::Digest
|
1043
|
+
hash = OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'), channel_secret, content)
|
904
1044
|
signature = Base64.strict_encode64(hash)
|
905
1045
|
|
906
1046
|
variable_secure_compare(channel_signature, signature)
|
@@ -932,6 +1072,7 @@ module Line
|
|
932
1072
|
if file.respond_to?(:content_type)
|
933
1073
|
content_type = file.content_type
|
934
1074
|
raise ArgumentError, "invalid content type: #{content_type}" unless ['image/jpeg', 'image/png'].include?(content_type)
|
1075
|
+
|
935
1076
|
content_type
|
936
1077
|
else
|
937
1078
|
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.21.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: 2021-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -114,15 +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
|
-
|
125
|
-
rubygems_version: 2.7.6
|
124
|
+
rubygems_version: 3.1.6
|
126
125
|
signing_key:
|
127
126
|
specification_version: 4
|
128
127
|
summary: SDK of the LINE Messaging API
|