quiz_api_client 4.7.0 → 4.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75b8beea94a5e16f60fd8f37f34e952b6fe7964178561e1d6e93a0c0a8fa7f93
4
- data.tar.gz: 43eaa7a546489ceaa98c9765357f70bdadb64da7348dfc6bdc7599da42b7ab43
3
+ metadata.gz: 7106b8bf0d1cc91d986ed54ea8b81d597813b2885d62dbde152aa4a6c55e0f42
4
+ data.tar.gz: 2bcb83542296f0f8aaf4e861e726bc7e82162b79207c8be6aaf16e0be70e95fb
5
5
  SHA512:
6
- metadata.gz: ffd1d5bb30fb3136429a3031aa847aa0fe9dd58c38a071f00c88e90ee37c8f56a0870cfc9cfb209fc8b1c24b6525cd38f57a891c922473b816305d62a64e3185
7
- data.tar.gz: 369fb4ddd2ebf9151d86637d6b2991e82e926fb0b9952854f86be2623c362361154e80e355c615717ab25e3b360a25442e3ada1253074f1e57f9eba8867567c7
6
+ metadata.gz: 16fb4f39928faeb5b0d5ead2511bee4c1720b6d29aecd898afe1d6406196b8aa28c3e8375d022c279318eee7bca38ee6b20dbda5ce89153bda46185187023502
7
+ data.tar.gz: 3387a506254fd75537e1925419f0cc4a793accb5946a281e7539f5cf0dd5af5ded63c1ad03c7579c71abbdf7508f7e070974598e6db161b2d30f20025136b5f1
@@ -0,0 +1,16 @@
1
+ module QuizApiClient::Services
2
+ class ContentExportsService < BaseApiService
3
+ def create(params:, token: nil)
4
+ post_to_quiz_api(params: params, token: token)
5
+ end
6
+
7
+ private
8
+
9
+ def post_to_quiz_api(params:, token:)
10
+ client(token: token).post(
11
+ '/api/content_exports',
12
+ content_export: params
13
+ )
14
+ end
15
+ end
16
+ end
@@ -23,7 +23,8 @@ module QuizApiClient::Services
23
23
  def list(params:, token: nil, all: false)
24
24
  raise 'Quiz Id Required' unless params && params[:id]
25
25
 
26
- get_from_quiz_api(params: params, token: token, all: all)
26
+ pagination_params = { page: params.delete(:page), per_page: params.delete(:per_page) }
27
+ get_from_quiz_api(params: params, token: token, pagination_params: pagination_params, all: all)
27
28
  end
28
29
 
29
30
  def destroy(params:, token: nil)
@@ -55,9 +56,10 @@ module QuizApiClient::Services
55
56
  )
56
57
  end
57
58
 
58
- def get_from_quiz_api(params:, token:, all:)
59
+ def get_from_quiz_api(params:, token:, pagination_params:, all:)
59
60
  client(token: token).get(
60
61
  "/api/quizzes/#{params[:id]}/quiz_entries",
62
+ query: pagination_params,
61
63
  all: all
62
64
  )
63
65
  end
@@ -1,3 +1,3 @@
1
1
  module QuizApiClient
2
- VERSION = '4.7.0'.freeze
2
+ VERSION = '4.8.1'.freeze
3
3
  end
@@ -22,6 +22,10 @@ module QuizApiClient
22
22
  @_config ||= QuizApiClient::Config.new
23
23
  end
24
24
 
25
+ def content_exports_service
26
+ @_content_exports_service ||= Services::ContentExportsService.new(config)
27
+ end
28
+
25
29
  def courses_service
26
30
  @_courses_service ||= Services::CoursesService.new(config)
27
31
  end
@@ -118,6 +122,7 @@ require 'quiz_api_client/http_request/metrics'
118
122
  require 'quiz_api_client/services/jwt_service'
119
123
  require 'quiz_api_client/services/base_api_service'
120
124
 
125
+ require 'quiz_api_client/services/content_exports_service'
121
126
  require 'quiz_api_client/services/courses_service'
122
127
  require 'quiz_api_client/services/interaction_types_service'
