fitbit_api 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +3 -3
- data/lib/fitbit_api/base.rb +1 -1
- data/lib/fitbit_api/breathing_rate.rb +49 -0
- data/lib/fitbit_api/cardio_score.rb +26 -0
- data/lib/fitbit_api/client.rb +5 -0
- data/lib/fitbit_api/heart_rate_variability.rb +49 -0
- data/lib/fitbit_api/oxygen_saturation.rb +43 -0
- data/lib/fitbit_api/temperature.rb +49 -0
- data/lib/fitbit_api/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32eab4ca789fa776fe5d1ddacf58dd51f43d01d12c049b2b4c5080c5969f902d
|
4
|
+
data.tar.gz: 4f83878440ed7f152f5a5eb3d101447972847c578adaf05b704d201565513189
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de894373c47758b4c7530ce3a4559a8284f3c2e2390f3925841015bced821a2c9370657199c527ac9a5416a597019c3bcf1d3a8dcb135fc0bda875aae4baea77
|
7
|
+
data.tar.gz: 3c03846f5f25e1117a88acbfb09e78903ec425deb663e7371154cbc3e57b8a70d43f17c5171bf41ee9c19a584fa932ad009a2171c1a2458637f01893c7b7e013
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
0.14.0
|
2
|
+
------
|
3
|
+
- Add support for the following endpoints:
|
4
|
+
- Breathing Rate
|
5
|
+
- Oxygen Saturation (SpO2)
|
6
|
+
- Cardio Score (VO2 Max)
|
7
|
+
- Heart Rate Variability
|
8
|
+
- Temperature (Core & Skin)
|
9
|
+
|
1
10
|
0.13.0
|
2
11
|
------
|
3
12
|
- Add support for token revocation via `revoke_token!`.
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# FitbitAPI
|
2
2
|
|
3
|
-
[![Gem Version](https://
|
4
|
-
[![Test Workflow](https://
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/fitbit_api)](https://rubygems.org/gems/fitbit_api)
|
4
|
+
[![Test Workflow](https://img.shields.io/github/workflow/status/zokioki/fitbit_api/Test)](https://github.com/zokioki/fitbit_api/actions/workflows/test.yml)
|
5
5
|
|
6
6
|
FitbitAPI provides a Ruby interface to the [Fitbit Web API](https://dev.fitbit.com/reference/web-api).
|
7
7
|
|
@@ -100,7 +100,7 @@ When initializing a `FitbitAPI::Client` instance, you're given access to a handf
|
|
100
100
|
| api_version | API version to be used when making requests (default: "1") |
|
101
101
|
| unit_system | The measurement unit system to use for response values (default: "en_US") |
|
102
102
|
| locale | The locale to use for response values (default: "en_US") |
|
103
|
-
| scope | A space-delimited list of permissions being requested (default: "activity nutrition profile settings sleep social weight heartrate") |
|
103
|
+
| scope | A space-delimited list of permissions being requested (default: "activity nutrition profile settings sleep social weight heartrate respiratory_rate oxygen_saturation cardio_fitness temperature") |
|
104
104
|
| snake_case_keys | Transform response payload's keys to snake case format (default: false) |
|
105
105
|
| symbolize_keys | Transform response payload's keys to symbols (default: false) |
|
106
106
|
| auto_refresh_token | Automatically refreshes the access token once expired (default: true) |
|
data/lib/fitbit_api/base.rb
CHANGED
@@ -15,7 +15,7 @@ module FitbitAPI
|
|
15
15
|
|
16
16
|
define_setting :unit_system, 'en_US'
|
17
17
|
define_setting :locale, 'en_US'
|
18
|
-
define_setting :scope, 'activity nutrition profile settings sleep social weight heartrate'
|
18
|
+
define_setting :scope, 'activity nutrition profile settings sleep social weight heartrate respiratory_rate oxygen_saturation cardio_fitness temperature'
|
19
19
|
|
20
20
|
define_setting :api_version, '1'
|
21
21
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module FitbitAPI
|
2
|
+
class Client
|
3
|
+
def breathing_rate_summary(opts={})
|
4
|
+
date = opts[:date] || Date.today
|
5
|
+
start_date = opts[:start_date]
|
6
|
+
end_date = opts[:end_date]
|
7
|
+
|
8
|
+
if start_date && !end_date
|
9
|
+
end_date = Date.today
|
10
|
+
end
|
11
|
+
|
12
|
+
unless date || start_date
|
13
|
+
raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
|
14
|
+
end
|
15
|
+
|
16
|
+
if start_date
|
17
|
+
result = get("user/#{user_id}/br/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
|
18
|
+
else
|
19
|
+
result = get("user/#{user_id}/br/date/#{format_date(date)}.json")
|
20
|
+
end
|
21
|
+
|
22
|
+
# remove root key from response
|
23
|
+
result.values[0]
|
24
|
+
end
|
25
|
+
|
26
|
+
def breathing_rate_intraday(opts={})
|
27
|
+
date = opts[:date] || Date.today
|
28
|
+
start_date = opts[:start_date]
|
29
|
+
end_date = opts[:end_date]
|
30
|
+
|
31
|
+
if start_date && !end_date
|
32
|
+
end_date = Date.today
|
33
|
+
end
|
34
|
+
|
35
|
+
unless date || start_date
|
36
|
+
raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
|
37
|
+
end
|
38
|
+
|
39
|
+
if start_date
|
40
|
+
result = get("user/#{user_id}/br/date/#{format_date(start_date)}/#{format_date(end_date)}/all.json")
|
41
|
+
else
|
42
|
+
result = get("user/#{user_id}/br/date/#{format_date(date)}/all.json")
|
43
|
+
end
|
44
|
+
|
45
|
+
# remove root key from response
|
46
|
+
result.values[0]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module FitbitAPI
|
2
|
+
class Client
|
3
|
+
def cardio_score_summary(opts={})
|
4
|
+
date = opts[:date] || Date.today
|
5
|
+
start_date = opts[:start_date]
|
6
|
+
end_date = opts[:end_date]
|
7
|
+
|
8
|
+
if start_date && !end_date
|
9
|
+
end_date = Date.today
|
10
|
+
end
|
11
|
+
|
12
|
+
unless date || start_date
|
13
|
+
raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
|
14
|
+
end
|
15
|
+
|
16
|
+
if start_date
|
17
|
+
result = get("user/#{user_id}/cardioscore/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
|
18
|
+
else
|
19
|
+
result = get("user/#{user_id}/cardioscore/date/#{format_date(date)}.json")
|
20
|
+
end
|
21
|
+
|
22
|
+
# remove root key from response
|
23
|
+
result.values[0]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/fitbit_api/client.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'fitbit_api/base'
|
2
2
|
require 'fitbit_api/activities'
|
3
|
+
require 'fitbit_api/breathing_rate'
|
4
|
+
require 'fitbit_api/cardio_score'
|
3
5
|
require 'fitbit_api/heart_rate'
|
6
|
+
require 'fitbit_api/heart_rate_variability'
|
4
7
|
require 'fitbit_api/goals'
|
5
8
|
require 'fitbit_api/alarms'
|
6
9
|
require 'fitbit_api/body'
|
@@ -8,8 +11,10 @@ require 'fitbit_api/devices'
|
|
8
11
|
require 'fitbit_api/food'
|
9
12
|
require 'fitbit_api/friends'
|
10
13
|
require 'fitbit_api/meals'
|
14
|
+
require 'fitbit_api/oxygen_saturation'
|
11
15
|
require 'fitbit_api/sleep'
|
12
16
|
require 'fitbit_api/subscriptions'
|
17
|
+
require 'fitbit_api/temperature'
|
13
18
|
require 'fitbit_api/user'
|
14
19
|
require 'fitbit_api/water'
|
15
20
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module FitbitAPI
|
2
|
+
class Client
|
3
|
+
def heart_rate_variability_summary(opts={})
|
4
|
+
date = opts[:date] || Date.today
|
5
|
+
start_date = opts[:start_date]
|
6
|
+
end_date = opts[:end_date]
|
7
|
+
|
8
|
+
if start_date && !end_date
|
9
|
+
end_date = Date.today
|
10
|
+
end
|
11
|
+
|
12
|
+
unless date || start_date
|
13
|
+
raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
|
14
|
+
end
|
15
|
+
|
16
|
+
if start_date
|
17
|
+
result = get("user/#{user_id}/hrv/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
|
18
|
+
else
|
19
|
+
result = get("user/#{user_id}/hrv/date/#{format_date(date)}.json")
|
20
|
+
end
|
21
|
+
|
22
|
+
# remove root key from response
|
23
|
+
result.values[0]
|
24
|
+
end
|
25
|
+
|
26
|
+
def heart_rate_variability_intraday(opts={})
|
27
|
+
date = opts[:date] || Date.today
|
28
|
+
start_date = opts[:start_date]
|
29
|
+
end_date = opts[:end_date]
|
30
|
+
|
31
|
+
if start_date && !end_date
|
32
|
+
end_date = Date.today
|
33
|
+
end
|
34
|
+
|
35
|
+
unless date || start_date
|
36
|
+
raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
|
37
|
+
end
|
38
|
+
|
39
|
+
if start_date
|
40
|
+
result = get("user/#{user_id}/hrv/date/#{format_date(start_date)}/#{format_date(end_date)}/all.json")
|
41
|
+
else
|
42
|
+
result = get("user/#{user_id}/hrv/date/#{format_date(date)}/all.json")
|
43
|
+
end
|
44
|
+
|
45
|
+
# remove root key from response
|
46
|
+
result.values[0]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module FitbitAPI
|
2
|
+
class Client
|
3
|
+
def oxygen_saturation_summary(opts={})
|
4
|
+
date = opts[:date] || Date.today
|
5
|
+
start_date = opts[:start_date]
|
6
|
+
end_date = opts[:end_date]
|
7
|
+
|
8
|
+
if start_date && !end_date
|
9
|
+
end_date = Date.today
|
10
|
+
end
|
11
|
+
|
12
|
+
unless date || start_date
|
13
|
+
raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
|
14
|
+
end
|
15
|
+
|
16
|
+
if start_date
|
17
|
+
get("user/#{user_id}/spo2/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
|
18
|
+
else
|
19
|
+
get("user/#{user_id}/spo2/date/#{format_date(date)}.json")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def oxygen_saturation_intraday(opts={})
|
24
|
+
date = opts[:date] || Date.today
|
25
|
+
start_date = opts[:start_date]
|
26
|
+
end_date = opts[:end_date]
|
27
|
+
|
28
|
+
if start_date && !end_date
|
29
|
+
end_date = Date.today
|
30
|
+
end
|
31
|
+
|
32
|
+
unless date || start_date
|
33
|
+
raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
|
34
|
+
end
|
35
|
+
|
36
|
+
if start_date
|
37
|
+
get("user/#{user_id}/spo2/date/#{format_date(start_date)}/#{format_date(end_date)}/all.json")
|
38
|
+
else
|
39
|
+
get("user/#{user_id}/spo2/date/#{format_date(date)}/all.json")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module FitbitAPI
|
2
|
+
class Client
|
3
|
+
def core_temperature_summary(opts={})
|
4
|
+
date = opts[:date] || Date.today
|
5
|
+
start_date = opts[:start_date]
|
6
|
+
end_date = opts[:end_date]
|
7
|
+
|
8
|
+
if start_date && !end_date
|
9
|
+
end_date = Date.today
|
10
|
+
end
|
11
|
+
|
12
|
+
unless date || start_date
|
13
|
+
raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
|
14
|
+
end
|
15
|
+
|
16
|
+
if start_date
|
17
|
+
result = get("user/#{user_id}/temp/core/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
|
18
|
+
else
|
19
|
+
result = get("user/#{user_id}/temp/core/date/#{format_date(date)}.json")
|
20
|
+
end
|
21
|
+
|
22
|
+
# remove root key from response
|
23
|
+
result.values[0]
|
24
|
+
end
|
25
|
+
|
26
|
+
def skin_temperature_summary(opts={})
|
27
|
+
date = opts[:date] || Date.today
|
28
|
+
start_date = opts[:start_date]
|
29
|
+
end_date = opts[:end_date]
|
30
|
+
|
31
|
+
if start_date && !end_date
|
32
|
+
end_date = Date.today
|
33
|
+
end
|
34
|
+
|
35
|
+
unless date || start_date
|
36
|
+
raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
|
37
|
+
end
|
38
|
+
|
39
|
+
if start_date
|
40
|
+
result = get("user/#{user_id}/temp/skin/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
|
41
|
+
else
|
42
|
+
result = get("user/#{user_id}/temp/skin/date/#{format_date(date)}.json")
|
43
|
+
end
|
44
|
+
|
45
|
+
# remove root key from response
|
46
|
+
result.values[0]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/fitbit_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fitbit_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zoran
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|
@@ -100,18 +100,23 @@ files:
|
|
100
100
|
- lib/fitbit_api/alarms.rb
|
101
101
|
- lib/fitbit_api/base.rb
|
102
102
|
- lib/fitbit_api/body.rb
|
103
|
+
- lib/fitbit_api/breathing_rate.rb
|
104
|
+
- lib/fitbit_api/cardio_score.rb
|
103
105
|
- lib/fitbit_api/client.rb
|
104
106
|
- lib/fitbit_api/devices.rb
|
105
107
|
- lib/fitbit_api/food.rb
|
106
108
|
- lib/fitbit_api/friends.rb
|
107
109
|
- lib/fitbit_api/goals.rb
|
108
110
|
- lib/fitbit_api/heart_rate.rb
|
111
|
+
- lib/fitbit_api/heart_rate_variability.rb
|
109
112
|
- lib/fitbit_api/helpers/configuration.rb
|
110
113
|
- lib/fitbit_api/helpers/exceptions.rb
|
111
114
|
- lib/fitbit_api/helpers/utils.rb
|
112
115
|
- lib/fitbit_api/meals.rb
|
116
|
+
- lib/fitbit_api/oxygen_saturation.rb
|
113
117
|
- lib/fitbit_api/sleep.rb
|
114
118
|
- lib/fitbit_api/subscriptions.rb
|
119
|
+
- lib/fitbit_api/temperature.rb
|
115
120
|
- lib/fitbit_api/user.rb
|
116
121
|
- lib/fitbit_api/version.rb
|
117
122
|
- lib/fitbit_api/water.rb
|