This commit is contained in:
JMARyA 2024-07-24 16:38:56 +02:00
parent 3b0e8c1866
commit ca364453a7
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
10 changed files with 341 additions and 604 deletions

View file

@ -14,9 +14,8 @@ use super::{item_does_not_exist_error, variant_does_not_exist_error};
pub struct SupplyForm {
item: String,
variant: String,
amount: Option<usize>,
price: String,
origin: String,
origin: Option<String>,
}
#[post("/supply", data = "<form>")]
@ -30,12 +29,11 @@ pub async fn supply_route(form: Json<SupplyForm>, itemdb: &State<ItemDB>) -> Fal
let transaction_id = variant
.supply(
form.amount.unwrap_or(1),
form.price
.clone()
.try_into()
.map_err(|()| api_error("Price malformed"))?,
&form.origin,
form.origin.as_deref(),
)
.await;