Source code for fatsecret.resources._generated.meals

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

from __future__ import annotations

from typing import Any, Optional

from .._base import BaseResource


class MealsResource(BaseResource):
    """Resource methods for the OAS `Saved Meals` tag (generated)."""

[docs] def create_v1( self, saved_meal_name: str, saved_meal_description: Optional[str] = None, meals: Optional[str] = None, ) -> Any: """Records a saved meal for the user according to the parameters specified. The result of the call is the new unique identifier of the newly created saved meal. :param saved_meal_name: New name of the saved meal :param saved_meal_description: New description of the saved meal :param meals: Comma separated list of meals the saved meal is suitable for :return: Raw FatSecret response shape (no typed model — see ``docs/migration-v3.rst``). Notes: saved_meal.create (v1). Premier-only. """ params: dict[str, Any] = {"method": "saved_meal.create"} params["saved_meal_name"] = saved_meal_name self._client._set_optional( params, [ ("saved_meal_description", saved_meal_description), ("meals", meals), ], ) payload = self._client._call(params, method="POST") raw = self._client._unwrap(payload, "saved_meal_id") return raw
[docs] def delete_v1( self, saved_meal_id: int, ) -> bool: """Deletes the specified saved meal for the user. :param saved_meal_id: Unique saved meal identifier Notes: saved_meal.delete (v1). Premier-only. """ params: dict[str, Any] = {"method": "saved_meal.delete"} params["saved_meal_id"] = saved_meal_id payload = self._client._call(params, method="DELETE") return self._client._mutator_success(payload)
[docs] def edit_v1( self, saved_meal_id: int, saved_meal_name: Optional[str] = None, saved_meal_description: Optional[str] = None, meals: Optional[str] = None, ) -> bool: """Records a change to a user's saved meal. :param saved_meal_id: Unique saved meal identifier :param saved_meal_name: New name of the saved meal :param saved_meal_description: New description of the saved meal :param meals: Comma separated list of meals the saved meal is suitable for Notes: saved_meal.edit (v1). Premier-only. """ params: dict[str, Any] = {"method": "saved_meal.edit"} params["saved_meal_id"] = saved_meal_id self._client._set_optional( params, [ ("saved_meal_name", saved_meal_name), ("saved_meal_description", saved_meal_description), ("meals", meals), ], ) payload = self._client._call(params, method="PUT") return self._client._mutator_success(payload)
[docs] def get_v1( self, meal: Optional[str] = None, ) -> list: """Returns saved meals for the specified user. :param meal: Type of meal eaten. Valid meal types are "breakfast", "lunch", "dinner" and "other" :return: Raw FatSecret response shape (no typed model — see ``docs/migration-v3.rst``). Notes: saved_meals.get (v1). DEPRECATED upstream. Premier-only. """ params: dict[str, Any] = {"method": "saved_meals.get"} self._client._set_optional( params, [ ("meal", meal), ], ) payload = self._client._call(params) raw = self._client._unwrap(payload, "saved_meals", list_key="saved_meal") return raw
[docs] def get_v2( self, meal: Optional[str] = None, ) -> list: """Returns saved meals for the specified user. :param meal: Type of meal eaten. Valid meal types are "breakfast", "lunch", "dinner" and "other" :return: Raw FatSecret response shape (no typed model — see ``docs/migration-v3.rst``). Notes: saved_meals.get (v2). Premier-only. """ params: dict[str, Any] = {"method": "saved_meals.get.v2"} self._client._set_optional( params, [ ("meal", meal), ], ) payload = self._client._call(params) raw = self._client._unwrap(payload, "saved_meals", list_key="saved_meal") return raw
[docs] def item_add_v1( self, saved_meal_id: int, food_id: int, saved_meal_item_name: str, serving_id: int, number_of_units: float, ) -> Any: """Adds a food to a user's saved meal according to the parameters specified. The result of the call is the new unique identifier of the newly created saved meal item. :param saved_meal_id: Unique saved meal identifier :param food_id: Unique food identifier :param saved_meal_item_name: New name of the saved meal item :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" :return: Raw FatSecret response shape (no typed model — see ``docs/migration-v3.rst``). Notes: saved_meal_item.add (v1). Premier-only. """ params: dict[str, Any] = {"method": "saved_meal_item.add"} params["saved_meal_id"] = saved_meal_id params["food_id"] = food_id params["saved_meal_item_name"] = saved_meal_item_name params["serving_id"] = serving_id params["number_of_units"] = number_of_units payload = self._client._call(params, method="POST") raw = self._client._unwrap(payload, "saved_meal_item_id") return raw
[docs] def item_delete_v1( self, saved_meal_item_id: int, ) -> bool: """Deletes the specified saved meal item for the user. :param saved_meal_item_id: Unique saved meal item identifier Notes: saved_meal_item.delete (v1). Premier-only. """ params: dict[str, Any] = {"method": "saved_meal_item.delete"} params["saved_meal_item_id"] = saved_meal_item_id payload = self._client._call(params, method="DELETE") return self._client._mutator_success(payload)
[docs] def item_edit_v1( self, saved_meal_item_id: int, saved_meal_item_name: Optional[str] = None, number_of_units: Optional[float] = None, ) -> bool: """Records a change to a user's saved meal item. Note that the serving_id of the saved meal item may not be adjusted, however one or more of the other remaining properties – saved_meal_item_name or number_of_units may be altered. In order to adjust a serving_id for which a saved_meal_item was recorded the original item must be deleted and a new item recorded. :param saved_meal_item_id: Unique saved meal item identifier :param saved_meal_item_name: New name of the saved meal item :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: saved_meal_item.edit (v1). Premier-only. """ params: dict[str, Any] = {"method": "saved_meal_item.edit"} params["saved_meal_item_id"] = saved_meal_item_id self._client._set_optional( params, [ ("saved_meal_item_name", saved_meal_item_name), ("number_of_units", number_of_units), ], ) payload = self._client._call(params, method="PUT") return self._client._mutator_success(payload)
[docs] def items_get_v1( self, saved_meal_id: int, ) -> list: """Returns saved meal items for a specified saved meal. :param saved_meal_id: Unique saved meal identifier :return: Raw FatSecret response shape (no typed model — see ``docs/migration-v3.rst``). Notes: saved_meal_items.get (v1). DEPRECATED upstream. Premier-only. """ params: dict[str, Any] = {"method": "saved_meal_items.get"} params["saved_meal_id"] = saved_meal_id payload = self._client._call(params) raw = self._client._unwrap(payload, "saved_meal_items", list_key="saved_meal_item") return raw
[docs] def items_get_v2( self, saved_meal_id: int, ) -> list: """Returns saved meal items for a specified saved meal. :param saved_meal_id: Unique saved meal identifier :return: Raw FatSecret response shape (no typed model — see ``docs/migration-v3.rst``). Notes: saved_meal_items.get (v2). Premier-only. """ params: dict[str, Any] = {"method": "saved_meal_items.get.v2"} params["saved_meal_id"] = saved_meal_id payload = self._client._call(params) raw = self._client._unwrap(payload, "saved_meal_items", list_key="saved_meal_item") return raw
MealsResource.__module__ = "fatsecret.resources.meals" __all__ = ["MealsResource"]