2022-05-10 16:20:37 +02:00
|
|
|
use chrono::NaiveDateTime;
|
2022-05-09 16:17:27 +02:00
|
|
|
use derive_more::Deref;
|
|
|
|
use serde::{Deserialize, Serialize};
|
2022-05-06 11:47:18 +02:00
|
|
|
|
2022-05-10 16:20:37 +02:00
|
|
|
use crate::*;
|
2022-05-08 14:59:59 +02:00
|
|
|
|
2022-05-15 10:30:15 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct Failure {
|
|
|
|
pub errors: Vec<String>,
|
|
|
|
}
|
|
|
|
|
2022-05-17 16:04:29 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Default)]
|
|
|
|
pub struct Config {
|
|
|
|
pub pay_methods: Vec<PaymentMethod>,
|
|
|
|
pub coupons: bool,
|
|
|
|
pub currency: String,
|
2022-05-18 09:48:01 +02:00
|
|
|
pub shipping: bool,
|
2022-05-18 15:40:50 +02:00
|
|
|
pub shipping_methods: Vec<ShippingMethod>,
|
2022-05-17 16:04:29 +02:00
|
|
|
}
|
|
|
|
|
2022-05-19 16:13:27 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct Account {
|
|
|
|
pub id: AccountId,
|
|
|
|
pub email: Email,
|
|
|
|
pub login: Login,
|
|
|
|
pub role: Role,
|
|
|
|
pub customer_id: uuid::Uuid,
|
|
|
|
pub state: AccountState,
|
2022-05-23 14:11:56 +02:00
|
|
|
pub addresses: Vec<AccountAddress>,
|
2022-05-19 16:13:27 +02:00
|
|
|
}
|
|
|
|
|
2022-05-23 14:11:56 +02:00
|
|
|
impl From<(FullAccount, Vec<crate::AccountAddress>)> for Account {
|
2022-05-19 16:13:27 +02:00
|
|
|
fn from(
|
|
|
|
(
|
|
|
|
FullAccount {
|
|
|
|
id,
|
|
|
|
email,
|
|
|
|
login,
|
|
|
|
pass_hash: _,
|
|
|
|
role,
|
|
|
|
customer_id,
|
|
|
|
state,
|
|
|
|
},
|
|
|
|
addresses,
|
2022-05-23 14:11:56 +02:00
|
|
|
): (FullAccount, Vec<crate::AccountAddress>),
|
2022-05-19 16:13:27 +02:00
|
|
|
) -> Self {
|
|
|
|
Self {
|
|
|
|
id,
|
|
|
|
email,
|
|
|
|
login,
|
|
|
|
role,
|
|
|
|
customer_id,
|
|
|
|
state,
|
|
|
|
addresses: addresses.into_iter().map(From::from).collect(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2022-05-23 14:11:56 +02:00
|
|
|
pub struct AccountAddress {
|
2022-05-19 16:13:27 +02:00
|
|
|
pub id: AddressId,
|
|
|
|
pub name: Name,
|
|
|
|
pub email: Email,
|
2022-05-29 13:36:25 +02:00
|
|
|
pub phone: Phone,
|
2022-05-19 16:13:27 +02:00
|
|
|
pub street: Street,
|
|
|
|
pub city: City,
|
|
|
|
pub country: Country,
|
|
|
|
pub zip: Zip,
|
|
|
|
pub account_id: AccountId,
|
2022-05-23 14:11:56 +02:00
|
|
|
pub is_default: bool,
|
2022-05-19 16:13:27 +02:00
|
|
|
}
|
|
|
|
|
2022-05-23 14:11:56 +02:00
|
|
|
impl From<crate::AccountAddress> for AccountAddress {
|
2022-05-19 16:13:27 +02:00
|
|
|
fn from(
|
2022-05-23 14:11:56 +02:00
|
|
|
crate::AccountAddress {
|
2022-05-19 16:13:27 +02:00
|
|
|
id,
|
|
|
|
name,
|
|
|
|
email,
|
2022-05-29 13:36:25 +02:00
|
|
|
phone,
|
2022-05-19 16:13:27 +02:00
|
|
|
street,
|
|
|
|
city,
|
|
|
|
country,
|
|
|
|
zip,
|
|
|
|
account_id,
|
2022-05-23 14:11:56 +02:00
|
|
|
is_default,
|
|
|
|
}: crate::AccountAddress,
|
2022-05-19 16:13:27 +02:00
|
|
|
) -> Self {
|
|
|
|
Self {
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
email,
|
2022-05-29 13:36:25 +02:00
|
|
|
phone,
|
2022-05-19 16:13:27 +02:00
|
|
|
street,
|
|
|
|
city,
|
|
|
|
country,
|
|
|
|
zip,
|
|
|
|
account_id,
|
2022-05-23 14:11:56 +02:00
|
|
|
is_default,
|
2022-05-19 16:13:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-09 16:17:27 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2022-05-06 11:47:18 +02:00
|
|
|
#[serde(transparent)]
|
2022-05-23 14:11:56 +02:00
|
|
|
pub struct Orders(pub Vec<Order>);
|
2022-05-06 11:47:18 +02:00
|
|
|
|
2022-05-23 14:11:56 +02:00
|
|
|
impl From<(Vec<crate::Order>, Vec<crate::OrderItem>)> for Orders {
|
|
|
|
fn from((orders, mut items): (Vec<crate::Order>, Vec<crate::OrderItem>)) -> Self {
|
2022-05-06 11:47:18 +02:00
|
|
|
Self(
|
|
|
|
orders
|
|
|
|
.into_iter()
|
|
|
|
.map(
|
2022-05-23 14:11:56 +02:00
|
|
|
|crate::Order {
|
2022-05-06 11:47:18 +02:00
|
|
|
id,
|
|
|
|
buyer_id,
|
|
|
|
status,
|
|
|
|
order_ext_id: _,
|
|
|
|
service_order_id: _,
|
2022-05-19 14:03:18 +02:00
|
|
|
checkout_notes,
|
2022-05-23 14:11:56 +02:00
|
|
|
address_id,
|
2022-05-06 11:47:18 +02:00
|
|
|
}| {
|
2022-05-23 14:11:56 +02:00
|
|
|
Order {
|
2022-05-06 11:47:18 +02:00
|
|
|
id,
|
|
|
|
buyer_id,
|
|
|
|
status,
|
|
|
|
items: items.drain_filter(|item| item.order_id == id).collect(),
|
2022-05-19 14:03:18 +02:00
|
|
|
checkout_notes,
|
2022-05-23 14:11:56 +02:00
|
|
|
address_id,
|
2022-05-06 11:47:18 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
|
|
|
.collect(),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-23 14:11:56 +02:00
|
|
|
impl From<(crate::Order, Vec<crate::OrderItem>)> for Order {
|
2022-05-06 11:47:18 +02:00
|
|
|
fn from(
|
|
|
|
(
|
2022-05-23 14:11:56 +02:00
|
|
|
crate::Order {
|
2022-05-06 11:47:18 +02:00
|
|
|
id,
|
|
|
|
buyer_id,
|
|
|
|
status,
|
|
|
|
order_ext_id: _,
|
|
|
|
service_order_id: _,
|
2022-05-19 14:03:18 +02:00
|
|
|
checkout_notes,
|
2022-05-23 14:11:56 +02:00
|
|
|
address_id,
|
2022-05-06 11:47:18 +02:00
|
|
|
},
|
|
|
|
mut items,
|
2022-05-23 14:11:56 +02:00
|
|
|
): (crate::Order, Vec<crate::OrderItem>),
|
2022-05-06 11:47:18 +02:00
|
|
|
) -> Self {
|
2022-05-23 14:11:56 +02:00
|
|
|
Order {
|
2022-05-06 11:47:18 +02:00
|
|
|
id,
|
|
|
|
buyer_id,
|
|
|
|
status,
|
|
|
|
items: items.drain_filter(|item| item.order_id == id).collect(),
|
2022-05-19 14:03:18 +02:00
|
|
|
checkout_notes,
|
2022-05-23 14:11:56 +02:00
|
|
|
address_id,
|
2022-05-06 11:47:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-09 16:17:27 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2022-05-23 14:11:56 +02:00
|
|
|
pub struct Order {
|
|
|
|
pub id: crate::OrderId,
|
2022-06-10 15:15:12 +02:00
|
|
|
pub buyer_id: Option<crate::AccountId>,
|
2022-05-06 11:47:18 +02:00
|
|
|
pub status: crate::OrderStatus,
|
|
|
|
pub items: Vec<crate::OrderItem>,
|
2022-05-19 14:03:18 +02:00
|
|
|
pub checkout_notes: Option<String>,
|
2022-05-23 14:11:56 +02:00
|
|
|
pub address_id: OrderAddressId,
|
2022-05-06 11:47:18 +02:00
|
|
|
}
|
|
|
|
|
2022-05-09 16:17:27 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2022-05-06 11:47:18 +02:00
|
|
|
pub struct ShoppingCartItem {
|
2022-05-18 16:10:39 +02:00
|
|
|
pub id: ShoppingCartItemId,
|
2022-05-10 16:20:37 +02:00
|
|
|
pub product_id: ProductId,
|
|
|
|
pub shopping_cart_id: ShoppingCartId,
|
|
|
|
pub quantity: Quantity,
|
|
|
|
pub quantity_unit: QuantityUnit,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<crate::ShoppingCartItem> for ShoppingCartItem {
|
|
|
|
fn from(
|
|
|
|
crate::ShoppingCartItem {
|
|
|
|
id,
|
|
|
|
product_id,
|
|
|
|
shopping_cart_id,
|
|
|
|
quantity,
|
|
|
|
quantity_unit,
|
|
|
|
}: crate::ShoppingCartItem,
|
|
|
|
) -> Self {
|
|
|
|
Self {
|
|
|
|
id,
|
|
|
|
product_id,
|
|
|
|
shopping_cart_id,
|
|
|
|
quantity,
|
|
|
|
quantity_unit,
|
|
|
|
}
|
|
|
|
}
|
2022-05-06 11:47:18 +02:00
|
|
|
}
|
|
|
|
|
2022-05-09 16:17:27 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2022-05-06 11:47:18 +02:00
|
|
|
pub struct ShoppingCart {
|
2022-05-10 16:20:37 +02:00
|
|
|
pub id: ShoppingCartId,
|
|
|
|
pub buyer_id: AccountId,
|
|
|
|
pub payment_method: PaymentMethod,
|
|
|
|
pub state: ShoppingCartState,
|
2022-05-06 11:47:18 +02:00
|
|
|
pub items: Vec<ShoppingCartItem>,
|
2022-05-19 14:03:18 +02:00
|
|
|
pub checkout_notes: String,
|
2022-05-06 11:47:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<(crate::ShoppingCart, Vec<crate::ShoppingCartItem>)> for ShoppingCart {
|
|
|
|
fn from(
|
|
|
|
(
|
|
|
|
crate::ShoppingCart {
|
|
|
|
id,
|
|
|
|
buyer_id,
|
|
|
|
payment_method,
|
|
|
|
state,
|
2022-05-19 14:03:18 +02:00
|
|
|
checkout_notes,
|
2022-05-06 11:47:18 +02:00
|
|
|
},
|
|
|
|
items,
|
|
|
|
): (crate::ShoppingCart, Vec<crate::ShoppingCartItem>),
|
|
|
|
) -> Self {
|
|
|
|
Self {
|
|
|
|
id,
|
|
|
|
buyer_id,
|
|
|
|
payment_method,
|
|
|
|
state,
|
2022-05-19 14:03:18 +02:00
|
|
|
checkout_notes: checkout_notes.unwrap_or_default(),
|
2022-05-06 11:47:18 +02:00
|
|
|
items: items
|
|
|
|
.into_iter()
|
|
|
|
.map(
|
|
|
|
|crate::ShoppingCartItem {
|
|
|
|
id,
|
|
|
|
product_id,
|
|
|
|
shopping_cart_id,
|
|
|
|
quantity,
|
|
|
|
quantity_unit,
|
|
|
|
}| ShoppingCartItem {
|
|
|
|
id,
|
|
|
|
product_id,
|
|
|
|
shopping_cart_id,
|
|
|
|
quantity,
|
|
|
|
quantity_unit,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
.collect(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-08 14:59:59 +02:00
|
|
|
|
2022-05-10 22:32:22 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Hash)]
|
2022-05-08 14:59:59 +02:00
|
|
|
pub struct Photo {
|
|
|
|
pub id: crate::PhotoId,
|
|
|
|
pub file_name: crate::FileName,
|
2022-05-09 16:17:27 +02:00
|
|
|
pub url: String,
|
|
|
|
pub unique_name: crate::UniqueName,
|
2022-05-08 14:59:59 +02:00
|
|
|
}
|
|
|
|
|
2022-05-11 15:56:41 +02:00
|
|
|
#[derive(Clone, Debug, Hash, PartialOrd, PartialEq, Eq, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "snake_case")]
|
|
|
|
pub struct Category {
|
|
|
|
pub name: String,
|
|
|
|
pub key: String,
|
|
|
|
pub svg: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<&crate::Category> for Category {
|
|
|
|
fn from(crate::Category { name, key, svg }: &crate::Category) -> Self {
|
|
|
|
Self {
|
|
|
|
name: (*name).into(),
|
|
|
|
key: (*key).into(),
|
|
|
|
svg: (*svg).into(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-10 22:32:22 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Hash)]
|
2022-05-08 14:59:59 +02:00
|
|
|
pub struct Product {
|
|
|
|
pub id: crate::ProductId,
|
|
|
|
pub name: crate::ProductName,
|
|
|
|
pub short_description: crate::ProductShortDesc,
|
|
|
|
pub long_description: crate::ProductLongDesc,
|
2022-05-11 15:56:41 +02:00
|
|
|
pub category: Option<Category>,
|
2022-05-08 14:59:59 +02:00
|
|
|
pub price: crate::Price,
|
2022-05-12 20:33:16 +02:00
|
|
|
pub available: bool,
|
|
|
|
pub quantity_unit: crate::QuantityUnit,
|
2022-05-08 14:59:59 +02:00
|
|
|
pub deliver_days_flag: crate::Days,
|
|
|
|
pub photos: Vec<Photo>,
|
|
|
|
}
|
|
|
|
|
2022-05-12 20:33:16 +02:00
|
|
|
impl<'path>
|
|
|
|
From<(
|
|
|
|
crate::Product,
|
|
|
|
&mut Vec<ProductLinkedPhoto>,
|
|
|
|
&mut Vec<crate::Stock>,
|
|
|
|
&'path str,
|
|
|
|
)> for Product
|
|
|
|
{
|
2022-05-08 14:59:59 +02:00
|
|
|
fn from(
|
|
|
|
(
|
|
|
|
crate::Product {
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
short_description,
|
|
|
|
long_description,
|
|
|
|
category,
|
|
|
|
price,
|
|
|
|
deliver_days_flag,
|
|
|
|
},
|
|
|
|
photos,
|
2022-05-12 20:33:16 +02:00
|
|
|
product_stocks,
|
2022-05-09 16:17:27 +02:00
|
|
|
public_path,
|
2022-05-12 20:33:16 +02:00
|
|
|
): (
|
|
|
|
crate::Product,
|
|
|
|
&mut Vec<ProductLinkedPhoto>,
|
|
|
|
&mut Vec<crate::Stock>,
|
|
|
|
&'path str,
|
|
|
|
),
|
2022-05-08 14:59:59 +02:00
|
|
|
) -> Self {
|
2022-05-12 20:33:16 +02:00
|
|
|
let pos = product_stocks
|
|
|
|
.iter()
|
|
|
|
.position(|stock| stock.product_id == id);
|
|
|
|
let (available, quantity_unit) = pos
|
|
|
|
.map(|idx| product_stocks.remove(idx))
|
|
|
|
.map(|stock| (**stock.quantity > 0, stock.quantity_unit))
|
|
|
|
.unwrap_or_else(|| (false, crate::QuantityUnit::Piece));
|
2022-05-08 14:59:59 +02:00
|
|
|
Self {
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
short_description,
|
|
|
|
long_description,
|
2022-05-11 15:56:41 +02:00
|
|
|
category: category.and_then(|name| {
|
|
|
|
crate::CATEGORIES.iter().find_map(|c| {
|
|
|
|
if c.name == name.as_str() {
|
|
|
|
Some(Category::from(c))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}),
|
2022-05-08 14:59:59 +02:00
|
|
|
price,
|
2022-05-12 20:33:16 +02:00
|
|
|
available,
|
|
|
|
quantity_unit,
|
2022-05-08 14:59:59 +02:00
|
|
|
deliver_days_flag,
|
|
|
|
photos: photos
|
|
|
|
.drain_filter(|photo| photo.product_id == id)
|
|
|
|
.map(
|
|
|
|
|ProductLinkedPhoto {
|
2022-06-06 15:09:13 +02:00
|
|
|
photo_id: id,
|
2022-05-08 14:59:59 +02:00
|
|
|
local_path: _,
|
|
|
|
file_name,
|
|
|
|
product_id: _,
|
2022-05-09 16:17:27 +02:00
|
|
|
unique_name,
|
|
|
|
}| Photo {
|
|
|
|
id,
|
|
|
|
url: format!("{}/{}", public_path, unique_name.as_str()),
|
|
|
|
unique_name,
|
|
|
|
file_name,
|
|
|
|
},
|
2022-05-08 14:59:59 +02:00
|
|
|
)
|
|
|
|
.collect(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-09 16:17:27 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Deref)]
|
2022-05-08 14:59:59 +02:00
|
|
|
#[serde(transparent)]
|
2022-05-09 16:17:27 +02:00
|
|
|
pub struct Products(pub Vec<Product>);
|
2022-05-08 14:59:59 +02:00
|
|
|
|
2022-05-12 20:33:16 +02:00
|
|
|
impl
|
|
|
|
From<(
|
|
|
|
Vec<crate::Product>,
|
|
|
|
Vec<ProductLinkedPhoto>,
|
|
|
|
Vec<crate::Stock>,
|
|
|
|
String,
|
|
|
|
)> for Products
|
|
|
|
{
|
2022-05-09 16:17:27 +02:00
|
|
|
fn from(
|
2022-05-12 20:33:16 +02:00
|
|
|
(products, mut photos, mut products_stock, public_path): (
|
|
|
|
Vec<crate::Product>,
|
|
|
|
Vec<ProductLinkedPhoto>,
|
|
|
|
Vec<crate::Stock>,
|
|
|
|
String,
|
|
|
|
),
|
2022-05-09 16:17:27 +02:00
|
|
|
) -> Self {
|
2022-05-08 14:59:59 +02:00
|
|
|
Self(
|
|
|
|
products
|
|
|
|
.into_iter()
|
2022-05-12 20:33:16 +02:00
|
|
|
.map(|p| (p, &mut photos, &mut products_stock, public_path.as_str()).into())
|
2022-05-08 14:59:59 +02:00
|
|
|
.collect(),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2022-05-10 16:20:37 +02:00
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct SignInInput {
|
|
|
|
pub login: Login,
|
|
|
|
pub password: Password,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2022-05-15 10:30:15 +02:00
|
|
|
pub struct SessionOutput {
|
2022-05-10 16:20:37 +02:00
|
|
|
pub access_token: AccessTokenString,
|
|
|
|
pub refresh_token: RefreshTokenString,
|
|
|
|
pub exp: NaiveDateTime,
|
2022-05-17 08:23:39 +02:00
|
|
|
pub role: Role,
|
2022-05-10 16:20:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct CreateAccountInput {
|
|
|
|
pub email: Email,
|
|
|
|
pub login: Login,
|
|
|
|
pub password: Password,
|
|
|
|
}
|
|
|
|
|
2022-05-28 14:03:14 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub enum OrderAddressInput {
|
|
|
|
Address(CreateOrderAddress),
|
|
|
|
AccountAddress(AddressId),
|
|
|
|
DefaultAccountAddress,
|
|
|
|
}
|
|
|
|
|
2022-05-10 16:20:37 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct CreateOrderInput {
|
|
|
|
/// Required customer e-mail
|
|
|
|
pub email: String,
|
|
|
|
/// Required customer phone number
|
|
|
|
pub phone: String,
|
|
|
|
/// Required customer first name
|
|
|
|
pub first_name: String,
|
|
|
|
/// Required customer last name
|
|
|
|
pub last_name: String,
|
|
|
|
/// Required customer language
|
|
|
|
pub language: String,
|
|
|
|
/// User currency
|
|
|
|
pub currency: String,
|
2022-05-28 14:03:14 +02:00
|
|
|
pub address: OrderAddressInput,
|
2022-06-07 11:36:01 +02:00
|
|
|
pub payment_method: PaymentMethod,
|
2022-05-10 16:20:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct DeleteItemInput {
|
|
|
|
pub shopping_cart_item_id: ShoppingCartItemId,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct DeleteItemOutput {
|
|
|
|
pub success: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2022-05-19 07:47:47 +02:00
|
|
|
pub struct UpdateItemInput {
|
2022-05-10 16:20:37 +02:00
|
|
|
pub product_id: ProductId,
|
|
|
|
pub quantity: Quantity,
|
|
|
|
pub quantity_unit: QuantityUnit,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
2022-05-19 07:47:47 +02:00
|
|
|
pub struct UpdateItemOutput {
|
2022-05-10 16:20:37 +02:00
|
|
|
pub shopping_cart_item: ShoppingCartItem,
|
|
|
|
}
|
|
|
|
|
2022-05-19 07:47:47 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct UpdateCartInput {
|
|
|
|
pub items: Vec<UpdateItemInput>,
|
2022-05-19 16:13:27 +02:00
|
|
|
pub notes: String,
|
|
|
|
pub payment_method: Option<PaymentMethod>,
|
2022-05-19 07:47:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct UpdateCartOutput {
|
2022-05-19 16:13:27 +02:00
|
|
|
pub cart_id: ShoppingCartId,
|
2022-05-19 07:47:47 +02:00
|
|
|
pub items: Vec<ShoppingCartItem>,
|
2022-05-19 16:13:27 +02:00
|
|
|
pub checkout_notes: String,
|
|
|
|
pub payment_method: PaymentMethod,
|
2022-05-19 07:47:47 +02:00
|
|
|
}
|
|
|
|
|
2022-05-13 15:24:11 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct SearchRequest {
|
|
|
|
/// Match string
|
|
|
|
pub q: String,
|
|
|
|
pub lang: String,
|
|
|
|
}
|
|
|
|
|
2022-05-23 14:11:56 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct CreateOrderAddress {
|
|
|
|
pub name: Name,
|
|
|
|
pub email: Email,
|
2022-05-29 13:36:25 +02:00
|
|
|
pub phone: Phone,
|
2022-05-23 14:11:56 +02:00
|
|
|
pub street: Street,
|
|
|
|
pub city: City,
|
|
|
|
pub country: Country,
|
|
|
|
pub zip: Zip,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct UpdateOrderAddress {
|
|
|
|
pub id: OrderAddressId,
|
|
|
|
pub name: Name,
|
|
|
|
pub email: Email,
|
|
|
|
pub street: Street,
|
|
|
|
pub city: City,
|
|
|
|
pub country: Country,
|
|
|
|
pub zip: Zip,
|
|
|
|
}
|
|
|
|
|
2022-05-28 14:03:14 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct PlaceOrderResult {
|
|
|
|
pub redirect_uri: String,
|
|
|
|
pub order_id: OrderId,
|
|
|
|
}
|
|
|
|
|
2022-05-10 16:20:37 +02:00
|
|
|
pub mod admin {
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
use crate::*;
|
|
|
|
|
|
|
|
#[derive(Deserialize, Serialize, Debug)]
|
|
|
|
pub struct RegisterInput {
|
|
|
|
pub login: Login,
|
|
|
|
pub email: Email,
|
|
|
|
pub password: Password,
|
|
|
|
pub password_confirmation: PasswordConfirmation,
|
|
|
|
pub role: Role,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Default)]
|
|
|
|
pub struct RegisterResponse {
|
|
|
|
pub errors: Vec<RegisterError>,
|
2022-05-19 16:13:27 +02:00
|
|
|
pub account: Option<super::Account>,
|
2022-05-10 16:20:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub enum RegisterError {
|
|
|
|
PasswordDiffer,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct SignInInput {
|
|
|
|
pub login: Option<Login>,
|
|
|
|
pub email: Option<Email>,
|
|
|
|
pub password: Password,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct LogoutResponse {}
|
|
|
|
}
|