fitbit_api 0.15.3 → 0.17.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35ca25eddb9d20edb608f8ba914c32b0056484d730c9b1c671385af4348320f0
4
- data.tar.gz: c79bc99fda06b0f6ad0f2ad321acf371ed619353c13c44d8225efa2263929358
3
+ metadata.gz: 71eacdb0827044b2e9395689f0e0466672d7ff64477f9ffe9c68b2e2059ea06b
4
+ data.tar.gz: ec29770679170f5996d246c008f1537e994e9131c7b8388aa8a27f83652778b3
5
5
  SHA512:
6
- metadata.gz: 5c35f3405ae380230338376184bda00152619b94bbc91a4eba3075b3dee0c4906da2327967733c17fd5cf3097dbf75ff123e6e8c55f15159a4476e4085573a46
7
- data.tar.gz: 5e136456daf9ec21fbb2fd89fb5b8ab001c3a99cce3b51ebd007fd320a79d1dcd530463d51b6976057541c6b39cfe152509c5829a160ac7bf7d9cade23f8c41e
6
+ metadata.gz: 16f0aab91afabb265db2f52ba4a8b6b897c952b2f467267d63a9387bbeee266aceaa4a2ea53b40978b8f6ecc7b49f0b02420bb26e15fb0878e1486a5208e6e1f
7
+ data.tar.gz: 3d051c0e8b1022e62bee715119f5747f34282ebd3044a825c5456b67696afc15ec4b8cff175de2397550a20f1ad32040eee6f324194bff949697e65e5ecadbe1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ 0.17.0
2
+ ------
3
+
4
+ - Add ECG endpoint support
5
+ - Add Active Zone Minutes endpoint support
6
+
7
+ 0.16.0
8
+ ------
9
+ - Add Sleep Log by Date Range endpoint support
10
+
1
11
  0.15.3
2
12
  ------
3
13
  - Use strict encoding for auth tokens
data/README.md CHANGED
@@ -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 | `"1"` |
101
101
  | `unit_system` | The measurement unit system to use for response values | `"en_US"` |
102
102
  | `locale` | The locale to use for response values | `"en_US"` |
103
- | `scope` | A list of permissions being requested (array or space-delimited string) | `%w[activity nutrition profile settings sleep social weight heartrate respiratory_rate oxygen_saturation cardio_fitness temperature]` |
103
+ | `scope` | A list of permissions being requested (array or space-delimited string) | `%w[activity nutrition profile settings sleep social weight heartrate respiratory_rate oxygen_saturation cardio_fitness temperature electrocardiogram]` |
104
104
  | `snake_case_keys` | Transform response payload's keys to snake case format | `false` |
105
105
  | `symbolize_keys` | Transform response payload's keys to symbols | `false` |
106
106
  | `auto_refresh_token` | Automatically refreshes the access token once expired | `true` |
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FitbitAPI
4
+ class Client
5
+ # Returns the daily summary Active Zone Minutes (AZM) values over a specified date range or period.
6
+ #
7
+ # active_zone_minutes_time_series(start_date: Date.parse('2021-04-16'), period: '7d')
8
+ # active_zone_minutes_time_series(start_date: Date.parse('2021-05-18'), end_date: Date.parse('2021-05-24'))
9
+ #
10
+ # @param opts [Hash] The request parameters
11
+ #
12
+ # @option opts :start_date [Date] The start of the date range
13
+ # @option opts :end_date [Date] The end of the date range
14
+ # @option opts :period [String] The range for which data will be returned
15
+
16
+ def active_zone_minutes_time_series(opts = {})
17
+ start_date = opts[:start_date]
18
+ end_date = opts[:end_date] || Date.today
19
+ period = opts[:period]
20
+
21
+ raise FitbitAPI::InvalidArgumentError, 'A start_date or period is required.' if [period, start_date].none?
22
+
23
+ if period && !PERIODS.include?(period)
24
+ raise FitbitAPI::InvalidArgumentError,
25
+ "Invalid period: \"#{period}\". Please provide one of the following: #{PERIODS}."
26
+ end
27
+
28
+ result = if period
29
+ get("user/#{user_id}/activities/active-zone-minutes/date/#{format_date(end_date)}/#{period}.json")
30
+ else
31
+ get("user/#{user_id}/activities/active-zone-minutes/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
32
+ end
33
+
34
+ strip_root_key(result)
35
+ end
36
+
37
+ # Retrieves the Active Zone Minutes (AZM) intraday time series data for a specific date or 24 hour period.
38
+ #
39
+ # @param opts [Hash] The request parameters
40
+ #
41
+ # @option opts :date [Date] The date for which to retrieve the data
42
+ # @option opts :detail_level [String] Number of data poins to include
43
+ # @option opts :start_time [String] The time in the format HH:mm
44
+ # @option opts :end_time [String] The time in the format HH:mm
45
+
46
+ def active_zone_minutes_intraday_time_series(opts = {})
47
+ date = opts[:date] || Date.today
48
+ detail_level = opts[:detail_level]
49
+ start_time = opts[:start_time]
50
+ end_time = opts[:end_time]
51
+
52
+ if [date, detail_level].any?(&:nil?)
53
+ raise FitbitAPI::InvalidArgumentError, 'A date and detail_level are required.'
54
+ end
55
+
56
+ unless %(1min 5min 15min).include? detail_level
57
+ raise FitbitAPI::InvalidArgumentError,
58
+ "Invalid detail_level: \"#{detail_level}\". Please provide one of the following: \"1min\", \"5min\" or \"15min\"."
59
+ end
60
+
61
+ if (start_time || end_time) && !(start_time && end_time)
62
+ raise FitbitAPI::InvalidArgumentError, 'Both start_time and end_time are required if time is being specified.'
63
+ end
64
+
65
+ path = "user/#{user_id}/activities/active-zone-minutes/date/#{format_date(date)}/1d/#{detail_level}"
66
+ path += "/time/#{format_time(start_time)}/#{format_time(end_time)}" if start_time && end_time
67
+
68
+ get("#{path}.json")
69
+ end
70
+ end
71
+ end
@@ -19,7 +19,7 @@ module FitbitAPI
19
19
  define_setting :locale, 'en_US'
20
20
  define_setting :scope, %w[activity nutrition profile settings sleep social weight
21
21
  heartrate respiratory_rate oxygen_saturation cardio_fitness
22
- temperature]
22
+ temperature electrocardiogram]
23
23
 
