refactor
This commit is contained in:
parent
3b0e8c1866
commit
ca364453a7
10 changed files with 341 additions and 604 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue