ondotori-ruby-client 0.0.2 → 0.0.3
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/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/README.md +11 -1
- data/example/get_current_temp.rb +47 -0
- data/lib/{ondotori-web-client.rb → ondotori-ruby-client.rb} +0 -0
- data/lib/ondotori/version.rb +1 -1
- data/lib/ondotori/webapi/api/params.rb +24 -0
- data/lib/ondotori/webapi/client.rb +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a4619b075e477a48b7a78b6f5f64647fded6a28e4c1f43206cb557aa3064365
|
4
|
+
data.tar.gz: e0952edf54eb7d0712f9278e243cbdf75af4cc6c0d79f8d7ca19b7f3e19578ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe2a855fed3c7b8b91a8da14532ef4513753b0820245a1289311fbb5068d26645e333fece2733f0d2d38d1d5818845472f379e6ab98ab56c8730357a09e78258
|
7
|
+
data.tar.gz: fc96e7f92398ed90e1325e83afb8557b63d68b5376295fc75e03c49c2a189766c743696fec59a7b6bd1bcd4ef9c839c26b6c91afa1790192de37a1c419e22575
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -58,6 +58,16 @@ client = Ondotori::WebAPI::Client.new(params)
|
|
58
58
|
response = client.latest_data("SERIAL")
|
59
59
|
```
|
60
60
|
|
61
|
+
#### Get Latest Data RTR500
|
62
|
+
|
63
|
+
To get latest data (RTR500), do the following.
|
64
|
+
|
65
|
+
```
|
66
|
+
params = { "api-key" => "API Key you create", "login-id" => "tbxxxx", "login-pass" => "password"}
|
67
|
+
client = Ondotori::WebAPI::Client.new(params)
|
68
|
+
response = client.latest_data_rtr500(base: "BaseUnit Serial", remote: "RemoteUnit Serial")
|
69
|
+
```
|
70
|
+
|
61
71
|
#### Error Handling
|
62
72
|
|
63
73
|
Ondotori Errors
|
@@ -84,7 +94,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
84
94
|
|
85
95
|
## Contributing
|
86
96
|
|
87
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
97
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/k28/ondotori-ruby-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/ondotori-ruby-client/blob/master/CODE_OF_CONDUCT.md).
|
88
98
|
|
89
99
|
## License
|
90
100
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "ondotori-ruby-client"
|
3
|
+
|
4
|
+
WEB_STORAGE_ACCESS_INFO_PATH = "/var/tmp/webstorage.json"
|
5
|
+
# The webstorage.json looks like the following.
|
6
|
+
# {
|
7
|
+
# "api-key":"T&D WebStorage API Key",
|
8
|
+
# "login-id" : "rbacxxxx",
|
9
|
+
# "login-pass" : "password"
|
10
|
+
# }
|
11
|
+
|
12
|
+
# Reads the information for API access from the file.
|
13
|
+
def load_params
|
14
|
+
File.open(WEB_STORAGE_ACCESS_INFO_PATH) do |file|
|
15
|
+
storage_info = file.read
|
16
|
+
load_info = JSON.parse(storage_info)
|
17
|
+
|
18
|
+
# This is not necessary, but is left for the explanation of the parameter settings.
|
19
|
+
wss_access_info = {}
|
20
|
+
wss_access_info["api-key"] = load_info["api-key"]
|
21
|
+
wss_access_info["login-id"] = load_info["login-id"]
|
22
|
+
wss_access_info["login-pass"] = load_info["login-pass"]
|
23
|
+
return wss_access_info
|
24
|
+
end
|
25
|
+
rescue SystemCallError => e
|
26
|
+
puts %(class=[#{e.class}] message=[#{e.message}])
|
27
|
+
rescue IOError => e
|
28
|
+
puts %(class=[#{e.class}] message=[#{e.message}])
|
29
|
+
end
|
30
|
+
|
31
|
+
def main
|
32
|
+
params = load_params
|
33
|
+
if params.nil?
|
34
|
+
puts "Load parameter error..."
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
39
|
+
client = Ondotori::WebAPI::Client.new(params)
|
40
|
+
response = client.current
|
41
|
+
puts "#{response}"
|
42
|
+
rescue Ondotori::WebAPI::Api::Errors::Error => e
|
43
|
+
puts "Some error happend #{e.message} #{e.code}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
main
|
File without changes
|
data/lib/ondotori/version.rb
CHANGED
@@ -49,6 +49,30 @@ module Ondotori
|
|
49
49
|
params
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
class LatestDataRTR500Params
|
54
|
+
def initialize(param, base: "", remote: "")
|
55
|
+
if base.empty? || remote.empty?
|
56
|
+
raise Ondotori::WebAPI::Api::Errors::InvaildParameter.new(
|
57
|
+
"latest-data-rtr500 need both the baseunit serial and remote unit serial.", 9993
|
58
|
+
)
|
59
|
+
end
|
60
|
+
@param = param
|
61
|
+
@base_serial = base
|
62
|
+
@remote_serial = remote
|
63
|
+
end
|
64
|
+
|
65
|
+
def to_ondotori_param
|
66
|
+
params = {}
|
67
|
+
params[Api::Param::API_KEY] = @param.api_key
|
68
|
+
params[Api::Param::LOGIN_ID] = @param.login_id
|
69
|
+
params[Api::Param::LOGIN_PASS] = @param.login_pass
|
70
|
+
params["base-serial"] = @base_serial
|
71
|
+
params["remote-serial"] = @remote_serial
|
72
|
+
|
73
|
+
params
|
74
|
+
end
|
75
|
+
end
|
52
76
|
end
|
53
77
|
end
|
54
78
|
end
|
@@ -24,6 +24,13 @@ module Ondotori
|
|
24
24
|
ondotori_response.result
|
25
25
|
end
|
26
26
|
|
27
|
+
def latest_data_rtr500(base: "", remote: "")
|
28
|
+
param = Api::LatestDataRTR500Params.new(@param, base: base, remote: remote)
|
29
|
+
response = @web_access.access("#{base_uri}latest-data-rtr500", param.to_ondotori_param)
|
30
|
+
ondotori_response = Ondotori::WebAPI::Api::Response.new(response)
|
31
|
+
ondotori_response.result
|
32
|
+
end
|
33
|
+
|
27
34
|
def base_uri
|
28
35
|
return @uri unless @uri.empty?
|
29
36
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ondotori-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuya Hatano
|
@@ -28,7 +28,8 @@ files:
|
|
28
28
|
- Rakefile
|
29
29
|
- bin/console
|
30
30
|
- bin/setup
|
31
|
-
-
|
31
|
+
- example/get_current_temp.rb
|
32
|
+
- lib/ondotori-ruby-client.rb
|
32
33
|
- lib/ondotori/version.rb
|
33
34
|
- lib/ondotori/webapi/api/errors.rb
|
34
35
|
- lib/ondotori/webapi/api/param.rb
|