quiz_api_client 4.20.0 → 4.22.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: 790a9d7b1622cf0d9d98e9eb3f62c1e481178223ee8e8f32f2461be744c2577a
4
- data.tar.gz: 36c83c014b77e91890c91e6f3081c38ef2d81965d274196dd5559eb9f644a556
3
+ metadata.gz: 0326a0567d52565a328e8baeef1121dd071fd3a6cc33d4f36a472d394c353382
4
+ data.tar.gz: d93ac7d560e617f2156ce313701826640791b78d5581f9c6a0298978d3281e67
5
5
  SHA512:
6
- metadata.gz: a0a74a8ea7236a4778eaeb13dd1d1e98d3f18d766260ca6151fbab889b7e036e3dc588282f587342fce1b2c867a690c8d6d091df8e2c04c117dcd164dd46d2d6
7
- data.tar.gz: c00de63348f7bf03c024ff5eb5f81d379139168a8e22faeedecacd7aa17692959a77a23e0ecefcc46c722ab0ce93a1ae0fd15536754a6ae0882dc746951d9d76
6
+ metadata.gz: 48d7c949f232d01e3cc6cd9a5408fd2ac921893154af5ea4ad244d0783d8950f966c0faab371a1d17f7a2265d64590b4061b18a33eaf3e3d4c2e98c8639e907a
7
+ data.tar.gz: 7aa68e7db93d0943492d7851b73a1f2b99c16d8cb7b7275bcbbc0001a956410bb45dc83a0e5e60c75c448169d57c9a186875e5044b7bde9ffaa13d18e2f04eec
@@ -15,26 +15,30 @@ module QuizApiClient::Services
15
15
  def show(params:, token: nil)
16
16
  client(token: token).get(
17
17
  "/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}",
18
- query: { filter: :last_attempt }
18
+ query: { filter: filter_value(params) }
19
19
  )
20
20
  end
21
21
 
22
22
  def export(params:, token: nil)
23
23
  client(token: token).get(
24
24
  "/api/quizzes/#{params[:quiz_id]}/analyses/export",
25
- query: { filter: :last_attempt, format: :csv, analysis_type: params[:analysis_type] }
25
+ query: { filter: filter_value(params), format: :csv, analysis_type: params[:analysis_type] }
26
26
  )
27
27
  end
28
28
 
29
29
  def status(params:, token: nil)
30
30
  client(token: token).get(
31
31
  "/api/quizzes/#{params[:quiz_id]}/analyses/status",
32
- query: { filter: :last_attempt, analysis_type: params[:analysis_type] }
32
+ query: { filter: filter_value(params), analysis_type: params[:analysis_type] }
33
33
  )
34
34
  end
35
35
 
36
36
  private
37
37
 
38
+ def filter_value(params)
39
+ params[:filter] || :last_attempt
40
+ end
41
+
38
42
  def post_to_create_report(params:, token:)
39
43
  path = "/api/quizzes/#{params[:quiz_id]}/analyses/create_report"
40
44
  post_to_quiz_api(path: path, params: params, token: token)
@@ -0,0 +1,14 @@
1
+ module QuizApiClient::Services
2
+ class YoutubeService < BaseApiService
3
+ def start_scan(params:, token: nil)
4
+ post_to_quiz_api(params: params, token: token)
5
+ end
6
+
7
+ def post_to_quiz_api(params:, token:)
8
+ client(token: token).post(
9
+ '/api/youtube/start_youtube_migration_scan',
10
+ params
11
+ )
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module QuizApiClient
2
- VERSION = '4.20.0'.freeze
2
+ VERSION = '4.22.0'.freeze
3
3
  end
@@ -125,6 +125,10 @@ module QuizApiClient
125
125
  def shared_banks
126
126
  @_shared_banks ||= QuizApiClient::Services::SharedBanks.new(config)
127
127
  end
128
+
129
+ def youtube_service
130
+ @_youtube_service ||= Services::YoutubeService.new(config)
131
+ end
128
132
  end
129
133
  end
130
134
 
@@ -163,3 +167,4 @@ require 'quiz_api_client/services/quiz_sync_jobs_service'
163
167
  require 'quiz_api_client/services/session_items_service'
164
168
  require 'quiz_api_client/services/session_item_results_service'
165
169
  require 'quiz_api_client/services/shared_banks'
170
+ require 'quiz_api_client/services/youtube_service'
@@ -58,81 +58,152 @@ describe QuizApiClient::Services::AnalysesService do
58
58
  end
59
59
 
60
60
  describe '#show' do
61
- let(:params) do
62
- { quiz_id: 1, id: 2 }
63
- end
61
+ let(:params) { { quiz_id: 1, id: 2 } }
64
62
  let(:stubbed_response) { { 'id' => 1 } }
65
- let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}?filter=last_attempt" }
66
63
  let(:status_code) { 200 }
67
64
 
