domoscio_admin 0.3.6 → 0.3.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4c0246319d89ad54f3d99b532f931378714c1f1dc2dd53674790d9d1742104f
4
- data.tar.gz: 82daf059a12007b9591a7380078b7322ef272786f392a87b3fceed7b64e52650
3
+ metadata.gz: ce104001c87e2d142f5db362be3e55e4878186dbd31411e7b277125b5fe25a90
4
+ data.tar.gz: 648cc946341a7b8f18b54ba3c0b820ce09b398af0f0377b890177564caca35b2
5
5
  SHA512:
6
- metadata.gz: ca430e346eb0d35cde4aebca69e88c51cc7f5a0cad67880efa57b0435872a7779ea44abaf6a332d8494225f8ddfa690f87d402e34af7350a902aa275e4a73b4c
7
- data.tar.gz: a190cc943f244d186267aa1d8af8ec234941b26c7f51748b43d8ead6f5a2d23df3e7ff57aeeae245f1467a1a82811696e15f4b9b023f4ad1db6c9cf904345878
6
+ metadata.gz: 339ae8cbacc55191daaad25a9708617315b9e647dd06083a2ecc52f15291cf0e0ecc3a248b3d1dabd09a6cf21a95eff1514d0218bf928bd778bccd427e1596b2
7
+ data.tar.gz: 6140dc2382b8d7b7ef72139be0338c61ce78ba0827b8e159cc9a28bfb76391c3dc08011703a2c3dd36af56993562114cbf1673fd132efbe9af24fcbb0b847062
@@ -1,3 +1,3 @@
1
1
  module DomoscioAdmin
2
- VERSION = '0.3.6'.freeze
2
+ VERSION = '0.3.7'.freeze
3
3
  end
@@ -51,15 +51,22 @@ module DomoscioAdmin
51
51
  # Raises DomoscioAdmin::ProcessingError on Internal Error
52
52
  #
53
53
  def self.request(method, url, params = {})
54
+ params ||= {}
54
55
  store_tokens, headers = request_headers
56
+ params.merge!({ 'per_page': 2000 }) unless params[:per_page]
55
57
  uri = api_uri(url)
56
-
57
58
  response = DomoscioAdmin.send_request(uri, method, params, headers)
58
59
  return response if response.is_a? DomoscioAdmin::ProcessingError
59
60
 
60
61
  begin
61
62
  raise_http_failure(uri, response, params)
62
- 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
+
63
70
  if store_tokens
64
71
  DomoscioAdmin::AuthorizationToken::Manager.storage.store({
65
72
  access_token: response['Accesstoken'],
@@ -72,6 +79,24 @@ module DomoscioAdmin
72
79
  data = e
73
80
  end
74
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
75
100
  data
76
101
  end
77
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.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pascal Lim
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-21 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
@@ -67,7 +67,7 @@ homepage: https://www.domoscio.com
67
67
  licenses:
68
68
  - MIT
69
69
  metadata: {}
70
- post_install_message:
70
+ post_install_message:
71
71
  rdoc_options: []
72
72
  require_paths:
73
73
  - lib
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubygems_version: 3.2.22
86
- signing_key:
86
+ signing_key:
87
87
  specification_version: 4
88
88
  summary: Summary of DomoscioAdmin.
89
89
  test_files: