domoscio_viz 0.1.1.4 → 0.2.0
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 +4 -4
- data/lib/domoscio_viz.rb +23 -10
- data/lib/domoscio_viz/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '03468c791eacd5b3f47a390530f79cf17e5958f62b4c10e4dbd6ae4f7142210e'
|
4
|
+
data.tar.gz: 97dd49337711f35d774db1b9958524dc6ac9a20f77cda5173723cce4e79061f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f96faeb12b74a5efe1d32e9e28a6d50763c05c969239114127c4cff14b45da9a6be097bd3596a2aa1976f3ab5601b916891fd423b68d5c2185a3ca4bb997b9f
|
7
|
+
data.tar.gz: 60fce846d350aa913453f5c35de699a26e7bae9cf7379d56b968bee6b1ae433ccf7bc065eb612a450af028738a8d81cca75f7c5e002906e953b5a681bc882931
|
data/lib/domoscio_viz.rb
CHANGED
@@ -66,10 +66,12 @@ module DomoscioViz
|
|
66
66
|
|
67
67
|
res = DomoscioViz.send_request(uri, method, params, headers, before_request_proc)
|
68
68
|
|
69
|
-
|
70
|
-
|
69
|
+
# decode json data
|
70
|
+
begin
|
71
71
|
data = DomoscioViz::JSON.load(res.body.nil? ? '' : res.body)
|
72
|
-
|
72
|
+
unless (res.kind_of? Net::HTTPClientError) || (res.kind_of? Net::HTTPServerError)
|
73
|
+
DomoscioViz::AuthorizationToken::Manager.storage.store({access_token: res['Accesstoken'], refresh_token: res['Refreshtoken']})
|
74
|
+
end
|
73
75
|
rescue MultiJson::LoadError
|
74
76
|
data = {}
|
75
77
|
end
|
@@ -77,7 +79,6 @@ module DomoscioViz
|
|
77
79
|
data
|
78
80
|
end
|
79
81
|
|
80
|
-
|
81
82
|
def self.send_request(uri, method, params, headers, before_request_proc)
|
82
83
|
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http| # , use_ssl: uri.scheme == 'https') do |http|
|
83
84
|
req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
|
@@ -108,12 +109,24 @@ module DomoscioViz
|
|
108
109
|
end
|
109
110
|
|
110
111
|
def self.request_headers
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
112
|
+
auth_token = DomoscioViz::AuthorizationToken::Manager.get_token
|
113
|
+
|
114
|
+
if !auth_token.is_a? String
|
115
|
+
headers = {
|
116
|
+
'user_agent' => "#{DomoscioViz.user_agent}",
|
117
|
+
'ClientId' => "#{DomoscioViz.configuration.client_id}",
|
118
|
+
'AccessToken' => "#{auth_token[:access_token]}",
|
119
|
+
'RefreshToken' => "#{auth_token[:refresh_token]}",
|
120
|
+
'Content-Type' => 'application/json'
|
121
|
+
}
|
122
|
+
else
|
123
|
+
headers = {
|
124
|
+
'user_agent' => "#{DomoscioViz.user_agent}",
|
125
|
+
'ClientId' => "#{DomoscioViz.configuration.client_id}",
|
126
|
+
'Authorization' => "Token token=#{DomoscioViz.configuration.client_passphrase}",
|
127
|
+
'Content-Type' => 'application/json'
|
128
|
+
}
|
129
|
+
end
|
117
130
|
headers
|
118
131
|
end
|
119
132
|
|
data/lib/domoscio_viz/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: domoscio_viz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benoit Praly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
|
-
rubygems_version: 3.
|
67
|
+
rubygems_version: 3.1.2
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Summary of DomoscioViz.
|