line-bot-api 1.16.0 → 1.20.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 +284 -1
- data/lib/line/bot/event/base.rb +4 -0
- data/lib/line/bot/httpclient.rb +7 -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: 06c883b0ee3ec91de695af601b3e147a9da46b4e75688522adbc76d98ef03758
|
4
|
+
data.tar.gz: 2fb79d8e282e2e832a9f66dad91f51db41bf9381ad7f015fb4efb5e6bac592af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '05859f1da6840e6803ee814b335af6b854db5832d52a6f9b5760a56cd38a33d2f6c2655ea82b8b3026855714454d74ae231ec66739677f28147743973511a793'
|
7
|
+
data.tar.gz: 25dc42c2df495b0221d74306cf831f68ab72004808a92f72d415e50b75837b937dc95f49f3bd8673ee2b16475d829f3e5d14c189f4170b5a0b645f5217f934db
|
data/lib/line/bot/api.rb
CHANGED
@@ -19,6 +19,7 @@ module Line
|
|
19
19
|
module API
|
20
20
|
DEFAULT_ENDPOINT = "https://api.line.me/v2"
|
21
21
|
DEFAULT_BLOB_ENDPOINT = "https://api-data.line.me/v2"
|
22
|
+
DEFAULT_LIFF_ENDPOINT = "https://api.line.me/liff/v1"
|
22
23
|
|
23
24
|
DEFAULT_HEADERS = {
|
24
25
|
'Content-Type' => 'application/json; charset=UTF-8',
|
data/lib/line/bot/api/version.rb
CHANGED
data/lib/line/bot/client.rb
CHANGED
@@ -66,6 +66,10 @@ module Line
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
def liff_endpoint
|
70
|
+
@liff_endpoint ||= API::DEFAULT_LIFF_ENDPOINT
|
71
|
+
end
|
72
|
+
|
69
73
|
# @return [Hash]
|
70
74
|
def credentials
|
71
75
|
{
|
@@ -270,6 +274,20 @@ module Line
|
|
270
274
|
get(endpoint, endpoint_path, credentials)
|
271
275
|
end
|
272
276
|
|
277
|
+
# Get user IDs of who added your LINE Official Account as a friend
|
278
|
+
#
|
279
|
+
# @param continuation_token [String] Identifier to return next page
|
280
|
+
# (next property to be included in the response)
|
281
|
+
#
|
282
|
+
# @return [Net::HTTPResponse]
|
283
|
+
def get_follower_ids(continuation_token = nil)
|
284
|
+
channel_token_required
|
285
|
+
|
286
|
+
endpoint_path = "/bot/followers/ids"
|
287
|
+
endpoint_path += "?start=#{continuation_token}" if continuation_token
|
288
|
+
get(endpoint, endpoint_path, credentials)
|
289
|
+
end
|
290
|
+
|
273
291
|
# Get user IDs of a group
|
274
292
|
#
|
275
293
|
# @param group_id [String] Group's identifier
|
@@ -474,6 +492,31 @@ module Line
|
|
474
492
|
delete(endpoint, endpoint_path, credentials)
|
475
493
|
end
|
476
494
|
|
495
|
+
# Set rich menu alias
|
496
|
+
#
|
497
|
+
# @param rich_menu_id [String] ID of an uploaded rich menu
|
498
|
+
# @param rich_menu_alias_id [String] string of alias words rich menu
|
499
|
+
#
|
500
|
+
# @return [Net::HTTPResponse]
|
501
|
+
def set_rich_menus_alias(rich_menu_id, rich_menu_alias_id)
|
502
|
+
channel_token_required
|
503
|
+
|
504
|
+
endpoint_path = '/bot/richmenu/alias'
|
505
|
+
post(endpoint, endpoint_path, { richMenuId: rich_menu_id, richMenuAliasId: rich_menu_alias_id }.to_json, credentials)
|
506
|
+
end
|
507
|
+
|
508
|
+
# Unset rich menu alias
|
509
|
+
#
|
510
|
+
# @param rich_menu_alias_id [String] string of alias words rich menu
|
511
|
+
#
|
512
|
+
# @return [Net::HTTPResponse]
|
513
|
+
def unset_rich_menus_alias(rich_menu_alias_id)
|
514
|
+
channel_token_required
|
515
|
+
|
516
|
+
endpoint_path = "/bot/richmenu/alias/#{rich_menu_alias_id}"
|
517
|
+
delete(endpoint, endpoint_path, credentials)
|
518
|
+
end
|
519
|
+
|
477
520
|
# Link a rich menu to a user
|
478
521
|
#
|
479
522
|
# If you want to link a rich menu to multiple users,
|
@@ -631,6 +674,232 @@ module Line
|
|
631
674
|
get(endpoint, endpoint_path, credentials)
|
632
675
|
end
|
633
676
|
|
677
|
+
# Gets a bot's basic information.
|
678
|
+
#
|
679
|
+
# @return [Net::HTTPResponse]
|
680
|
+
def get_bot_info
|
681
|
+
channel_token_required
|
682
|
+
|
683
|
+
endpoint_path = '/bot/info'
|
684
|
+
get(endpoint, endpoint_path, credentials)
|
685
|
+
end
|
686
|
+
|
687
|
+
# Gets information on a webhook endpoint.
|
688
|
+
#
|
689
|
+
# @return [Net::HTTPResponse]
|
690
|
+
def get_webhook_endpoint
|
691
|
+
channel_token_required
|
692
|
+
|
693
|
+
endpoint_path = '/bot/channel/webhook/endpoint'
|
694
|
+
get(endpoint, endpoint_path, credentials)
|
695
|
+
end
|
696
|
+
|
697
|
+
# Sets the webhook endpoint URL.
|
698
|
+
#
|
699
|
+
# @param webhook_endpoint [String]
|
700
|
+
#
|
701
|
+
# @return [Net::HTTPResponse]
|
702
|
+
def set_webhook_endpoint(webhook_endpoint)
|
703
|
+
channel_token_required
|
704
|
+
|
705
|
+
endpoint_path = '/bot/channel/webhook/endpoint'
|
706
|
+
body = {endpoint: webhook_endpoint}
|
707
|
+
put(endpoint, endpoint_path, body.to_json, credentials)
|
708
|
+
end
|
709
|
+
|
710
|
+
# Checks if the configured webhook endpoint can receive a test webhook event.
|
711
|
+
#
|
712
|
+
# @param webhook_endpoint [String] options
|
713
|
+
#
|
714
|
+
# @return [Net::HTTPResponse]
|
715
|
+
def test_webhook_endpoint(webhook_endpoint = nil)
|
716
|
+
channel_token_required
|
717
|
+
|
718
|
+
endpoint_path = '/bot/channel/webhook/test'
|
719
|
+
body = if webhook_endpoint.nil?
|
720
|
+
{}
|
721
|
+
else
|
722
|
+
{endpoint: webhook_endpoint}
|
723
|
+
end
|
724
|
+
post(endpoint, endpoint_path, body.to_json, credentials)
|
725
|
+
end
|
726
|
+
|
727
|
+
def get_liff_apps
|
728
|
+
channel_token_required
|
729
|
+
|
730
|
+
endpoint_path = '/apps'
|
731
|
+
get(liff_endpoint, endpoint_path, credentials)
|
732
|
+
end
|
733
|
+
|
734
|
+
def create_liff_app(app)
|
735
|
+
channel_token_required
|
736
|
+
|
737
|
+
endpoint_path = '/apps'
|
738
|
+
post(liff_endpoint, endpoint_path, app.to_json, credentials)
|
739
|
+
end
|
740
|
+
|
741
|
+
def update_liff_app(liff_id, app)
|
742
|
+
channel_token_required
|
743
|
+
|
744
|
+
endpoint_path = "/apps/#{liff_id}"
|
745
|
+
put(liff_endpoint, endpoint_path, app.to_json, credentials)
|
746
|
+
end
|
747
|
+
|
748
|
+
def delete_liff_app(liff_id)
|
749
|
+
channel_token_required
|
750
|
+
|
751
|
+
endpoint_path = "/apps/#{liff_id}"
|
752
|
+
delete(liff_endpoint, endpoint_path, credentials)
|
753
|
+
end
|
754
|
+
|
755
|
+
# Create an audience group by uploading user_ids
|
756
|
+
#
|
757
|
+
# Parameters are described here.
|
758
|
+
# https://developers.line.biz/en/reference/messaging-api/#create-upload-audience-group
|
759
|
+
#
|
760
|
+
# @param params [Hash] options
|
761
|
+
#
|
762
|
+
# @return [Net::HTTPResponse] This response includes an audience_group_id.
|
763
|
+
def create_user_id_audience(params)
|
764
|
+
channel_token_required
|
765
|
+
|
766
|
+
endpoint_path = '/bot/audienceGroup/upload'
|
767
|
+
post(endpoint, endpoint_path, params.to_json, credentials)
|
768
|
+
end
|
769
|
+
|
770
|
+
# Update an audience group
|
771
|
+
#
|
772
|
+
# Parameters are described here.
|
773
|
+
# https://developers.line.biz/en/reference/messaging-api/#update-upload-audience-group
|
774
|
+
#
|
775
|
+
# @param params [Hash] options
|
776
|
+
#
|
777
|
+
# @return [Net::HTTPResponse] This response includes an audience_group_id.
|
778
|
+
def update_user_id_audience(params)
|
779
|
+
channel_token_required
|
780
|
+
|
781
|
+
endpoint_path = '/bot/audienceGroup/upload'
|
782
|
+
put(endpoint, endpoint_path, params.to_json, credentials)
|
783
|
+
end
|
784
|
+
|
785
|
+
# Create an audience group of users that clicked a URL in a message sent in the past
|
786
|
+
#
|
787
|
+
# Parameters are described here.
|
788
|
+
# https://developers.line.biz/en/reference/messaging-api/#create-click-audience-group
|
789
|
+
#
|
790
|
+
# @param params [Hash] options
|
791
|
+
#
|
792
|
+
# @return [Net::HTTPResponse] This response includes an audience_group_id.
|
793
|
+
def create_click_audience(params)
|
794
|
+
channel_token_required
|
795
|
+
|
796
|
+
endpoint_path = '/bot/audienceGroup/click'
|
797
|
+
post(endpoint, endpoint_path, params.to_json, credentials)
|
798
|
+
end
|
799
|
+
|
800
|
+
# Create an audience group of users that opened a message sent in the past
|
801
|
+
#
|
802
|
+
# Parameters are described here.
|
803
|
+
# https://developers.line.biz/en/reference/messaging-api/#create-imp-audience-group
|
804
|
+
#
|
805
|
+
# @param params [Hash] options
|
806
|
+
#
|
807
|
+
# @return [Net::HTTPResponse] This response includes an audience_group_id.
|
808
|
+
def create_impression_audience(params)
|
809
|
+
channel_token_required
|
810
|
+
|
811
|
+
endpoint_path = '/bot/audienceGroup/imp'
|
812
|
+
post(endpoint, endpoint_path, params.to_json, credentials)
|
813
|
+
end
|
814
|
+
|
815
|
+
# Rename an existing audience group
|
816
|
+
#
|
817
|
+
# @param audience_group_id [Integer]
|
818
|
+
# @param description [String]
|
819
|
+
#
|
820
|
+
# @return [Net::HTTPResponse]
|
821
|
+
def rename_audience(audience_group_id, description)
|
822
|
+
channel_token_required
|
823
|
+
|
824
|
+
endpoint_path = "/bot/audienceGroup/#{audience_group_id}/updateDescription"
|
825
|
+
body = {description: description}
|
826
|
+
put(endpoint, endpoint_path, body.to_json, credentials)
|
827
|
+
end
|
828
|
+
|
829
|
+
# Delete an existing audience group
|
830
|
+
#
|
831
|
+
# Parameters are described here.
|
832
|
+
# https://developers.line.biz/en/reference/messaging-api/#delete-audience-group
|
833
|
+
#
|
834
|
+
# @param audience_group_id [Integer]
|
835
|
+
#
|
836
|
+
# @return [Net::HTTPResponse]
|
837
|
+
def delete_audience(audience_group_id)
|
838
|
+
channel_token_required
|
839
|
+
|
840
|
+
endpoint_path = "/bot/audienceGroup/#{audience_group_id}"
|
841
|
+
delete(endpoint, endpoint_path, credentials)
|
842
|
+
end
|
843
|
+
|
844
|
+
# Get audience group data
|
845
|
+
#
|
846
|
+
# Parameters are described here.
|
847
|
+
# https://developers.line.biz/en/reference/messaging-api/#get-audience-group
|
848
|
+
#
|
849
|
+
# @param audience_group_id [Integer]
|
850
|
+
#
|
851
|
+
# @return [Net::HTTPResponse]
|
852
|
+
def get_audience(audience_group_id)
|
853
|
+
channel_token_required
|
854
|
+
|
855
|
+
endpoint_path = "/bot/audienceGroup/#{audience_group_id}"
|
856
|
+
get(endpoint, endpoint_path, credentials)
|
857
|
+
end
|
858
|
+
|
859
|
+
# Get data for more than one audience group
|
860
|
+
#
|
861
|
+
# Parameters are described here.
|
862
|
+
# https://developers.line.biz/en/reference/messaging-api/#get-audience-groups
|
863
|
+
#
|
864
|
+
# @param params [Hash] key name `page` is required
|
865
|
+
#
|
866
|
+
# @return [Net::HTTPResponse]
|
867
|
+
def get_audiences(params)
|
868
|
+
channel_token_required
|
869
|
+
|
870
|
+
endpoint_path = "/bot/audienceGroup/list?" + URI.encode_www_form(params)
|
871
|
+
get(endpoint, endpoint_path, credentials)
|
872
|
+
end
|
873
|
+
|
874
|
+
# Get the authority level of the audience
|
875
|
+
#
|
876
|
+
# Parameters are described here.
|
877
|
+
# https://developers.line.biz/en/reference/messaging-api/#get-authority-level
|
878
|
+
#
|
879
|
+
# @return [Net::HTTPResponse]
|
880
|
+
def get_audience_authority_level
|
881
|
+
channel_token_required
|
882
|
+
|
883
|
+
endpoint_path = "/bot/audienceGroup/authorityLevel"
|
884
|
+
get(endpoint, endpoint_path, credentials)
|
885
|
+
end
|
886
|
+
|
887
|
+
# Change the authority level of the audience
|
888
|
+
#
|
889
|
+
# Parameters are described here.
|
890
|
+
# https://developers.line.biz/en/reference/messaging-api/#change-authority-level
|
891
|
+
#
|
892
|
+
# @param authority_level [String] value must be `PUBLIC` or `PRIVATE`
|
893
|
+
#
|
894
|
+
# @return [Net::HTTPResponse]
|
895
|
+
def update_audience_authority_level(authority_level)
|
896
|
+
channel_token_required
|
897
|
+
|
898
|
+
endpoint_path = "/bot/audienceGroup/authorityLevel"
|
899
|
+
body = {authorityLevel: authority_level}
|
900
|
+
put(endpoint, endpoint_path, body.to_json, credentials)
|
901
|
+
end
|
902
|
+
|
634
903
|
# Fetch data, get content of specified URL.
|
635
904
|
#
|
636
905
|
# @param endpoint_base [String]
|
@@ -656,6 +925,19 @@ module Line
|
|
656
925
|
httpclient.post(endpoint_base + endpoint_path, payload, headers)
|
657
926
|
end
|
658
927
|
|
928
|
+
# Put data, get content of specified URL.
|
929
|
+
#
|
930
|
+
# @param endpoint_base [String]
|
931
|
+
# @param endpoint_path [String]
|
932
|
+
# @param payload [String or NilClass]
|
933
|
+
# @param headers [Hash]
|
934
|
+
#
|
935
|
+
# @return [Net::HTTPResponse]
|
936
|
+
def put(endpoint_base, endpoint_path, payload = nil, headers = {})
|
937
|
+
headers = API::DEFAULT_HEADERS.merge(headers)
|
938
|
+
httpclient.put(endpoint_base + endpoint_path, payload, headers)
|
939
|
+
end
|
940
|
+
|
659
941
|
# Delete content of specified URL.
|
660
942
|
#
|
661
943
|
# @param endpoint_base [String]
|
@@ -697,7 +979,7 @@ module Line
|
|
697
979
|
def validate_signature(content, channel_signature)
|
698
980
|
return false if !channel_signature || !channel_secret
|
699
981
|
|
700
|
-
hash = OpenSSL::HMAC.digest(OpenSSL::Digest
|
982
|
+
hash = OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'), channel_secret, content)
|
701
983
|
signature = Base64.strict_encode64(hash)
|
702
984
|
|
703
985
|
variable_secure_compare(channel_signature, signature)
|
@@ -729,6 +1011,7 @@ module Line
|
|
729
1011
|
if file.respond_to?(:content_type)
|
730
1012
|
content_type = file.content_type
|
731
1013
|
raise ArgumentError, "invalid content type: #{content_type}" unless ['image/jpeg', 'image/png'].include?(content_type)
|
1014
|
+
|
732
1015
|
content_type
|
733
1016
|
else
|
734
1017
|
case file.path
|
data/lib/line/bot/event/base.rb
CHANGED
data/lib/line/bot/httpclient.rb
CHANGED
@@ -38,10 +38,8 @@ module Line
|
|
38
38
|
http.use_ssl = true
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
http.send("#{key}=", value)
|
44
|
-
end
|
41
|
+
http_options&.each do |key, value|
|
42
|
+
http.send("#{key}=", value)
|
45
43
|
end
|
46
44
|
|
47
45
|
http
|
@@ -57,6 +55,11 @@ module Line
|
|
57
55
|
http(uri).post(uri.request_uri, payload, header)
|
58
56
|
end
|
59
57
|
|
58
|
+
def put(url, payload, header = {})
|
59
|
+
uri = URI(url)
|
60
|
+
http(uri).put(uri.request_uri, payload, header)
|
61
|
+
end
|
62
|
+
|
60
63
|
def delete(url, header = {})
|
61
64
|
uri = URI(url)
|
62
65
|
http(uri).delete(uri.request_uri, header)
|
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.20.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-07-19 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.4
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: SDK of the LINE Messaging API
|