domoscio_admin 0.3.5 → 0.3.8

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: e13dd13b5a0c4607c41a261227b9be65de5badb861d91ecbb67aba15673f805f
4
- data.tar.gz: d784655c5a27452520635b6ac6583cae4d9284c0a3c4e2d179f8a6895a6ff776
3
+ metadata.gz: 97bfb339c4cb14de52c9e14dc52279aa19edc9985d1226968ae36ce2414a1b3b
4
+ data.tar.gz: 9193e30b9763df7354b9e4c07d864c120f5382c1f4266ad833c52f0055bceca6
5
5
  SHA512:
6
- metadata.gz: cb361e7fbe82c675eb44ace0a1832e37b350c7b559f89fb81d9e6fe56a94134870203afe62ad7e4bd97aff8c25afe5e73a948cbe19605da0e5fb72e43cbf359c
7
- data.tar.gz: 24bcca18f7358fd06da67754f7981f37d1359c752e31745b5d9d91361782faa688f14e38b72ad8eb14b6e5ed79b863865ccf692f375acd4fe5d24ea27bb7db64
6
+ metadata.gz: 45d91e72a7513da0c0814fefb9044f83418614e475ef839345f624777fc3c588360239d9eb7cfc9347f9829ecef404700ae9a1f53a8f812c567d016965fd54fa
7
+ data.tar.gz: 18507d0bffde33e49b05b34dd3fc4dfeffc0349e44832c41719d4690017a6e782b8ab7269135c9dc2af2d9291f6330223721b3a14c59662c4d681f4f884e6c96
@@ -41,7 +41,7 @@ module DomoscioAdmin
41
41
  f.flock(File::LOCK_SH)
42
42
  txt = f.read
43
43
  f.close
44
- YAML.safe_load(txt) || nil
44
+ YAML.load(txt) || nil
45
45
  rescue Errno::ENOENT
46
46
  nil
47
47
  end
@@ -0,0 +1,8 @@
1
+ module DomoscioAdmin
2
+ class LearningProgram < ResourceInstance
3
+ include DomoscioAdmin::HTTPCalls::Create
4
+ include DomoscioAdmin::HTTPCalls::Fetch
5
+ include DomoscioAdmin::HTTPCalls::Update
6
+ include DomoscioAdmin::HTTPCalls::Destroy
7
+ end
8
+ end
@@ -7,7 +7,7 @@ module DomoscioAdmin
7
7
  end
8
8
 
9
9
  build_url = "/users"
10
- build_url << "/#{CGI.escape(id.to_s.replace('.', '%2E'))}" if id
10
+ build_url << "/#{CGI.escape(id.to_s.gsub('.', '%2E'))}" if id
11
11
  return build_url
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module DomoscioAdmin
2
- VERSION = '0.3.5'.freeze
2
+ VERSION = '0.3.8'.freeze
3
3
  end
@@ -12,6 +12,7 @@ require 'domoscio_admin/resources/resource_instance'
12
12
  require 'domoscio_admin/resources/instances/instance_parameter'
13
13
  require 'domoscio_admin/resources/instances/instance_user'
14
14
  require 'domoscio_admin/resources/instances/student_group'
15
+ require 'domoscio_admin/resources/instances/learning_program'
15
16
  require 'domoscio_admin/resources/users/user'
16
17
 
17
18
  module DomoscioAdmin
@@ -50,15 +51,22 @@ module DomoscioAdmin
50
51
  # Raises DomoscioAdmin::ProcessingError on Internal Error
51
52
  #
52
53
  def self.request(method, url, params = {})
54
+ params ||= {}
53
55
  store_tokens, headers = request_headers
56
+ params.merge!({ 'per_page': 2000 }) unless params[:per_page]
54
57
  uri = api_uri(url)
55
-
56
58
  response = DomoscioAdmin.send_request(uri, method, params, headers)
57
59
  return response if response.is_a? DomoscioAdmin::ProcessingError
58
60
 
59
61
  begin
60
62
  raise_http_failure(uri, response, params)
61
- data = DomoscioAdmin::JSON.load(response.body.nil? ? '' : response.body)
63
+
64
+ if response['Content-Type'] == 'application/zip'
65
+ data = response
66
+ else
67
+ data = DomoscioAdmin::JSON.load(response.body.nil? ? '' : response.body)
68
+ end
69
+
62
70
  if store_tokens
63
71
  DomoscioAdmin::AuthorizationToken::Manager.storage.store({
64
72
  access_token: response['Accesstoken'],
@@ -71,6 +79,24 @@ module DomoscioAdmin
71
79
  data = e
72
80
  end
73
81
 
82
+ if response['Total']
83
+ pagetotal = (response['Total'].to_i / response['Per-Page'].to_f).ceil
84
+ (2..pagetotal).each do |j|
85
+ response = DomoscioAdmin.send_request(uri, method, params.merge({ page: j }), headers)
86
+ return response if response.is_a? DomoscioAdmin::ProcessingError
87
+
88
+ begin
89
+ raise_http_failure(uri, response, params)
90
+ body = DomoscioAdmin::JSON.load(response.body.nil? ? '' : response.body)
91
+ data += body
92
+ data.flatten!
93
+ rescue MultiJson::LoadError => e
94
+ return ProcessingError.new(uri, 500, e, response.body, params)
95
+ rescue ResponseError => e
96
+ return e
97
+ end
98
+ end
99
+ end
74
100
  data
75
101
  end
76
102
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domoscio_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pascal Lim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-15 00:00:00.000000000 Z
11
+ date: 2022-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -55,6 +55,7 @@ files:
55
55
  - lib/domoscio_admin/json.rb
56
56
  - lib/domoscio_admin/resources/instances/instance_parameter.rb
57
57
  - lib/domoscio_admin/resources/instances/instance_user.rb
58
+ - lib/domoscio_admin/resources/instances/learning_program.rb
58
59
  - lib/domoscio_admin/resources/instances/student_group.rb
59
60
  - lib/domoscio_admin/resources/resource.rb
60
61
  - lib/domoscio_admin/resources/resource_instance.rb