line-bot-api 1.12.0 → 1.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec352e50cd2b13df2d2c4d0f14ae9f6d3346c33358f343ae43448a1d489a3203
4
- data.tar.gz: 26e0c32ab9671267628fe4749ae039558409a4087f991869e310e293276ff386
3
+ metadata.gz: bf4665d3f64bd345493bbd462ff4a69f14089803a0ccbfa2af4a33ddba6dde87
4
+ data.tar.gz: ff297dbf91d2f862384a4e56a44496f28e6639dc90be48dffcd1f5e026195dea
5
5
  SHA512:
6
- metadata.gz: 1b924857b1fa6732824b648aebc131885e1638aba7e4f28beb281e1c402b74260727c9a1700ed8174fc6f312bad38eeef6e5bcf4be6bdd908f6a2e0d04df8f26
7
- data.tar.gz: e513999b3e4d52985efd98fcdcca98bbd45c48602f28911d49518a341b5ceeeee0ed8e1326d862f1ee51c1bfb93a51860b938cfec5b059277ca6a6da7e7d0a65
6
+ metadata.gz: 6a15e26e9071d289cbf00238cc4e15a50923db911a538f2756be9503f800a53ed8518da5435717f49b714d0c2a44b51be67a5ab2a0ff16405c5e2583483f20d3
7
+ data.tar.gz: e282f0efc0ffa2ae259de6ebdcb9cd7b9a650dad7d979ceaf13c8bdff4056695207850e7ed8195d03065509eabe9b712ebcfb62fbfc0b77ae40dd49ffc5170ed
data/lib/line/bot/api.rb CHANGED
@@ -18,6 +18,7 @@ module Line
18
18
  module Bot
19
19
  module API
20
20
  DEFAULT_ENDPOINT = "https://api.line.me/v2"
21
+ DEFAULT_BLOB_ENDPOINT = "https://api-data.line.me/v2"
21
22
 
