fitbit_api 0.12.0 → 0.12.1

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: d49f9a31d98fa1fddb1ccffd11d15cbd197ccf9847e0170f2db23410b5cd6eff
4
- data.tar.gz: b7d731600647e16ee1dad3e84371ae83fc2d38b6dd53d3ba88a796191d85e832
3
+ metadata.gz: cced5004604fd14351b0539ffe29efc102d6297f0a73e6d64edd6e4f18b24975
4
+ data.tar.gz: 66a12b7d4b92c0c75e0958b5f69ddbb87f376bc4196bebd8884804df09bf33d7
5
5
  SHA512:
6
- metadata.gz: 56ebf6e543e9c1c3bc7b7aa78018151e40fb3929447af8778adb0c7f65628e9d1ef9e17b2b2f11bd7c07c5f79c81018f8a27b25fa87a4f53a5e6ad20f79c9b54
7
- data.tar.gz: 1b5c912d4e7d80e9c0b01f0e9c5346e0d8c7c506943d03df0c6ebd5fd33b5f1239c73b78b97b4f1036fc29def97037faa549fd41f25b93883113ffaeef4ffe4d
6
+ metadata.gz: 2d3b0ee2261afc4a254dc3673796198e9dc832e78a21241b84a7c11a0f39d396fc8647abf6826a0c4aa3a3be731a63b812dcf4d0de9a45c3fb6ccae9b9297612
7
+ data.tar.gz: 67526aba18a4fe518d5d0b05e8a48979009fc3435ed627c59bff341872e6917387c14ae83709d2ae84c0ff5e16000bf2fca55a89870a436f41b5a389b6b33a2a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.12.1
2
+ ------
3
+ - Some docs improvements
4
+
1
5
  0.12.0
2
6
  ------
3
7
  - Expand endpont support for foods (searching foods, creating custom foods, updating/deleting logs).
@@ -11,12 +11,7 @@ module FitbitAPI
11
11
 
12
12
  ACTIVITY_INTRADAY_RESOURCES = %w(calories steps distance floors elevation)
13
13
 
14
- # GET Activities
15
- # ==============
16
-
17
- # Retrieves a summary and list of a user's activities and activity log entries
18
- # for a given day in the format requested using units in the unit system which
19
- # corresponds to the Accept-Language header provided.
14
+ # Retrieves a summary and list of a user's activities and activity log entries for a given day.
20
15
  #
21
16
  # @param date [Date] The date for which to retrieve the activity data.
22
17
 
@@ -24,13 +19,15 @@ module FitbitAPI
24
19
  get("user/#{user_id}/activities/date/#{format_date(date)}.json")
25
20
  end
26
21
 
27
- # Retrieves a list of a user's frequent activities in the format requested using
28
- # units in the unit system which corresponds to the Accept-Language header provided.
22
+ # Retrieves a list of a user's frequent activities.
29
23
 
30
24
  def frequent_activities
31
25
  get("user/#{user_id}/activities/frequent.json")
32
26
  end
33
27
 
28
+ # Retrieves a list of a user's recent activities types logged with some details
29
+ # of the last activity log of that type.
30
+
34
31
  def recent_activities
35
32
  get("user/#{user_id}/activities/recent.json")
36
33
  end
@@ -54,11 +51,13 @@ module FitbitAPI
54
51
  #
55
52
  # activity_logs_list(before_date: Date.parse('2021-05-24'), limit: 5)
56
53
  #
57
- # @param before_date [Date] Specify when filtering entries that occured before the given date
58
- # @param after_date [Date] Specify when filtering entries that occured after the given date
59
- # @param sort [String] the Sort order of entries by date (asc or desc)
60
- # @param offset [Integer] The offset number of entries. Must always be 0
61
- # @param limit [Integer] The max of the number of entries returned (max: 20)
54
+ # @param params [Hash] The request parameters
55
+ #
56
+ # @option params :before_date [Date] Specify when filtering entries that occured before the given date
57
+ # @option params :after_date [Date] Specify when filtering entries that occured after the given date
58
+ # @option params :sort [String] The Sort order of entries by date (asc or desc)
59
+ # @option params :offset [Integer] The offset number of entries. Must always be 0
60
+ # @option params :limit [Integer] The max of the number of entries returned (max: 20)
62
61
 
63
62
  def activity_logs_list(params={})
64
63
  default_params = { before_date: Date.today, after_date: nil, sort: 'desc', limit: 20, offset: 0 }
@@ -139,22 +138,21 @@ module FitbitAPI
139
138
  end
140
139
  end
