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 +4 -4
- data/lib/quiz_api_client/services/session_item_results_service.rb +5 -1
- data/lib/quiz_api_client/services/session_items_service.rb +1 -0
- data/lib/quiz_api_client/version.rb +1 -1
- data/spec/services/session_item_results_service_spec.rb +21 -14
- data/spec/services/session_items_service_spec.rb +21 -14
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46ae43ef7251183265800713aa817ab4a64dae2857ffefdb7cb41c2b0c382f55
|
|
4
|
+
data.tar.gz: 56c7f637f9ce24e5c1dcd413196ea0f22eb231730b1d136dc08376bd5f7ae94e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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(
|
|
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
|
|
@@ -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 '#
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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 '#
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
22
|
-
|
|
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.
|
|
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-
|
|
18
|
+
date: 2026-11-13 00:00:00.000000000 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: httparty
|