quiz_api_client 4.27.0 → 4.28.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: 10ceea5a7b48cb12714e234faec4cdfc7bc1cf9f21534b3681dd5184869801d6
4
- data.tar.gz: 86aa04c57d79dfb8604b87632376643cc5a14063bcad654053fd9c47306d8b6b
3
+ metadata.gz: 46ae43ef7251183265800713aa817ab4a64dae2857ffefdb7cb41c2b0c382f55
4
+ data.tar.gz: 56c7f637f9ce24e5c1dcd413196ea0f22eb231730b1d136dc08376bd5f7ae94e
5
5
  SHA512:
6
- metadata.gz: fcd4be13012bc3eed170e292c2d11c63e58a79417fe94f1d81a10a9b665d382f66dd7aadf13ad1c1e0ed497b9499cf4b3b9713174243aed4b37879ba591506c8
7
- data.tar.gz: 59763294f14c72eba1c9acb0a1ac134592e687b4e7f65ba02164fe4dd1fcbd198c3d7a0850babff21e5367f4f0ad632835dcb4144a10c34b9429699a0391f461
6
+ metadata.gz: 51237cf5f7622748da9ff40d3ae9a4e3d713e1bc8215a14ed7f7965c1ce738c918f354b3986de0311900d228fc09b040b9b8d97c888f1724c946114f90003167
7
+ data.tar.gz: 4fb59568a7ad19f902d5362cea762cd02b6eebb2cee67bbb1f6ed397ebd2b500951a9eb8fc8a934cb88ec4f90d96201e1cd33acd2420c39990d867746d861ebd
@@ -15,7 +15,11 @@ module QuizApiClient::Services
15
15
  session: params[:quiz_session_id],
16
16
  result: params[:quiz_session_result_id]
17
17
  )
18
- client(token: token).get(path, all: all)
18
+ client(token: token).get(
19
+ path,
20
+ query: params.slice(:per_page, :last_evaluated_hash_key, :last_evaluated_range_key),
21
+ all: all
22
+ )
19
23
  end
20
24
  end
21
25
  end
@@ -11,6 +11,7 @@ module QuizApiClient::Services
11
11
  def get_from_quiz_api(params:, token:, all:)
12
12
  client(token: token).get(
13
13
  "/api/quiz_sessions/#{params[:quiz_session_id]}/session_items",
14
+ query: params.slice(:per_page, :last_evaluated_hash_key, :last_evaluated_range_key),
14
15
  all: all
15
16
  )
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module QuizApiClient
2
- VERSION = '4.27.0'.freeze
2
+ VERSION = '4.28.0'.freeze
3
3
  end
@@ -3,9 +3,8 @@ describe QuizApiClient::Services::SessionItemResultsService do
3
3
  let(:config) { QuizApiClient::Config.new { |c| c.host = host } }
4
4
  let(:subject) { described_class.new(config) }
5
5
 
6
- describe '#index' do
6
+ describe '#list' do
7
7
  let(:params) { { quiz_session_id: 1, quiz_session_result_id: 1 } }
8
- let(:stubbed_response) { { 'id' => '1_1', 'item' => { 'id' => '1' } } }
9
8
  let(:expected_url) do
10
9
  format(
11
10
  'https://%<host>s/api/quiz_sessions/%<session>d/results/%<result>d/session_item_results',
@@ -14,20 +13,28 @@ describe QuizApiClient::Services::SessionItemResultsService do
14
13
  result: params[:quiz_session_result_id]
15
14
  )
16
15
  end
17
- let(:status_code) { 200 }
18
16
 