123
128
  require 'quiz_api_client/services/item_analyses_service'
@@ -51,6 +51,13 @@ describe QuizApiClient do
51
51
  end
52
52
  end
53
53
 
54
+ describe '#content_exports_service' do
55
+ it 'creates the service' do
56
+ expect(QuizApiClient::Services::ContentExportsService).to receive(:new).with(subject.config)
57
+ subject.content_exports_service
58
+ end
59
+ end
60
+
54
61
  describe '#courses_service' do
55
62
  it 'creates the service' do
56
63
  expect(QuizApiClient::Services::CoursesService).to receive(:new).with(subject.config)
@@ -0,0 +1,50 @@
1
+ describe QuizApiClient::Services::ContentExportsService 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_content_export_id: 1234,
10
+ export_settings: {
11
+ quizzes: [10, 11],
12
+ everything: false,
13
+ content_export_type: 'qti'
14
+ }
15
+ }
16
+ end
17
+
18
+ let(:response) do
19
+ {
20
+ 'id' => '1',
21
+ 'canvas_content_export_id' => '1234',
22
+ 'export_settings' => {
23
+ 'quizzes' => [10, 11],
24
+ 'everything' => false,
25
+ 'content_export_type' => 'qti'
26
+ },
27
+ 'created_at' => '2023-02-17T01:00:00.000Z',
28
+ 'updated_at' => '2023-02-17T01:00:00.000Z'
29
+ }
30
+ end
31
+
32
+ let(:expected_url) { "https://#{host}/api/content_exports" }
33
+
34
+ before do
35
+ stub_request(:post, expected_url)
36
+ .with(body: { content_export: params }.to_json)
37
+ .to_return(
38
+ status: 201,
39
+ body: response.to_json,
40
+ headers: { 'Content-Type' => 'application/json' }
41
+ )
42
+ end
43
+
44
+ it 'posts to the correct endpoint and returns the response' do
45
+ expect(
46
+ subject.create(params: params, token: 'token').parsed_response
47
+ ).to eq(response)
48
+ end
49
+ end
50
+ end
@@ -6,7 +6,7 @@ describe QuizApiClient::Services::QuizEntriesService do
6
6
  describe '#list' do
7
7
  let(:params) { { id: 1 } }
8
8
  let(:stubbed_response) { { 'id' => 1, 'entry' => { 'id' => 1 } } }
9
- let(:expected_url) { "https://#{host}/api/quizzes/#{params[:id]}/quiz_entries" }
9
+ let(:expected_url) { "https://#{host}/api/quizzes/#{params[:id]}/quiz_entries?page=&per_page=" }
10
10
  let(:status_code) { 200 }
11
11
 
12
12
  before do
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.7.0
4
+ version: 4.8.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-02-14 00:00:00.000000000 Z
18
+ date: 2023-03-06 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httparty
@@ -180,6 +180,7 @@ 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/base_api_service.rb
183
+ - lib/quiz_api_client/services/content_exports_service.rb
183
184
  - lib/quiz_api_client/services/courses_service.rb
184
185
  - lib/quiz_api_client/services/interaction_types_service.rb
185
186
  - lib/quiz_api_client/services/item_analyses_service.rb
@@ -209,6 +210,7 @@ files:
209
210
  - spec/quiz_api_client/http_request/metrics_spec.rb
210
211
  - spec/quiz_api_client_spec.rb
211
212
  - spec/services/base_api_service_spec.rb
213
+ - spec/services/content_exports_service_spec.rb
212
214
  - spec/services/courses_service_spec.rb
213
215
  - spec/services/interaction_types_service_spec.rb
214
216
  - spec/services/item_analyses_service_spec.rb
@@ -260,6 +262,7 @@ test_files:
260
262
  - spec/quiz_api_client/http_request/metrics_spec.rb
261
263
  - spec/quiz_api_client_spec.rb
262
264
  - spec/services/base_api_service_spec.rb
265
+ - spec/services/content_exports_service_spec.rb
263
266
  - spec/services/courses_service_spec.rb
264
267
  - spec/services/interaction_types_service_spec.rb
265
268
  - spec/services/item_analyses_service_spec.rb