quiz_api_client 4.3.0 → 4.4.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/README.md +1 -1
- data/lib/quiz_api_client/services/courses_service.rb +26 -0
- data/lib/quiz_api_client/version.rb +1 -1
- data/lib/quiz_api_client.rb +5 -0
- data/spec/quiz_api_client_spec.rb +7 -0
- data/spec/services/courses_service_spec.rb +59 -0
- metadata +11 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6e1f12f936c33b3cf09fe4f8475aa40dfc7dbde37e65ed81b7d62ef07d23c86c
|
|
4
|
+
data.tar.gz: 9b4895c5dedd2d56fb64a79d2d03e5c6a8989832a9a51f912920fd71aa67582b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '009317d5880a188a2ba3ed14f1b937fc34b35f169ab819aaedfd57c09550b5a9acea19db12d6ca8591c13cd41b252e200d82022a236cfdd6f6271a682496ee38'
|
|
7
|
+
data.tar.gz: 5f8059807154051560b72466ad20452f4f42b771e528ed1a9235d3eca12e0e802af9ca7fe5434dcd740dd808908181357474659bd6c66af25d9ff0072d0ee949
|
data/README.md
CHANGED
|
@@ -199,7 +199,7 @@ Pact file to a local Pact Broker.
|
|
|
199
199
|
|
|
200
200
|
### Development Workflow:
|
|
201
201
|
|
|
202
|
-
1. In the quiz_api repo, spin up the Quiz API service with `bin/
|
|
202
|
+
1. In the quiz_api repo, spin up the Quiz API service with `bin/setup`
|
|
203
203
|
2. In the quiz_pact_broker repo, spin up a Pact Broker with `bin/dev-setup`
|
|
204
204
|
3. In the quiz_api repo, write Pact provider states in the
|
|
205
205
|
spec/service_consumers/api/quiz_api_client_ruby/ directory as needed
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module QuizApiClient::Services
|
|
2
|
+
class CoursesService < BaseApiService
|
|
3
|
+
def create(params:, token: nil)
|
|
4
|
+
post_to_quiz_api(params: params, token: token)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def destroy(params:, token: nil)
|
|
8
|
+
delete_from_quiz_api(params: params, token: token)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def post_to_quiz_api(params:, token:)
|
|
14
|
+
client(token: token).post(
|
|
15
|
+
'/api/courses',
|
|
16
|
+
course: params
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def delete_from_quiz_api(params:, token:)
|
|
21
|
+
client(token: token).delete(
|
|
22
|
+
"/api/courses/#{params[:canvas_id]}"
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
data/lib/quiz_api_client.rb
CHANGED
|
@@ -22,6 +22,10 @@ module QuizApiClient
|
|
|
22
22
|
@_config ||= QuizApiClient::Config.new
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
def courses_service
|
|
26
|
+
@_courses_service ||= Services::CoursesService.new(config)
|
|
27
|
+
end
|
|
28
|
+
|
|
25
29
|
def jwt_service
|
|
26
30
|
@_jwt_service ||= QuizApiClient::Services::JwtService.new(config)
|
|
27
31
|
end
|
|
@@ -114,6 +118,7 @@ require 'quiz_api_client/http_request/metrics'
|
|
|
114
118
|
require 'quiz_api_client/services/jwt_service'
|
|
115
119
|
require 'quiz_api_client/services/base_api_service'
|
|
116
120
|
|
|
121
|
+
require 'quiz_api_client/services/courses_service'
|
|
117
122
|
require 'quiz_api_client/services/interaction_types_service'
|
|
118
123
|
require 'quiz_api_client/services/item_analyses_service'
|
|
119
124
|
require 'quiz_api_client/services/items_service'
|
|
@@ -51,6 +51,13 @@ describe QuizApiClient do
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
+
describe '#courses_service' do
|
|
55
|
+
it 'creates the service' do
|
|
56
|
+
expect(QuizApiClient::Services::CoursesService).to receive(:new).with(subject.config)
|
|
57
|
+
subject.courses_service
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
54
61
|
describe '#quizzes_service' do
|
|
55
62
|
it 'should create the service' do
|
|
56
63
|
expect(QuizApiClient::Services::QuizzesService).to receive(:new).with(subject.config)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
describe QuizApiClient::Services::CoursesService 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
|
+
title: 'foo',
|
|
10
|
+
canvas_id: 2,
|
|
11
|
+
is_blueprint: true
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
let(:response) do
|
|
16
|
+
{
|
|
17
|
+
'id' => '4',
|
|
18
|
+
'title' => 'foo',
|
|
19
|
+
'canvas_id' => '2',
|
|
20
|
+
'is_blueprint' => true,
|
|
21
|
+
'created_at' => '2022-06-22T18:59:27.577Z',
|
|
22
|
+
'updated_at' => '2022-06-22T18:59:27.577Z'
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
let(:expected_url) { "https://#{host}/api/courses" }
|
|
27
|
+
|
|
28
|
+
before do
|
|
29
|
+
stub_request(:post, expected_url)
|
|
30
|
+
.with(body: { course: params }.to_json)
|
|
31
|
+
.to_return(
|
|
32
|
+
status: 201,
|
|
33
|
+
body: response.to_json,
|
|
34
|
+
headers: { 'Content-Type' => 'application/json' }
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'posts to the correct endpoint and returns the response' do
|
|
39
|
+
expect(
|
|
40
|
+
subject.create(params: params, token: 'token').parsed_response
|
|
41
|
+
).to eq(response)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe '#destroy' do
|
|
46
|
+
let(:params) { { canvas_id: 1 } }
|
|
47
|
+
let(:expected_url) { "https://#{host}/api/courses/1" }
|
|
48
|
+
|
|
49
|
+
before do
|
|
50
|
+
stub_request(:delete, expected_url).to_return(status: 204)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'deletes to the correct endpoint and returns the response' do
|
|
54
|
+
response = subject.destroy(params: params, token: 'token')
|
|
55
|
+
expect(response.code).to eq 204
|
|
56
|
+
expect(response.body).to be_nil
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
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.4.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-06-
|
|
17
|
+
date: 2022-06-23 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
|
|
@@ -206,6 +206,7 @@ files:
|
|
|
206
206
|
- lib/quiz_api_client/http_request/metrics.rb
|
|
207
207
|
- lib/quiz_api_client/json_formatter.rb
|
|
208
208
|
- lib/quiz_api_client/services/base_api_service.rb
|
|
209
|
+
- lib/quiz_api_client/services/courses_service.rb
|
|
209
210
|
- lib/quiz_api_client/services/interaction_types_service.rb
|
|
210
211
|
- lib/quiz_api_client/services/item_analyses_service.rb
|
|
211
212
|
- lib/quiz_api_client/services/items_service.rb
|
|
@@ -257,6 +258,7 @@ files:
|
|
|
257
258
|
- spec/quiz_api_client/http_request/metrics_spec.rb
|
|
258
259
|
- spec/quiz_api_client_spec.rb
|
|
259
260
|
- spec/services/base_api_service_spec.rb
|
|
261
|
+
- spec/services/courses_service_spec.rb
|
|
260
262
|
- spec/services/interaction_types_service_spec.rb
|
|
261
263
|
- spec/services/item_analyses_service_spec.rb
|
|
262
264
|
- spec/services/items_service_spec.rb
|
|
@@ -279,10 +281,10 @@ files:
|
|
|
279
281
|
- spec/spec_helper.rb
|
|
280
282
|
- spec/support/pact_config.rb
|
|
281
283
|
- spec/support/pact_helper.rb
|
|
282
|
-
homepage:
|
|
284
|
+
homepage:
|
|
283
285
|
licenses: []
|
|
284
286
|
metadata: {}
|
|
285
|
-
post_install_message:
|
|
287
|
+
post_install_message:
|
|
286
288
|
rdoc_options: []
|
|
287
289
|
require_paths:
|
|
288
290
|
- lib
|
|
@@ -297,8 +299,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
297
299
|
- !ruby/object:Gem::Version
|
|
298
300
|
version: '0'
|
|
299
301
|
requirements: []
|
|
300
|
-
rubygems_version: 3.1.
|
|
301
|
-
signing_key:
|
|
302
|
+
rubygems_version: 3.1.6
|
|
303
|
+
signing_key:
|
|
302
304
|
specification_version: 4
|
|
303
305
|
summary: Ruby client for quiz_api
|
|
304
306
|
test_files:
|
|
@@ -332,6 +334,7 @@ test_files:
|
|
|
332
334
|
- spec/quiz_api_client/http_request/metrics_spec.rb
|
|
333
335
|
- spec/quiz_api_client_spec.rb
|
|
334
336
|
- spec/services/base_api_service_spec.rb
|
|
337
|
+
- spec/services/courses_service_spec.rb
|
|
335
338
|
- spec/services/interaction_types_service_spec.rb
|
|
336
339
|
- spec/services/item_analyses_service_spec.rb
|
|
337
340
|
- spec/services/items_service_spec.rb
|