fitbit_api 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +29 -0
- data/CHANGELOG.md +15 -0
- data/README.md +1 -1
- data/fitbit_api.gemspec +3 -3
- data/lib/fitbit_api/activities.rb +2 -2
- data/lib/fitbit_api/body.rb +2 -2
- data/lib/fitbit_api/client.rb +9 -8
- data/lib/fitbit_api/food.rb +73 -2
- data/lib/fitbit_api/goals.rb +65 -8
- data/lib/fitbit_api/heart_rate.rb +2 -2
- data/lib/fitbit_api/meals.rb +42 -0
- data/lib/fitbit_api/sleep.rb +35 -0
- data/lib/fitbit_api/version.rb +1 -1
- data/lib/fitbit_api/water.rb +25 -0
- metadata +16 -15
- data/.travis.yml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d49f9a31d98fa1fddb1ccffd11d15cbd197ccf9847e0170f2db23410b5cd6eff
|
4
|
+
data.tar.gz: b7d731600647e16ee1dad3e84371ae83fc2d38b6dd53d3ba88a796191d85e832
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56ebf6e543e9c1c3bc7b7aa78018151e40fb3929447af8778adb0c7f65628e9d1ef9e17b2b2f11bd7c07c5f79c81018f8a27b25fa87a4f53a5e6ad20f79c9b54
|
7
|
+
data.tar.gz: 1b5c912d4e7d80e9c0b01f0e9c5346e0d8c7c506943d03df0c6ebd5fd33b5f1239c73b78b97b4f1036fc29def97037faa549fd41f25b93883113ffaeef4ffe4d
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- pull_request
|
6
|
+
|
7
|
+
permissions:
|
8
|
+
contents: read
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
test:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby-version:
|
16
|
+
- 2.6
|
17
|
+
- 2.7
|
18
|
+
- 3.0
|
19
|
+
- 3.1
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v3
|
23
|
+
- name: Set up Ruby
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby-version }}
|
27
|
+
bundler-cache: true
|
28
|
+
- name: Run tests
|
29
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
0.12.0
|
2
|
+
------
|
3
|
+
- Expand endpont support for foods (searching foods, creating custom foods, updating/deleting logs).
|
4
|
+
- Expand endpoint support for water logging (create, update, delete water logs).
|
5
|
+
- Expand endpoint support for sleep (list sleep logs, create/delete sleep logs).
|
6
|
+
- Expand endpoint support for goals (food, sleep, water goals).
|
7
|
+
- Add endpoint support for meals.
|
8
|
+
- Allow `get`, `post`, and `delete` methods to accept blocks.
|
9
|
+
- Switch to Github Actions for CI.
|
10
|
+
- Rename a few methods for better accuracy/clarity:
|
11
|
+
- daily_goals -> daily_activity_goals
|
12
|
+
- weekly_goals -> weekly_activity_goals
|
13
|
+
- create_or_update_daily_goals -> update_daily_activity_goals
|
14
|
+
- create_or_update_weekly_goals -> update_weekly_activity_goals
|
15
|
+
|
1
16
|
0.11.0
|
2
17
|
------
|
3
18
|
- Add support for subscriptions endpoints.
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# FitbitAPI
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/fitbit_api.svg)](https://badge.fury.io/rb/fitbit_api)
|
4
|
-
[![
|
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)
|
5
5
|
|
6
6
|
FitbitAPI provides a Ruby interface to the [Fitbit Web API](https://dev.fitbit.com/reference/web-api).
|
7
7
|
|
data/fitbit_api.gemspec
CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_runtime_dependency 'oauth2', '~> 1.0'
|
23
23
|
|
24
|
-
spec.add_development_dependency 'byebug'
|
24
|
+
spec.add_development_dependency 'byebug', '~> 11.0'
|
25
25
|
spec.add_development_dependency 'bundler', '~> 2.3'
|
26
|
-
spec.add_development_dependency 'rake', '
|
27
|
-
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.11'
|
28
28
|
end
|
@@ -133,9 +133,9 @@ module FitbitAPI
|
|
133
133
|
end
|
134
134
|
|
135
135
|
if (start_time && end_time)
|
136
|
-
get("user
|
136
|
+
get("user/#{user_id}/activities/#{resource}/date/#{format_date(date)}/1d/#{detail_level}/time/#{format_time(start_time)}/#{format_time(end_time)}.json")
|
137
137
|
else
|
138
|
-
get("user
|
138
|
+
get("user/#{user_id}/activities/#{resource}/date/#{format_date(date)}/1d/#{detail_level}.json")
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
data/lib/fitbit_api/body.rb
CHANGED
@@ -3,11 +3,11 @@ module FitbitAPI
|
|
3
3
|
BODY_RESOURCES = %w(bmi fat weight)
|
4
4
|
|
5
5
|
def weight_logs(date=Date.today)
|
6
|
-
get("user
|
6
|
+
get("user/#{user_id}/body/log/weight/date/#{format_date(date)}.json")
|
7
7
|
end
|
8
8
|
|
9
9
|
def body_fat_logs(date=Date.today)
|
10
|
-
get("user
|
10
|
+
get("user/#{user_id}/body/log/fat/date/#{format_date(date)}.json")
|
11
11
|
end
|
12
12
|
|
13
13
|
def body_time_series(resource, opts={})
|
data/lib/fitbit_api/client.rb
CHANGED
@@ -7,6 +7,7 @@ require 'fitbit_api/body'
|
|
7
7
|
require 'fitbit_api/devices'
|
8
8
|
require 'fitbit_api/food'
|
9
9
|
require 'fitbit_api/friends'
|
10
|
+
require 'fitbit_api/meals'
|
10
11
|
require 'fitbit_api/sleep'
|
11
12
|
require 'fitbit_api/subscriptions'
|
12
13
|
require 'fitbit_api/user'
|
@@ -47,16 +48,16 @@ module FitbitAPI
|
|
47
48
|
@token
|
48
49
|
end
|
49
50
|
|
50
|
-
def get(path, params={}, opts={})
|
51
|
-
request(:get, path, opts.merge(params: params))
|
51
|
+
def get(path, params={}, opts={}, &block)
|
52
|
+
request(:get, path, opts.merge(params: params), &block)
|
52
53
|
end
|
53
54
|
|
54
|
-
def post(path, body={}, opts={})
|
55
|
-
request(:post, path, opts.merge(body: body))
|
55
|
+
def post(path, body={}, opts={}, &block)
|
56
|
+
request(:post, path, opts.merge(body: body), &block)
|
56
57
|
end
|
57
58
|
|
58
|
-
def delete(path, params={}, opts={})
|
59
|
-
request(:delete, path, opts.merge(params: params))
|
59
|
+
def delete(path, params={}, opts={}, &block)
|
60
|
+
request(:delete, path, opts.merge(params: params), &block)
|
60
61
|
end
|
61
62
|
|
62
63
|
private
|
@@ -115,7 +116,7 @@ module FitbitAPI
|
|
115
116
|
refresh_token! if @token.token.empty?
|
116
117
|
end
|
117
118
|
|
118
|
-
def request(verb, path, opts={})
|
119
|
+
def request(verb, path, opts={}, &block)
|
119
120
|
request_path = "#{@api_version}/#{path}"
|
120
121
|
request_headers = default_request_headers.merge(opts[:headers] || {})
|
121
122
|
request_options = opts.merge(headers: request_headers)
|
@@ -125,7 +126,7 @@ module FitbitAPI
|
|
125
126
|
|
126
127
|
refresh_token! if auto_refresh_token && token.expired?
|
127
128
|
|
128
|
-
response = token.public_send(verb, request_path, request_options).response
|
129
|
+
response = token.public_send(verb, request_path, request_options, &block).response
|
129
130
|
response_body = MultiJson.load(response.body) unless response.status == 204
|
130
131
|
|
131
132
|
process_keys!(response_body)
|
data/lib/fitbit_api/food.rb
CHANGED
@@ -6,6 +6,14 @@ module FitbitAPI
|
|
6
6
|
get("user/#{user_id}/foods/log/date/#{format_date(date)}.json")
|
7
7
|
end
|
8
8
|
|
9
|
+
# Retrieves a list of public foods from the Fitbit foods database and private foods the user created
|
10
|
+
#
|
11
|
+
# @params query [String] The search query
|
12
|
+
|
13
|
+
def search_foods(params)
|
14
|
+
get("foods/search.json", params)
|
15
|
+
end
|
16
|
+
|
9
17
|
def recent_foods
|
10
18
|
get("user/#{user_id}/foods/log/recent.json")
|
11
19
|
end
|
@@ -18,8 +26,59 @@ module FitbitAPI
|
|
18
26
|
get("user/#{user_id}/foods/log/favorite.json")
|
19
27
|
end
|
20
28
|
|
21
|
-
|
22
|
-
|
29
|
+
# Creates a new private food for a user
|
30
|
+
#
|
31
|
+
# @params body [Hash] The POST request body
|
32
|
+
|
33
|
+
def create_food(body)
|
34
|
+
post("user/#{user_id}/foods.json", body)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Deletes a custom food created by the user
|
38
|
+
#
|
39
|
+
# @params food_id [Integer] The ID of the food to be deleted
|
40
|
+
|
41
|
+
def delete_food(food_id)
|
42
|
+
delete("user/#{user_id}/foods/#{food_id}.json")
|
43
|
+
end
|
44
|
+
|
45
|
+
# Creates a food log entry
|
46
|
+
#
|
47
|
+
# @params body [Hash] The POST request body
|
48
|
+
|
49
|
+
def create_food_log(body)
|
50
|
+
post("user/#{user_id}/foods/log.json", body)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Updates the quantity or calories consumed for a user's food log entry with the given Food Log ID
|
54
|
+
#
|
55
|
+
# @params food_log_id [Integer] The ID of the food log to edit
|
56
|
+
# @params body [Hash] The POST request body
|
57
|
+
|
58
|
+
def update_food_log(food_log_id, body)
|
59
|
+
post("user/#{user_id}/foods/log/#{food_log_id}.json", body)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Deletes a user's food log entry using the given log ID
|
63
|
+
#
|
64
|
+
# @params food_log_id [Integer] The id of the food log entry
|
65
|
+
|
66
|
+
def delete_food_log(food_log_id)
|
67
|
+
delete("user/#{user_id}/foods/log/#{food_log_id}.json")
|
68
|
+
end
|
69
|
+
|
70
|
+
# Adds a food with the given ID to the user's list of favorite foods
|
71
|
+
|
72
|
+
def add_favorite_food(food_id)
|
73
|
+
post("user/#{user_id}/foods/log/favorite/#{food_id}.json")
|
74
|
+
end
|
75
|
+
|
76
|
+
# Deletes a food with the given ID from the user's list of favorite foods
|
77
|
+
#
|
78
|
+
# @params food_id [Integer] The ID of the food to delete from the user's favorites
|
79
|
+
|
80
|
+
def delete_favorite_food(food_id)
|
81
|
+
delete("user/#{user_id}/foods/log/favorite/#{food_id}.json")
|
23
82
|
end
|
24
83
|
|
25
84
|
def food_time_series(resource, opts={})
|
@@ -48,5 +107,17 @@ module FitbitAPI
|
|
48
107
|
# remove root key from response
|
49
108
|
result.values[0]
|
50
109
|
end
|
110
|
+
|
111
|
+
# Retrieves the food locales used to search, log or create food
|
112
|
+
|
113
|
+
def food_locales
|
114
|
+
get("foods/locales.json")
|
115
|
+
end
|
116
|
+
|
117
|
+
# Retrieves a list of all valid Fitbit food units
|
118
|
+
|
119
|
+
def food_units
|
120
|
+
get("foods/units.json")
|
121
|
+
end
|
51
122
|
end
|
52
123
|
end
|
data/lib/fitbit_api/goals.rb
CHANGED
@@ -6,34 +6,52 @@ module FitbitAPI
|
|
6
6
|
# Retrieves a user's current weight goal.
|
7
7
|
|
8
8
|
def weight_goal
|
9
|
-
get("user
|
9
|
+
get("user/#{user_id}/body/log/weight/goal.json")
|
10
10
|
end
|
11
11
|
|
12
12
|
# Retrieves a user's current body fat percentage goal.
|
13
13
|
|
14
14
|
def body_fat_goal
|
15
|
-
get("user
|
15
|
+
get("user/#{user_id}/body/log/fat/goal.json")
|
16
16
|
end
|
17
17
|
|
18
18
|
# Retrieves a user's current daily activity goals.
|
19
19
|
|
20
|
-
def
|
20
|
+
def daily_activity_goals
|
21
21
|
get("user/#{user_id}/activities/goals/daily.json")
|
22
22
|
end
|
23
23
|
|
24
24
|
# Retrieves a user's current weekly activity goals.
|
25
25
|
|
26
|
-
def
|
26
|
+
def weekly_activity_goals
|
27
27
|
get("user/#{user_id}/activities/goals/weekly.json")
|
28
28
|
end
|
29
29
|
|
30
|
+
# Retrieves a user's current sleep goal.
|
31
|
+
|
32
|
+
def sleep_goal
|
33
|
+
get("user/#{user_id}/sleep/goal.json")
|
34
|
+
end
|
35
|
+
|
36
|
+
# Retrieves the user's current daily calorie consumption goal and/or food plan.
|
37
|
+
|
38
|
+
def food_goals
|
39
|
+
get("user/#{user_id}/foods/log/goal.json")
|
40
|
+
end
|
41
|
+
|
42
|
+
# Retrieves a user's daily water consumption goal.
|
43
|
+
|
44
|
+
def water_goal
|
45
|
+
get("user/#{user_id}/foods/log/water/goal.json")
|
46
|
+
end
|
47
|
+
|
30
48
|
# POST Goals
|
31
49
|
# ==========
|
32
50
|
|
33
51
|
# Creates or updates a user's daily activity goals and returns a response using units
|
34
52
|
# in the unit system which corresponds to the Accept-Language header provided.
|
35
53
|
#
|
36
|
-
#
|
54
|
+
# update_daily_activity_goals(calories_out: 2000, active_minutes: 90, floors: 5)
|
37
55
|
#
|
38
56
|
# @param calories_out [Integer] Calories output goal value
|
39
57
|
# @param active_minutes [Integer] Active minutes goal value
|
@@ -41,14 +59,14 @@ module FitbitAPI
|
|
41
59
|
# @param distance [Integer, Float] Distance goal value
|
42
60
|
# @param steps [Integer] Steps goal value
|
43
61
|
|
44
|
-
def
|
62
|
+
def update_daily_activity_goals(body={})
|
45
63
|
post("user/#{user_id}/activities/goals/daily.json", body)
|
46
64
|
end
|
47
65
|
|
48
66
|
# Creates or updates a user's weekly activity goals and returns a response using units
|
49
67
|
# in the unit system which corresponds to the Accept-Language header provided.
|
50
68
|
#
|
51
|
-
#
|
69
|
+
# update_weekly_activity_goals(active_minutes: 300, floors: 20)
|
52
70
|
#
|
53
71
|
# @param calories_out [Integer] Calories output goal value
|
54
72
|
# @param active_minutes [Integer] Active minutes goal value
|
@@ -56,8 +74,47 @@ module FitbitAPI
|
|
56
74
|
# @param distance [Integer, Float] Distance goal value
|
57
75
|
# @param steps [Integer] Steps goal value
|
58
76
|
|
59
|
-
def
|
77
|
+
def update_weekly_activity_goals(body={})
|
60
78
|
post("user/#{user_id}/activities/goals/weekly.json", body)
|
61
79
|
end
|
80
|
+
|
81
|
+
# Creates or updates a user's weight goal.
|
82
|
+
#
|
83
|
+
# @param body [Hash] the POST request body
|
84
|
+
def update_weight_goal(body)
|
85
|
+
post("user/#{user_id}/body/log/weight/goal.json", body)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Creates or updates a user's body fat goal.
|
89
|
+
#
|
90
|
+
# @param body [Hash] the POST request body
|
91
|
+
|
92
|
+
def update_body_fat_goal(body)
|
93
|
+
post("user/#{user_id}/body/log/fat/goal.json", body)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Create or update a user's sleep goal.
|
97
|
+
#
|
98
|
+
# @param body [Hash] the POST request body
|
99
|
+
|
100
|
+
def update_sleep_goal(body)
|
101
|
+
post("user/#{user_id}/sleep/goal.json", body)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Creates or updates a user's daily calorie consumption or food plan goals.
|
105
|
+
#
|
106
|
+
# @param body [Hash] the POST request body
|
107
|
+
|
108
|
+
def update_food_goals(body)
|
109
|
+
post("user/#{user_id}/foods/log/goal.json", body)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Creates or updates a user's daily water consumption goal.
|
113
|
+
#
|
114
|
+
# @param body [Hash] the POST request body
|
115
|
+
|
116
|
+
def update_water_goal(body)
|
117
|
+
post("user/#{user_id}/foods/log/water/goal.json", body)
|
118
|
+
end
|
62
119
|
end
|
63
120
|
end
|
@@ -42,9 +42,9 @@ module FitbitAPI
|
|
42
42
|
end
|
43
43
|
|
44
44
|
if (start_time && end_time)
|
45
|
-
get("user
|
45
|
+
get("user/#{user_id}/activities/heart/date/#{format_date(date)}/1d/#{detail_level}/time/#{format_time(start_time)}/#{format_time(end_time)}.json")
|
46
46
|
else
|
47
|
-
get("user
|
47
|
+
get("user/#{user_id}/activities/heart/date/#{format_date(date)}/1d/#{detail_level}.json")
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module FitbitAPI
|
2
|
+
class Client
|
3
|
+
# Retrieves a list of meals created by the user from their food log
|
4
|
+
|
5
|
+
def meals
|
6
|
+
get("user/#{user_id}/meals.json")
|
7
|
+
end
|
8
|
+
|
9
|
+
# Retrieves a single meal created by the user from their food log given the meal id
|
10
|
+
#
|
11
|
+
# @params meal_id [Integer] The ID of the meal
|
12
|
+
|
13
|
+
def meal(meal_id)
|
14
|
+
get("user/#{user_id}/meals/#{meal_id}.json")
|
15
|
+
end
|
16
|
+
|
17
|
+
# Creates a meal with the given food
|
18
|
+
#
|
19
|
+
# @params body [Hash] The POST request body
|
20
|
+
|
21
|
+
def create_meal(body)
|
22
|
+
post("user/#{user_id}/meals.json", body)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Updates an existing meal with the contents of the request
|
26
|
+
#
|
27
|
+
# @params meal_id [Integer] The ID of the meal
|
28
|
+
# @params body [Hash] The POST request body
|
29
|
+
|
30
|
+
def update_meal(meal_id, body)
|
31
|
+
post("user/#{user_id}/meals/#{meal_id}.json", body)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Deletes an existing meal of the given meal ID
|
35
|
+
#
|
36
|
+
# @params meal_id [Integer] The ID of the meal
|
37
|
+
|
38
|
+
def delete_meal(meal_id)
|
39
|
+
delete("user/#{user_id}/meals/#{meal_id}.json")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/fitbit_api/sleep.rb
CHANGED
@@ -3,10 +3,45 @@ module FitbitAPI
|
|
3
3
|
SLEEP_RESOURCES = %w(startTime timeInBed minutesAsleep awakeningsCount
|
4
4
|
minutesAwake minutesToFallAsleep minutesAfterWakeup efficiency)
|
5
5
|
|
6
|
+
# Returns a list of a user's sleep log entries for a given date. The data returned can include sleep
|
7
|
+
# periods that began on the previous date. For example, if you request a Sleep Log for 2021-12-22,
|
8
|
+
# it may return a log entry that began the previous night on 2021-12-21, but ended on 2021-12-22.
|
9
|
+
#
|
10
|
+
# @params date [Date, String] The date for the sleep log to be returned in the format yyyy-MM-dd
|
11
|
+
|
6
12
|
def sleep_logs(date=Date.today)
|
7
13
|
get("user/#{user_id}/sleep/date/#{format_date(date)}.json")
|
8
14
|
end
|
9
15
|
|
16
|
+
# Returns a list of a user's sleep log entries before or after a given date, and specifying offset,
|
17
|
+
# limit and sort order. The data returned for different dates can include sleep periods that began
|
18
|
+
# on the previous date. For example, a sleep log entry for 2018-10-21 may have ended that day but
|
19
|
+
# started the previous night on 2018-10-20.
|
20
|
+
#
|
21
|
+
# sleep_logs_list(before_date: Date.parse('2021-05-24'), limit: 5)
|
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)
|
28
|
+
|
29
|
+
def sleep_logs_list(params={})
|
30
|
+
default_params = { before_date: Date.today, after_date: nil, sort: 'desc', limit: 20, offset: 0 }
|
31
|
+
get("user/#{user_id}/sleep/list.json", default_params.merge(params))
|
32
|
+
end
|
33
|
+
|
34
|
+
# Creates a log entry for a sleep event
|
35
|
+
|
36
|
+
def create_sleep_log(body)
|
37
|
+
post("user/#{user_id}/sleep.json", body)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Deletes a sleep log with the given log ID
|
41
|
+
def delete_sleep_log(sleep_log_id)
|
42
|
+
delete("user/#{user_id}/sleep/#{sleep_log_id}.json")
|
43
|
+
end
|
44
|
+
|
10
45
|
def sleep_time_series(resource, opts={})
|
11
46
|
start_date = opts[:start_date]
|
12
47
|
end_date = opts[:end_date] || Date.today
|
data/lib/fitbit_api/version.rb
CHANGED
data/lib/fitbit_api/water.rb
CHANGED
@@ -1,7 +1,32 @@
|
|
1
1
|
module FitbitAPI
|
2
2
|
class Client
|
3
|
+
# Retrieves a summary and list of a user's water log entries for a given day
|
4
|
+
#
|
5
|
+
# @param date [Date] The date for which entries are to be returned
|
3
6
|
def water_logs(date=Date.today)
|
4
7
|
get("user/#{user_id}/foods/log/water/date/#{format_date(date)}.json")
|
5
8
|
end
|
9
|
+
|
10
|
+
# Create a user's water log entry
|
11
|
+
#
|
12
|
+
# @param body [Hash] The POST request body for creating the water log entry
|
13
|
+
def log_water(body)
|
14
|
+
post("user/#{user_id}/foods/log/water.json", body)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Updates the quantity consumed for a user's water log entry with the given log ID
|
18
|
+
#
|
19
|
+
# @params water_log_id [Integer] The ID of the water log to be updated
|
20
|
+
# @params body [Hash] The POST request body for updating the water log
|
21
|
+
def update_water_log(water_log_id, body)
|
22
|
+
post("user/#{user_id}/foods/log/water/#{water_log_id}.json", body)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Deleted a user's water log entry using the given log ID
|
26
|
+
#
|
27
|
+
# @param water_log_id [Integer] The id of the water log entry
|
28
|
+
def delete_water_log(water_log_id)
|
29
|
+
delete("user/#{user_id}/foods/log/water/#{water_log_id}.json")
|
30
|
+
end
|
6
31
|
end
|
7
32
|
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.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zoran
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '11.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '11.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,39 +56,39 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '13.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '3.11'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '3.11'
|
83
83
|
description:
|
84
84
|
email:
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
88
88
|
files:
|
89
|
+
- ".github/workflows/test.yml"
|
89
90
|
- ".gitignore"
|
90
91
|
- ".rspec"
|
91
|
-
- ".travis.yml"
|
92
92
|
- CHANGELOG.md
|
93
93
|
- Gemfile
|
94
94
|
- LICENSE.txt
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/fitbit_api/helpers/configuration.rb
|
110
110
|
- lib/fitbit_api/helpers/exceptions.rb
|
111
111
|
- lib/fitbit_api/helpers/utils.rb
|
112
|
+
- lib/fitbit_api/meals.rb
|
112
113
|
- lib/fitbit_api/sleep.rb
|
113
114
|
- lib/fitbit_api/subscriptions.rb
|
114
115
|
- lib/fitbit_api/user.rb
|