Simplify web API (put ids in url)
This commit is contained in:
parent
0c43935bef
commit
6e017e41a3
14 changed files with 403 additions and 588 deletions
|
|
@ -80,24 +80,22 @@ impl RecipeScheduler {
|
|||
return Ok(vec![]);
|
||||
}
|
||||
|
||||
let titles: ron_api::Strings = request::get(
|
||||
let titles: Vec<String> = request::get_with_params(
|
||||
"recipe/titles",
|
||||
ron_api::Ids {
|
||||
ids: recipe_ids_and_dates
|
||||
.iter()
|
||||
.map(|r| r.recipe_id)
|
||||
.collect::<Vec<_>>(),
|
||||
},
|
||||
recipe_ids_and_dates
|
||||
.iter()
|
||||
.map(|r| r.recipe_id)
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(recipe_ids_and_dates
|
||||
.iter()
|
||||
.zip(titles.strs.into_iter())
|
||||
.zip(titles.into_iter())
|
||||
.map(|(id_and_date, title)| (id_and_date.date, title, id_and_date.recipe_id))
|
||||
.collect::<Vec<_>>())
|
||||
} else {
|
||||
let scheduled_recipes: ron_api::ScheduledRecipes = request::get(
|
||||
let scheduled_recipes: ron_api::ScheduledRecipes = request::get_with_params(
|
||||
"calendar/scheduled_recipes",
|
||||
ron_api::DateRange {
|
||||
start_date,
|
||||
|
|
@ -131,12 +129,12 @@ impl RecipeScheduler {
|
|||
} else {
|
||||
request::post::<ron_api::ScheduleRecipeResult, _>(
|
||||
"calendar/scheduled_recipe",
|
||||
ron_api::ScheduleRecipe {
|
||||
Some(ron_api::ScheduleRecipe {
|
||||
recipe_id,
|
||||
date,
|
||||
servings,
|
||||
add_ingredients_to_shopping_list,
|
||||
},
|
||||
}),
|
||||
)
|
||||
.await
|
||||
.map_err(Error::from)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue