domoscio_admin 0.3.4 → 0.3.7

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: 5214e024b43a24c60d9809df58679f069fddb06eefc4c77854f65b71a1a396e9
4
- data.tar.gz: 6d94481bf938506dbb0ecfc101923b915c66f38b3de172be0d3eeca5729f14b9
3
+ metadata.gz: ce104001c87e2d142f5db362be3e55e4878186dbd31411e7b277125b5fe25a90
4
+ data.tar.gz: 648cc946341a7b8f18b54ba3c0b820ce09b398af0f0377b890177564caca35b2
5
5
  SHA512:
6
- metadata.gz: 4a59bc2a5132a3dc3b797c388738aa47172a3185bae38d4b1e2d886f69e2b9e53b656d41a10089d769dad94462d4b1808cfd92b8c2acbe93ff15d60838574eda
7
- data.tar.gz: 5460680c16b4b5825e80f577ad811fff669456e2db9359b39b71ccdf9a7a5c517f7fdc16032b41078d64fe94333a306a8d486d72a8aff41252dc944b81b33d83
6
+ metadata.gz: 339ae8cbacc55191daaad25a9708617315b9e647dd06083a2ecc52f15291cf0e0ecc3a248b3d1dabd09a6cf21a95eff1514d0218bf928bd778bccd427e1596b2
7
+ data.tar.gz: 6140dc2382b8d7b7ef72139be0338c61ce78ba0827b8e159cc9a28bfb76391c3dc08011703a2c3dd36af56993562114cbf1673fd132efbe9af24fcbb0b847062
@@ -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
@@ -5,7 +5,7 @@ module DomoscioAdmin
5
5
  raise NotImplementedError, 'Resource is an abstract class. Do not use it directly.' if self == Resource
6
6
 
7
7
  build_url = "/instances/#{DomoscioAdmin.configuration.client_id}/#{underscore(class_name)}s"
8
- build_url << "/#{CGI.escape(id.to_s.replace('.', '%2E'))}" if id
8
+ build_url << "/#{CGI.escape(id.to_s).gsub('.', '%2E')}" if id
9
9
  build_url
10
10
  end
11
11
 
@@ -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.4'.freeze
2
+ VERSION = '0.3.7'.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.4
4
+ version: 0.3.7
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-02 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