141
140
 
142
- # POST Activities
143
- # ===============
144
-
145
141
  # Creates log entry for an activity or user's private custom activity using units
146
142
  # in the unit system which corresponds to the Accept-Language header provided.
147
143
  #
148
144
  # log_activity(activity_id: 90013, manual_calories: 300, duration_millis: 6000000)
149
145
  #
150
- # @param activity_id [Integer, String] The activity ID
151
- # @param activity_name [String] Custom activity name. Either activity ID or activity_name must be provided
152
- # @param manual_calories [Integer] Calories burned, specified manually. Required with activity_name, otherwise optional
153
- # @param start_time [String] Activity start time; formatted in HH:mm:ss
154
- # @param duration_millis [Integer] Duration in milliseconds
155
- # @param date [String] Log entry date; formatted in yyyy-MM-dd
156
- # @param distance [Integer] Distance; required for logging directory activity
157
- # @param distance_unit [String] Distance measurement unit
146
+ # @param body [Hash] The POST request body
147
+ #
148
+ # @option body :activity_id [Integer, String] The activity ID
149
+ # @option body :activity_name [String] Custom activity name. Either activity ID or activity_name must be provided
150
+ # @option body :manual_calories [Integer] Calories burned, specified manually. Required with activity_name, otherwise optional
151
+ # @option body :start_time [String] Activity start time; formatted in HH:mm:ss
152
+ # @option body :duration_millis [Integer] Duration in milliseconds
153
+ # @option body :date [String] Log entry date; formatted in yyyy-MM-dd
154
+ # @option body :distance [Integer] Distance; required for logging directory activity
155
+ # @option body :distance_unit [String] Distance measurement unit
158
156
 
159
157
  def log_activity(body)
160
158
  post("user/#{user_id}/activities.json", body)
@@ -168,9 +166,6 @@ module FitbitAPI
168
166
  post("user/#{user_id}/activities/favorite/#{activity_id}.json")
169
167
  end
170
168
 
171
- # DELETE Activities
172
- # =================
173
-
174
169
  # Deletes a user's activity log entry with the given ID.
175
170
  #
176
171
  # @param activity_log_id [Integer] The ID of the activity log entry
@@ -1,8 +1,5 @@
1
1
  module FitbitAPI
2
2
  class Client
3
- # GET Alarms
4
- # ==========
5
-
6
3
  # Returns a list of the set alarms connected to a user's account.
7
4
  #
8
5
  # @params tracker_id [Integer] The ID of the tracker for which the data is returned
@@ -11,19 +8,17 @@ module FitbitAPI
11
8
  get("user/#{user_id}/devices/tracker/#{tracker_id}/alarms.json")
12
9
  end
13
10
 
14
- # POST Alarms
15
- # ===========
16
-
17
11
  # Adds the alarm settings to a given ID for a given device.
18
12
  #
19
13
  # add_alarm(123, time: "07:15-08:00", recurring: true, week_days: "MONDAY,FRIDAY,SATURDAY")
20
14
  #
21
15
  # @param tracker_id [Integer] The ID of the tracker for which the alarm is created
16
+ # @param body [Hash] The POST request body
22
17
  #
23
- # @param time [String] Time of day that the alarm vibrates with a UTC timezone offset, e.g. 07:15-08:00
24
- # @param enabled [Boolean] If false, alarm does not vibrate until enabled is set to true
25
- # @param recurring [Boolean] If false, the alarm is a single event
26
- # @param week_days [String] Comma separated list of days of the week on which the alarm vibrates (MONDAY,TUESDAY)
18
+ # @option body :time [String] Time of day that the alarm vibrates with a UTC timezone offset, e.g. 07:15-08:00
19
+ # @option body :enabled [Boolean] If false, alarm does not vibrate until enabled is set to true
20
+ # @option body :recurring [Boolean] If false, the alarm is a single event
21
+ # @option body :week_days [String] Comma separated list of days of the week on which the alarm vibrates (MONDAY,TUESDAY)
27
22
 
28
23
  def add_alarm(tracker_id, body={})
29
24
  post("user/#{user_id}/devices/tracker/#{tracker_id}/alarms.json", body)
@@ -35,23 +30,21 @@ module FitbitAPI
35
30
  #
36
31
  # @param tracker_id [Integer] The ID of the tracker for which the alarm is created
37
32
  # @param alarm_id [Integer] The ID of the alarm to be updated
33
+ # @param body [Hash] The POST request body.
38
34
  #
39
- # @param time [String] Time of day that the alarm vibrates with a UTC timezone offset, e.g. 07:15-08:00
40
- # @param enabled [Boolean] If false, alarm does not vibrate until enabled is set to true
41
- # @param recurring [Boolean] If false, the alarm is a single event
42
- # @param week_days [String] Comma separated list of days of the week on which the alarm vibrates (MONDAY,TUESDAY)
43
- # @param snooze_length [Integer] Minutes between alarms
44
- # @param snooze_count [Integer] Maximum snooze count
45
- # @param label [String] Label for alarm
46
- # @param vibe [String] Vibe pattern; only one value for now (DEFAULT)
35
+ # @option body :time [String] Time of day that the alarm vibrates with a UTC timezone offset, e.g. 07:15-08:00
36
+ # @option body :enabled [Boolean] If false, alarm does not vibrate until enabled is set to true
37
+ # @option body :recurring [Boolean] If false, the alarm is a single event
38
+ # @option body :week_days [String] Comma separated list of days of the week on which the alarm vibrates (MONDAY,TUESDAY)
39
+ # @option body :snooze_length [Integer] Minutes between alarms
40
+ # @option body :snooze_count [Integer] Maximum snooze count
41
+ # @option body :label [String] Label for alarm
42
+ # @option body :vibe [String] Vibe pattern; only one value for now (DEFAULT)
47
43
 
48
44
  def update_alarm(tracker_id, alarm_id, body={})
49
45
  post("user/#{user_id}/devices/tracker/#{tracker_id}/alarms/#{alarm_id}.json", body)
50
46
  end
51
47
 
52
- # DELETE Alarms
53
- # =============
54
-
55
48
  # Deletes the user's device alarm entry with the given ID for a given device.
56
49
  #
57
50
  # delete_alarm(123, 987)
@@ -1,5 +1,7 @@
1
1
  module FitbitAPI
2
2
  class Client
3
+ # Retrieves a list of Fitbit devices paired to a user's account.
4
+
3
5
  def devices
4
6
  get("user/#{user_id}/devices.json")
5
7
  end
@@ -1,9 +1,13 @@
1
1
  module FitbitAPI
2
2
  class Client
3
+ # Retrieves a list of the Fitbit user's friends.
4
+
3
5
  def friends
4
6
  get("user/#{user_id}/friends.json")
5
7
  end
6
8
 
9
+ # Retrieves the user's friends leaderboard.
10
+
7
11
  def friends_leaderboard
8
12
  get("user/#{user_id}/friends/leaderboard.json")
9
13
  end
@@ -1,8 +1,5 @@
1
1
  module FitbitAPI
2
2
  class Client
3
- # GET Goals
4
- # =========
5
-
6
3
  # Retrieves a user's current weight goal.
7
4
 
8
5
  def weight_goal
@@ -45,19 +42,18 @@ module FitbitAPI
45
42
  get("user/#{user_id}/foods/log/water/goal.json")
46
43
  end
47
44
 
48
- # POST Goals
49
- # ==========
50
-
51
45
  # Creates or updates a user's daily activity goals and returns a response using units
52
46
  # in the unit system which corresponds to the Accept-Language header provided.
53
47
  #
54
48
  # update_daily_activity_goals(calories_out: 2000, active_minutes: 90, floors: 5)
55
49
  #
56
- # @param calories_out [Integer] Calories output goal value
57
- # @param active_minutes [Integer] Active minutes goal value
58
- # @param floors [Integer] Floor goal value
59
- # @param distance [Integer, Float] Distance goal value
60
- # @param steps [Integer] Steps goal value
50
+ # @param body [Hash] The POST request body
51
+ #
52
+ # @option body :calories_out [Integer] Calories output goal value
53
+ # @option body :active_minutes [Integer] Active minutes goal value
54
+ # @option body :floors [Integer] Floor goal value
55
+ # @option body :distance [Integer, Float] Distance goal value
56
+ # @option body :steps [Integer] Steps goal value
61
57
 
62
58
  def update_daily_activity_goals(body={})
63
59
  post("user/#{user_id}/activities/goals/daily.json", body)
@@ -68,11 +64,13 @@ module FitbitAPI
68
64
  #
69
65
  # update_weekly_activity_goals(active_minutes: 300, floors: 20)
70
66
  #
71
- # @param calories_out [Integer] Calories output goal value
72
- # @param active_minutes [Integer] Active minutes goal value
73
- # @param floors [Integer] Floor goal value
74
- # @param distance [Integer, Float] Distance goal value
75
- # @param steps [Integer] Steps goal value
67
+ # @param body [Hash] The POST request body
68
+ #
69
+ # @option body :calories_out [Integer] Calories output goal value
70
+ # @option body :active_minutes [Integer] Active minutes goal value
71
+ # @option body :floors [Integer] Floor goal value
72
+ # @option body :distance [Integer, Float] Distance goal value
73
+ # @option body :steps [Integer] Steps goal value
76
74
 
77
75
  def update_weekly_activity_goals(body={})
78
76
  post("user/#{user_id}/activities/goals/weekly.json", body)
@@ -1,6 +1,5 @@
1
1
  module FitbitAPI
2
2
  class Client
3
-
4
3
  PERIODS = %w(1d 7d 30d 1w 1m 3m 6m 1y max).freeze
5
4
 
6
5
  def format_date(date)
@@ -79,6 +78,5 @@ module FitbitAPI
79
78
  string.gsub!(/^\w{1}/) { |word| word.downcase } if opts[:lower]
80
79
  return string
81
80
  end
82
-
83
81
  end
84
82
  end
@@ -20,11 +20,13 @@ module FitbitAPI
20
20
  #
21
21
  # sleep_logs_list(before_date: Date.parse('2021-05-24'), limit: 5)
22
22
  #
23
- # @param before_date [Date] Specify when filtering entries that occured before the given date
24
- # @param after_date [Date] Specify when filtering entries that occured after the given date
25
- # @param sort [String] the Sort order of entries by date (asc or desc)
26
- # @param offset [Integer] The offset number of entries. Must always be 0
27
- # @param limit [Integer] The max of the number of entries returned (max: 100)
23
+ # @param params [Hash] The request parameters
24
+ #
25
+ # @option params :before_date [Date] Specify when filtering entries that occured before the given date
26
+ # @option params :after_date [Date] Specify when filtering entries that occured after the given date
27
+ # @option params :sort [String] the Sort order of entries by date (asc or desc)
28
+ # @option params :offset [Integer] The offset number of entries. Must always be 0
29
+ # @option params :limit [Integer] The max of the number of entries returned (max: 100)
28
30
 
29
31
  def sleep_logs_list(params={})
30
32
  default_params = { before_date: Date.today, after_date: nil, sort: 'desc', limit: 20, offset: 0 }
@@ -1,13 +1,21 @@
1
1
  module FitbitAPI
2
2
  class Client
3
+ # Retrieves the user's profile data.
4
+
3
5
  def profile
4
6
  get("user/#{user_id}/profile.json")
5
7
  end
6
8
 
9
+ # Retrieves a list of the user's badges.
10
+
7
11
  def badges
8
12
  get("user/#{user_id}/badges.json")
9
13
  end
10
14
 
15
+ # Modifies a user's profile data.
16
+ #
17
+ # @params body [Hash] The POST request body
18
+
11
19
  def update_profile(body)
12
20
  post("user/#{user_id}/profile.json", body)
13
21
  end
@@ -1,3 +1,3 @@
1
1
  module FitbitAPI
2
- VERSION = '0.12.0'
2
+ VERSION = '0.12.1'
3
3
  end
@@ -3,6 +3,7 @@ module FitbitAPI
3
3
  # Retrieves a summary and list of a user's water log entries for a given day
4
4
  #
5
5
  # @param date [Date] The date for which entries are to be returned
6
+
6
7
  def water_logs(date=Date.today)
7
8
  get("user/#{user_id}/foods/log/water/date/#{format_date(date)}.json")
8
9
  end
@@ -10,6 +11,7 @@ module FitbitAPI
10
11
  # Create a user's water log entry
11
12
  #
12
13
  # @param body [Hash] The POST request body for creating the water log entry
14
+
13
15
  def log_water(body)
14
16
  post("user/#{user_id}/foods/log/water.json", body)
15
17
  end
@@ -18,6 +20,7 @@ module FitbitAPI
18
20
  #
19
21
  # @params water_log_id [Integer] The ID of the water log to be updated
20
22
  # @params body [Hash] The POST request body for updating the water log
23
+
21
24
  def update_water_log(water_log_id, body)
22
25
  post("user/#{user_id}/foods/log/water/#{water_log_id}.json", body)
23
26
  end
@@ -25,6 +28,7 @@ module FitbitAPI
25
28
  # Deleted a user's water log entry using the given log ID
26
29
  #
27
30
  # @param water_log_id [Integer] The id of the water log entry
31
+
28
32
  def delete_water_log(water_log_id)
29
33
  delete("user/#{user_id}/foods/log/water/#{water_log_id}.json")
30
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fitbit_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zoran