domoscio_rails 0.2.14 → 0.2.16.9

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: f3eace41e37214c6a5a2649420cb57edd98ec923
4
- data.tar.gz: c87f19311410ae698ff78abb40a607a1f12d0103
3
+ metadata.gz: add91f521b4696d8f1b28a6bf6dcc1dd72503176
4
+ data.tar.gz: e574faa0b6825861ce4003d727c89132b954df62
5
5
  SHA512:
6
- metadata.gz: 79285394f183ebd822d66d1cab36a6185d7a6561d5a7cbf6ec01096a85c583c964b4aebaf1fab3fe07fc2fcf1ad3263f48edb3b2e256e09b3aa9361c8239a8cc
7
- data.tar.gz: d0f7faa57bd977033263b18fbcfab376027ad946105be2a25525cf9797744f8aede2b6309e204464366d7bb9f428897984c294d0dbe3a2f2a59e36af6c50d316
6
+ metadata.gz: 5448dbccc4872fdc44a40e41bc38de1320c8e4877950191047104d6e3058f6416ebf4b10e86e63bb40df4845568267f49c1310b73e1d38522aa1653ab6fd163b
7
+ data.tar.gz: 344c000e34b3f35778e387fd850a5e927a31366518a877d19fa27dabf484663d51bd418ec0912ed0760c430154a66d8fa35f89d29cd093c8fb67c53daf1c19f5
@@ -1,5 +1,5 @@
1
-
2
- require 'net/http'
1
+
2
+ require 'net/https'
3
3
  require 'cgi/util'
4
4
  require 'multi_json'
5
5
 
@@ -18,13 +18,12 @@ require 'domoscio_rails/adaptative/deterministic/rule_output'
18
18
  require 'domoscio_rails/adaptative/deterministic/rule_condition'
19
19
  require 'domoscio_rails/adaptative/predictive/objective'
20
20
  require 'domoscio_rails/adaptative/predictive/objective_student'
21
- require 'domoscio_rails/adaptative/predictive/objective_knowledge_node_student'
22
21
  require 'domoscio_rails/adaptative/predictive/objective_knowledge_node'
22
+ require 'domoscio_rails/adaptative/predictive/objective_knowledge_node_student'
23
23
  require 'domoscio_rails/adaptative/recommendation'
24
24
  require 'domoscio_rails/path/learning_path'
25
25
  require 'domoscio_rails/content/content'
26
26
  require 'domoscio_rails/content/knowledge_node_content'
27
- require 'domoscio_rails/admin/user'
28
27
  require 'domoscio_rails/student/student'
29
28
  require 'domoscio_rails/student/student_cluster'
30
29
  require 'domoscio_rails/knowledge/knowledge_graph'
@@ -38,15 +37,17 @@ require 'domoscio_rails/data/knowledge_node_student'
38
37
  require 'domoscio_rails/data/event'
39
38
  require 'domoscio_rails/utils/review_util'
40
39
  require 'domoscio_rails/utils/gameplay_util'
41
-
40
+ require 'domoscio_rails/utils/alerts_util'
41
+ require 'domoscio_rails/utils/recommendation_util'
42
+ require 'domoscio_rails/metadata/delta_object'
42
43
 
43
44
  module DomoscioRails
44
45
 
45
46
  class Configuration
46
- attr_accessor :preproduction, :root_url,
47
+ attr_accessor :preproduction, :test, :root_url,
47
48
  :client_id, :client_passphrase,
48
49
  :temp_dir, :disabled, :version
49
-
50
+
50
51
  def disabled
51
52
  @disabled || false
52
53
  end
@@ -54,13 +55,25 @@ module DomoscioRails
54
55
  def preproduction
55
56
  @preproduction || false
56
57
  end
57
-
58
+
59
+ def test
60
+ @test || false
61
+ end
62
+
58
63
  def version
59
64
  @version || 1
60
65
  end
61
66
 
62
67
  def root_url
63
- @root_url || (@preproduction == true ? ( @version > 1 ? "http://api.domoscio.com" : "http://stats-engine-api.domoscio.com" ) : "http://localhost:3001/")
68
+ if @preproduction == true
69
+ if @test == true
70
+ @root_url || "https://domoscio-adaptive-engine-staging.azurewebsites.net"
71
+ else
72
+ @root_url || "https://domoscio-adaptive-engine.azurewebsites.net"
73
+ end
74
+ else
75
+ @root_url || "http://localhost:3001"
76
+ end
64
77
  end
65
78
  end
66
79
 
@@ -90,22 +103,38 @@ module DomoscioRails
90
103
  def self.request(method, url, params={}, filters={}, headers = request_headers, before_request_proc = nil)
91
104
  return false if @disabled
92
105
  uri = api_uri(url)
