Add get_template_content and get_user_recipes methods - #272
Draft
erikzimmermann wants to merge 1 commit into
Draft
Add get_template_content and get_user_recipes methods#272erikzimmermann wants to merge 1 commit into
erikzimmermann wants to merge 1 commit into
Conversation
tr4nt0r
requested changes
Jul 23, 2026
Comment on lines
+1470
to
+1512
| async def get_user_recipes(self) -> list[BringTemplate]: | ||
| """Fetch all recipes and templates saved by the user, with full item details. | ||
|
|
||
| Combines :meth:`get_inspirations` (``filter="mine"``) with | ||
| :meth:`get_template_content` to return complete templates whose | ||
| ``items`` list is populated with ingredients and staples. | ||
|
|
||
| Returns | ||
| ------- | ||
| list[BringTemplate] | ||
| Full templates for every user-created recipe/template (ad entries | ||
| of type ``POST`` are excluded). Each template's ``items`` field | ||
| contains all ingredients; items with ``stock=True`` are staples. | ||
|
|
||
| Raises | ||
| ------ | ||
| BringRequestException | ||
| If any request fails. | ||
| BringParseException | ||
| If parsing of any response fails. | ||
| BringAuthException | ||
| If the request fails due to invalid or expired authorization token. | ||
|
|
||
| """ | ||
| inspirations = await self.get_inspirations("mine") | ||
| recipes: list[BringTemplate] = [] | ||
| for entry in inspirations.entries: | ||
| if entry.template_type == TemplateType.POST: | ||
| continue | ||
| summary = entry.content | ||
| if not summary.contentUuid: | ||
| recipes.append(summary) | ||
| continue | ||
| full = await self.get_template_content(summary.contentUuid) | ||
| # Detail endpoint may omit top-level metadata present in the summary | ||
| if not full.name: | ||
| full.name = summary.name or summary.title | ||
| if not full.linkOutUrl: | ||
| full.linkOutUrl = summary.linkOutUrl | ||
| if not full.imageUrl: | ||
| full.imageUrl = summary.imageUrl | ||
| recipes.append(full) | ||
| return recipes |
Collaborator
There was a problem hiding this comment.
I think the library should only serve as an interface to the Bring REST API. Any processing or interpretation of the API responses should be handled downstream rather than in the library itself.
tr4nt0r
marked this pull request as draft
July 23, 2026 00:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks @miaucl for the great work on this library. I am missing an export endpoint for the recipes though. So here it is.
Summary
get_template_content(content_uuid)to fetch full template details(including ingredients) from the
/v2/bringtemplates/content/{uuid}endpointget_user_recipes()as a convenience method that combinesget_inspirations("mine")withget_template_contentto return fullypopulated templates for all user-saved recipes (ad/POST entries excluded)
where the detail endpoint omits it
Note: existing tests are currently affected by an
aioresponses/aiohttp 3.13+incompatibility — a fix is pending upstream in pnuckowski/aioresponses.