File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -353,6 +353,16 @@ def create_rich_menu_image(rich_menu_id, file)
353
353
request . post
354
354
end
355
355
356
+ # Issue a link token to a user
357
+ #
358
+ # @param user_id [String] ID of the user
359
+ #
360
+ # @return [Net::HTTPResponse]
361
+ def create_link_token ( user_id )
362
+ endpoint_path = "/bot/user/#{ user_id } /linkToken"
363
+ post ( endpoint_path )
364
+ end
365
+
356
366
# Fetch data, get content of specified URL.
357
367
#
358
368
# @param endpoint_path [String]
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+ require 'webmock/rspec'
3
+ require 'json'
4
+
5
+ LINK_TOKEN_CONTENT = <<"EOS"
6
+ {
7
+ "linkToken":"abcdefg0123456789"
8
+ }
9
+ EOS
10
+
11
+ WebMock . allow_net_connect!
12
+
13
+ describe Line ::Bot ::Client do
14
+ let ( :client ) {
15
+ dummy_config = {
16
+ channel_token : 'access token' ,
17
+ }
18
+ Line ::Bot ::Client . new do |config |
19
+ config . channel_token = dummy_config [ :channel_token ]
20
+ end
21
+ }
22
+
23
+ it 'issues a link token' do
24
+ uri_template = Addressable ::Template . new Line ::Bot ::API ::DEFAULT_ENDPOINT + '/bot/user/{user_id}/linkToken'
25
+ stub_request ( :post , uri_template ) . to_return ( body : LINK_TOKEN_CONTENT , status : 200 )
26
+
27
+ response = client . create_link_token ( 'user_id' )
28
+ expect ( WebMock ) . to have_requested ( :post , Line ::Bot ::API ::DEFAULT_ENDPOINT + '/bot/user/user_id/linkToken' )
29
+ expect ( response . body ) . to eq LINK_TOKEN_CONTENT
30
+ end
31
+ end
You can’t perform that action at this time.
0 commit comments