22
23
  DEFAULT_HEADERS = {
23
24
  '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.12.0"
18
+ VERSION = "1.13.0"
19
19
  end
20
20
  end
21
21
  end
@@ -21,7 +21,7 @@ module Line
21
21
  module Bot
22
22
  class Client
23
23
  # @return [String]
24
- attr_accessor :channel_token, :channel_id, :channel_secret, :endpoint
24
+ attr_accessor :channel_token, :channel_id, :channel_secret, :endpoint, :blob_endpoint
25
25
 
26
26
  # @return [Object]
27
27
  attr_accessor :httpclient
@@ -49,6 +49,17 @@ module Line
49
49
  @endpoint ||= Line::Bot::API::DEFAULT_ENDPOINT
50
50
  end
51
51
 
52
+ def blob_endpoint
53
+ return @blob_endpoint if @blob_endpoint
54
+
55
+ @blob_endpoint = if endpoint == Line::Bot::API::DEFAULT_ENDPOINT
56
+ Line::Bot::API::DEFAULT_BLOB_ENDPOINT
57
+ else
58
+ # for backward compatible
59
+ endpoint
60
+ end
61
+ end
62
+
52
63
  # @return [Hash]
53
64
  def credentials
54
65
  {
@@ -72,7 +83,7 @@ module Line
72
83
  client_secret: channel_secret
73
84
  )
74
85
  headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
75
- post(endpoint_path, payload, headers)
86
+ post(endpoint, endpoint_path, payload, headers)
76
87
  end
77
88
 
78
89
  # Revoke channel access token
@@ -82,7 +93,7 @@ module Line
82
93
  endpoint_path = '/oauth/revoke'
83
94
  payload = URI.encode_www_form(access_token: access_token)
84
95
  headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
85
- post(endpoint_path, payload, headers)
96
+ post(endpoint, endpoint_path, payload, headers)
86
97
  end
87
98
 
88
99
  # Push messages to line server and to user.
@@ -98,7 +109,7 @@ module Line
98
109
 
99
110
  endpoint_path = '/bot/message/push'
100
111
  payload = { to: user_id, messages: messages }.to_json
101
- post(endpoint_path, payload, credentials)
112
+ post(endpoint, endpoint_path, payload, credentials)
102
113
  end
103
114
 
104
115
  # Reply messages to line server and to users.
@@ -114,7 +125,7 @@ module Line
114
125
 
115
126
  endpoint_path = '/bot/message/reply'
116
127
  payload = { replyToken: token, messages: messages }.to_json
117
- post(endpoint_path, payload, credentials)
128
+ post(endpoint, endpoint_path, payload, credentials)
118
129
  end
119
130
 
120
131
  # Multicast messages to line server and to users.
@@ -131,7 +142,7 @@ module Line
131
142
 
132
143
  endpoint_path = '/bot/message/multicast'
133
144
  payload = { to: to, messages: messages }.to_json
134
- post(endpoint_path, payload, credentials)
145
+ post(endpoint, endpoint_path, payload, credentials)
135
146
  end
136
147
 
137
148
  # Broadcast messages to users
@@ -146,21 +157,21 @@ module Line
146
157
 
147
158
  endpoint_path = '/bot/message/broadcast'
148
159
  payload = { messages: messages }.to_json
149
- post(endpoint_path, payload, credentials)
160
+ post(endpoint, endpoint_path, payload, credentials)
150
161
  end
151
162
 
152
163
  def leave_group(group_id)
153
164
  channel_token_required
154
165
 
155
166
  endpoint_path = "/bot/group/#{group_id}/leave"
156
- post(endpoint_path, nil, credentials)
167
+ post(endpoint, endpoint_path, nil, credentials)
157
168
  end
158
169
 
159
170
  def leave_room(room_id)
160
171
  channel_token_required
161
172
 
162
173
  endpoint_path = "/bot/room/#{room_id}/leave"
163
- post(endpoint_path, nil, credentials)
174
+ post(endpoint, endpoint_path, nil, credentials)
164
175
  end
165
176
 
166
177
  # Get message content.
@@ -172,7 +183,7 @@ module Line
172
183
  channel_token_required
173
184
 
174
185
  endpoint_path = "/bot/message/#{identifier}/content"
175
- get(endpoint_path, credentials)
186
+ get(blob_endpoint, endpoint_path, credentials)
176
187
  end
177
188
 
178
189
  # Get an user's profile.
@@ -184,7 +195,7 @@ module Line
184
195
  channel_token_required
185
196
 
186
197
  endpoint_path = "/bot/profile/#{user_id}"
187
- get(endpoint_path, credentials)
198
+ get(endpoint, endpoint_path, credentials)
188
199
  end
189
200
 
190
201
  # Get an user's profile of a group.
@@ -197,7 +208,7 @@ module Line
197
208
  channel_token_required
198
209
 
199
210
  endpoint_path = "/bot/group/#{group_id}/member/#{user_id}"
200
- get(endpoint_path, credentials)
211
+ get(endpoint, endpoint_path, credentials)
201
212
  end
202
213
 
203
214
  # Get an user's profile of a room.
@@ -210,7 +221,7 @@ module Line
210
221
  channel_token_required
211
222
 
212
223
  endpoint_path = "/bot/room/#{room_id}/member/#{user_id}"
213
- get(endpoint_path, credentials)
224
+ get(endpoint, endpoint_path, credentials)
214
225
  end
215
226
 
216
227
  # Get user IDs of a group
@@ -225,7 +236,7 @@ module Line
225
236
 
226
237
  endpoint_path = "/bot/group/#{group_id}/members/ids"
227
238
  endpoint_path += "?start=#{continuation_token}" if continuation_token
228
- get(endpoint_path, credentials)
239
+ get(endpoint, endpoint_path, credentials)
229
240
  end
230
241
 
231
242
  # Get user IDs of a room
@@ -240,7 +251,7 @@ module Line
240
251
 
241
252
  endpoint_path = "/bot/room/#{room_id}/members/ids"
242
253
  endpoint_path += "?start=#{continuation_token}" if continuation_token
243
- get(endpoint_path, credentials)
254
+ get(endpoint, endpoint_path, credentials)
244
255
  end
245
256
 
246
257
  # Get a list of all uploaded rich menus
@@ -250,7 +261,7 @@ module Line
250
261
  channel_token_required
251
262
 
252
263
  endpoint_path = '/bot/richmenu/list'
253
- get(endpoint_path, credentials)
264
+ get(endpoint, endpoint_path, credentials)
254
265
  end
255
266
 
256
267
  # Get a rich menu via a rich menu ID
@@ -262,7 +273,7 @@ module Line
262
273
  channel_token_required
263
274
 
264
275
  endpoint_path = "/bot/richmenu/#{rich_menu_id}"
265
- get(endpoint_path, credentials)
276
+ get(endpoint, endpoint_path, credentials)
266
277
  end
267
278
 
268
279
  # Gets the number of messages sent with the /bot/message/reply endpoint.
@@ -274,7 +285,7 @@ module Line
274
285
  channel_token_required
275
286
 
276
287
  endpoint_path = "/bot/message/delivery/reply?date=#{date}"
277
- get(endpoint_path, credentials)
288
+ get(endpoint, endpoint_path, credentials)
278
289
  end
279
290
 
280
291
  # Gets the number of messages sent with the /bot/message/push endpoint.
@@ -286,7 +297,7 @@ module Line
286
297
  channel_token_required
287
298
 
288
299
  endpoint_path = "/bot/message/delivery/push?date=#{date}"
289
- get(endpoint_path, credentials)
300
+ get(endpoint, endpoint_path, credentials)
290
301
  end
291
302
 
292
303
  # Gets the number of messages sent with the /bot/message/multicast endpoint.
@@ -298,7 +309,7 @@ module Line
298
309
  channel_token_required
299
310
 
300
311
  endpoint_path = "/bot/message/delivery/multicast?date=#{date}"
301
- get(endpoint_path, credentials)
312
+ get(endpoint, endpoint_path, credentials)
302
313
  end
303
314
 
304
315
  # Gets the number of messages sent with the /bot/message/multicast endpoint.
@@ -310,7 +321,7 @@ module Line
310
321
  channel_token_required
311
322
 
312
323
  endpoint_path = "/bot/message/delivery/broadcast?date=#{date}"
313
- get(endpoint_path, credentials)
324
+ get(endpoint, endpoint_path, credentials)
314
325
  end
315
326
 
316
327
  # Create a rich menu
@@ -322,7 +333,7 @@ module Line
322
333
  channel_token_required
323
334
 
324
335
  endpoint_path = '/bot/richmenu'
325
- post(endpoint_path, rich_menu.to_json, credentials)
336
+ post(endpoint, endpoint_path, rich_menu.to_json, credentials)
326
337
  end
327
338
 
328
339
  # Delete a rich menu
@@ -334,7 +345,7 @@ module Line
334
345
  channel_token_required
335
346
 
336
347
  endpoint_path = "/bot/richmenu/#{rich_menu_id}"
337
- delete(endpoint_path, credentials)
348
+ delete(endpoint, endpoint_path, credentials)
338
349
  end
339
350
 
340
351
  # Get the ID of the rich menu linked to a user
@@ -346,7 +357,7 @@ module Line
346
357
  channel_token_required
347
358
 
348
359
  endpoint_path = "/bot/user/#{user_id}/richmenu"
349
- get(endpoint_path, credentials)
360
+ get(endpoint, endpoint_path, credentials)
350
361
  end
351
362
 
352
363
  # Get default rich menu
@@ -356,7 +367,7 @@ module Line
356
367
  channel_token_required
357
368
 
358
369
  endpoint_path = '/bot/user/all/richmenu'
359
- get(endpoint_path, credentials)
370
+ get(endpoint, endpoint_path, credentials)
360
371
  end
361
372
 
362
373
  # Set default rich menu (Link a rich menu to all user)
@@ -368,7 +379,7 @@ module Line
368
379
  channel_token_required
369
380
 
370
381
  endpoint_path = "/bot/user/all/richmenu/#{rich_menu_id}"
371
- post(endpoint_path, nil, credentials)
382
+ post(endpoint, endpoint_path, nil, credentials)
372
383
  end
373
384
 
374
385
  # Unset default rich menu (Unlink a rich menu from all user)
@@ -378,7 +389,7 @@ module Line
378
389
  channel_token_required
379
390
 
380
391
  endpoint_path = "/bot/user/all/richmenu"
381
- delete(endpoint_path, credentials)
392
+ delete(endpoint, endpoint_path, credentials)
382
393
  end
383
394
 
384
395
  # Link a rich menu to a user
@@ -391,7 +402,7 @@ module Line
391
402
  channel_token_required
392
403
 
393
404
  endpoint_path = "/bot/user/#{user_id}/richmenu/#{rich_menu_id}"
394
- post(endpoint_path, nil, credentials)
405
+ post(endpoint, endpoint_path, nil, credentials)
395
406
  end
396
407
 
397
408
  # Unlink a rich menu from a user
@@ -403,7 +414,7 @@ module Line
403
414
  channel_token_required
404
415
 
405
416
  endpoint_path = "/bot/user/#{user_id}/richmenu"
406
- delete(endpoint_path, credentials)
417
+ delete(endpoint, endpoint_path, credentials)
407
418
  end
408
419
 
409
420
  # To link a rich menu to multiple users at a time
@@ -416,7 +427,7 @@ module Line
416
427
  channel_token_required
417
428
 
418
429
  endpoint_path = "/bot/richmenu/bulk/link"
419
- post(endpoint_path, { richMenuId: rich_menu_id, userIds: user_ids }.to_json, credentials)
430
+ post(endpoint, endpoint_path, { richMenuId: rich_menu_id, userIds: user_ids }.to_json, credentials)
420
431
  end
421
432
 
422
433
  # To unlink a rich menu from multiple users at a time
@@ -428,7 +439,7 @@ module Line
428
439
  channel_token_required
429
440
 
430
441
  endpoint_path = "/bot/richmenu/bulk/unlink"
431
- post(endpoint_path, { userIds: user_ids }.to_json, credentials)
442
+ post(endpoint, endpoint_path, { userIds: user_ids }.to_json, credentials)
432
443
  end
433
444
 
434
445
  # Download an image associated with a rich menu
@@ -440,7 +451,7 @@ module Line
440
451
  channel_token_required
441
452
 
442
453
  endpoint_path = "/bot/richmenu/#{rich_menu_id}/content"
443
- get(endpoint_path, credentials)
454
+ get(blob_endpoint, endpoint_path, credentials)
444
455
  end
445
456
 
446
457
  # Upload and attaches an image to a rich menu
@@ -461,7 +472,7 @@ module Line
461
472
 
462
473
  endpoint_path = "/bot/richmenu/#{rich_menu_id}/content"
463
474
  headers = credentials.merge('Content-Type' => content_type)
464
- post(endpoint_path, file.rewind && file.read, headers)
475
+ post(blob_endpoint, endpoint_path, file.rewind && file.read, headers)
465
476
  end
466
477
 
467
478
  # Issue a link token to a user
@@ -473,7 +484,7 @@ module Line
473
484
  channel_token_required
474
485
 
475
486
  endpoint_path = "/bot/user/#{user_id}/linkToken"
476
- post(endpoint_path, nil, credentials)
487
+ post(endpoint, endpoint_path, nil, credentials)
477
488
  end
478
489
 
479
490
  # Get the target limit for additional messages
@@ -483,7 +494,7 @@ module Line
483
494
  channel_token_required
484
495
 
485
496
  endpoint_path = "/bot/message/quota"
486
- get(endpoint_path, credentials)
497
+ get(endpoint, endpoint_path, credentials)
487
498
  end
488
499
 
489
500
  # Get number of messages sent this month
@@ -493,7 +504,7 @@ module Line
493
504
  channel_token_required
494
505
 
495
506
  endpoint_path = "/bot/message/quota/consumption"
496
- get(endpoint_path, credentials)
507
+ get(endpoint, endpoint_path, credentials)
497
508
  end
498
509
 
499
510
  # Returns the number of messages sent on a specified day
@@ -505,7 +516,7 @@ module Line
505
516
  channel_token_required
506
517
 
507
518
  endpoint_path = "/bot/insight/message/delivery?date=#{date}"
508
- get(endpoint_path, credentials)
519
+ get(endpoint, endpoint_path, credentials)
509
520
  end
510
521
 
511
522
  # Returns the number of followers
@@ -517,7 +528,7 @@ module Line
517
528
  channel_token_required
518
529
 
519
530
  endpoint_path = "/bot/insight/followers?date=#{date}"
520
- get(endpoint_path, credentials)
531
+ get(endpoint, endpoint_path, credentials)
521
532
  end
522
533
 
523
534
  # Retrieves the demographic attributes for a bot's friends.
@@ -527,41 +538,44 @@ module Line
527
538
  channel_token_required
528
539
 
529
540
  endpoint_path = '/bot/insight/demographic'
530
- get(endpoint_path, credentials)
541
+ get(endpoint, endpoint_path, credentials)
531
542
  end
532
543
 
533
544
  # Fetch data, get content of specified URL.
534
545
  #
546
+ # @param endpoint_base [String]
535
547
  # @param endpoint_path [String]
536
548
  # @param headers [Hash]
537
549
  #
538
550
  # @return [Net::HTTPResponse]
539
- def get(endpoint_path, headers = {})
551
+ def get(endpoint_base, endpoint_path, headers = {})
540
552
  headers = Line::Bot::API::DEFAULT_HEADERS.merge(headers)
541
- httpclient.get(endpoint + endpoint_path, headers)
553
+ httpclient.get(endpoint_base + endpoint_path, headers)
542
554
  end
543
555
 
544
556
  # Post data, get content of specified URL.
545
557
  #
558
+ # @param endpoint_base [String]
546
559
  # @param endpoint_path [String]
547
560
  # @param payload [String or NilClass]
548
561
  # @param headers [Hash]
549
562
  #
550
563
  # @return [Net::HTTPResponse]
551
- def post(endpoint_path, payload = nil, headers = {})
564
+ def post(endpoint_base, endpoint_path, payload = nil, headers = {})
552
565
  headers = Line::Bot::API::DEFAULT_HEADERS.merge(headers)
553
- httpclient.post(endpoint + endpoint_path, payload, headers)
566
+ httpclient.post(endpoint_base + endpoint_path, payload, headers)
554
567
  end
555
568
 
556
569
  # Delete content of specified URL.
557
570
  #
571
+ # @param endpoint_base [String]
558
572
  # @param endpoint_path [String]
559
573
  # @param headers [Hash]
560
574
  #
561
575
  # @return [Net::HTTPResponse]
562
- def delete(endpoint_path, headers = {})
576
+ def delete(endpoint_base, endpoint_path, headers = {})
563
577
  headers = Line::Bot::API::DEFAULT_HEADERS.merge(headers)
564
- httpclient.delete(endpoint + endpoint_path, headers)
578
+ httpclient.delete(endpoint_base + endpoint_path, headers)
565
579
  end
566
580
 
567
581
  # Parse events from request.body
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.12.0
4
+ version: 1.13.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: 2019-07-16 00:00:00.000000000 Z
11
+ date: 2019-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable