fitbit_api 0.13.0 → 0.14.1

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: '03139ae4b7cbf7a8243f05b155cd4795c4dd2d3f02b86adadc27cebed83be9d8'
4
- data.tar.gz: 9d2396e266cfa26e8e869e492c74d37605065eecb743ee5e8a64d59a1a13c8bb
3
+ metadata.gz: 35736e8dc53586ada210b2dc0431c619eed07d79001e5211283561f3922a2a2d
4
+ data.tar.gz: 36001c0eceb88dac465f1eabe2af276b009e504eef1ad39cdbcb105077b51df0
5
5
  SHA512:
6
- metadata.gz: 65750c1625faf8f7118120f8db01e1a80438baa496cce74c10aa6bc920692899595ad91973ecea3a1e63ffbb7d5b454f7f40f6433d2b1f08fdae40df4b4580ec
7
- data.tar.gz: 95db8df54a789b5ab0a1fdfa1a8906d7d8d4818d9af4fe33f41fcd5a156bd3fd90006bd927c233cee67f0714eeabbd41d5162a6b7171f2ef40d03b73774cf9e8
6
+ metadata.gz: 114303eb86c474c7e5e8c7338d5ff40e0febfb2c56fd85988cadd1a87c26babb535fa0829692f2582505f99e0a5434dae557f91b5a2a09f0be5ef06495db520d
7
+ data.tar.gz: 67594641c25ca473c4aa0edb6f96a84616805a0b1fbd4272483645d3e0f167d05be2412ae4b0fa996a1ceab88387b8701d1466bef554226ca3ee0d3fa134e1f5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ 0.14.1
2
+ ------
3
+ - Add documentation for several methods
4
+
5
+ 0.14.0
6
+ ------
7
+ - Add support for the following endpoints:
8
+ - Breathing Rate
9
+ - Oxygen Saturation (SpO2)
10
+ - Cardio Score (VO2 Max)
11
+ - Heart Rate Variability
12
+ - Temperature (Core & Skin)
13
+
1
14
  0.13.0
2
15
  ------
3
16
  - 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://badge.fury.io/rb/fitbit_api.svg)](https://badge.fury.io/rb/fitbit_api)
4
- [![Test Workflow](https://github.com/zokioki/fitbit_api/actions/workflows/test.yml/badge.svg)](https://github.com/zokioki/fitbit_api/actions/workflows/test.yml)
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) |
@@ -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,73 @@
1
+ module FitbitAPI
2
+ class Client
3
+ # Returns the average breathing rate data for a given date or date range.
4
+ # If both a date and a date range are given, the date range takes precedence.
5
+ #
6
+ # breathing_rate_summary(date: Date.parse('2021-04-16'))
7
+ # breathing_rate_summary(start_date: Date.parse('2021-05-18'), end_date: Date.parse('2021-05-24'))
8
+ #
9
+ # @param params [Hash] The request parameters
10
+ #
11
+ # @option params :date [Date] The target date
12
+ # @option params :start_date [Date] The start of the date range
13
+ # @option params :end_date [Date] The end of the date range
14
+
15
+ def breathing_rate_summary(opts={})
16
+ date = opts[:date] || Date.today
17
+ start_date = opts[:start_date]
18
+ end_date = opts[:end_date]
19
+
20
+ if start_date && !end_date
21
+ end_date = Date.today
22
+ end
23
+
24
+ unless date || start_date
25
+ raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
26
+ end
27
+
28
+ if start_date
29
+ result = get("user/#{user_id}/br/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
30
+ else
31
+ result = get("user/#{user_id}/br/date/#{format_date(date)}.json")
32
+ end
33
+
34
+ # remove root key from response
35
+ result.values[0]
36
+ end
37
+
38
+ # Returns the intraday breathing rate data for a given date or date range.
39
+ # If both a date and a date range are given, the date range takes precedence.
40
+ #
41
+ # breathing_rate_intraday(date: Date.parse('2021-04-16'))
42
+ # breathing_rate_intraday(start_date: Date.parse('2021-05-18'), end_date: Date.parse('2021-05-24'))
43
+ #
44
+ # @param params [Hash] The request parameters
45
+ #
46
+ # @option params :date [Date] The target date
47
+ # @option params :start_date [Date] The start of the date range
48
+ # @option params :end_date [Date] The end of the date range
49
+
50
+ def breathing_rate_intraday(opts={})
51
+ date = opts[:date] || Date.today
52
+ start_date = opts[:start_date]
53
+ end_date = opts[:end_date]
54
+
55
+ if start_date && !end_date
56
+ end_date = Date.today
57
+ end
58
+
59
+ unless date || start_date
60
+ raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
61
+ end
62
+
63
+ if start_date
64
+ result = get("user/#{user_id}/br/date/#{format_date(start_date)}/#{format_date(end_date)}/all.json")
65
+ else
66
+ result = get("user/#{user_id}/br/date/#{format_date(date)}/all.json")
67
+ end
68
+
69
+ # remove root key from response
70
+ result.values[0]
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,38 @@
1
+ module FitbitAPI
2
+ class Client
3
+ # Returns the cardio fitness score data for a given date or date range.
4
+ # If both a date and a date range are given, the date range takes precedence.
5
+ #
6
+ # cardio_score_summary(date: Date.parse('2021-04-16'))
7
+ # cardio_score_summary(start_date: Date.parse('2021-05-18'), end_date: Date.parse('2021-05-24'))
8
+ #
9
+ # @param params [Hash] The request parameters
10
+ #
11
+ # @option params :date [Date] The target date
12
+ # @option params :start_date [Date] The start of the date range
13
+ # @option params :end_date [Date] The end of the date range
14
+
15
+ def cardio_score_summary(opts={})
16
+ date = opts[:date] || Date.today
17
+ start_date = opts[:start_date]
18
+ end_date = opts[:end_date]
19
+
20
+ if start_date && !end_date
21
+ end_date = Date.today
22
+ end
23
+
24
+ unless date || start_date
25
+ raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
26
+ end
27
+
28
+ if start_date
29
+ result = get("user/#{user_id}/cardioscore/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
30
+ else
31
+ result = get("user/#{user_id}/cardioscore/date/#{format_date(date)}.json")
32
+ end
33
+
34
+ # remove root key from response
35
+ result.values[0]
36
+ end
37
+ end
38
+ end
@@ -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,73 @@
1
+ module FitbitAPI
2
+ class Client
3
+ # Returns the heart rate variability data for a given date or date range.
4
+ # If both a date and a date range are given, the date range takes precedence.
5
+ #
6
+ # heart_rate_variability_summary(date: Date.parse('2021-04-16'))
7
+ # heart_rate_variability_summary(start_date: Date.parse('2021-05-18'), end_date: Date.parse('2021-05-24'))
8
+ #
9
+ # @param params [Hash] The request parameters
10
+ #
11
+ # @option params :date [Date] The target date
12
+ # @option params :start_date [Date] The start of the date range
13
+ # @option params :end_date [Date] The end of the date range
14
+
15
+ def heart_rate_variability_summary(opts={})
16
+ date = opts[:date] || Date.today
17
+ start_date = opts[:start_date]
18
+ end_date = opts[:end_date]
19
+
20
+ if start_date && !end_date
21
+ end_date = Date.today
22
+ end
23
+
24
+ unless date || start_date
25
+ raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
26
+ end
27
+
28
+ if start_date
29
+ result = get("user/#{user_id}/hrv/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
30
+ else
31
+ result = get("user/#{user_id}/hrv/date/#{format_date(date)}.json")
32
+ end
33
+
34
+ # remove root key from response
35
+ result.values[0]
36
+ end
37
+
38
+ # Returns the heart rate variability intraday data for a given date or date range.
39
+ # If both a date and a date range are given, the date range takes precedence.
40
+ #
41
+ # heart_rate_variability_intraday(date: Date.parse('2021-04-16'))
42
+ # heart_rate_variability_intraday(start_date: Date.parse('2021-05-18'), end_date: Date.parse('2021-05-24'))
43
+ #
44
+ # @param params [Hash] The request parameters
45
+ #
46
+ # @option params :date [Date] The target date
47
+ # @option params :start_date [Date] The start of the date range
48
+ # @option params :end_date [Date] The end of the date range
49
+
50
+ def heart_rate_variability_intraday(opts={})
51
+ date = opts[:date] || Date.today
52
+ start_date = opts[:start_date]
53
+ end_date = opts[:end_date]
54
+
55
+ if start_date && !end_date
56
+ end_date = Date.today
57
+ end
58
+
59
+ unless date || start_date
60
+ raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
61
+ end
62
+
63
+ if start_date
64
+ result = get("user/#{user_id}/hrv/date/#{format_date(start_date)}/#{format_date(end_date)}/all.json")
65
+ else
66
+ result = get("user/#{user_id}/hrv/date/#{format_date(date)}/all.json")
67
+ end
68
+
69
+ # remove root key from response
70
+ result.values[0]
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,67 @@
1
+ module FitbitAPI
2
+ class Client
3
+ # Returns the oxygen saturation summary data for a given date or date range.
4
+ # If both a date and a date range are given, the date range takes precedence.
5
+ #
6
+ # oxygen_saturation_summary(date: Date.parse('2021-04-16'))
7
+ # oxygen_saturation_summary(start_date: Date.parse('2021-05-18'), end_date: Date.parse('2021-05-24'))
8
+ #
9
+ # @param params [Hash] The request parameters
10
+ #
11
+ # @option params :date [Date] The target date
12
+ # @option params :start_date [Date] The start of the date range
13
+ # @option params :end_date [Date] The end of the date range
14
+
15
+ def oxygen_saturation_summary(opts={})
16
+ date = opts[:date] || Date.today
17
+ start_date = opts[:start_date]
18
+ end_date = opts[:end_date]
19
+
20
+ if start_date && !end_date
21
+ end_date = Date.today
22
+ end
23
+
24
+ unless date || start_date
25
+ raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
26
+ end
27
+
28
+ if start_date
29
+ get("user/#{user_id}/spo2/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
30
+ else
31
+ get("user/#{user_id}/spo2/date/#{format_date(date)}.json")
32
+ end
33
+ end
34
+
35
+ # Returns the oxygen saturation intraday data for a given date or date range.
36
+ # If both a date and a date range are given, the date range takes precedence.
37
+ #
38
+ # oxygen_saturation_intraday(date: Date.parse('2021-04-16'))
39
+ # oxygen_saturation_intraday(start_date: Date.parse('2021-05-18'), end_date: Date.parse('2021-05-24'))
40
+ #
41
+ # @param params [Hash] The request parameters
42
+ #
43
+ # @option params :date [Date] The target date
44
+ # @option params :start_date [Date] The start of the date range
45
+ # @option params :end_date [Date] The end of the date range
46
+
47
+ def oxygen_saturation_intraday(opts={})
48
+ date = opts[:date] || Date.today
49
+ start_date = opts[:start_date]
50
+ end_date = opts[:end_date]
51
+
52
+ if start_date && !end_date
53
+ end_date = Date.today
54
+ end
55
+
56
+ unless date || start_date
57
+ raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
58
+ end
59
+
60
+ if start_date
61
+ get("user/#{user_id}/spo2/date/#{format_date(start_date)}/#{format_date(end_date)}/all.json")
62
+ else
63
+ get("user/#{user_id}/spo2/date/#{format_date(date)}/all.json")
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,73 @@
1
+ module FitbitAPI
2
+ class Client
3
+ # Returns the core temperature data for a given date or date range.
4
+ # If both a date and a date range are given, the date range takes precedence.
5
+ #
6
+ # core_temperature_summary(date: Date.parse('2021-04-16'))
7
+ # core_temperature_summary(start_date: Date.parse('2021-05-18'), end_date: Date.parse('2021-05-24'))
8
+ #
9
+ # @param params [Hash] The request parameters
10
+ #
11
+ # @option params :date [Date] The target date
12
+ # @option params :start_date [Date] The start of the date range
13
+ # @option params :end_date [Date] The end of the date range
14
+
15
+ def core_temperature_summary(opts={})
16
+ date = opts[:date] || Date.today
17
+ start_date = opts[:start_date]
18
+ end_date = opts[:end_date]
19
+
20
+ if start_date && !end_date
21
+ end_date = Date.today
22
+ end
23
+
24
+ unless date || start_date
25
+ raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
26
+ end
27
+
28
+ if start_date
29
+ result = get("user/#{user_id}/temp/core/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
30
+ else
31
+ result = get("user/#{user_id}/temp/core/date/#{format_date(date)}.json")
32
+ end
33
+
34
+ # remove root key from response
35
+ result.values[0]
36
+ end
37
+
38
+ # Returns the skin temperature data for a given date or date range.
39
+ # If both a date and a date range are given, the date range takes precedence.
40
+ #
41
+ # skin_temperature_summary(date: Date.parse('2021-04-16'))
42
+ # skin_temperature_summary(start_date: Date.parse('2021-05-18'), end_date: Date.parse('2021-05-24'))
43
+ #
44
+ # @param params [Hash] The request parameters
45
+ #
46
+ # @option params :date [Date] The target date
47
+ # @option params :start_date [Date] The start of the date range
48
+ # @option params :end_date [Date] The end of the date range
49
+
50
+ def skin_temperature_summary(opts={})
51
+ date = opts[:date] || Date.today
52
+ start_date = opts[:start_date]
53
+ end_date = opts[:end_date]
54
+
55
+ if start_date && !end_date
56
+ end_date = Date.today
57
+ end
58
+
59
+ unless date || start_date
60
+ raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
61
+ end
62
+
63
+ if start_date
64
+ result = get("user/#{user_id}/temp/skin/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
65
+ else
66
+ result = get("user/#{user_id}/temp/skin/date/#{format_date(date)}.json")
67
+ end
68
+
69
+ # remove root key from response
70
+ result.values[0]
71
+ end
72
+ end
73
+ end
@@ -1,3 +1,3 @@
1
1
  module FitbitAPI
2
- VERSION = '0.13.0'
2
+ VERSION = '0.14.1'
3
3
  end
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.13.0
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zoran
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-31 00:00:00.000000000 Z
11
+ date: 2022-11-06 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