68
- before do
69
- stub_request(:get, expected_url)
70
- .to_return(
71
- status: status_code,
72
- body: stubbed_response.to_json,
73
- headers: { 'Content-Type' => 'application/json' }
74
- )
65
+ context 'when filter is last_attempt' do
66
+ let(:expected_url) do
67
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}?filter=last_attempt"
68
+ end
69
+
70
+ before do
71
+ stub_request(:get, expected_url)
72
+ .to_return(
73
+ status: status_code,
74
+ body: stubbed_response.to_json,
75
+ headers: { 'Content-Type' => 'application/json' }
76
+ )
77
+ end
78
+
79
+ it 'returns the last_attempt report' do
80
+ result = subject.show(params: params.merge(filter: 'last_attempt'), token: 'token')
81
+ expect(result.parsed_response).to eql(stubbed_response)
82
+ end
75
83
  end
76
84
 
77
- it 'gets to quiz_api/api/quizzes/{id}/reports/{id} and returns the response' do
78
- result = subject.show(params: params, token: 'token')
79
- expect(result.parsed_response).to eql(stubbed_response)
85
+ context 'when filter is all_attempts' do
86
+ let(:expected_url) do
87
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/reports/#{params[:id]}?filter=all_attempts"
88
+ end
89
+
90
+ before do
91
+ stub_request(:get, expected_url)
92
+ .to_return(
93
+ status: status_code,
94
+ body: stubbed_response.to_json,
95
+ headers: { 'Content-Type' => 'application/json' }
96
+ )
97
+ end
98
+
99
+ it 'returns the all_attempts report' do
100
+ result = subject.show(params: params.merge(filter: 'all_attempts'), token: 'token')
101
+ expect(result.parsed_response).to eql(stubbed_response)
102
+ end
80
103
  end
81
104
  end
82
105
 
83
- describe 'status' do
84
- let(:params) do
85
- { quiz_id: 1, analysis_type: 'item_analysis' }
86
- end
106
+ describe '#status' do
107
+ let(:base_params) { { quiz_id: 1, analysis_type: 'item_analysis' } }
87
108
  let(:stubbed_response) { { 'id' => 1 } }
88
- let(:expected_url) do
89
- "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/status?filter=last_attempt" +
90
- + "&analysis_type=#{params[:analysis_type]}"
91
- end
92
109
  let(:status_code) { 200 }
93
110
 
94
- before do
95
- stub_request(:get, expected_url)
96
- .to_return(
97
- status: status_code,
98
- body: stubbed_response.to_json,
99
- headers: { 'Content-Type' => 'application/json' }
100
- )
111
+ context 'when filter is last_attempt' do
112
+ let(:params) { base_params.merge(filter: 'last_attempt') }
113
+ let(:expected_url) do
114
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/status" \
115
+ "?filter=#{params[:filter]}&analysis_type=#{params[:analysis_type]}"
116
+ end
117
+
118
+ before do
119
+ stub_request(:get, expected_url)
120
+ .to_return(
121
+ status: status_code,
122
+ body: stubbed_response.to_json,
123
+ headers: { 'Content-Type' => 'application/json' }
124
+ )
125
+ end
126
+
127
+ it 'returns the last_attempt analysis status' do
128
+ result = subject.status(params: params, token: 'token')
129
+ expect(result.parsed_response).to eql(stubbed_response)
130
+ end
101
131
  end
102
132
 
103
- it 'gets to quiz_api/api/quizzes/{id}/analyses/status and returns the response' do
104
- result = subject.status(params: params, token: 'token')
105
- expect(result.parsed_response).to eql(stubbed_response)
133
+ context 'when filter is all_attempts' do
134
+ let(:params) { base_params.merge(filter: 'all_attempts') }
135
+ let(:expected_url) do
136
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/status" \
137
+ "?filter=#{params[:filter]}&analysis_type=#{params[:analysis_type]}"
138
+ end
139
+
140
+ before do
141
+ stub_request(:get, expected_url)
142
+ .to_return(
143
+ status: status_code,
144
+ body: stubbed_response.to_json,
145
+ headers: { 'Content-Type' => 'application/json' }
146
+ )
147
+ end
148
+
149
+ it 'returns the all_attempts analysis status' do
150
+ result = subject.status(params: params, token: 'token')
151
+ expect(result.parsed_response).to eql(stubbed_response)
152
+ end
106
153
  end
107
154
  end
108
155
 
109
- describe 'export' do
110
- let(:params) do
111
- { quiz_id: 1, analysis_type: 'item_analysis' }
112
- end
156
+ describe '#export' do
157
+ let(:base_params) { { quiz_id: 1, analysis_type: 'item_analysis' } }
113
158
  let(:stubbed_response) do
114
159
  CSV.generate(headers: true) do |csv|
115
160
  csv << %w[column1 column2 column3]
116
161
  end
117
162
  end
118
- let(:expected_url) do
119
- "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/export" \
120
- "?analysis_type=#{params[:analysis_type]}&filter=last_attempt&format=csv"
121
- end
122
163
  let(:status_code) { 200 }
123
164
 
