quiz_api_client 4.2.1 → 4.3.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/quiz_clone_jobs_service.rb +11 -0
- data/lib/quiz_api_client/services/quiz_sync_job_service.rb +17 -0
- data/lib/quiz_api_client/services/quiz_sync_jobs_service.rb +16 -0
- data/lib/quiz_api_client/version.rb +1 -1
- data/lib/quiz_api_client.rb +10 -0
- data/spec/contracts/quiz_sync_job_service_spec.rb +21 -0
- data/spec/contracts/quiz_sync_jobs_service_spec.rb +21 -0
- data/spec/contracts/shared_examples/http_post_example.rb +9 -1
- data/spec/services/quiz_clone_jobs_service_spec.rb +36 -0
- data/spec/services/quiz_sync_job_service_spec.rb +41 -0
- data/spec/services/quiz_sync_jobs_service_spec.rb +77 -0
- metadata +18 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11e55f74ad6fd90e5f09e214394d3d44103e7027d83ce03299f5670cbc79111d
|
4
|
+
data.tar.gz: 836308804ec45f08806c57bf63c6d7b9167e03eee52d955e7bca38b310f75305
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ed1d073d41458ff170b5767eec5d37e560af8211f6fa5da0906d7d644411a9a4e589c7d644b807300dd76400374e0e9bcd58d4595bd2e4004d65d228e4afb9f
|
7
|
+
data.tar.gz: 26d1ce56705ad6a1ba18c93175ae572e4ab54e95438513095c663c6a3d6efda3a57cce29ff432ac6885b5bf139305f954bab53890360b89945fdc0c48878b123
|
@@ -4,6 +4,10 @@ module QuizApiClient::Services
|
|
4
4
|
post_to_quiz_api(params: params, token: token)
|
5
5
|
end
|
6
6
|
|
7
|
+
def create_batch(body:, token: nil)
|
8
|
+
batch_post_to_quiz_api(body: body, token: token)
|
9
|
+
end
|
10
|
+
|
7
11
|
private
|
8
12
|
|
9
13
|
def post_to_quiz_api(params:, token:)
|
@@ -11,5 +15,12 @@ module QuizApiClient::Services
|
|
11
15
|
"/api/quizzes/#{params.fetch(:quiz_id)}/quiz_clone_jobs"
|
12
16
|
)
|
13
17
|
end
|
18
|
+
|
19
|
+
def batch_post_to_quiz_api(body:, token:)
|
20
|
+
client(token: token).post(
|
21
|
+
'/api/quiz_clone_jobs/create_batch',
|
22
|
+
body
|
23
|
+
)
|
24
|
+
end
|
14
25
|
end
|
15
26
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module QuizApiClient::Services
|
2
|
+
class QuizSyncJobService < BaseApiService
|
3
|
+
def show(params:, token: nil)
|
4
|
+
raise 'Quiz Sync Job Id Required' unless params && params[:id]
|
5
|
+
|
6
|
+
get_from_quiz_api(params: params, token: token)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def get_from_quiz_api(params:, token:)
|
12
|
+
client(token: token).get(
|
13
|
+
"/api/quiz_sync_jobs/#{params.fetch(:id)}"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module QuizApiClient::Services
|
2
|
+
class QuizSyncJobsService < BaseApiService
|
3
|
+
def create_batch(body:, token: nil)
|
4
|
+
batch_post_to_quiz_api(body: body, token: token)
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def batch_post_to_quiz_api(body:, token:)
|
10
|
+
client(token: token).post(
|
11
|
+
'/api/quiz_sync_jobs/create_batch',
|
12
|
+
body
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/quiz_api_client.rb
CHANGED
@@ -50,6 +50,14 @@ module QuizApiClient
|
|
50
50
|
@_quiz_clone_jobs_service ||= Services::QuizCloneJobsService.new(config)
|
51
51
|
end
|
52
52
|
|
53
|
+
def quiz_sync_job_service
|
54
|
+
@_quiz_sync_job_service ||= Services::QuizSyncJobService.new(config)
|
55
|
+
end
|
56
|
+
|
57
|
+
def quiz_sync_jobs_service
|
58
|
+
@_quiz_sync_jobs_service ||= Services::QuizSyncJobsService.new(config)
|
59
|
+
end
|
60
|
+
|
53
61
|
def qti_imports_service
|
54
62
|
@_qti_imports_service ||= Services::QtiImportsService.new(config)
|
55
63
|
end
|
@@ -120,6 +128,8 @@ require 'quiz_api_client/services/quizzes_service'
|
|
120
128
|
require 'quiz_api_client/services/quiz_session_result_service'
|
121
129
|
require 'quiz_api_client/services/quiz_clone_job_service'
|
122
130
|
require 'quiz_api_client/services/quiz_clone_jobs_service'
|
131
|
+
require 'quiz_api_client/services/quiz_sync_job_service'
|
132
|
+
require 'quiz_api_client/services/quiz_sync_jobs_service'
|
123
133
|
require 'quiz_api_client/services/session_items_service'
|
124
134
|
require 'quiz_api_client/services/session_item_results_service'
|
125
135
|
require 'quiz_api_client/services/shared_banks'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
describe QuizApiClient::Services::QuizSyncJobService, :pact do
|
2
|
+
include PactHelper
|
3
|
+
|
4
|
+
it_behaves_like 'a http get request to quiz_api' do
|
5
|
+
let(:request_description) { 'a request to retrieve a quiz sync job' }
|
6
|
+
let(:quizzes_api_path) { "/api/quiz_sync_jobs/#{resource_id}" }
|
7
|
+
let(:provider_state) { 'a quiz sync job' }
|
8
|
+
let(:scope) { 'quiz_sync_job.show' }
|
9
|
+
let(:params) { { id: resource_id } }
|
10
|
+
let(:resource_id) { '1' }
|
11
|
+
let(:response_body) do
|
12
|
+
{
|
13
|
+
id: Pact.like('1'),
|
14
|
+
original_quiz_id: Pact.like('1'),
|
15
|
+
cloned_quiz_id: Pact.like('2'),
|
16
|
+
status: Pact.like('scheduled')
|
17
|
+
}
|
18
|
+
end
|
19
|
+
let(:service_name) { :quiz_sync_job_service }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
describe QuizApiClient::Services::QuizSyncJobsService, :pact do
|
2
|
+
include PactHelper
|
3
|
+
|
4
|
+
it_behaves_like 'a http post request to quiz_api' do
|
5
|
+
let(:batch) { true }
|
6
|
+
let(:request_description) { 'a request to sync many quizzes' }
|
7
|
+
let(:quizzes_api_path) { '/api/quiz_sync_jobs/create_batch' }
|
8
|
+
let(:provider_state) { 'a completed quiz clone job' }
|
9
|
+
let(:scope) { 'quiz_sync_job.create_batch' }
|
10
|
+
let(:params) { { quiz_ids: ['1'] } }
|
11
|
+
let(:body) { { quiz_ids: ['1'] } }
|
12
|
+
let(:response_body) do
|
13
|
+
[
|
14
|
+
{
|
15
|
+
id: Pact.like('1')
|
16
|
+
}
|
17
|
+
]
|
18
|
+
end
|
19
|
+
let(:service_name) { :quiz_sync_jobs_service }
|
20
|
+
end
|
21
|
+
end
|
@@ -14,6 +14,7 @@ shared_examples 'a http post request to quiz_api' do
|
|
14
14
|
let(:params) { raise 'Override in spec' }
|
15
15
|
let(:body) { raise 'Override in spec' }
|
16
16
|
let(:request_description) { raise 'Override in spec (must be unique!)' }
|
17
|
+
let(:batch) { false }
|
17
18
|
|
18
19
|
let(:client) do
|
19
20
|
QuizApiClient::Client.new(
|
@@ -53,7 +54,14 @@ shared_examples 'a http post request to quiz_api' do
|
|
53
54
|
end
|
54
55
|
|
55
56
|
it 'verifies the request is valid' do
|
56
|
-
|
57
|
+
service = client.send(service_name)
|
58
|
+
|
59
|
+
result = if batch
|
60
|
+
service.create_batch(token: token, body: params)
|
61
|
+
else
|
62
|
+
service.create(token: token, params: params)
|
63
|
+
end
|
64
|
+
|
57
65
|
expect(result).to be_truthy
|
58
66
|
end
|
59
67
|
end
|
@@ -38,4 +38,40 @@ describe QuizApiClient::Services::QuizCloneJobsService do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
describe '#create_batch' do
|
43
|
+
let(:expected_url) { "https://#{host}/api/quiz_clone_jobs/create_batch" }
|
44
|
+
let(:body) { { quiz_ids: [1, 2] } }
|
45
|
+
let(:stubbed_response) { { 'id' => '1' } }
|
46
|
+
|
47
|
+
context 'on success' do
|
48
|
+
before do
|
49
|
+
stub_request(:post, expected_url)
|
50
|
+
.to_return(
|
51
|
+
status: 200,
|
52
|
+
body: stubbed_response.to_json,
|
53
|
+
headers: { 'Content-Type' => 'application/json' }
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'posts to /api/quiz_clone_jobs/create_batch' do
|
58
|
+
result = subject.create_batch(body: body, token: 'token')
|
59
|
+
expect(result.parsed_response).to eql(stubbed_response)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'on failure' do
|
64
|
+
let(:status_code) { 401 }
|
65
|
+
|
66
|
+
before do
|
67
|
+
stub_request(:post, expected_url)
|
68
|
+
.to_return(status: status_code)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns a response with the correct code' do
|
72
|
+
response = subject.create_batch(body: body, token: 'token')
|
73
|
+
expect(response.code).to eq(status_code)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
41
77
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
describe QuizApiClient::Services::QuizSyncJobService do
|
2
|
+
let(:host) { 'api.host' }
|
3
|
+
let(:config) { QuizApiClient::Config.new { |c| c.host = host } }
|
4
|
+
let(:subject) { described_class.new(config) }
|
5
|
+
|
6
|
+
describe '#show' do
|
7
|
+
let(:expected_url) { "https://#{host}/api/quiz_sync_jobs/#{params[:id]}" }
|
8
|
+
let(:params) { { id: 1 } }
|
9
|
+
let(:stubbed_response) { { 'id' => 1, 'original_quiz_id' => 666, 'status' => 'completed' } }
|
10
|
+
|
11
|
+
context 'on success' do
|
12
|
+
before do
|
13
|
+
stub_request(:get, expected_url)
|
14
|
+
.to_return(
|
15
|
+
status: 200,
|
16
|
+
body: stubbed_response.to_json,
|
17
|
+
headers: { 'Content-Type' => 'application/json' }
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'gets from /api/quiz_sync_jobs/:id' do
|
22
|
+
result = subject.show(params: params, token: 'token')
|
23
|
+
expect(result.parsed_response).to eql(stubbed_response)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'on failure' do
|
28
|
+
let(:status_code) { 401 }
|
29
|
+
|
30
|
+
before do
|
31
|
+
stub_request(:get, expected_url)
|
32
|
+
.to_return(status: status_code)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns a response with the correct code' do
|
36
|
+
response = subject.show(params: params, token: 'token')
|
37
|
+
expect(response.code).to eq(status_code)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
describe QuizApiClient::Services::QuizCloneJobsService do
|
2
|
+
let(:host) { 'api.host' }
|
3
|
+
let(:config) { QuizApiClient::Config.new { |c| c.host = host } }
|
4
|
+
let(:subject) { described_class.new(config) }
|
5
|
+
|
6
|
+
describe '#create' do
|
7
|
+
let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/quiz_clone_jobs" }
|
8
|
+
let(:params) { { quiz_id: 1 } }
|
9
|
+
let(:stubbed_response) { { 'id' => '1' } }
|
10
|
+
|
11
|
+
context 'on success' do
|
12
|
+
before do
|
13
|
+
stub_request(:post, expected_url)
|
14
|
+
.to_return(
|
15
|
+
status: 200,
|
16
|
+
body: stubbed_response.to_json,
|
17
|
+
headers: { 'Content-Type' => 'application/json' }
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'posts to /api/quizzes/:quiz_id/quiz_clone_job' do
|
22
|
+
result = subject.create(params: params, token: 'token')
|
23
|
+
expect(result.parsed_response).to eql(stubbed_response)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'on failure' do
|
28
|
+
let(:status_code) { 401 }
|
29
|
+
|
30
|
+
before do
|
31
|
+
stub_request(:post, expected_url)
|
32
|
+
.to_return(status: status_code)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns a response with the correct code' do
|
36
|
+
response = subject.create(params: params, token: 'token')
|
37
|
+
expect(response.code).to eq(status_code)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#create_batch' do
|
43
|
+
let(:expected_url) { "https://#{host}/api/quiz_clone_jobs/create_batch" }
|
44
|
+
let(:body) { { quiz_ids: [1, 2] } }
|
45
|
+
let(:stubbed_response) { { 'id' => '1' } }
|
46
|
+
|
47
|
+
context 'on success' do
|
48
|
+
before do
|
49
|
+
stub_request(:post, expected_url)
|
50
|
+
.to_return(
|
51
|
+
status: 200,
|
52
|
+
body: stubbed_response.to_json,
|
53
|
+
headers: { 'Content-Type' => 'application/json' }
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'posts to /api/quiz_clone_jobs/create_batch' do
|
58
|
+
result = subject.create_batch(body: body, token: 'token')
|
59
|
+
expect(result.parsed_response).to eql(stubbed_response)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'on failure' do
|
64
|
+
let(:status_code) { 401 }
|
65
|
+
|
66
|
+
before do
|
67
|
+
stub_request(:post, expected_url)
|
68
|
+
.to_return(status: status_code)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns a response with the correct code' do
|
72
|
+
response = subject.create_batch(body: body, token: 'token')
|
73
|
+
expect(response.code).to eq(status_code)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Slaughter
|
@@ -11,10 +11,10 @@ authors:
|
|
11
11
|
- Michael Hargiss
|
12
12
|
- Robin Kuss
|
13
13
|
- Ryan Taylor
|
14
|
-
autorequire:
|
14
|
+
autorequire:
|
15
15
|
bindir: exe
|
16
16
|
cert_chain: []
|
17
|
-
date: 2022-
|
17
|
+
date: 2022-06-17 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: httparty
|
@@ -184,7 +184,7 @@ dependencies:
|
|
184
184
|
- - ">="
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
|
-
description:
|
187
|
+
description:
|
188
188
|
email:
|
189
189
|
- aslaughter@instructure.com
|
190
190
|
- jhiggins@instructure.com
|
@@ -220,6 +220,8 @@ files:
|
|
220
220
|
- lib/quiz_api_client/services/quiz_session_result_service.rb
|
221
221
|
- lib/quiz_api_client/services/quiz_session_service.rb
|
222
222
|
- lib/quiz_api_client/services/quiz_sessions_service.rb
|
223
|
+
- lib/quiz_api_client/services/quiz_sync_job_service.rb
|
224
|
+
- lib/quiz_api_client/services/quiz_sync_jobs_service.rb
|
223
225
|
- lib/quiz_api_client/services/quizzes_service.rb
|
224
226
|
- lib/quiz_api_client/services/session_item_results_service.rb
|
225
227
|
- lib/quiz_api_client/services/session_items_service.rb
|
@@ -238,6 +240,8 @@ files:
|
|
238
240
|
- spec/contracts/quiz_session_result_service_spec.rb
|
239
241
|
- spec/contracts/quiz_session_service_spec.rb
|
240
242
|
- spec/contracts/quiz_sessions_service_spec.rb
|
243
|
+
- spec/contracts/quiz_sync_job_service_spec.rb
|
244
|
+
- spec/contracts/quiz_sync_jobs_service_spec.rb
|
241
245
|
- spec/contracts/quizzes_service_spec.rb
|
242
246
|
- spec/contracts/session_item_results_service_spec.rb
|
243
247
|
- spec/contracts/session_items_service_spec.rb
|
@@ -267,16 +271,18 @@ files:
|
|
267
271
|
- spec/services/quiz_session_result_service_spec.rb
|
268
272
|
- spec/services/quiz_session_service_spec.rb
|
269
273
|
- spec/services/quiz_sessions_service_spec.rb
|
274
|
+
- spec/services/quiz_sync_job_service_spec.rb
|
275
|
+
- spec/services/quiz_sync_jobs_service_spec.rb
|
270
276
|
- spec/services/quizzes_service_spec.rb
|
271
277
|
- spec/services/session_item_results_service_spec.rb
|
272
278
|
- spec/services/session_items_service_spec.rb
|
273
279
|
- spec/spec_helper.rb
|
274
280
|
- spec/support/pact_config.rb
|
275
281
|
- spec/support/pact_helper.rb
|
276
|
-
homepage:
|
282
|
+
homepage:
|
277
283
|
licenses: []
|
278
284
|
metadata: {}
|
279
|
-
post_install_message:
|
285
|
+
post_install_message:
|
280
286
|
rdoc_options: []
|
281
287
|
require_paths:
|
282
288
|
- lib
|
@@ -291,8 +297,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
297
|
- !ruby/object:Gem::Version
|
292
298
|
version: '0'
|
293
299
|
requirements: []
|
294
|
-
rubygems_version: 3.1.
|
295
|
-
signing_key:
|
300
|
+
rubygems_version: 3.1.4
|
301
|
+
signing_key:
|
296
302
|
specification_version: 4
|
297
303
|
summary: Ruby client for quiz_api
|
298
304
|
test_files:
|
@@ -309,6 +315,8 @@ test_files:
|
|
309
315
|
- spec/contracts/quiz_session_result_service_spec.rb
|
310
316
|
- spec/contracts/quiz_session_service_spec.rb
|
311
317
|
- spec/contracts/quiz_sessions_service_spec.rb
|
318
|
+
- spec/contracts/quiz_sync_job_service_spec.rb
|
319
|
+
- spec/contracts/quiz_sync_jobs_service_spec.rb
|
312
320
|
- spec/contracts/quizzes_service_spec.rb
|
313
321
|
- spec/contracts/session_item_results_service_spec.rb
|
314
322
|
- spec/contracts/session_items_service_spec.rb
|
@@ -338,6 +346,8 @@ test_files:
|
|
338
346
|
- spec/services/quiz_session_result_service_spec.rb
|
339
347
|
- spec/services/quiz_session_service_spec.rb
|
340
348
|
- spec/services/quiz_sessions_service_spec.rb
|
349
|
+
- spec/services/quiz_sync_job_service_spec.rb
|
350
|
+
- spec/services/quiz_sync_jobs_service_spec.rb
|
341
351
|
- spec/services/quizzes_service_spec.rb
|
342
352
|
- spec/services/session_item_results_service_spec.rb
|
343
353
|
- spec/services/session_items_service_spec.rb
|