|
43 | 43 | .with( |
44 | 44 | body: "{\"description\":\"Test Audience\"}", |
45 | 45 | headers: { |
46 | | - 'Authorization'=>"Bearer #{channel_access_token}", |
47 | | - 'Content-Type'=>'application/json', |
| 46 | + 'Authorization' => "Bearer #{channel_access_token}", |
| 47 | + 'Content-Type' => 'application/json', |
48 | 48 | } |
49 | 49 | ) |
50 | 50 | .to_return(status: 202, body: "{\"description\": \"Test Audience response\"}", headers: {}) |
|
231 | 231 | it "doesn't require bearer token" do |
232 | 232 | stub_request(:post, "https://api.line.me/v2/oauth/accessToken") |
233 | 233 | .with( |
234 | | - body: {"clientId"=>"test-client-id", "clientSecret"=>"test-client-secret", "grantType"=>"client_credentials" } |
| 234 | + body: { "clientId" => "test-client-id", "clientSecret" => "test-client-secret", "grantType" => "client_credentials" } |
235 | 235 | ) |
236 | 236 | .to_return(status: response_code, body: response_body, headers: { 'Content-Type' => 'application/json' }) |
237 | 237 |
|
|
248 | 248 |
|
249 | 249 | describe 'GET /v2/bot/followers/ids' do |
250 | 250 | let(:client) { Line::Bot::V2::MessagingApi::ApiClient.new(channel_access_token: 'test-channel-access-token') } |
251 | | - let(:response_body) { { "user_ids" => ["U1234567890", "U0987654321"] }.to_json } |
252 | 251 | let(:response_code) { 200 } |
253 | 252 |
|
254 | 253 | it 'returns a list of followers successfully without optional parameters' do |
| 254 | + response_body = { "user_ids" => ["U1234567890", "U0987654321"] }.to_json |
255 | 255 | stub_request(:get, "https://api.line.me/v2/bot/followers/ids") |
256 | 256 | .with( |
257 | 257 | headers: { |
|
265 | 265 | expect(status_code).to eq(200) |
266 | 266 | expect(body.user_ids).to eq(["U1234567890", "U0987654321"]) |
267 | 267 | end |
| 268 | + |
| 269 | + it 'query with only start' do |
| 270 | + response_body = { "user_ids" => ["U1234567890", "U0987654321"], "next" => "nExT Token" }.to_json |
| 271 | + stub_request(:get, "https://api.line.me/v2/bot/followers/ids?start=from%20previous%20NEXT") |
| 272 | + .with( |
| 273 | + headers: { |
| 274 | + 'Authorization' => "Bearer test-channel-access-token" |
| 275 | + } |
| 276 | + ) |
| 277 | + .to_return(status: response_code, body: response_body, headers: { 'Content-Type' => 'application/json' }) |
| 278 | + |
| 279 | + body, status_code, headers = client.get_followers_with_http_info(start: "from previous NEXT") |
| 280 | + |
| 281 | + expect(status_code).to eq(200) |
| 282 | + expect(body.user_ids).to eq(["U1234567890", "U0987654321"]) |
| 283 | + expect(body._next).to eq("nExT Token") |
| 284 | + end |
| 285 | + |
| 286 | + it 'query with limit and start' do |
| 287 | + response_body = { "user_ids" => ["U1234567890", "U0987654321"], "next" => "nExT Token" }.to_json |
| 288 | + stub_request(:get, "https://api.line.me/v2/bot/followers/ids?limit=10&start=from%20previous%20NEXT") |
| 289 | + .with( |
| 290 | + headers: { |
| 291 | + 'Authorization' => "Bearer test-channel-access-token" |
| 292 | + } |
| 293 | + ) |
| 294 | + .to_return(status: response_code, body: response_body, headers: { 'Content-Type' => 'application/json' }) |
| 295 | + |
| 296 | + body, status_code, headers = client.get_followers_with_http_info(start: "from previous NEXT", limit: 10) |
| 297 | + |
| 298 | + expect(status_code).to eq(200) |
| 299 | + expect(body.user_ids).to eq(["U1234567890", "U0987654321"]) |
| 300 | + expect(body._next).to eq("nExT Token") |
| 301 | + end |
268 | 302 | end |
269 | 303 |
|
270 | 304 | describe 'PUT /liff/v1/apps/{liffId}' do |
|
0 commit comments