Skip to content

Commit adca724

Browse files
committed
Make it compatible
1 parent c5bc173 commit adca724

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

lib/line/bot/client.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,14 @@ def get_room_member_profile(room_id, user_id)
337337
# @param limit [Integer] The maximum number of user IDs to retrieve in a single request
338338
#
339339
# @return [Net::HTTPResponse]
340-
def get_follower_ids(start: nil, limit: nil)
340+
def get_follower_ids(deprecated_continuation_token = nil, start: nil, limit: nil)
341341
channel_token_required
342342

343+
if deprecated_continuation_token
344+
warn "continuation_token as the first argument is deprecated. Please use :start instead."
345+
start = deprecated_continuation_token
346+
end
347+
343348
params = { start: start, limit: limit }.compact
344349

345350
endpoint_path = "/bot/followers/ids"

spec/line/bot/client_get_follower_spec.rb

+26
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,30 @@ def generate_client
9696
expect(response).to be_a(Net::HTTPOK)
9797
expect(result['userIds']).to eq ["Uxxxxxxxxxxxxxx1", "Uxxxxxxxxxxxxxx2"]
9898
end
99+
100+
it 'gets follower ids using deprecated_continuation_token argument' do
101+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/followers/ids'
102+
stub_request(:get, uri_template).to_return { |request| {body: USER_ID_CONTENT, status: 200} }
103+
104+
uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/followers/ids?start={start}'
105+
stub_request(:get, uri_template).to_return { |request| {body: NEXT_USER_ID_CONTENT, status: 200} }
106+
107+
client = generate_client
108+
109+
# first page
110+
response = client.get_follower_ids
111+
112+
expect(response).to be_a(Net::HTTPOK)
113+
result = JSON.parse(response.body)
114+
expect(result['userIds']).to eq ["Uxxxxxxxxxxxxxx1", "Uxxxxxxxxxxxxxx2", "Uxxxxxxxxxxxxxx3"]
115+
expect(result['next']).to eq "jxEWCEEP"
116+
117+
# second page
118+
response = client.get_follower_ids(result['next'])
119+
120+
expect(response).to be_a(Net::HTTPOK)
121+
result = JSON.parse(response.body)
122+
expect(result['userIds']).to eq ["Uxxxxxxxxxxxxxx4", "Uxxxxxxxxxxxxxx5", "Uxxxxxxxxxxxxxx6"]
123+
expect(result['next']).to be nil
124+
end
99125
end

0 commit comments

Comments
 (0)