line-bot-api 1.14.0 → 1.18.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 +2 -1
- data/lib/line/bot/api/version.rb +1 -1
- data/lib/line/bot/client.rb +317 -25
- data/lib/line/bot/event.rb +2 -0
- data/lib/line/bot/event/message.rb +2 -2
- data/lib/line/bot/event/things.rb +2 -2
- data/lib/line/bot/event/unsend.rb +27 -0
- data/lib/line/bot/event/video_play_complete.rb +25 -0
- data/lib/line/bot/httpclient.rb +5 -0
- data/line-bot-api.gemspec +2 -2
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23b8ceb7011bc2da255888239f7d9a26622ea7713f8fb6154c8aa4637c5c0be0
|
4
|
+
data.tar.gz: 885e68bbd4485d411f5e79e1bfc1aa2a29e9d6c07d64d91db22cd4387c0d334d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c0e0b1dec8a0a39167225065c44c58b19d662178cd68162c1f3c98cbf0350dfcec8dc73922506bb9a7251479380e21cbe62e3765f97fbf91200267f19aef340
|
7
|
+
data.tar.gz: 924774871d263700bc7e38dd0ab338e66009f573222e3bb49c7c97464d5da0017d7ec8a902f82c5713c1cfe9dedd9d8ba6e749e73ecdfc2282db833c41a66d5e
|
data/lib/line/bot/api.rb
CHANGED
@@ -19,10 +19,11 @@ 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',
|
25
|
-
'User-Agent' => "LINE-BotSDK-Ruby/#{
|
26
|
+
'User-Agent' => "LINE-BotSDK-Ruby/#{VERSION}"
|
26
27
|
}.freeze
|
27
28
|
end
|
28
29
|
end
|
data/lib/line/bot/api/version.rb
CHANGED
data/lib/line/bot/client.rb
CHANGED
@@ -48,24 +48,28 @@ module Line
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def httpclient
|
51
|
-
@httpclient ||=
|
51
|
+
@httpclient ||= HTTPClient.new(http_options)
|
52
52
|
end
|
53
53
|
|
54
54
|
def endpoint
|
55
|
-
@endpoint ||=
|
55
|
+
@endpoint ||= API::DEFAULT_ENDPOINT
|
56
56
|
end
|
57
57
|
|
58
58
|
def blob_endpoint
|
59
59
|
return @blob_endpoint if @blob_endpoint
|
60
60
|
|
61
|
-
@blob_endpoint = if endpoint ==
|
62
|
-
|
61
|
+
@blob_endpoint = if endpoint == API::DEFAULT_ENDPOINT
|
62
|
+
API::DEFAULT_BLOB_ENDPOINT
|
63
63
|
else
|
64
64
|
# for backward compatible
|
65
65
|
endpoint
|
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
|
{
|
@@ -106,15 +110,16 @@ module Line
|
|
106
110
|
#
|
107
111
|
# @param user_id [String] User Id
|
108
112
|
# @param messages [Hash or Array] Message Objects
|
113
|
+
# @param headers [Hash] HTTP Headers
|
109
114
|
# @return [Net::HTTPResponse]
|
110
|
-
def push_message(user_id, messages)
|
115
|
+
def push_message(user_id, messages, headers: {})
|
111
116
|
channel_token_required
|
112
117
|
|
113
118
|
messages = [messages] if messages.is_a?(Hash)
|
114
119
|
|
115
120
|
endpoint_path = '/bot/message/push'
|
116
121
|
payload = { to: user_id, messages: messages }.to_json
|
117
|
-
post(endpoint, endpoint_path, payload, credentials)
|
122
|
+
post(endpoint, endpoint_path, payload, credentials.merge(headers))
|
118
123
|
end
|
119
124
|
|
120
125
|
# Reply messages to a user using replyToken.
|
@@ -151,8 +156,9 @@ module Line
|
|
151
156
|
#
|
152
157
|
# @param to [Array or String] Array of userIds
|
153
158
|
# @param messages [Hash or Array] Message Objects
|
159
|
+
# @param headers [Hash] HTTP Headers
|
154
160
|
# @return [Net::HTTPResponse]
|
155
|
-
def multicast(to, messages)
|
161
|
+
def multicast(to, messages, headers: {})
|
156
162
|
channel_token_required
|
157
163
|
|
158
164
|
to = [to] if to.is_a?(String)
|
@@ -160,21 +166,23 @@ module Line
|
|
160
166
|
|
161
167
|
endpoint_path = '/bot/message/multicast'
|
162
168
|
payload = { to: to, messages: messages }.to_json
|
163
|
-
post(endpoint, endpoint_path, payload, credentials)
|
169
|
+
post(endpoint, endpoint_path, payload, credentials.merge(headers))
|
164
170
|
end
|
165
171
|
|
166
172
|
# Send messages to all friends.
|
167
173
|
#
|
168
174
|
# @param messages [Hash or Array] Message Objects
|
175
|
+
# @param headers [Hash] HTTP Headers
|
176
|
+
#
|
169
177
|
# @return [Net::HTTPResponse]
|
170
|
-
def broadcast(messages)
|
178
|
+
def broadcast(messages, headers: {})
|
171
179
|
channel_token_required
|
172
180
|
|
173
181
|
messages = [messages] if messages.is_a?(Hash)
|
174
182
|
|
175
183
|
endpoint_path = '/bot/message/broadcast'
|
176
184
|
payload = { messages: messages }.to_json
|
177
|
-
post(endpoint, endpoint_path, payload, credentials)
|
185
|
+
post(endpoint, endpoint_path, payload, credentials.merge(headers))
|
178
186
|
end
|
179
187
|
|
180
188
|
# Narrowcast messages to users
|
@@ -186,9 +194,10 @@ module Line
|
|
186
194
|
# @param recipient [Hash]
|
187
195
|
# @param filter [Hash]
|
188
196
|
# @param limit [Hash]
|
197
|
+
# @param headers [Hash] HTTP Headers
|
189
198
|
#
|
190
199
|
# @return [Net::HTTPResponse]
|
191
|
-
def narrowcast(messages, recipient: nil, filter: nil, limit: nil)
|
200
|
+
def narrowcast(messages, recipient: nil, filter: nil, limit: nil, headers: {})
|
192
201
|
channel_token_required
|
193
202
|
|
194
203
|
messages = [messages] if messages.is_a?(Hash)
|
@@ -200,7 +209,7 @@ module Line
|
|
200
209
|
filter: filter,
|
201
210
|
limit: limit
|
202
211
|
}.to_json
|
203
|
-
post(endpoint, endpoint_path, payload, credentials)
|
212
|
+
post(endpoint, endpoint_path, payload, credentials.merge(headers))
|
204
213
|
end
|
205
214
|
|
206
215
|
def leave_group(group_id)
|
@@ -295,6 +304,42 @@ module Line
|
|
295
304
|
get(endpoint, endpoint_path, credentials)
|
296
305
|
end
|
297
306
|
|
307
|
+
# Gets the group ID, group name, and group icon URL of a group where the LINE Official Account is a member.
|
308
|
+
#
|
309
|
+
# @param group_id [String] Group's identifier
|
310
|
+
#
|
311
|
+
# @return [Net::HTTPResponse]
|
312
|
+
def get_group_summary(group_id)
|
313
|
+
channel_token_required
|
314
|
+
|
315
|
+
endpoint_path = "/bot/group/#{group_id}/summary"
|
316
|
+
get(endpoint, endpoint_path, credentials)
|
317
|
+
end
|
318
|
+
|
319
|
+
# Gets the user IDs of the members of a group that the bot is in.
|
320
|
+
#
|
321
|
+
# @param group_id [String] Group's identifier
|
322
|
+
#
|
323
|
+
# @return [Net::HTTPResponse]
|
324
|
+
def get_group_members_count(group_id)
|
325
|
+
channel_token_required
|
326
|
+
|
327
|
+
endpoint_path = "/bot/group/#{group_id}/members/count"
|
328
|
+
get(endpoint, endpoint_path, credentials)
|
329
|
+
end
|
330
|
+
|
331
|
+
# Gets the count of members in a room.
|
332
|
+
#
|
333
|
+
# @param room_id [String] Room's identifier
|
334
|
+
#
|
335
|
+
# @return [Net::HTTPResponse]
|
336
|
+
def get_room_members_count(room_id)
|
337
|
+
channel_token_required
|
338
|
+
|
339
|
+
endpoint_path = "/bot/room/#{room_id}/members/count"
|
340
|
+
get(endpoint, endpoint_path, credentials)
|
341
|
+
end
|
342
|
+
|
298
343
|
# Get a list of all uploaded rich menus
|
299
344
|
#
|
300
345
|
# @return [Net::HTTPResponse]
|
@@ -507,15 +552,8 @@ module Line
|
|
507
552
|
def create_rich_menu_image(rich_menu_id, file)
|
508
553
|
channel_token_required
|
509
554
|
|
510
|
-
content_type = case file.path
|
511
|
-
when /\.jpe?g\z/i then 'image/jpeg'
|
512
|
-
when /\.png\z/i then 'image/png'
|
513
|
-
else
|
514
|
-
raise ArgumentError, "invalid file extension: #{file.path}"
|
515
|
-
end
|
516
|
-
|
517
555
|
endpoint_path = "/bot/richmenu/#{rich_menu_id}/content"
|
518
|
-
headers = credentials.merge('Content-Type' => content_type)
|
556
|
+
headers = credentials.merge('Content-Type' => content_type(file))
|
519
557
|
post(blob_endpoint, endpoint_path, file.rewind && file.read, headers)
|
520
558
|
end
|
521
559
|
|
@@ -597,6 +635,232 @@ module Line
|
|
597
635
|
get(endpoint, endpoint_path, credentials)
|
598
636
|
end
|
599
637
|
|
638
|
+
# Gets a bot's basic information.
|
639
|
+
#
|
640
|
+
# @return [Net::HTTPResponse]
|
641
|
+
def get_bot_info
|
642
|
+
channel_token_required
|
643
|
+
|
644
|
+
endpoint_path = '/bot/info'
|
645
|
+
get(endpoint, endpoint_path, credentials)
|
646
|
+
end
|
647
|
+
|
648
|
+
# Gets information on a webhook endpoint.
|
649
|
+
#
|
650
|
+
# @return [Net::HTTPResponse]
|
651
|
+
def get_webhook_endpoint
|
652
|
+
channel_token_required
|
653
|
+
|
654
|
+
endpoint_path = '/bot/channel/webhook/endpoint'
|
655
|
+
get(endpoint, endpoint_path, credentials)
|
656
|
+
end
|
657
|
+
|
658
|
+
# Sets the webhook endpoint URL.
|
659
|
+
#
|
660
|
+
# @param webhook_endpoint [String]
|
661
|
+
#
|
662
|
+
# @return [Net::HTTPResponse]
|
663
|
+
def set_webhook_endpoint(webhook_endpoint)
|
664
|
+
channel_token_required
|
665
|
+
|
666
|
+
endpoint_path = '/bot/channel/webhook/endpoint'
|
667
|
+
body = {endpoint: webhook_endpoint}
|
668
|
+
put(endpoint, endpoint_path, body.to_json, credentials)
|
669
|
+
end
|
670
|
+
|
671
|
+
# Checks if the configured webhook endpoint can receive a test webhook event.
|
672
|
+
#
|
673
|
+
# @param webhook_endpoint [String] options
|
674
|
+
#
|
675
|
+
# @return [Net::HTTPResponse]
|
676
|
+
def test_webhook_endpoint(webhook_endpoint = nil)
|
677
|
+
channel_token_required
|
678
|
+
|
679
|
+
endpoint_path = '/bot/channel/webhook/test'
|
680
|
+
body = if webhook_endpoint.nil?
|
681
|
+
{}
|
682
|
+
else
|
683
|
+
{endpoint: webhook_endpoint}
|
684
|
+
end
|
685
|
+
post(endpoint, endpoint_path, body.to_json, credentials)
|
686
|
+
end
|
687
|
+
|
688
|
+
def get_liff_apps
|
689
|
+
channel_token_required
|
690
|
+
|
691
|
+
endpoint_path = '/apps'
|
692
|
+
get(liff_endpoint, endpoint_path, credentials)
|
693
|
+
end
|
694
|
+
|
695
|
+
def create_liff_app(app)
|
696
|
+
channel_token_required
|
697
|
+
|
698
|
+
endpoint_path = '/apps'
|
699
|
+
post(liff_endpoint, endpoint_path, app.to_json, credentials)
|
700
|
+
end
|
701
|
+
|
702
|
+
def update_liff_app(liff_id, app)
|
703
|
+
channel_token_required
|
704
|
+
|
705
|
+
endpoint_path = "/apps/#{liff_id}"
|
706
|
+
put(liff_endpoint, endpoint_path, app.to_json, credentials)
|
707
|
+
end
|
708
|
+
|
709
|
+
def delete_liff_app(liff_id)
|
710
|
+
channel_token_required
|
711
|
+
|
712
|
+
endpoint_path = "/apps/#{liff_id}"
|
713
|
+
delete(liff_endpoint, endpoint_path, credentials)
|
714
|
+
end
|
715
|
+
|
716
|
+
# Create an audience group by uploading user_ids
|
717
|
+
#
|
718
|
+
# Parameters are described here.
|
719
|
+
# https://developers.line.biz/en/reference/messaging-api/#create-upload-audience-group
|
720
|
+
#
|
721
|
+
# @param params [Hash] options
|
722
|
+
#
|
723
|
+
# @return [Net::HTTPResponse] This response includes an audience_group_id.
|
724
|
+
def create_user_id_audience(params)
|
725
|
+
channel_token_required
|
726
|
+
|
727
|
+
endpoint_path = '/bot/audienceGroup/upload'
|
728
|
+
post(endpoint, endpoint_path, params.to_json, credentials)
|
729
|
+
end
|
730
|
+
|
731
|
+
# Update an audience group
|
732
|
+
#
|
733
|
+
# Parameters are described here.
|
734
|
+
# https://developers.line.biz/en/reference/messaging-api/#update-upload-audience-group
|
735
|
+
#
|
736
|
+
# @param params [Hash] options
|
737
|
+
#
|
738
|
+
# @return [Net::HTTPResponse] This response includes an audience_group_id.
|
739
|
+
def update_user_id_audience(params)
|
740
|
+
channel_token_required
|
741
|
+
|
742
|
+
endpoint_path = '/bot/audienceGroup/upload'
|
743
|
+
put(endpoint, endpoint_path, params.to_json, credentials)
|
744
|
+
end
|
745
|
+
|
746
|
+
# Create an audience group of users that clicked a URL in a message sent in the past
|
747
|
+
#
|
748
|
+
# Parameters are described here.
|
749
|
+
# https://developers.line.biz/en/reference/messaging-api/#create-click-audience-group
|
750
|
+
#
|
751
|
+
# @param params [Hash] options
|
752
|
+
#
|
753
|
+
# @return [Net::HTTPResponse] This response includes an audience_group_id.
|
754
|
+
def create_click_audience(params)
|
755
|
+
channel_token_required
|
756
|
+
|
757
|
+
endpoint_path = '/bot/audienceGroup/click'
|
758
|
+
post(endpoint, endpoint_path, params.to_json, credentials)
|
759
|
+
end
|
760
|
+
|
761
|
+
# Create an audience group of users that opened a message sent in the past
|
762
|
+
#
|
763
|
+
# Parameters are described here.
|
764
|
+
# https://developers.line.biz/en/reference/messaging-api/#create-imp-audience-group
|
765
|
+
#
|
766
|
+
# @param params [Hash] options
|
767
|
+
#
|
768
|
+
# @return [Net::HTTPResponse] This response includes an audience_group_id.
|
769
|
+
def create_impression_audience(params)
|
770
|
+
channel_token_required
|
771
|
+
|
772
|
+
endpoint_path = '/bot/audienceGroup/imp'
|
773
|
+
post(endpoint, endpoint_path, params.to_json, credentials)
|
774
|
+
end
|
775
|
+
|
776
|
+
# Rename an existing audience group
|
777
|
+
#
|
778
|
+
# @param audience_group_id [Integer]
|
779
|
+
# @param description [String]
|
780
|
+
#
|
781
|
+
# @return [Net::HTTPResponse]
|
782
|
+
def rename_audience(audience_group_id, description)
|
783
|
+
channel_token_required
|
784
|
+
|
785
|
+
endpoint_path = "/bot/audienceGroup/#{audience_group_id}/updateDescription"
|
786
|
+
body = {description: description}
|
787
|
+
put(endpoint, endpoint_path, body.to_json, credentials)
|
788
|
+
end
|
789
|
+
|
790
|
+
# Delete an existing audience group
|
791
|
+
#
|
792
|
+
# Parameters are described here.
|
793
|
+
# https://developers.line.biz/en/reference/messaging-api/#delete-audience-group
|
794
|
+
#
|
795
|
+
# @param audience_group_id [Integer]
|
796
|
+
#
|
797
|
+
# @return [Net::HTTPResponse]
|
798
|
+
def delete_audience(audience_group_id)
|
799
|
+
channel_token_required
|
800
|
+
|
801
|
+
endpoint_path = "/bot/audienceGroup/#{audience_group_id}"
|
802
|
+
delete(endpoint, endpoint_path, credentials)
|
803
|
+
end
|
804
|
+
|
805
|
+
# Get audience group data
|
806
|
+
#
|
807
|
+
# Parameters are described here.
|
808
|
+
# https://developers.line.biz/en/reference/messaging-api/#get-audience-group
|
809
|
+
#
|
810
|
+
# @param audience_group_id [Integer]
|
811
|
+
#
|
812
|
+
# @return [Net::HTTPResponse]
|
813
|
+
def get_audience(audience_group_id)
|
814
|
+
channel_token_required
|
815
|
+
|
816
|
+
endpoint_path = "/bot/audienceGroup/#{audience_group_id}"
|
817
|
+
get(endpoint, endpoint_path, credentials)
|
818
|
+
end
|
819
|
+
|
820
|
+
# Get data for more than one audience group
|
821
|
+
#
|
822
|
+
# Parameters are described here.
|
823
|
+
# https://developers.line.biz/en/reference/messaging-api/#get-audience-groups
|
824
|
+
#
|
825
|
+
# @param params [Hash] key name `page` is required
|
826
|
+
#
|
827
|
+
# @return [Net::HTTPResponse]
|
828
|
+
def get_audiences(params)
|
829
|
+
channel_token_required
|
830
|
+
|
831
|
+
endpoint_path = "/bot/audienceGroup/list?" + URI.encode_www_form(params)
|
832
|
+
get(endpoint, endpoint_path, credentials)
|
833
|
+
end
|
834
|
+
|
835
|
+
# Get the authority level of the audience
|
836
|
+
#
|
837
|
+
# Parameters are described here.
|
838
|
+
# https://developers.line.biz/en/reference/messaging-api/#get-authority-level
|
839
|
+
#
|
840
|
+
# @return [Net::HTTPResponse]
|
841
|
+
def get_audience_authority_level
|
842
|
+
channel_token_required
|
843
|
+
|
844
|
+
endpoint_path = "/bot/audienceGroup/authorityLevel"
|
845
|
+
get(endpoint, endpoint_path, credentials)
|
846
|
+
end
|
847
|
+
|
848
|
+
# Change the authority level of the audience
|
849
|
+
#
|
850
|
+
# Parameters are described here.
|
851
|
+
# https://developers.line.biz/en/reference/messaging-api/#change-authority-level
|
852
|
+
#
|
853
|
+
# @param authority_level [String] value must be `PUBLIC` or `PRIVATE`
|
854
|
+
#
|
855
|
+
# @return [Net::HTTPResponse]
|
856
|
+
def update_audience_authority_level(authority_level)
|
857
|
+
channel_token_required
|
858
|
+
|
859
|
+
endpoint_path = "/bot/audienceGroup/authorityLevel"
|
860
|
+
body = {authorityLevel: authority_level}
|
861
|
+
put(endpoint, endpoint_path, body.to_json, credentials)
|
862
|
+
end
|
863
|
+
|
600
864
|
# Fetch data, get content of specified URL.
|
601
865
|
#
|
602
866
|
# @param endpoint_base [String]
|
@@ -605,7 +869,7 @@ module Line
|
|
605
869
|
#
|
606
870
|
# @return [Net::HTTPResponse]
|
607
871
|
def get(endpoint_base, endpoint_path, headers = {})
|
608
|
-
headers =
|
872
|
+
headers = API::DEFAULT_HEADERS.merge(headers)
|
609
873
|
httpclient.get(endpoint_base + endpoint_path, headers)
|
610
874
|
end
|
611
875
|
|
@@ -618,10 +882,23 @@ module Line
|
|
618
882
|
#
|
619
883
|
# @return [Net::HTTPResponse]
|
620
884
|
def post(endpoint_base, endpoint_path, payload = nil, headers = {})
|
621
|
-
headers =
|
885
|
+
headers = API::DEFAULT_HEADERS.merge(headers)
|
622
886
|
httpclient.post(endpoint_base + endpoint_path, payload, headers)
|
623
887
|
end
|
624
888
|
|
889
|
+
# Put data, get content of specified URL.
|
890
|
+
#
|
891
|
+
# @param endpoint_base [String]
|
892
|
+
# @param endpoint_path [String]
|
893
|
+
# @param payload [String or NilClass]
|
894
|
+
# @param headers [Hash]
|
895
|
+
#
|
896
|
+
# @return [Net::HTTPResponse]
|
897
|
+
def put(endpoint_base, endpoint_path, payload = nil, headers = {})
|
898
|
+
headers = API::DEFAULT_HEADERS.merge(headers)
|
899
|
+
httpclient.put(endpoint_base + endpoint_path, payload, headers)
|
900
|
+
end
|
901
|
+
|
625
902
|
# Delete content of specified URL.
|
626
903
|
#
|
627
904
|
# @param endpoint_base [String]
|
@@ -630,7 +907,7 @@ module Line
|
|
630
907
|
#
|
631
908
|
# @return [Net::HTTPResponse]
|
632
909
|
def delete(endpoint_base, endpoint_path, headers = {})
|
633
|
-
headers =
|
910
|
+
headers = API::DEFAULT_HEADERS.merge(headers)
|
634
911
|
httpclient.delete(endpoint_base + endpoint_path, headers)
|
635
912
|
end
|
636
913
|
|
@@ -644,10 +921,10 @@ module Line
|
|
644
921
|
|
645
922
|
json['events'].map do |item|
|
646
923
|
begin
|
647
|
-
klass =
|
924
|
+
klass = Event.const_get(Util.camelize(item['type']))
|
648
925
|
klass.new(item)
|
649
926
|
rescue NameError
|
650
|
-
|
927
|
+
Event::Base.new(item)
|
651
928
|
end
|
652
929
|
end
|
653
930
|
end
|
@@ -691,6 +968,21 @@ module Line
|
|
691
968
|
res == 0
|
692
969
|
end
|
693
970
|
|
971
|
+
def content_type(file)
|
972
|
+
if file.respond_to?(:content_type)
|
973
|
+
content_type = file.content_type
|
974
|
+
raise ArgumentError, "invalid content type: #{content_type}" unless ['image/jpeg', 'image/png'].include?(content_type)
|
975
|
+
content_type
|
976
|
+
else
|
977
|
+
case file.path
|
978
|
+
when /\.jpe?g\z/i then 'image/jpeg'
|
979
|
+
when /\.png\z/i then 'image/png'
|
980
|
+
else
|
981
|
+
raise ArgumentError, "invalid file extension: #{file.path}"
|
982
|
+
end
|
983
|
+
end
|
984
|
+
end
|
985
|
+
|
694
986
|
def channel_token_required
|
695
987
|
raise ArgumentError, '`channel_token` is not configured' unless channel_token
|
696
988
|
end
|
data/lib/line/bot/event.rb
CHANGED
@@ -21,6 +21,8 @@ require 'line/bot/event/leave'
|
|
21
21
|
require 'line/bot/event/message'
|
22
22
|
require 'line/bot/event/postback'
|
23
23
|
require 'line/bot/event/unfollow'
|
24
|
+
require 'line/bot/event/unsend'
|
24
25
|
require 'line/bot/event/member_joined'
|
25
26
|
require 'line/bot/event/member_left'
|
26
27
|
require 'line/bot/event/things'
|
28
|
+
require 'line/bot/event/video_play_complete'
|
@@ -31,9 +31,9 @@ module Line
|
|
31
31
|
# https://developers.line.biz/en/reference/messaging-api/#message-event
|
32
32
|
class Message < Base
|
33
33
|
def type
|
34
|
-
|
34
|
+
MessageType.const_get(@src['message']['type'].capitalize)
|
35
35
|
rescue NameError => e
|
36
|
-
|
36
|
+
MessageType::Unsupport
|
37
37
|
end
|
38
38
|
|
39
39
|
def message
|
@@ -29,9 +29,9 @@ module Line
|
|
29
29
|
# * https://developers.line.biz/en/reference/messaging-api/#scenario-result-event
|
30
30
|
class Things < Base
|
31
31
|
def type
|
32
|
-
|
32
|
+
ThingsType.const_get(Util.camelize(@src['things']['type']))
|
33
33
|
rescue NameError
|
34
|
-
|
34
|
+
ThingsType::Unsupport
|
35
35
|
end
|
36
36
|
|
37
37
|
def device_id
|
@@ -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,0 +1,25 @@
|
|
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 for when a user finishes viewing a video at least once with the specified trackingId sent by the LINE Official Account.
|
19
|
+
#
|
20
|
+
# https://developers.line.biz/en/reference/messaging-api/#video-viewing-complete
|
21
|
+
class VideoPlayComplete < Base
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/line/bot/httpclient.rb
CHANGED
@@ -57,6 +57,11 @@ module Line
|
|
57
57
|
http(uri).post(uri.request_uri, payload, header)
|
58
58
|
end
|
59
59
|
|
60
|
+
def put(url, payload, header = {})
|
61
|
+
uri = URI(url)
|
62
|
+
http(uri).put(uri.request_uri, payload, header)
|
63
|
+
end
|
64
|
+
|
60
65
|
def delete(url, header = {})
|
61
66
|
uri = URI(url)
|
62
67
|
http(uri).delete(uri.request_uri, header)
|
data/line-bot-api.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_development_dependency "addressable", "~> 2.3"
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.11" if RUBY_VERSION < "2.3"
|
24
|
-
spec.add_development_dependency 'rake', "~>
|
24
|
+
spec.add_development_dependency 'rake', "~> 13.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
-
spec.add_development_dependency "webmock", "~>
|
26
|
+
spec.add_development_dependency "webmock", "~> 3.8"
|
27
27
|
end
|
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.18.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-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.8'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.8'
|
69
69
|
description: Line::Bot::API - SDK of the LINE Messaging API for Ruby
|
70
70
|
email:
|
71
71
|
- kimoto@linecorp.com
|
@@ -97,6 +97,8 @@ files:
|
|
97
97
|
- lib/line/bot/event/postback.rb
|
98
98
|
- lib/line/bot/event/things.rb
|
99
99
|
- lib/line/bot/event/unfollow.rb
|
100
|
+
- lib/line/bot/event/unsend.rb
|
101
|
+
- lib/line/bot/event/video_play_complete.rb
|
100
102
|
- lib/line/bot/httpclient.rb
|
101
103
|
- lib/line/bot/util.rb
|
102
104
|
- line-bot-api.gemspec
|
@@ -119,8 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
121
|
- !ruby/object:Gem::Version
|
120
122
|
version: '0'
|
121
123
|
requirements: []
|
122
|
-
|
123
|
-
rubygems_version: 2.7.6
|
124
|
+
rubygems_version: 3.1.2
|
124
125
|
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: SDK of the LINE Messaging API
|