quiz_api_client 4.12.0 → 4.13.1

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: cf8ebb895e11ed001175aa646a27c6a9b8667f8a1a0caa787f58d2035de8b898
4
- data.tar.gz: 52a4fa85e3091c58e852b8c7e5f82b24f724e69793df3fdd449f0a2803df90ef
3
+ metadata.gz: 9ba12e6decb1a28b9587740a754e454a58c5345d28cf72632b267484bc82eab0
4
+ data.tar.gz: 7f7773f75f5f586abf61542bb32b013cba0c25e70feb498d709b6682b6f65f2a
5
5
  SHA512:
6
- metadata.gz: 775ff430f08c656af27901035b17ca44c0ba22a804ae533d97ef938cb78ff5bf774a98241d825a40e0501dfd45119853b187bf810142298ffc19fdba6d7afd2b
7
- data.tar.gz: 756a49f30f6bd9e020ad817206a6afaf6121599507fea8dc7399df4f680fe8cf0c0601b2f733356402a1b3978199bb11c97a482b0b1222b9bb87373f4ab128cc
6
+ metadata.gz: 3820e1479d10ed16e76f278a741b359334af9c494fd06d3d4db93f597f7209201a4a43b7492d7c90e5d84187e12f69ca56fb0deff1e404dac91bb95a15c5ef82
7
+ data.tar.gz: fdc87d815718c2a0585cbe1bcc50b93c9aadcf0b18e384ab0dd000f9e619e83e89a881b70db478732e1f44d949eabcfbb5f4b4b99d9de4e9462caa36b699b6ac
@@ -0,0 +1,20 @@
1
+ module QuizApiClient::Services
2
+ class BankEntriesService < BaseApiService
3
+ def list(params:, token: nil, all: false)
4
+ raise 'Bank Id Required' unless params && params[:id]
5
+
6
+ pagination_params = { page: params.delete(:page), per_page: params.delete(:per_page) }
7
+ get_from_quiz_api(params: params, token: token, pagination_params: pagination_params, all: all)
8
+ end
9
+
10
+ private
11
+
12
+ def get_from_quiz_api(params:, token:, pagination_params:, all:)
13
+ client(token: token).get(
14
+ "/api/internal_services/banks/#{params[:id]}/bank_entries",
15
+ query: pagination_params,
16
+ all: all
17
+ )
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ module QuizApiClient::Services
2
+ class BankService < BaseApiService
3
+ def show(params:, token: nil)
4
+ get_from_quiz_api(params: params, token: token)
5
+ end
6
+
7
+ private
8
+
9
+ def get_from_quiz_api(params:, token:)
10
+ client(token: token).get(
11
+ "/api/internal_services/banks/#{params[:id]}"
12
+ )
13
+ end
14
+ end
15
+ end
@@ -26,6 +26,13 @@ module QuizApiClient::Services
26
26
  )
27
27
  end
28
28
 
29
+ def associate_courses(params:, token: nil)
30
+ client(token: token).patch(
31
+ "/api/courses/#{params[:canvas_id]}/associate_courses",
32
+ course_canvas_ids: params[:course_canvas_ids]
33
+ )
34
+ end
35
+
29
36
  private
30
37
 
31
38
  def post_to_quiz_api(params:, token:)
@@ -1,3 +1,3 @@
1
1
  module QuizApiClient
2
- VERSION = '4.12.0'.freeze
2
+ VERSION = '4.13.1'.freeze
3
3
  end
@@ -18,6 +18,14 @@ module QuizApiClient
18
18
  yield(config) if block_given?
19
19
  end
20
20
 
21
+ def bank_service
22
+ @_bank_service ||= Services::BankService.new(config)
23
+ end
24
+
25
+ def bank_entries_service
26
+ @_bank_entries_service ||= Services::BankEntriesService.new(config)
27
+ end
28
+
21
29
  def config
22
30
  @_config ||= QuizApiClient::Config.new
23
31
  end
@@ -126,6 +134,8 @@ require 'quiz_api_client/http_request/metrics'
126
134
  require 'quiz_api_client/services/jwt_service'
127
135
  require 'quiz_api_client/services/base_api_service'
128
136
 
137
+ require 'quiz_api_client/services/bank_service'
138
+ require 'quiz_api_client/services/bank_entries_service'
129
139
  require 'quiz_api_client/services/content_exports_service'
130
140
  require 'quiz_api_client/services/courses_service'
131
141
  require 'quiz_api_client/services/interaction_types_service'
@@ -128,6 +128,34 @@ describe QuizApiClient do
128
128
  end
129
129
  end
130
130
 
131
+ describe '#quiz_service' do
132
+ it 'should create the service' do
133
+ expect(QuizApiClient::Services::QuizService).to receive(:new).with(subject.config)
134
+ subject.quiz_service
135
+ end
136
+ end
137
+
138
+ describe '#quiz_entries_service' do
139
+ it 'should create the service' do
140
+ expect(QuizApiClient::Services::QuizEntriesService).to receive(:new).with(subject.config)
141
+ subject.quiz_entries_service
142
+ end
143
+ end
144
+
145
+ describe '#bank_service' do
146
+ it 'should create the service' do
147
+ expect(QuizApiClient::Services::BankService).to receive(:new).with(subject.config)
148
+ subject.bank_service
149
+ end
150
+ end
151
+
152
+ describe '#bank_entries_service' do
153
+ it 'should create the service' do
154
+ expect(QuizApiClient::Services::BankEntriesService).to receive(:new).with(subject.config)
155
+ subject.bank_entries_service
156
+ end
157
+ end
158
+
131
159
  describe '#interaction_types_service' do
