regalade/api/src/lib.rs

126 lines
2.7 KiB
Rust
Raw Normal View History

use std::collections::HashMap;
2023-05-19 11:23:44 +02:00
use serde::{Deserialize, Serialize};
use uuid::Uuid;
2023-05-19 11:23:44 +02:00
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
2023-05-19 11:23:44 +02:00
pub struct LoginRequest {
pub username: String,
pub password: String,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
2023-05-19 11:23:44 +02:00
pub struct LoginResponse {
pub token: String,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct EmptyResponse {}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Household {
pub name: String,
pub members: Vec<Uuid>,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Households {
pub households: HashMap<Uuid, Household>,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CreateHouseholdRequest {
pub name: String,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CreateHouseholdResponse {
pub id: Uuid,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
2023-05-29 22:08:43 +02:00
pub struct RenameHouseholdRequest {
pub name: String,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AddToHouseholdRequest {
pub user: Uuid,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct UserInfo {
pub name: String,
pub id: Uuid,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CreateIngredientRequest {
pub name: String,
pub unit: Option<String>,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CreateIngredientResponse {
pub id: i64,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct IngredientInfo {
pub name: String,
pub unit: Option<String>,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct IngredientList {
pub ingredients: HashMap<i64, IngredientInfo>,
}
2023-06-17 21:52:31 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct EditIngredientRequest {
pub name: Option<String>,
pub unit: Option<String>,
#[serde(default)]
pub has_unit: bool,
}
2023-06-22 22:29:53 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CreateRecipeRequest {
pub name: String,
pub rating: u8,
pub ingredients: Vec<(i64, f64)>,
pub steps: String,
2023-06-22 22:29:53 +02:00
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CreateRecipeResponse {
pub id: i64,
}
2023-06-22 23:04:46 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct ListRecipesResponse {
pub recipes: Vec<(i64, String)>,
}
2023-06-25 15:13:15 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct RecipeInfo {
pub name: String,
pub steps: String,
2023-06-25 15:13:15 +02:00
pub ingredients: Vec<(i64, IngredientInfo, f64)>,
}
2023-06-25 16:11:26 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct RecipeRenameRequest {
pub name: String,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct RecipeIngredientEditRequest {
pub amount: f64,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct AddRecipeIngredientRequest {
pub amount: f64,
}