Source code for fatsecret.resources._generated.profile_foods

# AUTO-GENERATED by scripts/oas-sync emit-resource Profile Foods. Do not edit by hand.
"""Resource wrapper for the OAS ``Profile Foods`` tag (generated)."""

from __future__ import annotations

from typing import Any, Optional

from .._base import BaseResource

from ...models._generated.foods import Food


class ProfileFoodsResource(BaseResource):
    """Resource methods for the OAS `Profile Foods` tag (generated)."""

[docs] def add_favorite_v1( self, food_id: int, serving_id: Optional[int] = None, number_of_units: Optional[float] = None, ) -> bool: """Add a food to a user's favorite according to the parameters specified. :param food_id: Unique food identifier :param serving_id: Unique serving identifier :param number_of_units: Number of units in this standard serving size. For instance, if the serving description is "2 tablespoons" the number of units is "2", while if the serving size is "1 cup" the number of units is "1". Please note that this is only applicable for when food_type is "Generic" whereas for "Brand" the number of units will always be "1" Notes: food.add_favorite (v1). Premier-only. """ params: dict[str, Any] = {"method": "food.add_favorite"} params["food_id"] = food_id self._client._set_optional( params, [ ("serving_id", serving_id), ("number_of_units", number_of_units), ], ) payload = self._client._call(params, method="POST") return self._client._mutator_success(payload)
[docs] def create_v1( self, brand_name: str, food_name: str, serving_size: str, calories: float, fat: float, carbohydrate: float, protein: float, brand_type: Optional[str] = None, serving_amount: Optional[str] = None, serving_amount_unit: Optional[str] = None, calories_from_fat: Optional[float] = None, saturated_fat: Optional[float] = None, polyunsaturated_fat: Optional[float] = None, monounsaturated_fat: Optional[float] = None, trans_fat: Optional[float] = None, cholesterol: Optional[float] = None, sodium: Optional[float] = None, potassium: Optional[float] = None, fiber: Optional[float] = None, sugar: Optional[float] = None, other_carbohydrate: Optional[float] = None, vitamin_a: Optional[float] = None, vitamin_c: Optional[float] = None, calcium: Optional[float] = None, iron: Optional[float] = None, region: Optional[str] = None, language: Optional[str] = None, ) -> Any: """Creates a food for the user according to the parameters specified. The result of the call is the new unique identifier of the newly created food. :param brand_name: Brand name, only when food_type is "Brand". E.G.: "Quaker" :param food_name: Name of the food, not including the brand name. E.G.: "Instant Oatmeal" :param serving_size: Full description of the serving size. E.G.: "1 serving" :param calories: Energy content in kcal :param fat: Total fat content in grams :param carbohydrate: Total carbohydrate content in grams :param protein: Protein content in grams :param brand_type: Either "manufacturer", "restaurant" or "supermarket" (default value is "manufacturer") :param serving_amount: The quantity combined with serving_amount_unit to derive the total standardized quantity of the serving :param serving_amount_unit: The metric unit of measure for the serving size – either "g" or "ml" or "oz" – combined with metric_serving_amount to derive the total standardized quantity of the serving (default value is "g") :param calories_from_fat: The energy content in kcal from fat :param saturated_fat: Saturated fat content in grams (where available) :param polyunsaturated_fat: Polyunsaturated fat content in grams (where available) :param monounsaturated_fat: Monounsaturated fat content in grams (where available) :param trans_fat: Trans fat content in grams (where available) :param cholesterol: Cholesterol content in milligrams (where available) :param sodium: Sodium content in milligrams (where available) :param potassium: Potassium content in milligrams (where available) :param fiber: Fiber content in grams (where available) :param sugar: Sugar content in grams (where available) :param other_carbohydrate: The other carbohydrate content in grams :param vitamin_a: Percentage of daily recommended Vitamin A, based on a 2000 calorie diet (where available) :param vitamin_c: Percentage of daily recommended Vitamin C, based on a 2000 calorie diet (where available) :param calcium: Percentage of daily recommended Calcium, based on a 2000 calorie diet (where available) :param iron: Percentage of daily recommended Iron, based on a 2000 calorie diet (where available) :param region: Results will be filtered by region. E.G.: "FR" returns results from France. If not specified this will default to "US" (United States). Click here for full documentation on localization. :param language: (Ignored unless region is also specified) Results will be in the specified language. E.G.: "fr" returns results in French :return: Raw FatSecret response shape (no typed model — see ``docs/migration-v3.rst``). Notes: food.create (v1). DEPRECATED upstream. Premier-only. """ params: dict[str, Any] = {"method": "food.create"} params["brand_name"] = brand_name params["food_name"] = food_name params["serving_size"] = serving_size params["calories"] = calories params["fat"] = fat params["carbohydrate"] = carbohydrate params["protein"] = protein self._client._set_optional( params, [ ("brand_type", brand_type), ("serving_amount", serving_amount), ("serving_amount_unit", serving_amount_unit), ("calories_from_fat", calories_from_fat), ("saturated_fat", saturated_fat), ("polyunsaturated_fat", polyunsaturated_fat), ("monounsaturated_fat", monounsaturated_fat), ("trans_fat", trans_fat), ("cholesterol", cholesterol), ("sodium", sodium), ("potassium", potassium), ("fiber", fiber), ("sugar", sugar), ("other_carbohydrate", other_carbohydrate), ("vitamin_a", vitamin_a), ("vitamin_c", vitamin_c), ("calcium", calcium), ("iron", iron), ("region", region), ("language", language), ], ) payload = self._client._call(params, method="POST") raw = self._client._unwrap(payload, "food_id") return raw
[docs] def create_v2( self, brand_name: str, food_name: str, serving_size: str, calories: float, fat: float, carbohydrate: float, protein: float, brand_type: Optional[str] = None, serving_amount: Optional[str] = None, serving_amount_unit: Optional[str] = None, calories_from_fat: Optional[float] = None, saturated_fat: Optional[float] = None, polyunsaturated_fat: Optional[float] = None, monounsaturated_fat: Optional[float] = None, trans_fat: Optional[float] = None, cholesterol: Optional[float] = None, sodium: Optional[float] = None, potassium: Optional[float] = None, fiber: Optional[float] = None, sugar: Optional[float] = None, added_sugars: Optional[float] = None, vitamin_d: Optional[float] = None, vitamin_a: Optional[float] = None, vitamin_c: Optional[float] = None, calcium: Optional[float] = None, iron: Optional[float] = None, region: Optional[str] = None, language: Optional[str] = None, ) -> Any: """Creates a food for the user according to the parameters specified. The result of the call is the new unique identifier of the newly created food. :param brand_name: Brand name, only when food_type is "Brand". E.G.: "Quaker" :param food_name: Name of the food, not including the brand name. E.G.: "Instant Oatmeal" :param serving_size: Full description of the serving size. E.G.: "1 serving" :param calories: Energy content in kcal :param fat: Total fat content in grams :param carbohydrate: Total carbohydrate content in grams :param protein: Protein content in grams :param brand_type: Either "manufacturer", "restaurant" or "supermarket" (default value is "manufacturer") :param serving_amount: The quantity combined with serving_amount_unit to derive the total standardized quantity of the serving :param serving_amount_unit: The metric unit of measure for the serving size – either "g" or "ml" or "oz" – combined with metric_serving_amount to derive the total standardized quantity of the serving (default value is "g") :param calories_from_fat: The energy content in kcal from fat :param saturated_fat: Saturated fat content in grams (where available) :param polyunsaturated_fat: Polyunsaturated fat content in grams (where available) :param monounsaturated_fat: Monounsaturated fat content in grams (where available) :param trans_fat: Trans fat content in grams (where available) :param cholesterol: Cholesterol content in milligrams (where available) :param sodium: Sodium content in milligrams (where available) :param potassium: Potassium content in milligrams (where available) :param fiber: Fiber content in grams (where available) :param sugar: Sugar content in grams (where available) :param added_sugars: Added Sugars content in grams (where available) :param vitamin_d: Vitamin D content in micrograms (where available) :param vitamin_a: Vitamin A content in micrograms (where available) :param vitamin_c: Vitamin C content in milligrams (where available) :param calcium: Calcium content in milligrams (where available) :param iron: Iron content in milligrams (where available) :param region: Results will be filtered by region. E.G.: "FR" returns results from France. If not specified this will default to "US" (United States). Click here for full documentation on localization. :param language: (Ignored unless region is also specified) Results will be in the specified language. E.G.: "fr" returns results in French :return: Raw FatSecret response shape (no typed model — see ``docs/migration-v3.rst``). Notes: food.create (v2). Premier-only. """ params: dict[str, Any] = {"method": "food.create.v2"} params["brand_name"] = brand_name params["food_name"] = food_name params["serving_size"] = serving_size params["calories"] = calories params["fat"] = fat params["carbohydrate"] = carbohydrate params["protein"] = protein self._client._set_optional( params, [ ("brand_type", brand_type), ("serving_amount", serving_amount), ("serving_amount_unit", serving_amount_unit), ("calories_from_fat", calories_from_fat), ("saturated_fat", saturated_fat), ("polyunsaturated_fat", polyunsaturated_fat), ("monounsaturated_fat", monounsaturated_fat), ("trans_fat", trans_fat), ("cholesterol", cholesterol), ("sodium", sodium), ("potassium", potassium), ("fiber", fiber), ("sugar", sugar), ("added_sugars", added_sugars), ("vitamin_d", vitamin_d), ("vitamin_a", vitamin_a), ("vitamin_c", vitamin_c), ("calcium", calcium), ("iron", iron), ("region", region), ("language", language), ], ) payload = self._client._call(params, method="POST") raw = self._client._unwrap(payload, "food_id") return raw
[docs] def delete_favorite_v1( self, food_id: int, serving_id: Optional[int] = None, number_of_units: Optional[float] = None, ) -> bool: """Deletes the specified food from the user's favorite. :param food_id: Unique food identifier :param serving_id: Unique serving identifier :param number_of_units: Number of units in this standard serving size. For instance, if the serving description is "2 tablespoons" the number of units is "2", while if the serving size is "1 cup" the number of units is "1". Please note that this is only applicable for when food_type is "Generic" whereas for "Brand" the number of units will always be "1" Notes: food.delete_favorite (v1). Premier-only. """ params: dict[str, Any] = {"method": "food.delete_favorite"} params["food_id"] = food_id self._client._set_optional( params, [ ("serving_id", serving_id), ("number_of_units", number_of_units), ], ) payload = self._client._call(params, method="DELETE") return self._client._mutator_success(payload)
[docs] def get_favorites_v1( self, ) -> list[Food]: """Returns the favorite foods for the specified user. :return: List of :class:`Food` instances. Notes: foods.get_favorites (v1). DEPRECATED upstream. Premier-only. """ params: dict[str, Any] = {"method": "foods.get_favorites"} payload = self._client._call(params) raw = self._client._unwrap(payload, "foods", list_key="food") return [Food.model_validate(r) for r in raw]
[docs] def get_favorites_v2( self, ) -> list[Food]: """Returns the favorite foods for the specified user. :return: List of :class:`Food` instances. Notes: foods.get_favorites (v2). Premier-only. """ params: dict[str, Any] = {"method": "foods.get_favorites.v2"} payload = self._client._call(params) raw = self._client._unwrap(payload, "foods", list_key="food") return [Food.model_validate(r) for r in raw]
[docs] def get_most_eaten_v1( self, meal: Optional[str] = None, ) -> list[Food]: """Returns the favorite foods for the specified user. :param meal: Type of meal eaten. Valid meal types are "breakfast", "lunch", "dinner" and "other" :return: List of :class:`Food` instances. Notes: foods.get_most_eaten (v1). DEPRECATED upstream. Premier-only. """ params: dict[str, Any] = {"method": "foods.get_most_eaten"} self._client._set_optional( params, [ ("meal", meal), ], ) payload = self._client._call(params) raw = self._client._unwrap(payload, "foods", list_key="food") return [Food.model_validate(r) for r in raw]
[docs] def get_most_eaten_v2( self, meal: Optional[str] = None, ) -> list[Food]: """Returns the favorite foods for the specified user. :param meal: Type of meal eaten. Valid meal types are "breakfast", "lunch", "dinner" and "other" :return: List of :class:`Food` instances. Notes: foods.get_most_eaten (v2). Premier-only. """ params: dict[str, Any] = {"method": "foods.get_most_eaten.v2"} self._client._set_optional( params, [ ("meal", meal), ], ) payload = self._client._call(params) raw = self._client._unwrap(payload, "foods", list_key="food") return [Food.model_validate(r) for r in raw]
[docs] def get_recently_eaten_v1( self, meal: Optional[str] = None, ) -> list[Food]: """Returns the favorite foods for the specified user. :param meal: Type of meal eaten. Valid meal types are "breakfast", "lunch", "dinner" and "other" :return: List of :class:`Food` instances. Notes: foods.get_recently_eaten (v1). DEPRECATED upstream. Premier-only. """ params: dict[str, Any] = {"method": "foods.get_recently_eaten"} self._client._set_optional( params, [ ("meal", meal), ], ) payload = self._client._call(params) raw = self._client._unwrap(payload, "foods", list_key="food") return [Food.model_validate(r) for r in raw]
[docs] def get_recently_eaten_v2( self, meal: Optional[str] = None, ) -> list[Food]: """Returns the favorite foods for the specified user. :param meal: Type of meal eaten. Valid meal types are "breakfast", "lunch", "dinner" and "other" :return: List of :class:`Food` instances. Notes: foods.get_recently_eaten (v2). Premier-only. """ params: dict[str, Any] = {"method": "foods.get_recently_eaten.v2"} self._client._set_optional( params, [ ("meal", meal), ], ) payload = self._client._call(params) raw = self._client._unwrap(payload, "foods", list_key="food") return [Food.model_validate(r) for r in raw]
__all__ = ["ProfileFoodsResource"]