# AUTO-GENERATED by scripts/oas-sync emit-resource Recipes. Do not edit by hand.
"""Resource wrapper for the OAS ``Recipes`` tag (generated)."""
from __future__ import annotations
from typing import Any, Optional
from .._base import BaseResource
from ...models._generated.recipes import RecipesRecipe
class RecipesResource(BaseResource):
"""Resource methods for the OAS `Recipes` tag (generated)."""
def add_favorite_v1(
self,
recipe_id: int,
) -> bool:
"""recipe.add_favorite (v1). Premier-only."""
params: dict[str, Any] = {"method": "recipe.add_favorite"}
params["recipe_id"] = recipe_id
payload = self._client._call(params, method="POST")
return self._client._mutator_success(payload)
def delete_favorite_v1(
self,
recipe_id: int,
) -> bool:
"""recipe.delete_favorite (v1). Premier-only."""
params: dict[str, Any] = {"method": "recipe.delete_favorite"}
params["recipe_id"] = recipe_id
payload = self._client._call(params, method="DELETE")
return self._client._mutator_success(payload)
def get_favorites_v1(
self,
) -> list[RecipesRecipe]:
"""recipes.get_favorites (v1). DEPRECATED upstream. Premier-only."""
params: dict[str, Any] = {"method": "recipes.get_favorites"}
payload = self._client._call(params)
raw = self._client._unwrap(payload, "recipes", list_key="recipe")
return [RecipesRecipe.model_validate(r) for r in raw]
def get_favorites_v2(
self,
) -> list[RecipesRecipe]:
"""recipes.get_favorites (v2). Premier-only."""
params: dict[str, Any] = {"method": "recipes.get_favorites.v2"}
payload = self._client._call(params)
raw = self._client._unwrap(payload, "recipes", list_key="recipe")
return [RecipesRecipe.model_validate(r) for r in raw]
[docs]
def get_v1(
self,
recipe_id: int,
region: Optional[str] = None,
) -> Optional[RecipesRecipe]:
"""recipe.get (v1). DEPRECATED upstream. Premier-only."""
params: dict[str, Any] = {"method": "recipe.get"}
params["recipe_id"] = recipe_id
self._client._set_optional(
params,
[
("region", region),
],
)
payload = self._client._call(params)
raw = self._client._unwrap(payload, "recipe")
if raw is None:
return None
return RecipesRecipe.model_validate(raw)
[docs]
def get_v2(
self,
recipe_id: int,
region: Optional[str] = None,
) -> Optional[RecipesRecipe]:
"""recipe.get (v2). Premier-only."""
params: dict[str, Any] = {"method": "recipe.get.v2"}
params["recipe_id"] = recipe_id
self._client._set_optional(
params,
[
("region", region),
],
)
payload = self._client._call(params)
raw = self._client._unwrap(payload, "recipe")
if raw is None:
return None
return RecipesRecipe.model_validate(raw)
[docs]
def search_v1(
self,
search_expression: Optional[str] = None,
recipe_type: Optional[str] = None,
page_number: Optional[int] = None,
max_results: Optional[int] = None,
) -> list[RecipesRecipe]:
"""recipes.search (v1). DEPRECATED upstream. Premier-only."""
params: dict[str, Any] = {"method": "recipes.search"}
self._client._set_optional(
params,
[
("search_expression", search_expression),
("recipe_type", recipe_type),
("page_number", page_number),
("max_results", max_results),
],
)
payload = self._client._call(params)
raw = self._client._unwrap(payload, "recipes", list_key="recipe")
return [RecipesRecipe.model_validate(r) for r in raw]
def search_v2(
self,
search_expression: Optional[str] = None,
must_have_images: Optional[str] = None,
calories_from: Optional[int] = None,
calories_to: Optional[int] = None,
carb_percentage_from: Optional[int] = None,
carb_percentage_to: Optional[int] = None,
protein_percentage_from: Optional[int] = None,
protein_percentage_to: Optional[int] = None,
fat_percentage_from: Optional[int] = None,
fat_percentage_to: Optional[int] = None,
prep_time_from: Optional[int] = None,
prep_time_to: Optional[int] = None,
page_number: Optional[int] = None,
max_results: Optional[int] = None,
sort_by: Optional[str] = None,
region: Optional[str] = None,
) -> list[RecipesRecipe]:
"""recipes.search (v2). DEPRECATED upstream. Premier-only."""
params: dict[str, Any] = {"method": "recipes.search.v2"}
self._client._set_optional(
params,
[
("search_expression", search_expression),
("must_have_images", must_have_images),
("calories.from", calories_from),
("calories.to", calories_to),
("carb_percentage.from", carb_percentage_from),
("carb_percentage.to", carb_percentage_to),
("protein_percentage.from", protein_percentage_from),
("protein_percentage.to", protein_percentage_to),
("fat_percentage.from", fat_percentage_from),
("fat_percentage.to", fat_percentage_to),
("prep_time.from", prep_time_from),
("prep_time.to", prep_time_to),
("page_number", page_number),
("max_results", max_results),
("sort_by", sort_by),
("region", region),
],
)
payload = self._client._call(params)
raw = self._client._unwrap(payload, "recipes", list_key="recipe")
return [RecipesRecipe.model_validate(r) for r in raw]
def search_v3(
self,
recipe_types: Optional[str] = None,
recipe_types_matchall: Optional[str] = None,
search_expression: Optional[str] = None,
must_have_images: Optional[str] = None,
calories_from: Optional[int] = None,
calories_to: Optional[int] = None,
carb_percentage_from: Optional[int] = None,
carb_percentage_to: Optional[int] = None,
protein_percentage_from: Optional[int] = None,
protein_percentage_to: Optional[int] = None,
fat_percentage_from: Optional[int] = None,
fat_percentage_to: Optional[int] = None,
prep_time_from: Optional[int] = None,
prep_time_to: Optional[int] = None,
page_number: Optional[int] = None,
max_results: Optional[int] = None,
sort_by: Optional[str] = None,
region: Optional[str] = None,
) -> list[RecipesRecipe]:
"""recipes.search (v3). Premier-only."""
params: dict[str, Any] = {"method": "recipes.search.v3"}
self._client._set_optional(
params,
[
("recipe_types", recipe_types),
("recipe_types_matchall", recipe_types_matchall),
("search_expression", search_expression),
("must_have_images", must_have_images),
("calories.from", calories_from),
("calories.to", calories_to),
("carb_percentage.from", carb_percentage_from),
("carb_percentage.to", carb_percentage_to),
("protein_percentage.from", protein_percentage_from),
("protein_percentage.to", protein_percentage_to),
("fat_percentage.from", fat_percentage_from),
("fat_percentage.to", fat_percentage_to),
("prep_time.from", prep_time_from),
("prep_time.to", prep_time_to),
("page_number", page_number),
("max_results", max_results),
("sort_by", sort_by),
("region", region),
],
)
payload = self._client._call(params)
raw = self._client._unwrap(payload, "recipes", list_key="recipe")
return [RecipesRecipe.model_validate(r) for r in raw]
[docs]
def types_get_v1(
self,
) -> list:
"""No typed model — returns the raw FatSecret response shape. See ``docs/migration-v3.rst`` for details. recipe_types.get (v1). DEPRECATED upstream. Premier-only."""
params: dict[str, Any] = {"method": "recipe_types.get"}
payload = self._client._call(params)
raw = self._client._unwrap(payload, "recipe_types", list_key="recipe_type")
return raw
[docs]
def types_get_v2(
self,
region: Optional[str] = None,
language: Optional[str] = None,
) -> list:
"""No typed model — returns the raw FatSecret response shape. See ``docs/migration-v3.rst`` for details. recipe_types.get (v2). Premier-only."""
params: dict[str, Any] = {"method": "recipe_types.get.v2"}
self._client._set_optional(
params,
[
("region", region),
("language", language),
],
)
payload = self._client._call(params)
raw = self._client._unwrap(payload, "recipe_types", list_key="recipe_type")
return raw
__all__ = ["RecipesResource"]