tanita-api-client 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -9
- data/CHANGELOG.md +16 -10
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/lib/tanita/api/client.rb +24 -24
- data/lib/tanita/api/client/base.rb +0 -2
- data/lib/tanita/api/client/base_api_client.rb +13 -11
- data/lib/tanita/api/client/base_entity.rb +1 -1
- data/lib/tanita/api/client/configuration.rb +5 -9
- data/lib/tanita/api/client/helpers.rb +1 -1
- data/lib/tanita/api/client/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: 2cb4cedf41e749ea0b6b75bb3477d80e3572ecb38fa39667af9b0aadabcdab11
|
4
|
+
data.tar.gz: 2beef47a5586a8b1fecf0c413d3bd330ee9ca2fb05031620ff85412eb5ec9af9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdd24c58765cff70412a19471edd7a0349a472f180d62bda703756a59d03158e9a804e209cdd05d3c415e10080b5c3155b69e21e2a4b5486db10407321b9f139
|
7
|
+
data.tar.gz: efa02fb10dffbc58efc8009ebf5d98e53da1fe5df5d8ea0e4611bfeea1f6f78fa9115c39b4743931d5654fa18efb11a9b3e10721f00de33cb1fcc4f3b9f933d8
|
data/.rubocop.yml
CHANGED
@@ -23,12 +23,11 @@ Metrics/BlockNesting:
|
|
23
23
|
Max: 2
|
24
24
|
|
25
25
|
Layout/LineLength:
|
26
|
-
|
27
|
-
Enabled: false
|
26
|
+
Max: 120
|
28
27
|
|
29
28
|
Metrics/MethodLength:
|
30
29
|
CountComments: false
|
31
|
-
Max:
|
30
|
+
Max: 20
|
32
31
|
|
33
32
|
Metrics/ParameterLists:
|
34
33
|
Max: 4
|
@@ -39,10 +38,10 @@ Metrics/AbcSize:
|
|
39
38
|
|
40
39
|
Style/CollectionMethods:
|
41
40
|
PreferredMethods:
|
42
|
-
map:
|
43
|
-
reduce:
|
44
|
-
find:
|
45
|
-
find_all:
|
41
|
+
map: "collect"
|
42
|
+
reduce: "inject"
|
43
|
+
find: "detect"
|
44
|
+
find_all: "select"
|
46
45
|
|
47
46
|
Style/Documentation:
|
48
47
|
Enabled: false
|
@@ -60,10 +59,13 @@ Style/ExpandPathArguments:
|
|
60
59
|
Enabled: false
|
61
60
|
|
62
61
|
Style/HashSyntax:
|
63
|
-
EnforcedStyle:
|
62
|
+
EnforcedStyle: ruby19
|
64
63
|
|
65
64
|
Style/Lambda:
|
66
65
|
Enabled: false
|
67
66
|
|
68
67
|
Style/RaiseArgs:
|
69
|
-
EnforcedStyle: compact
|
68
|
+
EnforcedStyle: compact
|
69
|
+
|
70
|
+
Style/AsciiComments:
|
71
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,17 +1,23 @@
|
|
1
|
-
#
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## 0.5.1
|
4
|
+
|
5
|
+
- fix rubocop warnings.
|
6
|
+
|
7
|
+
## 0.5.0
|
2
8
|
|
3
9
|
- refs #12 fix dependencies.
|
4
10
|
|
5
|
-
|
11
|
+
## 0.4.1
|
6
12
|
|
7
13
|
- refs #4 fix settings for simplecov.
|
8
14
|
|
9
|
-
|
15
|
+
## 0.4.0
|
10
16
|
|
11
17
|
- refs #4 measure code coverage
|
12
18
|
- refs #5 setup GitHub Actions for rspec and pushing to RubyGems
|
13
19
|
|
14
|
-
|
20
|
+
## 0.3.0
|
15
21
|
|
16
22
|
changed Result hash to be Object.
|
17
23
|
|
@@ -22,11 +28,11 @@ result.items[0][:weight]
|
|
22
28
|
result.items[0].weight
|
23
29
|
```
|
24
30
|
|
25
|
-
|
31
|
+
## 0.2.3
|
26
32
|
|
27
33
|
remove Gemfile.lock
|
28
34
|
|
29
|
-
|
35
|
+
## 0.2.2
|
30
36
|
|
31
37
|
- define constants
|
32
38
|
- `Tanita::Api::Client::AUTH_URL`
|
@@ -34,12 +40,12 @@ remove Gemfile.lock
|
|
34
40
|
- `Tanita::Api::Client::TOKEN_URL`
|
35
41
|
- `Tanita::Api::Client::TOKEN_URL_PATH`
|
36
42
|
|
37
|
-
|
43
|
+
## 0.2.1
|
38
44
|
|
39
45
|
- rename constant
|
40
46
|
- from `Tanita::Api::Client::HttpHelper::BASE_URL` to `Tanita::Api::Client::BASE_URL`
|
41
47
|
|
42
|
-
|
48
|
+
## 0.2.0
|
43
49
|
|
44
50
|
- set required ruby version to greater than or equal to v2.4
|
45
51
|
- added `data_type` argument in BaseApiClient#initialize
|
@@ -49,11 +55,11 @@ remove Gemfile.lock
|
|
49
55
|
- `@data` to `@items`
|
50
56
|
- `@data[0][:date]` to `@items[0][:measured_at]` or `@items[0][:registered_at]`
|
51
57
|
|
52
|
-
|
58
|
+
## 0.1.1
|
53
59
|
|
54
60
|
- support Tanita::Api::Client.configure
|
55
61
|
- wrote spec
|
56
62
|
|
57
|
-
|
63
|
+
## 0.1.0
|
58
64
|
|
59
65
|
- Initial release
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/lib/tanita/api/client.rb
CHANGED
@@ -35,21 +35,21 @@ module Tanita
|
|
35
35
|
|
36
36
|
def auth_uri
|
37
37
|
params = {
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
38
|
+
client_id: @client_id,
|
39
|
+
redirect_uri: @redirect_uri,
|
40
|
+
scope: @scopes.join(','),
|
41
|
+
response_type: 'code'
|
42
42
|
}
|
43
43
|
generate_uri(AUTH_URL_PATH, params)
|
44
44
|
end
|
45
45
|
|
46
46
|
def exchange_token(auth_code:)
|
47
47
|
params = {
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
48
|
+
client_id: @client_id,
|
49
|
+
client_secret: @client_secret,
|
50
|
+
redirect_uri: DEFAULT_REDIRECT_URI,
|
51
|
+
code: auth_code,
|
52
|
+
grant_type: 'authorization_code'
|
53
53
|
}
|
54
54
|
res = request(TOKEN_URL_PATH, params)
|
55
55
|
token = parse_json(res.body)
|
@@ -76,14 +76,14 @@ module Tanita
|
|
76
76
|
|
77
77
|
def self.properties
|
78
78
|
{
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
79
|
+
weight: {code: '6021', type: Float},
|
80
|
+
body_fat: {code: '6022', type: Float},
|
81
|
+
muscle_mass: {code: '6023', type: Float},
|
82
|
+
physique_rating: {code: '6024', type: Integer},
|
83
|
+
visceral_fat_rating: {code: '6025', type: Float},
|
84
|
+
basal_metabolic_rate: {code: '6027', type: Integer},
|
85
|
+
metabolic_age: {code: '6028', type: Integer},
|
86
|
+
bone_mass: {code: '6029', type: Float}
|
87
87
|
}
|
88
88
|
end
|
89
89
|
end
|
@@ -95,9 +95,9 @@ module Tanita
|
|
95
95
|
|
96
96
|
def self.properties
|
97
97
|
{
|
98
|
-
:
|
99
|
-
:
|
100
|
-
:
|
98
|
+
maximal_pressure: {code: '622E', type: Integer},
|
99
|
+
minimal_pressure: {code: '622F', type: Integer},
|
100
|
+
pulse: {code: '6230', type: Integer}
|
101
101
|
}
|
102
102
|
end
|
103
103
|
end
|
@@ -109,9 +109,9 @@ module Tanita
|
|
109
109
|
|
110
110
|
def self.properties
|
111
111
|
{
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
112
|
+
steps: {code: '6331', type: Integer},
|
113
|
+
exercise: {code: '6335', type: Integer},
|
114
|
+
calories: {code: '6336', type: Integer}
|
115
115
|
}
|
116
116
|
end
|
117
117
|
end
|
@@ -123,7 +123,7 @@ module Tanita
|
|
123
123
|
|
124
124
|
def self.properties
|
125
125
|
{
|
126
|
-
:
|
126
|
+
urinary_sugar: {code: '6240', type: Integer}
|
127
127
|
}
|
128
128
|
end
|
129
129
|
end
|
@@ -26,7 +26,9 @@ module Tanita
|
|
26
26
|
raise Error.new("param:'access_token' is required.'") if @access_token.nil?
|
27
27
|
|
28
28
|
@date_type = date_type
|
29
|
-
|
29
|
+
unless [DATE_TYPE_REGISTERD_AT, DATE_TYPE_MEASURED_AT].include? date_type
|
30
|
+
raise Error.new("param:'date_type' is invalid.'")
|
31
|
+
end
|
30
32
|
|
31
33
|
ClassBuilder.load
|
32
34
|
end
|
@@ -37,9 +39,9 @@ module Tanita
|
|
37
39
|
)
|
38
40
|
tags = self.class.properties.values.map { |i| i[:code] }.join(',')
|
39
41
|
params = {
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
42
|
+
access_token: @access_token,
|
43
|
+
date: @date_type,
|
44
|
+
tag: tags
|
43
45
|
}
|
44
46
|
params[:from] = time_format(from) unless from.nil?
|
45
47
|
params[:to] = time_format(to) unless to.nil?
|
@@ -56,10 +58,10 @@ module Tanita
|
|
56
58
|
def build_result(res)
|
57
59
|
result = parse_json(res.body)
|
58
60
|
Result.new(
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
61
|
+
birth_date: Date.parse(result[:birth_date]),
|
62
|
+
height: result[:height].to_f,
|
63
|
+
sex: result[:sex],
|
64
|
+
items: build_result_items(raw_items: result[:data])
|
63
65
|
)
|
64
66
|
end
|
65
67
|
|
@@ -69,8 +71,8 @@ module Tanita
|
|
69
71
|
date = item[:date]
|
70
72
|
model = item[:model]
|
71
73
|
key = "#{date}_#{model}"
|
72
|
-
property = find_property_by_code(:
|
73
|
-
value = cast(:
|
74
|
+
property = find_property_by_code(code: item[:tag])
|
75
|
+
value = cast(value: item[:keydata], type: property[:type])
|
74
76
|
item_dic[key] ||= {}
|
75
77
|
item_dic[key][date_key] = Time.parse("#{date} +09:00").to_i unless item_dic[key].key? :date
|
76
78
|
item_dic[key][:model] = model unless item_dic[key].key? :model
|
@@ -93,7 +95,7 @@ module Tanita
|
|
93
95
|
|
94
96
|
@property_code_dic = {}
|
95
97
|
self.class.properties.each do |m_name, m_info|
|
96
|
-
@property_code_dic[m_info[:code]] = {:
|
98
|
+
@property_code_dic[m_info[:code]] = {name: m_name, type: m_info[:type]}
|
97
99
|
end
|
98
100
|
@property_code_dic[code]
|
99
101
|
end
|
@@ -4,19 +4,15 @@ module Tanita
|
|
4
4
|
module Api
|
5
5
|
module Client
|
6
6
|
class Configuration
|
7
|
-
# [String]
|
7
|
+
# @return [String]
|
8
8
|
attr_accessor :client_id
|
9
|
-
|
10
|
-
# [String]
|
9
|
+
# @return [String]
|
11
10
|
attr_accessor :client_secret
|
12
|
-
|
13
|
-
# [String]
|
11
|
+
# @return [String]
|
14
12
|
attr_accessor :redirect_uri
|
15
|
-
|
16
|
-
# [String]
|
13
|
+
# @return [String]
|
17
14
|
attr_accessor :access_token
|
18
|
-
|
19
|
-
# [Array<Tanita::Api::Client::Scope>]
|
15
|
+
# @return [Array<Tanita::Api::Client::Scope>]
|
20
16
|
attr_accessor :scopes
|
21
17
|
end
|
22
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tanita-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenji Koshikawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -130,7 +130,7 @@ metadata:
|
|
130
130
|
homepage_uri: https://github.com/koshilife/tanita-api-ruby-client
|
131
131
|
source_code_uri: https://github.com/koshilife/tanita-api-ruby-client
|
132
132
|
changelog_uri: https://github.com/koshilife/tanita-api-ruby-client/blob/master/CHANGELOG.md
|
133
|
-
documentation_uri: https://www.rubydoc.info/gems/tanita-api-client/0.5.
|
133
|
+
documentation_uri: https://www.rubydoc.info/gems/tanita-api-client/0.5.1
|
134
134
|
post_install_message:
|
135
135
|
rdoc_options: []
|
136
136
|
require_paths:
|