fitbit_api 0.16.0 → 0.17.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: 84c71b886a0267daec62f3be7c7a4f1b8da73a893cb766b3a0a246089f5bded0
4
- data.tar.gz: f662e151b49f846953dd278676c0bb70d5f473b33ce5727df2a496311f09fcf7
3
+ metadata.gz: 69af80fbdb9af28b9eb94f8eb53627586f4a37fd5761dc761e60487f275be752
4
+ data.tar.gz: 22cff0c61fb2679040f643f09b5a62200d17bc94a7e64b9b00fe57c7e05f9b05
5
5
  SHA512:
6
- metadata.gz: '03948d366e08835c27d58c128c654c46c8a11ad8eb306de10a8584aae78d0e6c885e9a6ee3e4d4a3a1a60bb45dafe1b807c57649c3dc9eb58af85381845323c3'
7
- data.tar.gz: 6b39da3d88cd2f0440196a9ce52466950892bf25af5e5ecb60a5f9438c0a14d14b48f10cf4b792151b4d23da1e52086ac7767b9a6ad82b7c00ea3cabf1858aa0
6
+ metadata.gz: bbf0efb4eda29415684a74c762782306325364b5ed582c8d457d2d6c1c7c8bea3e3d7df76b5818ac088e5e6202bf78ea39567fa8c4e6b100b14874c1d22d08c9
7
+ data.tar.gz: d29e794b7af47d27d1a0cc818ab20a70959106d4cb5d534c6f82d9638a4328ce25f091159ae741cd292829164a6b9a42bc7ff9864e1caee5068f4f7dd072d41f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ 0.17.1
2
+ ------
3
+ - Some internal cleanup
4
+
5
+ 0.17.0
6
+ ------
7
+ - Add ECG endpoint support
8
+ - Add Active Zone Minutes endpoint support
9
+
1
10
  0.16.0
2
11
  ------
3
12
  - 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,76 @@
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(
32
+ "user/#{user_id}/activities/active-zone-minutes/date/" \
33
+ "#{format_date(start_date)}/#{format_date(end_date)}.json"
34
+ )
35
+ end
36
+
37
+ strip_root_key(result)
38
+ end
39
+
40
+ # Retrieves the Active Zone Minutes (AZM) intraday time series data for a specific date or 24 hour period.
41
+ #
42
+ # @param opts [Hash] The request parameters
43
+ #
44
+ # @option opts :date [Date] The date for which to retrieve the data
45
+ # @option opts :detail_level [String] Number of data poins to include
46
+ # @option opts :start_time [String] The time in the format HH:mm
47
+ # @option opts :end_time [String] The time in the format HH:mm
48
+
49
+ def active_zone_minutes_intraday_time_series(opts = {})
50
+ date = opts[:date] || Date.today
51
+ detail_level = opts[:detail_level]
52
+ start_time = opts[:start_time]
53
+ end_time = opts[:end_time]
54
+
55
+ if [date, detail_level].any?(&:nil?)
56
+ raise FitbitAPI::InvalidArgumentError, 'A date and detail_level are required.'
57
+ end
58
+
59
+ detail_levels = %(1min 5min 15min)
60
+
61
+ unless detail_levels.include? detail_level
62
+ raise FitbitAPI::InvalidArgumentError,
63
+ "Invalid detail_level: \"#{detail_level}\". Please provide one of the following: #{detail_levels}."
64
+ end
65
+
66
+ if (start_time || end_time) && !(start_time && end_time)
67
+ raise FitbitAPI::InvalidArgumentError, 'Both start_time and end_time are required if time is being specified.'
68
+ end
69
+
70
+ path = "user/#{user_id}/activities/active-zone-minutes/date/#{format_date(date)}/1d/#{detail_level}"
71
+ path += "/time/#{format_time(start_time)}/#{format_time(end_time)}" if start_time && end_time
72
+
73
+ get("#{path}.json")
74
+ end
75
+ end
76
+ 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.1'
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.1
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.1/CHANGELOG.md
125
+ documentation_uri: https://www.rubydoc.info/gems/fitbit_api/0.17.1
124
126
  rubygems_mfa_required: 'true'
125
127
  post_install_message:
126
128
  rdoc_options: []