inventory
This commit is contained in:
parent
72586df67f
commit
0be7fff77d
6 changed files with 49 additions and 9 deletions
|
@ -56,3 +56,23 @@ pub async fn supply_log_route(
|
|||
|
||||
Ok(json!(transactions))
|
||||
}
|
||||
|
||||
#[get("/item/<item_id>/<variant_id>/inventory")]
|
||||
pub async fn inventory_route(
|
||||
item_id: &str,
|
||||
variant_id: &str,
|
||||
itemdb: &State<ItemDB>,
|
||||
) -> FallibleApiResponse {
|
||||
let variant = itemdb
|
||||
.get_item(item_id)
|
||||
.ok_or_else(item_does_not_exist_error)?
|
||||
.variant(variant_id)
|
||||
.ok_or_else(variant_does_not_exist_error)?;
|
||||
|
||||
let transactions = variant.inventory().await;
|
||||
|
||||
Ok(json!(transactions
|
||||
.into_iter()
|
||||
.map(|x| x.api_json())
|
||||
.collect::<Vec<_>>()))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue