line-bot-api 1.14.1 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d265a003f523763063653537df89119ee79f3fc1c987640fbd78090d081045ca
4
- data.tar.gz: a5fd82fa00d302b4b804432b87fde84034492e7245a9665d4ab9f480a0fd12df
3
+ metadata.gz: a8864bff59b1e7a50a3f63bd2aef939319c9731b9facbb4116d0aa4bb7894101
4
+ data.tar.gz: df898ac583f61824837b3e92f98867be4aafb74fbdc5b89ad094edf164e098ee
5
5
  SHA512:
6
- metadata.gz: 6d89224a7a2eae22ff20ff38e08d472d595500356b54c6836cdf0af9e7345edeb42c6a6fcfb3c4500402c76635cd8e4d3e932526a0718e403fc5fa2d858b2d48
7
- data.tar.gz: f2de6de836fa6f95a93f98acb88021a1206506dfebabd7f734c38747b6bbb141c59d3bebd6b7c2cc3743564dc498b929f700bdf33dada17d65a1953972dbe9eb
6
+ metadata.gz: 921d2f1896c8c60759eeccbd3ca40a57bd2d401558a1d5d5bedceb967f00d1be6d56b1d886987e7883cd9b2b43541b555ec895759607235265accd787aed6653
7
+ data.tar.gz: 3a50ac3a250aa087eb7285a7a1144e4f64c15443acaca6d28e747f979198902ef887bc589fad8e31aa74fb526820ebc3eff1e4413f83460b227caa327021e172
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',
@@ -15,7 +15,7 @@
15
15
  module Line
16
16
  module Bot
17
17
  module API
18
- VERSION = "1.14.1"
18
+ VERSION = "1.19.0"
19
19
  end
20
20
  end
21
21
  end
@@ -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
  {
@@ -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)
@@ -265,6 +274,20 @@ module Line
265
274
  get(endpoint, endpoint_path, credentials)
266
275
  end
267
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
+
268
291
  # Get user IDs of a group
269
292
  #
270
293
  # @param group_id [String] Group's identifier
@@ -295,6 +318,42 @@ module Line
295
318
  get(endpoint, endpoint_path, credentials)
296
319
  end
297
320
 
321
+ # Gets the group ID, group name, and group icon URL of a group where the LINE Official Account is a member.
322
+ #
323
+ # @param group_id [String] Group's identifier
324
+ #
325
+ # @return [Net::HTTPResponse]
326
+ def get_group_summary(group_id)
327
+ channel_token_required
328
+
329
+ endpoint_path = "/bot/group/#{group_id}/summary"
330
+ get(endpoint, endpoint_path, credentials)
331
+ end
332
+
333
+ # Gets the user IDs of the members of a group that the bot is in.
334
+ #
335
+ # @param group_id [String] Group's identifier
336
+ #
337
+ # @return [Net::HTTPResponse]
338
+ def get_group_members_count(group_id)
339
+ channel_token_required
340
+
341
+ endpoint_path = "/bot/group/#{group_id}/members/count"
342
+ get(endpoint, endpoint_path, credentials)
343
+ end
344
+
345
+ # Gets the count of members in a room.
346
+ #
347
+ # @param room_id [String] Room's identifier
348
+ #
349
+ # @return [Net::HTTPResponse]
350
+ def get_room_members_count(room_id)
351
+ channel_token_required
352
+
353
+ endpoint_path = "/bot/room/#{room_id}/members/count"
354
+ get(endpoint, endpoint_path, credentials)
355
+ end
356
+
298
357
  # Get a list of all uploaded rich menus
299
358
  #
300
359
  # @return [Net::HTTPResponse]
@@ -590,6 +649,232 @@ module Line
590
649
  get(endpoint, endpoint_path, credentials)
591
650
  end
592
651
 
652
+ # Gets a bot's basic information.
653
+ #
654
+ # @return [Net::HTTPResponse]
655
+ def get_bot_info
656
+ channel_token_required
657
+
658
+ endpoint_path = '/bot/info'
659
+ get(endpoint, endpoint_path, credentials)
660
+ end
661
+
662
+ # Gets information on a webhook endpoint.
663
+ #
664
+ # @return [Net::HTTPResponse]
665
+ def get_webhook_endpoint
666
+ channel_token_required
667
+
668
+ endpoint_path = '/bot/channel/webhook/endpoint'
669
+ get(endpoint, endpoint_path, credentials)
670
+ end
671
+
672
+ # Sets the webhook endpoint URL.
673
+ #
674
+ # @param webhook_endpoint [String]
675
+ #
676
+ # @return [Net::HTTPResponse]
677
+ def set_webhook_endpoint(webhook_endpoint)
678
+ channel_token_required
679
+
680
+ endpoint_path = '/bot/channel/webhook/endpoint'
681
+ body = {endpoint: webhook_endpoint}
682
+ put(endpoint, endpoint_path, body.to_json, credentials)
683
+ end
684
+
685
+ # Checks if the configured webhook endpoint can receive a test webhook event.
686
+ #
687
+ # @param webhook_endpoint [String] options
688
+ #
689
+ # @return [Net::HTTPResponse]
690
+ def test_webhook_endpoint(webhook_endpoint = nil)
691
+ channel_token_required
692
+
693
+ endpoint_path = '/bot/channel/webhook/test'
694
+ body = if webhook_endpoint.nil?
695
+ {}
696
+ else
697
+ {endpoint: webhook_endpoint}
698
+ end
699
+ post(endpoint, endpoint_path, body.to_json, credentials)
700
+ end
701
+
702
+ def get_liff_apps
703
+ channel_token_required
704
+
705
+ endpoint_path = '/apps'
706
+ get(liff_endpoint, endpoint_path, credentials)
707
+ end
708
+
709
+ def create_liff_app(app)
710
+ channel_token_required
711
+
712
+ endpoint_path = '/apps'
713
+ post(liff_endpoint, endpoint_path, app.to_json, credentials)
714
+ end
715
+
716
+ def update_liff_app(liff_id, app)
717
+ channel_token_required
718
+
719
+ endpoint_path = "/apps/#{liff_id}"
720
+ put(liff_endpoint, endpoint_path, app.to_json, credentials)
721
+ end
722
+
723
+ def delete_liff_app(liff_id)
724
+ channel_token_required
725
+
726
+ endpoint_path = "/apps/#{liff_id}"
727
+ delete(liff_endpoint, endpoint_path, credentials)
728
+ end
729
+
730
+ # Create an audience group by uploading user_ids
731
+ #
732
+ # Parameters are described here.
733
+ # https://developers.line.biz/en/reference/messaging-api/#create-upload-audience-group
734
+ #
735
+ # @param params [Hash] options
736
+ #
737
+ # @return [Net::HTTPResponse] This response includes an audience_group_id.
738
+ def create_user_id_audience(params)
739
+ channel_token_required
740
+
741
+ endpoint_path = '/bot/audienceGroup/upload'
742
+ post(endpoint, endpoint_path, params.to_json, credentials)
743
+ end
744
+
745
+ # Update an audience group
746
+ #
747
+ # Parameters are described here.
748
+ # https://developers.line.biz/en/reference/messaging-api/#update-upload-audience-group
749
+ #
750
+ # @param params [Hash] options
751
+ #
752
+ # @return [Net::HTTPResponse] This response includes an audience_group_id.
753
+ def update_user_id_audience(params)
754
+ channel_token_required
755
+
756
+ endpoint_path = '/bot/audienceGroup/upload'
757
+ put(endpoint, endpoint_path, params.to_json, credentials)
758
+ end
759
+
760
+ # Create an audience group of users that clicked a URL in a message sent in the past
761
+ #
762
+ # Parameters are described here.
763
+ # https://developers.line.biz/en/reference/messaging-api/#create-click-audience-group
764
+ #
765
+ # @param params [Hash] options
766
+ #
767
+ # @return [Net::HTTPResponse] This response includes an audience_group_id.
768
+ def create_click_audience(params)
769
+ channel_token_required
770
+
771
+ endpoint_path = '/bot/audienceGroup/click'
772
+ post(endpoint, endpoint_path, params.to_json, credentials)
773
+ end
774
+
775
+ # Create an audience group of users that opened a message sent in the past
776
+ #
777
+ # Parameters are described here.
778
+ # https://developers.line.biz/en/reference/messaging-api/#create-imp-audience-group
779
+ #
780
+ # @param params [Hash] options
781
+ #
782
+ # @return [Net::HTTPResponse] This response includes an audience_group_id.
783
+ def create_impression_audience(params)
784
+ channel_token_required
785
+
786
+ endpoint_path = '/bot/audienceGroup/imp'
787
+ post(endpoint, endpoint_path, params.to_json, credentials)
788
+ end
789
+
790
+ # Rename an existing audience group
791
+ #
792
+ # @param audience_group_id [Integer]
793
+ # @param description [String]
794
+ #
795
+ # @return [Net::HTTPResponse]
796
+ def rename_audience(audience_group_id, description)
797
+ channel_token_required
798
+
799
+ endpoint_path = "/bot/audienceGroup/#{audience_group_id}/updateDescription"
800
+ body = {description: description}
801
+ put(endpoint, endpoint_path, body.to_json, credentials)
802
+ end
803
+
804
+ # Delete an existing audience group
805
+ #
806
+ # Parameters are described here.
807
+ # https://developers.line.biz/en/reference/messaging-api/#delete-audience-group
808
+ #
809
+ # @param audience_group_id [Integer]
810
+ #
811
+ # @return [Net::HTTPResponse]
812
+ def delete_audience(audience_group_id)
813
+ channel_token_required
814
+
815
+ endpoint_path = "/bot/audienceGroup/#{audience_group_id}"
816
+ delete(endpoint, endpoint_path, credentials)
817
+ end
818
+
819
+ # Get audience group data
820
+ #
821
+ # Parameters are described here.
822
+ # https://developers.line.biz/en/reference/messaging-api/#get-audience-group
823
+ #
824
+ # @param audience_group_id [Integer]
825
+ #
826
+ # @return [Net::HTTPResponse]
827
+ def get_audience(audience_group_id)
828
+ channel_token_required
829
+
830
+ endpoint_path = "/bot/audienceGroup/#{audience_group_id}"
831
+ get(endpoint, endpoint_path, credentials)
832
+ end
833
+
834
+ # Get data for more than one audience group
835
+ #
836
+ # Parameters are described here.
837
+ # https://developers.line.biz/en/reference/messaging-api/#get-audience-groups
838
+ #
839
+ # @param params [Hash] key name `page` is required
840
+ #
841
+ # @return [Net::HTTPResponse]
842
+ def get_audiences(params)
843
+ channel_token_required
844
+
845
+ endpoint_path = "/bot/audienceGroup/list?" + URI.encode_www_form(params)
846
+ get(endpoint, endpoint_path, credentials)
847
+ end
848
+
849
+ # Get the authority level of the audience
850
+ #
851
+ # Parameters are described here.
852
+ # https://developers.line.biz/en/reference/messaging-api/#get-authority-level
853
+ #
854
+ # @return [Net::HTTPResponse]
855
+ def get_audience_authority_level
856
+ channel_token_required
857
+
858
+ endpoint_path = "/bot/audienceGroup/authorityLevel"
859
+ get(endpoint, endpoint_path, credentials)
860
+ end
861
+
862
+ # Change the authority level of the audience
863
+ #
864
+ # Parameters are described here.
865
+ # https://developers.line.biz/en/reference/messaging-api/#change-authority-level
866
+ #
867
+ # @param authority_level [String] value must be `PUBLIC` or `PRIVATE`
868
+ #
869
+ # @return [Net::HTTPResponse]
870
+ def update_audience_authority_level(authority_level)
871
+ channel_token_required
872
+
873
+ endpoint_path = "/bot/audienceGroup/authorityLevel"
874
+ body = {authorityLevel: authority_level}
875
+ put(endpoint, endpoint_path, body.to_json, credentials)
876
+ end
877
+
593
878
  # Fetch data, get content of specified URL.
594
879
  #
595
880
  # @param endpoint_base [String]
@@ -615,6 +900,19 @@ module Line
615
900
  httpclient.post(endpoint_base + endpoint_path, payload, headers)
616
901
  end
617
902
 
903
+ # Put data, get content of specified URL.
904
+ #
905
+ # @param endpoint_base [String]
906
+ # @param endpoint_path [String]
907
+ # @param payload [String or NilClass]
908
+ # @param headers [Hash]
909
+ #
910
+ # @return [Net::HTTPResponse]
911
+ def put(endpoint_base, endpoint_path, payload = nil, headers = {})
912
+ headers = API::DEFAULT_HEADERS.merge(headers)
913
+ httpclient.put(endpoint_base + endpoint_path, payload, headers)
914
+ end
915
+
618
916
  # Delete content of specified URL.
619
917
  #
620
918
  # @param endpoint_base [String]
@@ -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'
@@ -23,6 +23,10 @@ module Line
23
23
  def [](key)
24
24
  @src[key]
25
25
  end
26
+
27
+ def to_hash
28
+ @src
29
+ end
26
30
  end
27
31
  end
28
32
  end
@@ -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
@@ -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)
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.14.1
4
+ version: 1.19.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: 2020-04-06 00:00:00.000000000 Z
11
+ date: 2021-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -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