Food Logs
Get Food Logs reference on the official Fitbit documentation.
This function gets a Carbon date and retrieves a summary and list of a user's food log entries for a given day in the format requested.
Example call:
$yesterday = Carbon\Carbon::yesterday();
$fitbit->food()->foodLogs()->get($yesterday);
Example formatted JSON output:
{
"foods":[
],
"summary":{
"calories":0,
"carbs":0,
"fat":0,
"fiber":0,
"protein":0,
"sodium":0,
"water":0
}
}
Log Food reference on the official Fitbit documentation.
This function gets an implementation of a FoodLog can can be either a PublicFoodLog or a PrivateFoodLog instance and creates a food log entry on the users food log records.
Example calls:
$publicLog = new \Namelivia\Fitbit\Food\Foods\PublicFoodLog(
'536870130',
new \Namelivia\Fitbit\Food\Foods\MealType(\Namelivia\Fitbit\Food\Foods\MealType::LUNCH),
'16053',
200,
Carbon\Carbon::today(),
false,
2000
);
$fitbit->food()->logs()->add($publicLog);
$privateLog = new \Namelivia\Fitbit\Food\Foods\PrivateFoodLog(
'exampleFood',
new \Namelivia\Fitbit\Food\Foods\MealType(\Namelivia\Fitbit\Food\Foods\MealType::LUNCH),
$unitId,
200,
Carbon\Carbon::today(),
'someBrandName',
2000
);
$fitbit->food()->logs()->add($privateLog);
Example formatted JSON outputs:
{
"foodDay":{
"date":"2019-09-18",
"summary":{
"calories":44,
"carbs":10.8,
"fat":0,
"fiber":0.2,
"protein":0.4,
"sodium":20,
"water":2.4000000953674316
}
},
"foodLog":{
"isFavorite":false,
"logDate":"2019-09-18",
"logId":19248009524,
"loggedFood":{
"accessLevel":"PUBLIC",
"amount":2,
"brand":"Don simon",
"calories":44,
"foodId":536870130,
"locale":"es_ES",
"mealTypeId":3,
"name":"Zumo de Mango y Manzana",
"unit":{
"id":16053,
"name":"porción",
"plural":"porción"
},
"units":[
16053,
209,
189,
128,
364,
349,
91,
256,
279,
401
]
},
"nutritionalValues":{
"calories":44,
"carbs":10.8,
"fat":0,
"fiber":0.2,
"protein":0.4,
"sodium":20
}
}
}
{
"foodDay":{
"date":"2019-09-18",
"summary":{
"calories":2000,
"carbs":0,
"fat":0,
"fiber":0,
"protein":0,
"sodium":0,
"water":2.4000000953674316
}
},
"foodLog":{
"isFavorite":false,
"logDate":"2019-09-18",
"logId":19247530703,
"loggedFood":{
"accessLevel":"PRIVATE",
"amount":2,
"brand":"someBrandName",
"calories":2000,
"foodId":0,
"mealTypeId":3,
"name":"exampleFood",
"unit":{
"id":16053,
"name":"porción",
"plural":"porción"
},
"units":[
16053
]
},
"nutritionalValues":{
"calories":2000,
"carbs":0,
"fat":0,
"fiber":0,
"protein":0,
"sodium":0
}
}
}
Update Food Log reference on the official Fitbit documentation.
This function gets a string representing the log id and an implementation of UpdateFoodLog that can either be a UpdatedPublicFoodLog instance oa a UpdatedPrivateFoodLog and updates the corresponding a food log entry with the updated log information.
Example call:
$updatedLog = new Namelivia\Fitbit\Food\Foods\UpdatedPublicFoodLog(
new \Namelivia\Fitbit\Food\Foods\MealType(\Namelivia\Fitbit\Food\Foods\MealType::LUNCH),
'16053',
50
);
$fitbit->food()->logs()->update('19248587821', $updatedLog);
Example formatted JSON output:
{
"foodLog":{
"isFavorite":false,
"logDate":"2019-09-18",
"logId":19248587821,
"loggedFood":{
"accessLevel":"PUBLIC",
"amount":0.5,
"brand":"Don simon",
"calories":11,
"foodId":536870130,
"locale":"es_ES",
"mealTypeId":3,
"name":"Zumo de Mango y Manzana",
"unit":{
"id":16053,
"name":"porción",
"plural":"porción"
},
"units":[
16053,
209,
189,
128,
364,
349,
91,
256,
279,
401
]
},
"nutritionalValues":{
"calories":11,
"carbs":2.7,
"fat":0,
"fiber":0.05,
"protein":0.1,
"sodium":5
}
}
}
Delete Food Log reference on the official Fitbit documentation.
This function gets the food log id and deletes the log entry from the users food log records.
Example call:
$fitbit->food()->logs()->remove('6613588938');
Example formatted JSON output:
""
A PublicFoodLog
represents the consumption log of a public food type stored on Fitbit's food database. The values passed to the constructor are foodId
, mealType
,unitId
, amount
and date
, amount
optionally favorite
and calories
values can be passed as well. mealType
has to be an instance of MealType
Example:
new \Namelivia\Fitbit\Food\Foods\PublicFoodLog(
'536870130',
new \Namelivia\Fitbit\Food\Foods\MealType(\Namelivia\Fitbit\Food\Foods\MealType::LUNCH),
'16053',
200,
Carbon\Carbon::today(),
false,
2000
);
A PrivateFoodLog
represents the consumption log of a private food type, one that is not stored on Fitbit's food database. The values passed to the constructor are foodName
, mealType
,unitId
, amount
and date
, amount
optionally brandName
and calories
values can be passed as well. mealType
has to be an instance of MealType. A PrivateFoodLog instance NutritionalValues can also be set by calling the setNutritionalValues
method.
Example:
$nutritionalValues = (new \Namelivia\Fitbit\Food\Foods\NutritionalValues())
->setCopper(12)
->setIron(10)
->setProtein(99)
->setVitaminA(686);
(new \Namelivia\Fitbit\Food\Foods\PrivateFoodLog(
'exampleFood',
new \Namelivia\Fitbit\Food\Foods\MealType(\Namelivia\Fitbit\Food\Foods\MealType::LUNCH),
$unitId,
200,
Carbon\Carbon::today(),
'someBrandName',
2000))->setNutritionalValues($nutritionalValues)
An UpdatedPublicFoodLog
represents food consumption log data update for an entry that holds a public food (a food that is on Fitbit's database) on the food consumption log. The values passed to the constructor are mealType
,unitId
and amount
. mealType
has to be an instance of MealType
Example:
new Namelivia\Fitbit\Food\Foods\UpdatedPublicFoodLog(
new \Namelivia\Fitbit\Food\Foods\MealType(\Namelivia\Fitbit\Food\Foods\MealType::LUNCH),
'16053',
50
);
An UpdatedPrivateFoodLog
represents food consumption log data update for an entry that holds a private food (a food that is not on Fitbit's database) on the food consumption log. The values passed to the constructor are mealType
and calories
. mealType
has to be an instance of MealType
Example:
new Namelivia\Fitbit\Food\Foods\UpdatedPrivateFoodLog(
new \Namelivia\Fitbit\Food\Foods\MealType(\Namelivia\Fitbit\Food\Foods\MealType::LUNCH),
3000
);
A MealType
represents one of the possible meal types available.
Possible values are:
\Namelivia\Fitbit\Food\Foods\MealType::BREAKFAST
\Namelivia\Fitbit\Food\Foods\MealType::MORNING_SNACK
\Namelivia\Fitbit\Food\Foods\MealType::LUNCH
\Namelivia\Fitbit\Food\Foods\MealType::AFTERNOON_SNACK
\Namelivia\Fitbit\Food\Foods\MealType::DINNER
\Namelivia\Fitbit\Food\Foods\MealType::ANYTIME