From 7110942e59468411d586cb7c3c081dc81bee9269 Mon Sep 17 00:00:00 2001 From: Andrew Doyon Date: Mon, 25 May 2020 17:34:08 -0700 Subject: [PATCH] Added function log_food() which allows you to post a food item to the current user's database on Fitbit --- fitbit/api.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fitbit/api.py b/fitbit/api.py index 1b458b1..539c286 100644 --- a/fitbit/api.py +++ b/fitbit/api.py @@ -269,6 +269,24 @@ def make_request(self, *args, **kwargs): return rep + def log_food(self, foodId, mealTypeId, unitId, amount, date, user_id=None): + """ + Log a food item. + + https://dev.fitbit.com/build/reference/web-api/food-logging#logging-and-deleting-collection-data + """ + url = "{0}/{1}/user/{2}/foods/log.json".format(*self._get_common_args(user_id)) + + data={ + 'foodId': str(foodId), + 'mealTypeId': str(mealTypeId), + 'unitId': str(unitId), + 'amount': str(amount), + 'date': str(date) + } + + return self.make_request(url,data=data) + def user_profile_get(self, user_id=None): """ Get a user profile. You can get other user's profile information