24
24
  define_setting :api_version, '1'
25
25
 
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'fitbit_api/base'
4
+ require 'fitbit_api/active_zone_minutes'
4
5
  require 'fitbit_api/activities'
5
6
  require 'fitbit_api/breathing_rate'
6
7
  require 'fitbit_api/cardio_score'
8
+ require 'fitbit_api/electrocardiogram'
7
9
  require 'fitbit_api/heart_rate'
8
10
  require 'fitbit_api/heart_rate_variability'
9
11
  require 'fitbit_api/goals'
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FitbitAPI
4
+ class Client
5
+ # This endpoint retrieves a list of the user's Electrocardiogram
6
+ # (ECG) log entries before or after a given day.
7
+ #
8
+ # ecg_logs_list(before_date: Date.parse('2021-05-24'), limit: 5)
9
+ #
10
+ # @param params [Hash] The request parameters
11
+ #
12
+ # @option params :before_date [Date] Specify when filtering entries that occured before the given date
13
+ # @option params :after_date [Date] Specify when filtering entries that occured after the given date
14
+ # @option params :sort [String] the Sort order of entries by date (asc or desc)
15
+ # @option params :offset [Integer] The offset number of entries. Must always be 0
16
+ # @option params :limit [Integer] The max of the number of entries returned (max: 10)
17
+
18
+ def ecg_logs_list(params = {})
19
+ default_params = { before_date: Date.today, after_date: nil, sort: 'desc', limit: 10, offset: 0 }
20
+ get("user/#{user_id}/ecg/list.json", default_params.merge(params))
21
+ end
22
+ end
23
+ end
@@ -15,6 +15,25 @@ module FitbitAPI
15
15
  get("user/#{user_id}/sleep/date/#{format_date(date)}.json")
16
16
  end
17
17
 
18
+ # Returns a list of a user's sleep log entries for a given date range. The data returned for either date
19
+ # can include a sleep period that ended that date but began on the previous date. For example, if you
20
+ # request a Sleep Log between 2021-12-22 and 2021-12-26, it may return log entries that span 2021-12-21
21
+ # and 2021-12-22, as well as 2021-12-25 and 2021-12-26.
22
+ #
23
+ # @param opts [Hash] The request options
24
+ #
25
+ # @option opts :start_date [Date] The start of the date range
26
+ # @option opts :end_date [Date] The end of the date range
27
+
28
+ def sleep_logs_by_date_range(opts = {})
29
+ start_date = opts[:start_date]
30
+ end_date = opts[:end_date]
31
+
32
+ raise FitbitAPI::InvalidArgumentError, 'A start_date and end_date are required.' unless start_date && end_date
33
+
34
+ get("user/#{user_id}/sleep/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
35
+ end
36
+
18
37
  # Returns a list of a user's sleep log entries before or after a given date, and specifying offset,
19
38
  # limit and sort order. The data returned for different dates can include sleep periods that began
20
39
  # on the previous date. For example, a sleep log entry for 2018-10-21 may have ended that day but
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FitbitAPI
4
- VERSION = '0.15.3'
4
+ VERSION = '0.17.0'
5
5
  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.15.3
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zoran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-19 00:00:00.000000000 Z
11
+ date: 2023-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -90,6 +90,7 @@ files:
90
90
  - LICENSE.txt
91
91
  - README.md
92
92
  - lib/fitbit_api.rb
93
+ - lib/fitbit_api/active_zone_minutes.rb
93
94
  - lib/fitbit_api/activities.rb
94
95
  - lib/fitbit_api/alarms.rb
95
96
  - lib/fitbit_api/base.rb
@@ -98,6 +99,7 @@ files:
98
99
  - lib/fitbit_api/cardio_score.rb
99
100
  - lib/fitbit_api/client.rb
100
101
  - lib/fitbit_api/devices.rb
102
+ - lib/fitbit_api/electrocardiogram.rb
101
103
  - lib/fitbit_api/food.rb
102
104
  - lib/fitbit_api/friends.rb
103
105
  - lib/fitbit_api/goals.rb
@@ -119,8 +121,8 @@ licenses:
119
121
  - MIT
120
122
  metadata:
121
123
  source_code_uri: https://github.com/zokioki/fitbit_api
122
- changelog_uri: https://github.com/zokioki/fitbit_api/blob/v0.15.3/CHANGELOG.md
123
- documentation_uri: https://www.rubydoc.info/gems/fitbit_api/0.15.3
124
+ changelog_uri: https://github.com/zokioki/fitbit_api/blob/v0.17.0/CHANGELOG.md
125
+ documentation_uri: https://www.rubydoc.info/gems/fitbit_api/0.17.0
124
126
  rubygems_mfa_required: 'true'
125
127
  post_install_message:
126
128
  rdoc_options: []