fitbit_api 0.16.0 → 0.17.0

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: 84c71b886a0267daec62f3be7c7a4f1b8da73a893cb766b3a0a246089f5bded0
4
- data.tar.gz: f662e151b49f846953dd278676c0bb70d5f473b33ce5727df2a496311f09fcf7
3
+ metadata.gz: 71eacdb0827044b2e9395689f0e0466672d7ff64477f9ffe9c68b2e2059ea06b
4
+ data.tar.gz: ec29770679170f5996d246c008f1537e994e9131c7b8388aa8a27f83652778b3
5
5
  SHA512:
6
- metadata.gz: '03948d366e08835c27d58c128c654c46c8a11ad8eb306de10a8584aae78d0e6c885e9a6ee3e4d4a3a1a60bb45dafe1b807c57649c3dc9eb58af85381845323c3'
7
- data.tar.gz: 6b39da3d88cd2f0440196a9ce52466950892bf25af5e5ecb60a5f9438c0a14d14b48f10cf4b792151b4d23da1e52086ac7767b9a6ad82b7c00ea3cabf1858aa0
6
+ metadata.gz: 16f0aab91afabb265db2f52ba4a8b6b897c952b2f467267d63a9387bbeee266aceaa4a2ea53b40978b8f6ecc7b49f0b02420bb26e15fb0878e1486a5208e6e1f
7
+ data.tar.gz: 3d051c0e8b1022e62bee715119f5747f34282ebd3044a825c5456b67696afc15ec4b8cff175de2397550a20f1ad32040eee6f324194bff949697e65e5ecadbe1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.17.0
2
+ ------
3
+
4
+ - Add ECG endpoint support
5
+ - Add Active Zone Minutes endpoint support
6
+
1
7
  0.16.0
2
8
  ------
3
9
  - Add Sleep Log by Date Range endpoint support
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FitbitAPI
4
- VERSION = '0.16.0'
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.16.0
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.16.0/CHANGELOG.md
123
- documentation_uri: https://www.rubydoc.info/gems/fitbit_api/0.16.0
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: []