93
- uri.query = URI.encode_www_form(filters) unless filters.empty?
94
-
95
- res = Net::HTTP.start(uri.host, uri.port) do |http| # , use_ssl: uri.scheme == 'https') do |http|
96
- req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
97
- req.body = DomoscioRails::JSON.dump(params)
98
- before_request_proc.call(req) if before_request_proc
99
- http.request req
100
- end
106
+ uri.query = URI.encode_www_form(filters) unless filters.empty?
107
+
108
+ res = DomoscioRails.send_request(uri, method, params, headers, before_request_proc)
101
109
 
102
110
  # decode json data
103
111
  begin
104
112
  data = DomoscioRails::JSON.load(res.body.nil? ? '' : res.body)
113
+ unless (res.kind_of? Net::HTTPClientError) || (res.kind_of? Net::HTTPServerError)
114
+ DomoscioRails::AuthorizationToken::Manager.storage.store({access_token: res['Accesstoken'], refresh_token: res['Refreshtoken']})
115
+ end
105
116
  rescue MultiJson::LoadError
106
117
  data = {}
107
118
  end
108
119
 
120
+ if res['Total'] && !filters[:page]
121
+ pagetotal = (res['Total'].to_i / res['Per-Page'].to_f).ceil
122
+
123
+ for j in 2..pagetotal
124
+ params = params.merge({page: j})
125
+ res = DomoscioRails.send_request(uri, method, params, headers, before_request_proc)
126
+
127
+ # decode json data
128
+ begin
129
+ data += DomoscioRails::JSON.load(res.body.nil? ? '' : res.body)
130
+ data.flatten!
131
+ rescue MultiJson::LoadError
132
+ data = {}
133
+ end
134
+
135
+ end
136
+ end
137
+
109
138
  ############### TEMP!!!! #######################################################
110
139
  #pp method, uri.request_uri, params #, filters, headers
111
140
  #pp res, data
@@ -126,6 +155,16 @@ module DomoscioRails
126
155
  data
127
156
  end
128
157
 
158
+
159
+ def self.send_request(uri, method, params, headers, before_request_proc)
160
+ res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http| # , use_ssl: uri.scheme == 'https') do |http|
161
+ req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
162
+ req.body = DomoscioRails::JSON.dump(params)
163
+ before_request_proc.call(req) if before_request_proc
164
+ http.request req
165
+ end
166
+ end
167
+
129
168
  private
130
169
 
131
170
  def self.user_agent
@@ -148,17 +187,24 @@ module DomoscioRails
148
187
 
149
188
  def self.request_headers
150
189
  auth_token = DomoscioRails::AuthorizationToken::Manager.get_token
151
- headers = {
152
- 'user_agent' => "DomoscioRails V2 RubyBindings/#{DomoscioRails::VERSION}",
153
- 'Authorization' => "Token token=#{DomoscioRails.configuration.client_passphrase}",#"#{auth_token['token_type']} #{auth_token['access_token']}",
154
- 'Content-Type' => 'application/json'
155
- }
156
- # begin
157
- # headers.update('x_mangopay_client_user_agent' => DomoscioRails::JSON.dump(user_agent))
158
- # rescue => e
159
- # headers.update('x_mangopay_client_raw_user_agent' => user_agent.inspect, error: "#{e} (#{e.class})")
160
- # end
190
+
191
+ if !auth_token.is_a? String
192
+ headers = {
193
+ 'user_agent' => "DomoscioRails V2 RubyBindings/#{DomoscioRails::VERSION}",
194
+ 'AccessToken' => "#{auth_token[:access_token]}",
195
+ 'RefreshToken' => "#{auth_token[:refresh_token]}",
196
+ 'Content-Type' => 'application/json'
197
+ }
198
+ else
199
+ headers = {
200
+ 'user_agent' => "DomoscioRails V2 RubyBindings/#{DomoscioRails::VERSION}",
201
+ 'Authorization' => "Token token=#{DomoscioRails.configuration.client_passphrase}",#"#{auth_token['token_type']} #{auth_token['access_token']}",
202
+ 'Content-Type' => 'application/json'
203
+ }
204
+ end
205
+ headers
206
+
161
207
  end
162
-
163
-
208
+
209
+
164
210
  end
@@ -1,6 +1,6 @@
1
1
  module DomoscioRails
2
- # An objective knowledge node.
3
- class ObjectiveKnowledgeNode < Resource
4
- include DomoscioRails::HTTPCalls::Fetch
2
+ # An objective knowledge node.
3
+ class ObjectiveKnowledgeNode < Resource
4
+ include DomoscioRails::HTTPCalls::Fetch
5
+ end
5
6
  end
6
- end
@@ -1,6 +1,6 @@
1
1
  module DomoscioRails
2
- # An objective knowledge node student.
3
- class ObjectiveKnowledgeNodeStudent < Resource
4
- include DomoscioRails::HTTPCalls::Fetch
2
+ # An objective knowledge node student.
3
+ class ObjectiveKnowledgeNodeStudent < Resource
4
+ include DomoscioRails::HTTPCalls::Fetch
5
+ end
5
6
  end
6
- end
@@ -5,7 +5,7 @@ module DomoscioRails
5
5
 
6
6
  class << self
7
7
  def storage
8
- @@storage ||= StaticStorage.new
8
+ @@storage ||= FileStorage.new
9
9
  end
10
10
 
11
11
  def storage= (storage)
@@ -13,17 +13,8 @@ module DomoscioRails
13
13
  end
14
14
 
15
15
  def get_token
16
- # token = storage.get
17
- # if token.nil? || token['timestamp'].nil? || token['timestamp'] <= Time.now
18
- # token = DomoscioRails.request(:post, '/api/oauth/token', {}, {}, {}, Proc.new do |req|
19
- # cfg = DomoscioRails.configuration
20
- # req.basic_auth cfg.client_id, cfg.client_passphrase
21
- # req.body = 'grant_type=client_credentials'
22
- # end)
23
- # token['timestamp'] = Time.now + token['expires_in'].to_i
24
- # storage.store token
25
- # end
26
- token = DomoscioRails.configuration.client_passphrase
16
+ token = storage.get
17
+ token = DomoscioRails.configuration.client_passphrase if token.nil?
27
18
  token
28
19
  end
29
20
  end
@@ -72,6 +72,9 @@ module DomoscioRails
72
72
  def util(id = nil, util_name = nil, params = {})
73
73
  DomoscioRails.request(:get, url(id, util_name), params)
74
74
  end
75
+ def util_post(id = nil, util_name = nil, params = {})
76
+ DomoscioRails.request(:post, url(id, util_name), params)
77
+ end
75
78
  end
76
79
 
77
80
  def self.included(base)
@@ -0,0 +1,6 @@
1
+ module DomoscioRails
2
+ # A delta object.
3
+ class DeltaObject < Resource
4
+ include DomoscioRails::HTTPCalls::Fetch
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module DomoscioRails
2
+ # A company.
3
+ class AlertsUtil < Resource
4
+ include DomoscioRails::HTTPCalls::Util
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module DomoscioRails
2
+ # A company.
3
+ class RecommendationUtil < Resource
4
+ include DomoscioRails::HTTPCalls::Util
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module DomoscioRails
2
- VERSION = "0.2.14"
2
+ VERSION = "0.2.16.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domoscio_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.16.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benoit Praly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-30 00:00:00.000000000 Z
11
+ date: 2018-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
- description: Description of DomoscioRails.
27
+ description: Ruby client to interact with Domoscio API.
28
28
  email:
29
29
  - benoit.praly@domoscio.com
30
30
  executables: []
@@ -46,7 +46,6 @@ files:
46
46
  - lib/domoscio_rails/adaptative/predictive/objective_student.rb
47
47
  - lib/domoscio_rails/adaptative/recommendation.rb
48
48
  - lib/domoscio_rails/admin/instance.rb
49
- - lib/domoscio_rails/admin/user.rb
50
49
  - lib/domoscio_rails/authorization_token.rb
51
50
  - lib/domoscio_rails/content/content.rb
52
51
  - lib/domoscio_rails/content/knowledge_node_content.rb
@@ -59,6 +58,7 @@ files:
59
58
  - lib/domoscio_rails/knowledge/knowledge_edge.rb
60
59
  - lib/domoscio_rails/knowledge/knowledge_graph.rb
61
60
  - lib/domoscio_rails/knowledge/knowledge_node.rb
61
+ - lib/domoscio_rails/metadata/delta_object.rb
62
62
  - lib/domoscio_rails/metadata/tag.rb
63
63
  - lib/domoscio_rails/metadata/tag_edge.rb
64
64
  - lib/domoscio_rails/metadata/tag_set.rb
@@ -67,7 +67,9 @@ files:
67
67
  - lib/domoscio_rails/resource.rb
68
68
  - lib/domoscio_rails/student/student.rb
69
69
  - lib/domoscio_rails/student/student_cluster.rb
70
+ - lib/domoscio_rails/utils/alerts_util.rb
70
71
  - lib/domoscio_rails/utils/gameplay_util.rb
72
+ - lib/domoscio_rails/utils/recommendation_util.rb
71
73
  - lib/domoscio_rails/utils/review_util.rb
72
74
  - lib/domoscio_rails/version.rb
73
75
  - lib/tasks/domoscio_rails_tasks.rake
@@ -91,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
93
  version: '0'
92
94
  requirements: []
93
95
  rubyforge_project:
94
- rubygems_version: 2.6.8
96
+ rubygems_version: 2.6.14
95
97
  signing_key:
96
98
  specification_version: 4
97
99
  summary: Summary of DomoscioRails.
@@ -1,10 +0,0 @@
1
- module DomoscioRails
2
- # A user of the API.
3
- class User < Resource
4
-
5
- include DomoscioRails::HTTPCalls::Create
6
- include DomoscioRails::HTTPCalls::Fetch
7
- include DomoscioRails::HTTPCalls::Update
8
-
9
- end
10
- end