quiz_api_client 0.1.9 → 0.1.10

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
  SHA1:
3
- metadata.gz: 6fcf6e2dd779c820b2952adfccb070ada9110dc4
4
- data.tar.gz: 63961779d89a36fadf43754447594f3a6ef3c8d5
3
+ metadata.gz: ca9a16246b654bd00e0c7c3fb55d6a9594004037
4
+ data.tar.gz: ac33399eb56be356559f4045bdb30be585bd1560
5
5
  SHA512:
6
- metadata.gz: 9a577ddd3f7233e8c68aeae12b283c040c5be76e9ddd0a2ce7670481731afa0fcd1312d2c40d72cd720e1c185221205a8b71d66ff255004630ee3cc08d3537ad
7
- data.tar.gz: 96a301cdd54943c267dc1ace7958b33896193f1ec926d8edad445dd35b9befeb08b2c44245b6c27791b9a97b6c6f79afd6c1fde4286e916e2086ed8a3e909486
6
+ metadata.gz: ca0918f5f2daf3f3855a81e46fd3b5165e4d7c58fea2cef97f32bb4043088d18a75b226f00c06006bddf7e3998f0f54492094edb2b1d45d0bcd7d7f5e4e5d2fa
7
+ data.tar.gz: cc75ae00dd9f1c4fd921390fc414818fbbfb69fcd4f7bce5945ce531314833460ec102ee70f59b8daeb1bf89661fe5de3be73a8fbfb615e845911e6f484aa9d6
@@ -48,6 +48,10 @@ module QuizApiClient
48
48
  @_quiz_session_events_service ||= Services::QuizSessionEventsService.new(service_params)
49
49
  end
50
50
 
51
+ def quiz_session_result_service
52
+ @_quiz_session_result_service ||= Services::QuizSessionResultService.new(service_params)
53
+ end
54
+
51
55
  private
52
56
 
53
57
  def service_params
@@ -74,3 +78,4 @@ require 'quiz_api_client/services/quiz_session_events_service'
74
78
  require 'quiz_api_client/services/quiz_session_service'
75
79
  require 'quiz_api_client/services/quiz_sessions_service'
76
80
  require 'quiz_api_client/services/quizzes_service'
81
+ require 'quiz_api_client/services/quiz_session_result_service'
@@ -13,7 +13,7 @@ module QuizApiClient::Services
13
13
 
14
14
  def grant_permission(scope:, exp: nil, resource_id: nil)
15
15
  payload = {
16
- host: host,
16
+ host: URI.parse("#{protocol}://#{host}").host,
17
17
  consumer_key: consumer_key,
18
18
  scope: scope,
19
19
  exp: exp || Time.now.utc.to_i + 60,
@@ -5,14 +5,10 @@ module QuizApiClient::Services
5
5
  generate_token(scope: scope, exp: exp, resource_id: resource_id)
6
6
  end
7
7
 
8
- def scope_build
9
- 'quiz.build'
10
- end
11
-
12
8
  private
13
9
 
14
10
  def allowed_scopes
15
- [scope_build]
11
+ ['quiz.build', 'quiz.analysis']
16
12
  end
17
13
  end
18
14
  end
@@ -0,0 +1,29 @@
1
+ module QuizApiClient::Services
2
+ class QuizSessionResultService < BaseApiService
3
+ def token(scope:, exp: nil, resource_id: nil)
4
+ return unless allowed_scopes.include?(scope)
5
+ generate_token(scope: scope, exp: exp, resource_id: resource_id)
6
+ end
7
+
8
+ def show(params:, default_token: nil)
9
+ raise 'Quiz Session Result Id Required' unless params && params[:id]
10
+ get_from_quiz_api(params: params, token: token_for_api(default_token, scope_show, params[:id]))
11
+ end
12
+
13
+ def scope_show
14
+ 'quiz_session_result.show'
15
+ end
16
+
17
+ private
18
+
19
+ def get_from_quiz_api(params:, token:)
20
+ client(token: token).get(
21
+ "/api/results/#{params[:id]}"
22
+ )
23
+ end
24
+
25
+ def allowed_scopes
26
+ [scope_show]
27
+ end
28
+ end
29
+ end
@@ -9,6 +9,11 @@ module QuizApiClient::Services
9
9
  patch_to_quiz_api(params: params, token: token_for_api(default_token, scope_update, params[:id]))
10
10
  end
11
11
 
12
+ def show(params:, default_token: nil)
13
+ raise 'Quiz Session Id Required' unless params && params[:id]
14
+ get_from_quiz_api(params: params, token: token_for_api(default_token, scope_show, params[:id]))
15
+ end
16
+
12
17
  def scope_update
13
18
  'quiz_session.update'
14
19
  end
@@ -21,6 +26,10 @@ module QuizApiClient::Services
21
26
  'quiz_session.grade'
22
27
  end
23
28
 
29
+ def scope_show
30
+ 'quiz_session.show'
31
+ end
32
+
24
33
  private
25
34
 
26
35
  def patch_to_quiz_api(params:, token:)
@@ -30,11 +39,18 @@ module QuizApiClient::Services
30
39
  )
31
40
  end
32
41
 
42
+ def get_from_quiz_api(params:, token:)
43
+ client(token: token).get(
44
+ "/api/quiz_sessions/#{params[:id]}"
45
+ )
46
+ end
47
+
33
48
  def allowed_scopes
34
49
  [
35
50
  scope_grade,
36
51
  scope_take,
37
- scope_update
52
+ scope_update,
53
+ scope_show
38
54
  ]
39
55
  end
40
56
  end
@@ -1,3 +1,3 @@
1
1
  module QuizApiClient
2
- VERSION = '0.1.9'.freeze
2
+ VERSION = '0.1.10'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quiz_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-25 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -138,6 +138,7 @@ files:
138
138
  - lib/quiz_api_client/services/quiz_analyses_service.rb
139
139
  - lib/quiz_api_client/services/quiz_service.rb
140
140
  - lib/quiz_api_client/services/quiz_session_events_service.rb
141
+ - lib/quiz_api_client/services/quiz_session_result_service.rb
141
142
  - lib/quiz_api_client/services/quiz_session_service.rb
142
143
  - lib/quiz_api_client/services/quiz_sessions_service.rb
143
144
  - lib/quiz_api_client/services/quizzes_service.rb
@@ -162,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
163
  version: '0'
163
164
  requirements: []
164
165
  rubyforge_project:
165
- rubygems_version: 2.5.1
166
+ rubygems_version: 2.5.2
166
167
  signing_key:
167
168
  specification_version: 4
168
169
  summary: Ruby client for quiz_api