domoscio_viz 0.1.1.4 → 0.2.0

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: 4b56d8068cc89b1fd70f1d0d085e960307ce7038261c9a2640fc2033286f7b49
4
- data.tar.gz: d64091ea450a17c5500f13caa3b48618c12f8cdf7e135eac6912fff31254367e
3
+ metadata.gz: '03468c791eacd5b3f47a390530f79cf17e5958f62b4c10e4dbd6ae4f7142210e'
4
+ data.tar.gz: 97dd49337711f35d774db1b9958524dc6ac9a20f77cda5173723cce4e79061f3
5
5
  SHA512:
6
- metadata.gz: 5fd0f66253608031e7ccb578492430d9b4d0febc8b8c9fff50f8cae52a910f3ae77d81acc53b3b6c21e6deedbb07a81a677b1855bc255989e046084370fe817c
7
- data.tar.gz: ecf4b4b43f307db1d29950ecadbbccc25ebd3cec5ad2e0a310afe6d1aa5200d7c1ce7bfc57b15f3f604f0cb89882192dc2339a2b65bfeeda1ef48ee35e30983f
6
+ metadata.gz: 6f96faeb12b74a5efe1d32e9e28a6d50763c05c969239114127c4cff14b45da9a6be097bd3596a2aa1976f3ab5601b916891fd423b68d5c2185a3ca4bb997b9f
7
+ data.tar.gz: 60fce846d350aa913453f5c35de699a26e7bae9cf7379d56b968bee6b1ae433ccf7bc065eb612a450af028738a8d81cca75f7c5e002906e953b5a681bc882931
@@ -66,10 +66,12 @@ module DomoscioViz
66
66
 
67
67
  res = DomoscioViz.send_request(uri, method, params, headers, before_request_proc)
68
68
 
69
- # decode json data
70
- begin
69
+ # decode json data
70
+ begin
71
71
  data = DomoscioViz::JSON.load(res.body.nil? ? '' : res.body)
72
- DomoscioViz::AuthorizationToken::Manager.storage.store({client_id: res['ClientID'], client_passphrase: res['ClientPassphrase']})
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
- headers = {
112
- 'user_agent' => "DomoscioViz RubyBindings/#{DomoscioViz::VERSION}",
113
- 'ClientID' => "#{DomoscioViz.configuration.client_id}",
114
- 'ClientPassphrase' => "#{DomoscioViz.configuration.client_passphrase}",
115
- 'Content-Type' => 'application/json'
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
 
@@ -1,3 +1,3 @@
1
1
  module DomoscioViz
2
- VERSION = "0.1.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.1.4
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-10-17 00:00:00.000000000 Z
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.0.8
67
+ rubygems_version: 3.1.2
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: Summary of DomoscioViz.