124
- before do
125
- stub_request(:get, expected_url)
126
- .to_return(
127
- status: status_code,
128
- body: stubbed_response,
129
- headers: { 'Content-Type' => 'text/csv' }
130
- )
165
+ context 'when filter is last_attempt' do
166
+ let(:params) { base_params.merge(filter: 'last_attempt') }
167
+ let(:expected_url) do
168
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/export" \
169
+ "?analysis_type=#{params[:analysis_type]}&filter=#{params[:filter]}&format=csv"
170
+ end
171
+
172
+ before do
173
+ stub_request(:get, expected_url)
174
+ .to_return(
175
+ status: status_code,
176
+ body: stubbed_response,
177
+ headers: { 'Content-Type' => 'text/csv' }
178
+ )
179
+ end
180
+
181
+ it 'returns the last_attempt CSV export' do
182
+ result = subject.export(params: params, token: 'token')
183
+ expect(result.parsed_response).to eql([%w[column1 column2 column3]])
184
+ end
131
185
  end
132
186
 
133
- it 'gets to quiz_api/api/quizzes/{id}/analyses/export and returns the response' do
134
- result = subject.export(params: params, token: 'token')
135
- expect(result.parsed_response).to eql([%w[column1 column2 column3]])
187
+ context 'when filter is all_attempts' do
188
+ let(:params) { base_params.merge(filter: 'all_attempts') }
189
+ let(:expected_url) do
190
+ "https://#{host}/api/quizzes/#{params[:quiz_id]}/analyses/export" \
191
+ "?analysis_type=#{params[:analysis_type]}&filter=#{params[:filter]}&format=csv"
192
+ end
193
+
194
+ before do
195
+ stub_request(:get, expected_url)
196
+ .to_return(
197
+ status: status_code,
198
+ body: stubbed_response,
199
+ headers: { 'Content-Type' => 'text/csv' }
200
+ )
201
+ end
202
+
203
+ it 'returns the all_attempts CSV export' do
204
+ result = subject.export(params: params, token: 'token')
205
+ expect(result.parsed_response).to eql([%w[column1 column2 column3]])
206
+ end
136
207
  end
137
208
  end
138
209
 
@@ -0,0 +1,33 @@
1
+ describe QuizApiClient::Services::YoutubeService do
2
+ let(:host) { 'api.host' }
3
+ let(:config) { QuizApiClient::Config.new { |c| c.host = host } }
4
+ let(:subject) { described_class.new(config) }
5
+ let(:stubbed_response) do
6
+ {
7
+ 'id' => 1,
8
+ 'scan_id' => 'abc-123',
9
+ 'status' => 'in_progress'
10
+ }
11
+ end
12
+
13
+ describe '#start_scan' do
14
+ let(:params) { { course_id: 42, scan_id: 'abc-123', quiz_assignment_map: { 123 => 456 } } }
15
+ let(:expected_url) { "https://#{host}/api/youtube/start_youtube_migration_scan" }
16
+
17
+ before do
18
+ stub_request(:post, expected_url)
19
+ .with(body: params.to_json)
20
+ .to_return(
21
+ status: 202,
22
+ body: stubbed_response.to_json,
23
+ headers: { 'Content-Type' => 'application/json' }
24
+ )
25
+ end
26
+
27
+ it 'posts to the correct endpoint and returns the response' do
28
+ expect(
29
+ subject.start_scan(params: params, token: 'token').parsed_response
30
+ ).to eq(stubbed_response)
31
+ end
32
+ end
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.20.0
4
+ version: 4.22.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-04-15 00:00:00.000000000 Z
18
+ date: 2025-09-12 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httparty
@@ -207,6 +207,7 @@ files:
207
207
  - lib/quiz_api_client/services/session_item_results_service.rb
208
208
  - lib/quiz_api_client/services/session_items_service.rb
209
209
  - lib/quiz_api_client/services/shared_banks.rb
210
+ - lib/quiz_api_client/services/youtube_service.rb
210
211
  - lib/quiz_api_client/version.rb
211
212
  - spec/config_spec.rb
212
213
  - spec/http_client_spec.rb
@@ -240,6 +241,7 @@ files:
240
241
  - spec/services/quizzes_service_spec.rb
241
242
  - spec/services/session_item_results_service_spec.rb
242
243
  - spec/services/session_items_service_spec.rb
244
+ - spec/services/youtube_service_spec.rb
243
245
  - spec/spec_helper.rb
244
246
  homepage:
245
247
  licenses: []
@@ -259,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
261
  - !ruby/object:Gem::Version
260
262
  version: '0'
261
263
  requirements: []
262
- rubygems_version: 3.4.10
264
+ rubygems_version: 3.5.22
263
265
  signing_key:
264
266
  specification_version: 4
265
267
  summary: Ruby client for quiz_api
@@ -296,4 +298,5 @@ test_files:
296
298
  - spec/services/quizzes_service_spec.rb
297
299
  - spec/services/session_item_results_service_spec.rb
298
300
  - spec/services/session_items_service_spec.rb
301
+ - spec/services/youtube_service_spec.rb
299
302
  - spec/spec_helper.rb