quiz_api_client 4.23.0 → 4.24.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7e14132240ede40616dabc2feac9400fe84262ba29cf2d2aacbdedddcded259
|
|
4
|
+
data.tar.gz: 745e10dfc3a5e4917ad9e0000a66022c31cd16fc4f8dfb7c386eb9a09846267d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d62d169bf07dad6adfcf0fbc43d850ebaf705cccd9db6bc848d74268501769b98a983fed9028e12d0dbffb67d9e0bcfa73d1f721c5a4f83220c4ee1d1323589
|
|
7
|
+
data.tar.gz: 2a4b338ae4b34b16fcfbe36b2e99ed13fec4b8ea9e08e636b830dec0215e9d01300973ded39e25907dcc7457c1961b33b265eb60f2b8adbb55aa000d32156791
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module QuizApiClient
|
|
4
|
+
module Services
|
|
5
|
+
class ContentMigrationJobService < BaseApiService
|
|
6
|
+
def create(params:, token: nil)
|
|
7
|
+
post_to_quiz_api(params: params, token: token)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def retry(params:, token: nil)
|
|
11
|
+
retry_on_quiz_api(params: params, token: token)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def show(params:, token: nil)
|
|
15
|
+
get_from_quiz_api(params: params, token: token)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def post_to_quiz_api(params:, token:)
|
|
21
|
+
client(token: token).post(
|
|
22
|
+
'/api/content_migration/jobs',
|
|
23
|
+
course: params
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def retry_on_quiz_api(params:, token:)
|
|
28
|
+
client(token: token).post(
|
|
29
|
+
'/api/content_migration/jobs/retry',
|
|
30
|
+
params
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get_from_quiz_api(params:, token:)
|
|
35
|
+
client(token: token).get(
|
|
36
|
+
"/api/content_migration/jobs/#{params[:external_content_migration_id]}"
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/quiz_api_client.rb
CHANGED
|
@@ -129,6 +129,10 @@ module QuizApiClient
|
|
|
129
129
|
def youtube_service
|
|
130
130
|
@_youtube_service ||= Services::YoutubeService.new(config)
|
|
131
131
|
end
|
|
132
|
+
|
|
133
|
+
def content_migration_job_service
|
|
134
|
+
@_content_migration_job_service ||= Services::ContentMigrationJobService.new(config)
|
|
135
|
+
end
|
|
132
136
|
end
|
|
133
137
|
end
|
|
134
138
|
|
|
@@ -168,3 +172,4 @@ require 'quiz_api_client/services/session_items_service'
|
|
|
168
172
|
require 'quiz_api_client/services/session_item_results_service'
|
|
169
173
|
require 'quiz_api_client/services/shared_banks'
|
|
170
174
|
require 'quiz_api_client/services/youtube_service'
|
|
175
|
+
require 'quiz_api_client/services/content_migration_job_service'
|
|
@@ -162,5 +162,12 @@ describe QuizApiClient do
|
|
|
162
162
|
subject.interaction_types_service
|
|
163
163
|
end
|
|
164
164
|
end
|
|
165
|
+
|
|
166
|
+
describe '#content_migration_job_service' do
|
|
167
|
+
it 'should create the service' do
|
|
168
|
+
expect(QuizApiClient::Services::ContentMigrationJobService).to receive(:new).with(subject.config)
|
|
169
|
+
subject.content_migration_job_service
|
|
170
|
+
end
|
|
171
|
+
end
|
|
165
172
|
end
|
|
166
173
|
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
describe QuizApiClient::Services::ContentMigrationJobService 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(:params) do
|
|
8
|
+
{
|
|
9
|
+
canvas_course_id: 123,
|
|
10
|
+
external_content_migration_id: 'abc-123',
|
|
11
|
+
settings: {
|
|
12
|
+
import_quizzes_next: true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
let(:expected_url) { "https://#{host}/api/content_migration/jobs" }
|
|
18
|
+
|
|
19
|
+
let(:stubbed_response) do
|
|
20
|
+
{
|
|
21
|
+
'id' => '1',
|
|
22
|
+
'external_content_migration_id' => 'abc-123',
|
|
23
|
+
'status' => 'queued',
|
|
24
|
+
'created_at' => '2024-01-01T00:00:00.000Z',
|
|
25
|
+
'updated_at' => '2024-01-01T00:00:00.000Z'
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
before do
|
|
30
|
+
stub_request(:post, expected_url)
|
|
31
|
+
.with(body: { course: params }.to_json)
|
|
32
|
+
.to_return(
|
|
33
|
+
status: 201,
|
|
34
|
+
body: stubbed_response.to_json,
|
|
35
|
+
headers: { 'Content-Type' => 'application/json' }
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'posts to the correct endpoint and returns the response' do
|
|
40
|
+
expect(
|
|
41
|
+
subject.create(params: params, token: 'token').parsed_response
|
|
42
|
+
).to eq(stubbed_response)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '#retry' do
|
|
47
|
+
let(:params) do
|
|
48
|
+
{
|
|
49
|
+
external_content_migration_id: 'abc-123'
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
let(:expected_url) { "https://#{host}/api/content_migration/jobs/retry" }
|
|
54
|
+
|
|
55
|
+
let(:stubbed_response) do
|
|
56
|
+
{
|
|
57
|
+
'id' => '1',
|
|
58
|
+
'external_content_migration_id' => 'abc-123',
|
|
59
|
+
'status' => 'queued',
|
|
60
|
+
'created_at' => '2024-01-01T00:00:00.000Z',
|
|
61
|
+
'updated_at' => '2024-01-01T00:00:00.000Z'
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
before do
|
|
66
|
+
stub_request(:post, expected_url)
|
|
67
|
+
.with(body: params.to_json)
|
|
68
|
+
.to_return(
|
|
69
|
+
status: 200,
|
|
70
|
+
body: stubbed_response.to_json,
|
|
71
|
+
headers: { 'Content-Type' => 'application/json' }
|
|
72
|
+
)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'posts to the correct endpoint and returns the response' do
|
|
76
|
+
expect(
|
|
77
|
+
subject.retry(params: params, token: 'token').parsed_response
|
|
78
|
+
).to eq(stubbed_response)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe '#show' do
|
|
83
|
+
let(:params) { { external_content_migration_id: 'abc-123' } }
|
|
84
|
+
let(:expected_url) { "https://#{host}/api/content_migration/jobs/#{params[:external_content_migration_id]}" }
|
|
85
|
+
let(:stubbed_response) do
|
|
86
|
+
{
|
|
87
|
+
'id' => '1',
|
|
88
|
+
'external_content_migration_id' => 'abc-123',
|
|
89
|
+
'status' => 'completed',
|
|
90
|
+
'created_at' => '2024-01-01T00:00:00.000Z',
|
|
91
|
+
'updated_at' => '2024-01-01T00:00:00.000Z'
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
context 'on success' do
|
|
96
|
+
before do
|
|
97
|
+
stub_request(:get, expected_url)
|
|
98
|
+
.to_return(
|
|
99
|
+
status: 200,
|
|
100
|
+
body: stubbed_response.to_json,
|
|
101
|
+
headers: { 'Content-Type' => 'application/json' }
|
|
102
|
+
)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'gets from /api/content_migration/jobs/:external_content_migration_id' do
|
|
106
|
+
result = subject.show(params: params, token: 'token')
|
|
107
|
+
expect(result.parsed_response).to eql(stubbed_response)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
context 'on failure' do
|
|
112
|
+
let(:status_code) { 401 }
|
|
113
|
+
|
|
114
|
+
before do
|
|
115
|
+
stub_request(:get, expected_url)
|
|
116
|
+
.to_return(status: status_code)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it 'returns a response with the correct code' do
|
|
120
|
+
response = subject.show(params: params, token: 'token')
|
|
121
|
+
expect(response.code).to eq(status_code)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
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.24.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: 2025-
|
|
18
|
+
date: 2025-12-02 00:00:00.000000000 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: httparty
|
|
@@ -186,6 +186,7 @@ files:
|
|
|
186
186
|
- lib/quiz_api_client/services/bank_service.rb
|
|
187
187
|
- lib/quiz_api_client/services/base_api_service.rb
|
|
188
188
|
- lib/quiz_api_client/services/content_exports_service.rb
|
|
189
|
+
- lib/quiz_api_client/services/content_migration_job_service.rb
|
|
189
190
|
- lib/quiz_api_client/services/courses_service.rb
|
|
190
191
|
- lib/quiz_api_client/services/interaction_types_service.rb
|
|
191
192
|
- lib/quiz_api_client/services/item_analyses_service.rb
|
|
@@ -221,6 +222,7 @@ files:
|
|
|
221
222
|
- spec/services/bank_service_spec.rb
|
|
222
223
|
- spec/services/base_api_service_spec.rb
|
|
223
224
|
- spec/services/content_exports_service_spec.rb
|
|
225
|
+
- spec/services/content_migration_job_service_spec.rb
|
|
224
226
|
- spec/services/courses_service_spec.rb
|
|
225
227
|
- spec/services/interaction_types_service_spec.rb
|
|
226
228
|
- spec/services/item_analyses_service_spec.rb
|
|
@@ -278,6 +280,7 @@ test_files:
|
|
|
278
280
|
- spec/services/bank_service_spec.rb
|
|
279
281
|
- spec/services/base_api_service_spec.rb
|
|
280
282
|
- spec/services/content_exports_service_spec.rb
|
|
283
|
+
- spec/services/content_migration_job_service_spec.rb
|
|
281
284
|
- spec/services/courses_service_spec.rb
|
|
282
285
|
- spec/services/interaction_types_service_spec.rb
|
|
283
286
|
- spec/services/item_analyses_service_spec.rb
|