-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrecipes.rs
More file actions
49 lines (42 loc) · 1.35 KB
/
recipes.rs
File metadata and controls
49 lines (42 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use anylist_rs::{AnyListClient, Ingredient, Result};
#[tokio::main]
async fn main() -> Result<()> {
let client = AnyListClient::new("email@example.com", "password").await?;
// Create a recipe
let ingredients = vec![
Ingredient {
name: "Flour".to_string(),
quantity: Some("2 cups".to_string()),
note: None,
raw_ingredient: None,
},
Ingredient {
name: "Sugar".to_string(),
quantity: Some("1 cup".to_string()),
note: None,
raw_ingredient: None,
},
Ingredient {
name: "Eggs".to_string(),
quantity: Some("2".to_string()),
note: None,
raw_ingredient: None,
},
];
let steps = vec![
"Preheat oven to 350°F".to_string(),
"Mix dry ingredients".to_string(),
"Add eggs and mix well".to_string(),
"Bake for 30 minutes".to_string(),
];
let recipe = client.create_recipe("Simple Cake", ingredients, steps).await?;
println!("Created recipe: {}", recipe.name);
// Get all recipes
let recipes = client.get_recipes().await?;
for recipe in &recipes {
println!("Recipe: {} ({} ingredients)", recipe.name, recipe.ingredients.len());
}
// Delete a recipe
client.delete_recipe(&recipe.id).await?;
Ok(())
}