ondotori-ruby-client 0.0.3 → 0.0.4
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/README.md +14 -0
- data/lib/ondotori/version.rb +1 -1
- data/lib/ondotori/webapi/api/params.rb +60 -18
- data/lib/ondotori/webapi/client.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a629b226e96126e7f1164d71fcd36700b7af8d2229c2e16a2ccbb6c5a44213a8
|
4
|
+
data.tar.gz: 5a134e0ca23f3fb706566f86fb335fddf2ae3ce3fcbbe035bcefeb546dfc35a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0044b0473197e69e7f978f399ec29c24e62f406118f1e1808f76d822b371e4f41cf311e66727953fd8e1ba446f535aba101d8d92552ad0e658e21e8136d85b1
|
7
|
+
data.tar.gz: 1a0826dcc6e452c31f15f6c364559f8102d7403731659c1d55bb5974375fc0832199d63f9d40c8ca9e629be37e1d9ef1633a90f8553162e141536d79057d5444
|
data/README.md
CHANGED
@@ -68,6 +68,20 @@ client = Ondotori::WebAPI::Client.new(params)
|
|
68
68
|
response = client.latest_data_rtr500(base: "BaseUnit Serial", remote: "RemoteUnit Serial")
|
69
69
|
```
|
70
70
|
|
71
|
+
#### Get Data (TR-7wb/nw/wf, TR4)
|
72
|
+
|
73
|
+
To get data (TR-7wb/nw/wf, TR4), do the following.
|
74
|
+
|
75
|
+
```
|
76
|
+
from = Time.now - (3600 * 24)
|
77
|
+
to = Time.now
|
78
|
+
limit = 173
|
79
|
+
params = { "api-key" => "API Key you create", "login-id" => "tbxxxx", "login-pass" => "password"}
|
80
|
+
client = Ondotori::WebAPI::Client.new(params)
|
81
|
+
response = client.data("Device Serial", from: from, to: to, limit: limit)
|
82
|
+
```
|
83
|
+
from, to and limit parameter is optional.
|
84
|
+
|
71
85
|
#### Error Handling
|
72
86
|
|
73
87
|
Ondotori Errors
|
data/lib/ondotori/version.rb
CHANGED
@@ -3,9 +3,24 @@
|
|
3
3
|
module Ondotori
|
4
4
|
module WebAPI
|
5
5
|
module Api
|
6
|
-
class
|
7
|
-
def initialize(param
|
6
|
+
class ParamsBase
|
7
|
+
def initialize(param)
|
8
8
|
@param = param
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_ondotori_param
|
12
|
+
params = {}
|
13
|
+
params[Api::Param::API_KEY] = @param.api_key
|
14
|
+
params[Api::Param::LOGIN_ID] = @param.login_id
|
15
|
+
params[Api::Param::LOGIN_PASS] = @param.login_pass
|
16
|
+
|
17
|
+
params
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class CurrentParams < ParamsBase
|
22
|
+
def initialize(param, remote: [], base: [])
|
23
|
+
super(param)
|
9
24
|
|
10
25
|
if remote.length.positive? && base.length.positive?
|
11
26
|
raise Ondotori::WebAPI::Api::Errors::InvaildParameter.new(
|
@@ -17,10 +32,7 @@ module Ondotori
|
|
17
32
|
end
|
18
33
|
|
19
34
|
def to_ondotori_param
|
20
|
-
params =
|
21
|
-
params[Api::Param::API_KEY] = @param.api_key
|
22
|
-
params[Api::Param::LOGIN_ID] = @param.login_id
|
23
|
-
params[Api::Param::LOGIN_PASS] = @param.login_pass
|
35
|
+
params = super
|
24
36
|
params["remote-serial"] = @remote_serial_list if @remote_serial_list.length.positive?
|
25
37
|
params["base-serial"] = @base_serial_list if @base_serial_list.length.positive?
|
26
38
|
|
@@ -28,51 +40,81 @@ module Ondotori
|
|
28
40
|
end
|
29
41
|
end
|
30
42
|
|
31
|
-
class LatestDataParams
|
43
|
+
class LatestDataParams < ParamsBase
|
32
44
|
def initialize(param, serial: "")
|
45
|
+
super(param)
|
33
46
|
if serial.empty?
|
34
47
|
raise Ondotori::WebAPI::Api::Errors::InvaildParameter.new(
|
35
48
|
"latest-data need remote-serial", 9994
|
36
49
|
)
|
37
50
|
end
|
38
|
-
@param = param
|
39
51
|
@remote_serial = serial
|
40
52
|
end
|
41
53
|
|
42
54
|
def to_ondotori_param
|
43
|
-
params =
|
44
|
-
params[Api::Param::API_KEY] = @param.api_key
|
45
|
-
params[Api::Param::LOGIN_ID] = @param.login_id
|
46
|
-
params[Api::Param::LOGIN_PASS] = @param.login_pass
|
55
|
+
params = super
|
47
56
|
params["remote-serial"] = @remote_serial
|
48
57
|
|
49
58
|
params
|
50
59
|
end
|
51
60
|
end
|
52
61
|
|
53
|
-
class LatestDataRTR500Params
|
62
|
+
class LatestDataRTR500Params < ParamsBase
|
54
63
|
def initialize(param, base: "", remote: "")
|
64
|
+
super(param)
|
55
65
|
if base.empty? || remote.empty?
|
56
66
|
raise Ondotori::WebAPI::Api::Errors::InvaildParameter.new(
|
57
67
|
"latest-data-rtr500 need both the baseunit serial and remote unit serial.", 9993
|
58
68
|
)
|
59
69
|
end
|
60
|
-
@param = param
|
61
70
|
@base_serial = base
|
62
71
|
@remote_serial = remote
|
63
72
|
end
|
64
73
|
|
65
74
|
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
|
75
|
+
params = super
|
70
76
|
params["base-serial"] = @base_serial
|
71
77
|
params["remote-serial"] = @remote_serial
|
72
78
|
|
73
79
|
params
|
74
80
|
end
|
75
81
|
end
|
82
|
+
|
83
|
+
class DataParams < ParamsBase
|
84
|
+
def initialize(param, serial, from: nil, to: nil, limit: nil)
|
85
|
+
super(param)
|
86
|
+
validate(serial, from, to, limit)
|
87
|
+
@serial = serial
|
88
|
+
@from = from
|
89
|
+
@to = to
|
90
|
+
@limit = limit.nil? ? 0 : [0, limit].max
|
91
|
+
end
|
92
|
+
|
93
|
+
def validate(serial, from, to, _limit)
|
94
|
+
unless serial.instance_of?(String)
|
95
|
+
raise Ondotori::WebAPI::Api::Errors::InvaildParameter.new(
|
96
|
+
"serial must be String.", 9991
|
97
|
+
)
|
98
|
+
end
|
99
|
+
[from, to].each do |param|
|
100
|
+
next if param.nil? || param.instance_of?(Time)
|
101
|
+
|
102
|
+
raise Ondotori::WebAPI::Api::Errors::InvaildParameter.new(
|
103
|
+
"from and to parameter must be nil or Time.", 9992
|
104
|
+
)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def to_ondotori_param
|
109
|
+
params = super
|
110
|
+
params["remote-serial"] = @serial
|
111
|
+
params["unixtime-from"] = @from.to_i unless @from.nil?
|
112
|
+
params["unixtime-to"] = @to.to_i unless @to.nil?
|
113
|
+
params["number"] = @limit if @limit != 0
|
114
|
+
|
115
|
+
params
|
116
|
+
end
|
117
|
+
end
|
76
118
|
end
|
77
119
|
end
|
78
120
|
end
|
@@ -31,6 +31,13 @@ module Ondotori
|
|
31
31
|
ondotori_response.result
|
32
32
|
end
|
33
33
|
|
34
|
+
def data(serial, from: nil, to: nil, limit: nil)
|
35
|
+
param = Api::DataParams.new(@param, serial, from: from, to: to, limit: limit)
|
36
|
+
response = @web_access.access("#{base_uri}data", param.to_ondotori_param)
|
37
|
+
ondotori_response = Ondotori::WebAPI::Api::Response.new(response)
|
38
|
+
ondotori_response.result
|
39
|
+
end
|
40
|
+
|
34
41
|
def base_uri
|
35
42
|
return @uri unless @uri.empty?
|
36
43
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuya Hatano
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: You can use this gem to get the recorded data from WebStorage.
|
14
14
|
email:
|