132
160
  it 'should create the service' do
133
161
  expect(QuizApiClient::Services::InteractionTypesService).to receive(:new).with(subject.config)
@@ -0,0 +1,26 @@
1
+ describe QuizApiClient::Services::BankEntriesService 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 '#list' do
7
+ let(:params) { { id: 1 } }
8
+ let(:stubbed_response) { { 'id' => 1, 'entry' => { 'id' => 1 } } }
9
+ let(:expected_url) { "https://#{host}/api/internal_services/banks/#{params[:id]}/bank_entries?page=&per_page=" }
10
+ let(:status_code) { 200 }
11
+
12
+ before do
13
+ stub_request(:get, expected_url)
14
+ .to_return(
15
+ status: status_code,
16
+ body: stubbed_response.to_json,
17
+ headers: { 'Content-Type' => 'application/json' }
18
+ )
19
+ end
20
+
21
+ it 'gets from quiz_api/api/banks/{id}/bank_entries and returns the response' do
22
+ result = subject.list(params: params, token: 'token')
23
+ expect(result.parsed_response).to eql(stubbed_response)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ describe QuizApiClient::Services::BankService 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(:params) { { id: 1 } }
8
+ let(:stubbed_response) { { 'id' => 1, 'title' => 'some title' } }
9
+ let(:expected_url) { "https://#{host}/api/internal_services/banks/#{params[:id]}" }
10
+ let(:status_code) { 200 }
11
+
12
+ before do
13
+ stub_request(:get, expected_url)
14
+ .to_return(
15
+ status: status_code,
16
+ body: stubbed_response.to_json,
17
+ headers: { 'Content-Type' => 'application/json' }
18
+ )
19
+ end
20
+
21
+ it 'gets from quiz_api/api/banks and returns the response' do
22
+ result = subject.show(params: params, token: 'token')
23
+ expect(result.parsed_response).to eql(stubbed_response)
24
+ end
25
+ end
26
+ end
@@ -174,4 +174,39 @@ describe QuizApiClient::Services::CoursesService do
174
174
  ).to eq(response)
175
175
  end
176
176
  end
177
+
178
+ describe '#associate_courses' do
179
+ let(:params) { { canvas_id: 1, course_canvas_ids: [2, 3, 4] } }
180
+ let(:response) do
181
+ {
182
+ 'course' => {
183
+ 'id' => '4',
184
+ 'title' => 'foo',
185
+ 'canvas_id' => '2',
186
+ 'is_blueprint' => true,
187
+ 'created_at' => '2022-06-22T18:59:27.577Z',
188
+ 'updated_at' => '2022-06-22T18:59:27.577Z'
189
+ },
190
+ 'courses_synced' => params[:course_canvas_ids]
191
+ }
192
+ end
193
+
194
+ let(:expected_url) { "https://#{host}/api/courses/1/associate_courses" }
195
+
196
+ before do
197
+ stub_request(:patch, expected_url)
198
+ .with(body: { course_canvas_ids: params[:course_canvas_ids] }.to_json)
199
+ .to_return(
200
+ status: 200,
201
+ body: response.to_json,
202
+ headers: { 'Content-Type' => 'application/json' }
203
+ )
204
+ end
205
+
206
+ it 'patches to the correct endpoint and returns the response' do
207
+ expect(
208
+ subject.associate_courses(params: params, token: 'token').parsed_response
209
+ ).to eq(response)
210
+ end
211
+ end
177
212
  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.12.0
4
+ version: 4.13.1
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-06-05 00:00:00.000000000 Z
18
+ date: 2023-08-23 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httparty
@@ -180,6 +180,8 @@ files:
180
180
  - lib/quiz_api_client/http_request/metrics.rb
181
181
  - lib/quiz_api_client/json_formatter.rb
182
182
  - lib/quiz_api_client/services/analyses_service.rb
183
+ - lib/quiz_api_client/services/bank_entries_service.rb
184
+ - lib/quiz_api_client/services/bank_service.rb
183
185
  - lib/quiz_api_client/services/base_api_service.rb
184
186
  - lib/quiz_api_client/services/content_exports_service.rb
185
187
  - lib/quiz_api_client/services/courses_service.rb
@@ -211,6 +213,8 @@ files:
211
213
  - spec/quiz_api_client/http_request/metrics_spec.rb
212
214
  - spec/quiz_api_client_spec.rb
213
215
  - spec/services/analyses_service_spec.rb
216
+ - spec/services/bank_entries_service_spec.rb
217
+ - spec/services/bank_service_spec.rb
214
218
  - spec/services/base_api_service_spec.rb
215
219
  - spec/services/content_exports_service_spec.rb
216
220
  - spec/services/courses_service_spec.rb
@@ -264,6 +268,8 @@ test_files:
264
268
  - spec/quiz_api_client/http_request/metrics_spec.rb
265
269
  - spec/quiz_api_client_spec.rb
266
270
  - spec/services/analyses_service_spec.rb
271
+ - spec/services/bank_entries_service_spec.rb
272
+ - spec/services/bank_service_spec.rb
267
273
  - spec/services/base_api_service_spec.rb
268
274
  - spec/services/content_exports_service_spec.rb
269
275
  - spec/services/courses_service_spec.rb