Debian Codegraph @

cookidoo_api/raw_types.py

raw
1 """Cookidoo API raw json types."""
2
3 from typing import Literal, NotRequired, Required, TypedDict
4
5
6 class UserInfoJSON(TypedDict):
7 """The json for a user info in the API."""
8
9 username: str
10 description: str | None
11 picture: str | None
12
13
14 class CommunityProfileJSON(TypedDict):
15 """The json for the community profile response."""
16
17 id: str
18 userInfo: UserInfoJSON
19
20
21 class SubscriptionJSON(TypedDict):
22 """The json for a subscription in the API."""
23
24 active: bool
25 expires: str
26 startDate: str
27 status: str
28 subscriptionLevel: str
29 subscriptionSource: str
30 type: str
31 extendedType: str
32
33
34 # class QuantityJSON(TypedDict):
35 # """The json for an quantity in the API."""
36
37 # value: int | None
38 # from: int | None
39 # to: int | None
40
41 # Need to use alternative syntax as "from" is a protected keyword
42 QuantityJSON = TypedDict(
43 "QuantityJSON", {"value": int | None, "from": int | None, "to": int | None}
44 )
45
46
47 class AdditionalItemJSON(TypedDict):
48 """The json for an additional item in the API."""
49
50 id: str
51 name: str
52 isOwned: bool
53
54
55 class ItemJSON(TypedDict):
56 """The json for an item in the API."""
57
58 id: str
59 ingredientNotation: str
60 isOwned: bool
61 quantity: QuantityJSON | None
62 unitNotation: str | None
63
64
65 class IngredientJSON(TypedDict):
66 """The json for an ingredient in the API."""
67
68 localId: str
69 ingredientNotation: str
70 quantity: QuantityJSON | None
71 unitNotation: str | None
72
73
74 class DescriptiveAssetJSON(TypedDict):
75 """The json for a descriptive asset in the API."""
76
77 square: str | None
78 portrait: str | None
79 landscape: str | None
80
81
82 class RecipeJSON(TypedDict):
83 """The json for a recipe in the API."""
84
85 id: str
86 title: str
87 recipeIngredientGroups: list[ItemJSON]
88 descriptiveAssets: list[DescriptiveAssetJSON] | None
89
90
91 class RecipeDetailsAdditionalInformationJSON(TypedDict):
92 """The json for a recipe details additional information in the API."""
93
94 content: str
95
96
97 class RecipeDetailsCategoryJSON(TypedDict):
98 """The json for a recipe details category in the API."""
99
100 id: str
101 title: str
102 subtitle: str
103
104
105 class RecipeDetailsCollectionCountJSON(TypedDict):
106 """The json for a recipe details collection count in the API."""
107
108 value: int
109
110
111 class RecipeDetailsCollectionJSON(TypedDict):
112 """The json for a recipe details collection in the API."""
113
114 id: str
115 title: str
116 recipesCount: RecipeDetailsCollectionCountJSON
117
118
119 class RecipeDetailsIngredientGroupJSON(TypedDict):
120 """The json for a recipe details ingredient group in the API."""
121
122 recipeIngredients: list[IngredientJSON]
123
124
125 class RecipeDetailsStepJSON(TypedDict):
126 """The json for a recipe step in the API."""
127
128 formattedText: str
129 title: str
130
131
132 class RecipeDetailsStepGroupJSON(TypedDict):
133 """The json for a recipe step group in the API."""
134
135 title: str
136 recipeSteps: list[RecipeDetailsStepJSON]
137
138
139 class RecipeDetailsUtensilsJSON(TypedDict):
140 """The json for a recipe utensils in the API."""
141
142 utensilNotation: str
143
144
145 class RecipeDetailsServingSizeJSON(TypedDict):
146 """The json for a recipe serving size in the API."""
147
148 quantity: QuantityJSON
149 unitNotation: str
150
151
152 class RecipeDetailsTimeJSON(TypedDict):
153 """The json for a recipe time in the API."""
154
155 quantity: QuantityJSON
156 type: str
157 comment: str
158
159
160 class RecipeDetailsNutritionJSON(TypedDict):
161 """The json for a recipe nutrition in the API."""
162
163 number: float
164 type: str
165 unittype: str
166
167
168 class RecipeDetailsRecipeNutritionJSON(TypedDict):
169 """The json for a recipe nutrition item in the API."""
170
171 nutritions: list[RecipeDetailsNutritionJSON]
172 quantity: int
173 unitNotation: str
174
175
176 class RecipeDetailsNutritionGroupJSON(TypedDict):
177 """The json for a recipe nutrition group in the API."""
178
179 name: str
180 recipeNutritions: list[RecipeDetailsRecipeNutritionJSON]
181
182
183 class RecipeDetailsJSON(TypedDict):
184 """The json for a recipe details in the API."""
185
186 id: str
187 title: str
188 difficulty: str
189 additionalInformation: list[RecipeDetailsAdditionalInformationJSON]
190 categories: list[RecipeDetailsCategoryJSON]
191 inCollections: list[RecipeDetailsCollectionJSON]
192 recipeIngredientGroups: list[RecipeDetailsIngredientGroupJSON]
193 recipeStepGroups: list[RecipeDetailsStepGroupJSON]
194 recipeUtensils: list[RecipeDetailsUtensilsJSON]
195 servingSize: RecipeDetailsServingSizeJSON
196 times: list[RecipeDetailsTimeJSON]
197 nutritionGroups: list[RecipeDetailsNutritionGroupJSON]
198 descriptiveAssets: list[DescriptiveAssetJSON] | None
199
200
201 class CustomRecipeYieldJSON(TypedDict):
202 """The json for a custom recipe yield in the API."""
203
204 value: int
205 unitText: str
206
207
208 class CustomRecipeTextJSON(TypedDict):
209 """A text item in a custom recipe list response."""
210
211 text: str
212
213
214 CustomRecipeContentJSON = TypedDict(
215 "CustomRecipeContentJSON",
216 {
217 "name": Required[str],
218 "totalTime": str | int | float,
219 "prepTime": str | int | float,
220 "tool": list[str],
221 "tools": list[str],
222 "recipeYield": CustomRecipeYieldJSON,
223 "yield": CustomRecipeYieldJSON,
224 "recipeIngredient": list[str | CustomRecipeTextJSON],
225 "ingredients": list[str | CustomRecipeTextJSON],
226 "recipeInstructions": list[str | CustomRecipeTextJSON],
227 "instructions": list[str | CustomRecipeTextJSON],
228 "image": str | None,
229 },
230 total=False,
231 )
232
233
234 class CustomRecipeJSON(TypedDict):
235 """The json for a custom recipe in the API."""
236
237 recipeId: str
238 title: NotRequired[str]
239 recipeContent: CustomRecipeContentJSON
240
241
242 class CustomRecipesJSON(TypedDict):
243 """The json for a custom recipe list response."""
244
245 items: list[CustomRecipeJSON]
246
247
248 class ChapterRecipeJSON(TypedDict):
249 """The json for a chapter recipe in the API."""
250
251 id: str
252 title: str
253 type: Literal["VORWERK"] | Literal["CUSTOM"]
254 totalTime: int
255
256
257 class ChapterJSON(TypedDict):
258 """The json for a chapter in the API."""
259
260 title: str
261 recipes: list[ChapterRecipeJSON]
262
263
264 class CustomCollectionJSON(TypedDict):
265 """The json for a custom collection in the API."""
266
267 id: str
268 title: str
269 chapters: list[ChapterJSON]
270 listType: Literal["CUSTOMLIST"]
271 author: str
272
273
274 class ManagedCollectionJSON(TypedDict):
275 """The json for a managed collection in the API."""
276
277 id: str
278 title: str
279 description: str
280 chapters: list[ChapterJSON]
281 listType: Literal["MANAGEDLIST"]
282 author: Literal["Vorwerk"]
283
284
285 class CalenderDayRecipeAssetsJSON(TypedDict):
286 """The json for calendar day recipe assets in the API."""
287
288 images: DescriptiveAssetJSON | None
289
290
291 class CalenderDayRecipeJSON(TypedDict):
292 """The json for a calender day recipe in the API."""
293
294 id: str
295 title: str
296 totalTime: int
297 assets: CalenderDayRecipeAssetsJSON | None
298
299
300 class CalendarDayJSON(TypedDict):
301 """The json for a calendar day in the API."""
302
303 id: str
304 title: str
305 dayKey: str
306 recipes: list[CalenderDayRecipeJSON]
307 customerRecipes: NotRequired[list[CalenderDayRecipeJSON]]
308 customerRecipeIds: NotRequired[list[str]]
309
310
311 class SearchRecipeHitJSON(TypedDict, total=False):
312 """The json for a single recipe hit in search results."""
313
314 id: str
315 title: str
316 name: str
317 descriptiveAssets: list[DescriptiveAssetJSON] | None
318
319
320 class SearchResultJSON(TypedDict, total=False):
321 """The json for a search result from the API."""
322
323 data: list[SearchRecipeHitJSON]
324 recipes: list[SearchRecipeHitJSON]
325 total: int
326
327
328 class PaginationJSON(TypedDict):
329 """The json for pagination info in collection responses."""
330
331 totalElements: int
332 totalPages: int
333
334
335 __all__ = ["QuantityJSON"]