118 lines
2.5 KiB
Rust
118 lines
2.5 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use uuid::Uuid;
|
|
|
|
// Struct for the users answer to a captcha
|
|
#[derive(Clone, Debug, FromForm)]
|
|
pub struct CaptchaAnswer {
|
|
pub text: String,
|
|
}
|
|
|
|
// Struct for modifying an order
|
|
#[derive(FromForm, Copy, Clone)]
|
|
pub struct OrderUpdate<'r> {
|
|
pub r#order_uuid: &'r str,
|
|
pub status: OrderStatus,
|
|
pub payment_type: PaymentOption,
|
|
pub r#password: &'r str,
|
|
}
|
|
|
|
// Return status
|
|
#[derive(Serialize)]
|
|
pub struct Status {
|
|
pub status: String,
|
|
pub reason: String,
|
|
}
|
|
|
|
// User authentication
|
|
#[derive(Clone, Debug, FromForm)]
|
|
pub struct Authenticate {
|
|
pub password: String,
|
|
}
|
|
|
|
// Struct for new product
|
|
#[derive(Clone, Debug, FromForm)]
|
|
pub struct ProductRequest {
|
|
pub full_name: String,
|
|
pub short_name: String,
|
|
pub description: String,
|
|
pub price_usd: f64,
|
|
pub stock: u32,
|
|
pub class: ProductClass,
|
|
pub password: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Copy, Clone, Debug, FromFormField)]
|
|
pub enum ProductClass {
|
|
Estrogens,
|
|
AntiAndrogens,
|
|
Progestogens,
|
|
}
|
|
|
|
// Struct for a stored product
|
|
#[derive(Clone, Serialize, Deserialize, Debug, FromForm)]
|
|
pub struct Product {
|
|
pub full_name: String,
|
|
pub short_name: String,
|
|
pub description: String,
|
|
pub price_usd: f64,
|
|
pub stock: u32,
|
|
pub class: ProductClass,
|
|
}
|
|
|
|
// User order request
|
|
#[derive(FromForm)]
|
|
pub struct OrderRequest<'r> {
|
|
pub r#name: &'r str,
|
|
pub r#email: &'r str,
|
|
pub r#user_message: &'r str,
|
|
pub r#encryption_key: &'r str,
|
|
pub r#payment_type: PaymentOption,
|
|
pub r#captcha: &'r str,
|
|
}
|
|
|
|
// Struct for a stored order
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
pub struct Order {
|
|
pub name: String,
|
|
pub email: String,
|
|
pub message: String,
|
|
pub encryption_key: String,
|
|
pub payment_type: PaymentOption,
|
|
pub uuid: Uuid,
|
|
pub status: OrderStatus,
|
|
}
|
|
|
|
#[derive(FromFormField)]
|
|
pub enum UpdateField {
|
|
Price,
|
|
Stock,
|
|
Description,
|
|
}
|
|
|
|
// Struct for a request to update a product
|
|
#[derive(FromForm)]
|
|
pub struct Update<'r> {
|
|
pub r#product: &'r str,
|
|
pub field: UpdateField,
|
|
pub value: Option<f64>,
|
|
pub text: Option<&'r str>,
|
|
pub r#password: &'r str,
|
|
}
|
|
|
|
// Possible status states for an order
|
|
#[derive(Debug, PartialEq, FromFormField, Serialize, Clone, Copy, Deserialize)]
|
|
pub enum OrderStatus {
|
|
Submitted,
|
|
Processing,
|
|
Shipping,
|
|
Complete,
|
|
}
|
|
|
|
// Options for payment
|
|
#[derive(Debug, PartialEq, FromFormField, Serialize, Deserialize, Clone, Copy)]
|
|
pub enum PaymentOption {
|
|
XMR,
|
|
ETH,
|
|
BTC,
|
|
}
|