quiz_api_client 4.13.3 → 4.14.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/http_client.rb +5 -2
- data/lib/quiz_api_client/services/quiz_clone_jobs_service.rb +11 -0
- data/lib/quiz_api_client/services/quiz_session_service.rb +7 -3
- data/lib/quiz_api_client/version.rb +1 -1
- data/spec/services/quiz_clone_jobs_service_spec.rb +37 -0
- data/spec/services/quiz_session_service_spec.rb +21 -0
- 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: 450aa47af30bde7b962ac76248bde2fa992b4168875f1e8847c48539813576e5
|
4
|
+
data.tar.gz: 73da155fb2da7763ec9a07f557250842e62bd38ddfe570418df8a7eeee7608aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd2bf29f5d1a2b3d512e8cb75b40479789138551d7fce2438e3a215158b423f174bb19bb5f854f48373f6ea685815ca73dfa0431cbde2e0839c8ae191aeff1f0
|
7
|
+
data.tar.gz: 3a95461f774db17ccb8ed636d6a552c3ea4c50291d648989d44d2f621434c196ef21468de4c8e81d0f3ccf215e6dff132dcd8cfd5c404bceba484316319062a7
|
@@ -138,7 +138,8 @@ module QuizApiClient
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def next_page_link(response, options)
|
141
|
-
return if response.headers['link'].
|
141
|
+
return if response.headers['link'].nil?
|
142
|
+
return if response.headers['link'].empty?
|
142
143
|
|
143
144
|
links = LinkHeader.parse(response.headers['link']).links
|
144
145
|
next_link = links.find { |link| link['rel'] == 'next' }
|
@@ -148,7 +149,9 @@ module QuizApiClient
|
|
148
149
|
def next_page_dynamo(response, url, options)
|
149
150
|
hash_key = response.headers['x-last-evaluated-hash-key']
|
150
151
|
range_key = response.headers['x-last-evaluated-range-key']
|
151
|
-
|
152
|
+
|
153
|
+
return if hash_key.nil? || hash_key.empty?
|
154
|
+
return if range_key.nil? || range_key.empty?
|
152
155
|
|
153
156
|
query = (options[:query] || {}).merge(
|
154
157
|
last_evaluated_hash_key: hash_key,
|
@@ -4,6 +4,10 @@ module QuizApiClient::Services
|
|
4
4
|
post_to_quiz_api(body: body, params: params, token: token)
|
5
5
|
end
|
6
6
|
|
7
|
+
def update(body: {}, params:, token: nil)
|
8
|
+
put_to_quiz_api(body: body, params: params, token: token)
|
9
|
+
end
|
10
|
+
|
7
11
|
def create_batch(body:, token: nil)
|
8
12
|
batch_post_to_quiz_api(body: body, token: token)
|
9
13
|
end
|
@@ -17,6 +21,13 @@ module QuizApiClient::Services
|
|
17
21
|
)
|
18
22
|
end
|
19
23
|
|
24
|
+
def put_to_quiz_api(body:, params:, token:)
|
25
|
+
client(token: token).put(
|
26
|
+
"/api/quiz_clone_jobs/#{params.fetch(:id)}",
|
27
|
+
body
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
20
31
|
def batch_post_to_quiz_api(body:, token:)
|
21
32
|
client(token: token).post(
|
22
33
|
'/api/quiz_clone_jobs/create_batch',
|
@@ -7,7 +7,10 @@ module QuizApiClient::Services
|
|
7
7
|
def show(params:, token: nil)
|
8
8
|
raise 'Quiz Session Id Required' unless params && params[:id]
|
9
9
|
|
10
|
-
|
10
|
+
access_code_params = {
|
11
|
+
disable_ac_invalidation: params.delete(:disable_ac_invalidation)
|
12
|
+
}.compact
|
13
|
+
get_from_quiz_api(params: params, token: token, access_code_params: access_code_params)
|
11
14
|
end
|
12
15
|
|
13
16
|
private
|
@@ -19,9 +22,10 @@ module QuizApiClient::Services
|
|
19
22
|
)
|
20
23
|
end
|
21
24
|
|
22
|
-
def get_from_quiz_api(params:, token:)
|
25
|
+
def get_from_quiz_api(params:, token:, access_code_params:)
|
23
26
|
client(token: token).get(
|
24
|
-
"/api/quiz_sessions/#{params[:id]}"
|
27
|
+
"/api/quiz_sessions/#{params[:id]}",
|
28
|
+
query: access_code_params
|
25
29
|
)
|
26
30
|
end
|
27
31
|
end
|
@@ -40,6 +40,43 @@ describe QuizApiClient::Services::QuizCloneJobsService do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
describe '#update' do
|
44
|
+
let(:body) { { resource_map_url: 'http://foo.bar/123' } }
|
45
|
+
let(:params) { { id: 1 } }
|
46
|
+
let(:expected_url) { "https://#{host}/api/quiz_clone_jobs/#{params.fetch(:id)}" }
|
47
|
+
let(:stubbed_response) { { 'id' => '1' } }
|
48
|
+
|
49
|
+
context 'on success' do
|
50
|
+
before do
|
51
|
+
stub_request(:put, expected_url)
|
52
|
+
.to_return(
|
53
|
+
status: 200,
|
54
|
+
body: stubbed_response.to_json,
|
55
|
+
headers: { 'Content-Type' => 'application/json' }
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'puts to /api/quiz_clone_jobs/:id' do
|
60
|
+
result = subject.update(body: body, params: params, token: 'token')
|
61
|
+
expect(result.parsed_response).to eql(stubbed_response)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'on failure' do
|
66
|
+
let(:status_code) { 401 }
|
67
|
+
|
68
|
+
before do
|
69
|
+
stub_request(:put, expected_url)
|
70
|
+
.to_return(status: status_code)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'returns a response with the correct code' do
|
74
|
+
response = subject.update(body: body, params: params, token: 'token')
|
75
|
+
expect(response.code).to eq(status_code)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
43
80
|
describe '#create_batch' do
|
44
81
|
let(:expected_url) { "https://#{host}/api/quiz_clone_jobs/create_batch" }
|
45
82
|
let(:body) { { quiz_ids: [1, 2] } }
|
@@ -45,5 +45,26 @@ describe QuizApiClient::Services::QuizSessionService do
|
|
45
45
|
response = subject.show(params: params, token: 'token')
|
46
46
|
expect(response.parsed_response).to eql(stubbed_response)
|
47
47
|
end
|
48
|
+
|
49
|
+
context 'when the query param "disable_ac_invalidation" is given' do
|
50
|
+
let(:params) { { id: 1, disable_ac_invalidation: true } }
|
51
|
+
let(:stubbed_response) { { 'id' => 1, 'time_limit_seconds' => 10 } }
|
52
|
+
let(:expected_url) { "https://#{host}/api/quiz_sessions/#{params[:id]}?disable_ac_invalidation=true" }
|
53
|
+
let(:status_code) { 200 }
|
54
|
+
|
55
|
+
before do
|
56
|
+
stub_request(:get, expected_url)
|
57
|
+
.to_return(
|
58
|
+
status: status_code,
|
59
|
+
body: stubbed_response.to_json,
|
60
|
+
headers: { 'Content-Type' => 'application/json' }
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'gets from quiz_api/api/quiz_sessions and returns the response' do
|
65
|
+
response = subject.show(params: params, token: 'token')
|
66
|
+
expect(response.parsed_response).to eql(stubbed_response)
|
67
|
+
end
|
68
|
+
end
|
48
69
|
end
|
49
70
|
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.14.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: 2023-
|
18
|
+
date: 2023-10-23 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: httparty
|