19
- before do
20
- stub_request(:get, expected_url)
21
- .to_return(
22
- status: status_code,
23
- body: stubbed_response.to_json,
24
- headers: { 'Content-Type' => 'application/json' }
25
- )
26
- end
17
+ it 'reads a bounded page and resumes from its cursor' do
18
+ cursor = { last_evaluated_hash_key: 'result/account+', last_evaluated_range_key: '1_2' }
19
+ stub_request(:get, expected_url).with(query: { per_page: '1' }).to_return(
20
+ body: [{ 'item_id' => 1 }].to_json,
21
+ headers: {
22
+ 'Content-Type' => 'application/json',
23
+ 'X-Last-Evaluated-Hash-Key' => 'result/account+',
24
+ 'X-Last-Evaluated-Range-Key' => '1_2'
25
+ }
26
+ )
27
+ stub_request(:get, expected_url).with(query: { per_page: '1', **cursor }).to_return(
28
+ body: [{ 'item_id' => 2 }].to_json,
29
+ headers: { 'Content-Type' => 'application/json' }
30
+ )
31
+
32
+ first = subject.list(params: params.merge(per_page: 1), token: 'token')
33
+ expect(first.parsed_response).to eq([{ 'item_id' => 1 }])
34
+ expect(first.headers['x-last-evaluated-range-key']).to eq('1_2')
27
35
 
28
- it 'gets session_item_results and returns the response' do
29
- response = subject.list(params: params, token: 'token')
30
- expect(response.parsed_response).to eql(stubbed_response)
36
+ second = subject.list(params: params.merge(per_page: 1, **cursor, unrelated: 'ignored'), token: 'token')
37
+ expect(second.parsed_response).to eq([{ 'item_id' => 2 }])
31
38
  end
32
39
  end
33
40
  end
@@ -3,24 +3,31 @@ describe QuizApiClient::Services::SessionItemsService do
3
3
  let(:config) { QuizApiClient::Config.new { |c| c.host = host } }
4
4
  let(:subject) { described_class.new(config) }
5
5
 
6
- describe '#index' do
6
+ describe '#list' do
7
7
  let(:params) { { quiz_session_id: 1 } }
8
- let(:stubbed_response) { { 'id' => '1_1', 'item' => { 'id' => '1' } } }
9
8
  let(:expected_url) { "https://#{host}/api/quiz_sessions/#{params[:quiz_session_id]}/session_items" }
10
- let(:status_code) { 200 }
11
9
 
12
- before do
13
- stub_request(:get, expected_url)
14
- .to_return(
15
- status: status_code,
16
- body: stubbed_response.to_json,
17
- headers: { 'Content-Type' => 'application/json' }
18
- )
19
- end
10
+ it 'reads a bounded page and resumes from its cursor' do
11
+ cursor = { last_evaluated_hash_key: 'session/account+', last_evaluated_range_key: '1' }
12
+ stub_request(:get, expected_url).with(query: { per_page: '1' }).to_return(
13
+ body: [{ 'position' => 1 }].to_json,
14
+ headers: {
15
+ 'Content-Type' => 'application/json',
16
+ 'X-Last-Evaluated-Hash-Key' => 'session/account+',
17
+ 'X-Last-Evaluated-Range-Key' => '1'
18
+ }
19
+ )
20
+ stub_request(:get, expected_url).with(query: { per_page: '1', **cursor }).to_return(
21
+ body: [{ 'position' => 2 }].to_json,
22
+ headers: { 'Content-Type' => 'application/json' }
23
+ )
24
+
25
+ first = subject.list(params: params.merge(per_page: 1), token: 'token')
26
+ expect(first.parsed_response).to eq([{ 'position' => 1 }])
27
+ expect(first.headers['x-last-evaluated-range-key']).to eq('1')
20
28
 
21
- it 'gets from quiz_api/api/quiz_sessions/:id/session_items and returns the response' do
22
- result = subject.list(params: params, token: 'token')
23
- expect(result.parsed_response).to eql(stubbed_response)
29
+ second = subject.list(params: params.merge(per_page: 1, **cursor, unrelated: 'ignored'), token: 'token')
30
+ expect(second.parsed_response).to eq([{ 'position' => 2 }])
24
31
  end
25
32
  end
26
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quiz_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.27.0
4
+ version: 4.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Slaughter
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: exe
17
17
  cert_chain: []
18
- date: 2026-05-26 00:00:00.000000000 Z
18
+ date: 2026-11-13 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httparty