Crates.io | pantry_client |
lib.rs | pantry_client |
version | 0.1.1 |
source | src |
created_at | 2024-03-16 17:29:48.5706 |
updated_at | 2024-03-16 17:35:30.279573 |
description | A client for the Pantry API |
homepage | |
repository | |
max_upload_size | |
id | 1175810 |
size | 52,277 |
This is a Rust client for interacting with the Pantry API.
cargo add pantry_client
or add the following to your Cargo.toml
file:
pantry_client = "0.1.0"
Create a new client by bringing in the package in scope
let client = pantry_client::new_client("<PANTRY ID HERE>");
To get a pantry, use the GetPantry method.
let res = client.get_pantry().await?;
println!("Pantry: {:#?}", res);
To update pantry details, use the UpdatePantryDetails method.
let req = pantry_client::UpdatePantryRequest {
name: "My Pantry".to_string(),
description: "My Pantry Description".to_string(),
};
let res = p.update_pantry_details(req).await.unwrap();
println!("Pantry: {:#?}", res);
To update basket, use the UpdateBasket method.
let data = serde_json::json!({
"name": "My Basket",
"description": "My Basket Description",
});
let res = p.upsert_basket("my_basket", data).await?;
println!("Upsert Basket: {:#?}", res);
To get contents of the basket, use the GetContents method.
let res = p.get_basket_content("my_basket").await?;
println!("Basket Content: {:#?}", res);
To delete a basket, use the DeleteBasket method.
let del = p.delete_basket("my_basket_2").await?;
println!("Delete Basket 2: {:#?}", del);
To update basket contents, use the UpdateBasketContents method.
let update = serde_json::json!({
"name": "My Basket",
"description": "My Basket Description",
"items": [
{
"name": "Item 1",
"description": "Item 1 Description",
"quantity": 1,
},
{
"name": "Item 2",
"description": "Item 2 Description",
"quantity": 2,
},
],
});
let res = p.update_basket_content("my_basket", update).await?;
println!("Update Basket: {:#?}", res);