Upgrade deps, clippy fixes and start payment tests

This commit is contained in:
Adrian Woźniak 2022-06-13 16:16:19 +02:00
parent ead4722989
commit 846d0b5000
No known key found for this signature in database
GPG Key ID: 0012845A89C7352B
46 changed files with 172 additions and 107 deletions

1
Cargo.lock generated
View File

@ -2918,6 +2918,7 @@ dependencies = [
"pay_u",
"pretty_env_logger",
"serde",
"testx",
"thiserror",
"tracing",
"uuid 0.8.2",

View File

@ -1,6 +1,6 @@
use crate::{db_async_handler, Result};
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
pub enum Error {
#[error("Can't load account addresses")]
AccountAddresses,
@ -274,7 +274,7 @@ mod test {
city: City::new(city.clone()),
country: Country::new(country.clone()),
zip: Zip::new(zip.clone()),
account_id: account_id.clone(),
account_id,
is_default,
},
&mut t,
@ -322,7 +322,7 @@ mod test {
city: address.city.clone(),
country: address.country.clone(),
zip: address.zip.clone(),
account_id: address.account_id.clone(),
account_id: address.account_id,
is_default: true,
},
&mut t,

View File

@ -4,7 +4,7 @@ use model::*;
use crate::{db_async_handler, Result};
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
#[serde(rename_all = "kebab-case")]
pub enum Error {
#[error("Can't create account")]

View File

@ -32,7 +32,7 @@ pub mod tokens;
#[macro_export]
macro_rules! db_async_handler {
($msg: ty, $async: ident, $res: ty) => {
impl actix::Handler<$msg> for crate::Database {
impl actix::Handler<$msg> for $crate::Database {
type Result = actix::ResponseActFuture<Self, Result<$res>>;
fn handle(&mut self, msg: $msg, _ctx: &mut Self::Context) -> Self::Result {
@ -63,7 +63,7 @@ macro_rules! db_async_handler {
}
}
impl actix::Handler<$msg> for crate::Database {
impl actix::Handler<$msg> for $crate::Database {
type Result = actix::ResponseActFuture<Self, Result<$res>>;
fn handle(&mut self, msg: $msg, _ctx: &mut Self::Context) -> Self::Result {
@ -74,7 +74,7 @@ macro_rules! db_async_handler {
}
#[async_trait::async_trait]
impl $crate::Queue<$msg> for crate::Transaction {
impl $crate::Queue<$msg> for $crate::Transaction {
type Result = $res;
async fn handle(&mut self, msg: $msg) -> Result<Self::Result> {
@ -134,7 +134,7 @@ macro_rules! query_db {
};
}
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
#[serde(rename_all = "kebab-case")]
pub enum Error {
#[error("{0}")]
@ -336,7 +336,7 @@ where
if let Some(s) = self.sort.as_deref() {
query.push_str("\nORDER BY ");
query.push_str(s);
query.push_str(" ");
query.push(' ');
}
let q = sqlx::query_as_with(
query.as_str(),

View File

@ -1,6 +1,6 @@
use crate::{db_async_handler, Result};
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
pub enum Error {
#[error("Can't load order addresses")]
OrderAddress,

View File

@ -5,7 +5,7 @@ use model::*;
use super::Result;
use crate::db_async_handler;
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
pub enum Error {
#[error("Can't create order item")]
CantCreate,

View File

@ -6,7 +6,7 @@ use crate::{
ShoppingCartSetState,
};
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
#[serde(rename_all = "kebab-case", tag = "account-order")]
pub enum Error {
#[error("Can't create account order")]

View File

@ -1,6 +1,6 @@
use crate::{MultiLoad, Result};
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
pub enum Error {
#[error("Failed to create photo")]
Create,

View File

@ -1,6 +1,6 @@
use crate::{db_async_handler, Result};
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
pub enum Error {
#[error("Failed to attach photo to product")]
Create,

View File

@ -9,7 +9,7 @@ use model::{
use super::Result;
use crate::MultiLoad;
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
pub enum Error {
#[error("Unable to load all products")]
All,

View File

@ -3,7 +3,7 @@ use model::*;
use super::Result;
use crate::db_async_handler;
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
pub enum Error {
#[error("Can't create shopping cart item")]
CantCreate,

View File

@ -4,7 +4,7 @@ use sqlx::PgPool;
use super::Result;
use crate::db_async_handler;
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
pub enum Error {
#[error("Can't create shopping cart")]
CantCreate,

View File

@ -3,7 +3,7 @@ use model::{ProductId, Quantity, QuantityUnit, Stock, StockId};
use crate::{MultiLoad, Result};
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
pub enum Error {
#[error("Unable to load all stocks")]
All,
@ -193,7 +193,7 @@ async fn product_stock(
msg: ProductsStock,
pool: &mut sqlx::Transaction<'_, sqlx::Postgres>,
) -> Result<Vec<Stock>> {
Ok(MultiLoad::new(
MultiLoad::new(
pool,
r#"
SELECT id, product_id, quantity, quantity_unit
@ -207,7 +207,7 @@ WHERE
msg.product_ids.into_iter().map(|id| *id),
|_e| crate::Error::Stock(Error::ProductStock),
)
.await?)
.await
}
#[cfg(test)]
@ -251,7 +251,7 @@ mod tests {
_ => test_product(&mut *pool).await.id,
};
let quantity = quantity.unwrap_or_else(|| Quantity::from_u32(345));
let quantity_unit = quantity_unit.unwrap_or_else(|| QuantityUnit::Piece);
let quantity_unit = quantity_unit.unwrap_or(QuantityUnit::Piece);
super::create_stock(
CreateStock {

View File

@ -3,7 +3,7 @@ use model::{AccountId, Audience, Token, TokenId};
use crate::{db_async_handler, Result};
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, thiserror::Error)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, thiserror::Error)]
pub enum Error {
#[error("Failed to save new token")]
Create,
@ -204,13 +204,13 @@ mod tests {
audience: Option<Audience>,
expiration_time: Option<chrono::NaiveDateTime>,
) -> Token {
let customer_id = customer_id.unwrap_or_else(|| Uuid::new_v4());
let role = role.unwrap_or_else(|| Role::Admin);
let customer_id = customer_id.unwrap_or_else(Uuid::new_v4);
let role = role.unwrap_or(Role::Admin);
let subject = match subject {
Some(id) => id,
_ => test_create_account(t).await.id,
};
let audience = audience.unwrap_or_else(|| Audience::Web);
let audience = audience.unwrap_or(Audience::Web);
let expiration_time = expiration_time
.unwrap_or_else(|| (chrono::Utc::now() + chrono::Duration::days(60)).naive_utc());

View File

@ -25,3 +25,6 @@ parking_lot = { version = "0.12", features = [] }
serde = { version = "1.0", features = ["derive"] }
pay_u = { version = '0.1', features = ["single-client"] }
[dev-dependencies]
testx = { path = "../../shared/testx" }

View File

@ -100,7 +100,8 @@ impl PaymentManager {
)
};
client.authorize().await.unwrap_or_else(|e| {
tracing::error!("{}", e);
tracing::error!("{e}");
dbg!(e);
std::process::exit(1);
});
Self {
@ -315,3 +316,22 @@ pub(crate) async fn update_payment(
.await;
Ok(())
}
#[cfg(test)]
mod tests {
use actix::Actor;
use crate::*;
pub struct NoOpts;
impl config::UpdateConfig for NoOpts {}
#[actix::test]
async fn create() {
testx::db!(config, db);
let db = db.start();
let manager = PaymentManager::build(config, db).await;
}
}

View File

@ -9,11 +9,11 @@ macro_rules! admin_send_db {
Ok(Ok(res)) => res,
Ok(Err(e)) => {
tracing::error!("{}", e);
return Err(crate::routes::Error::from(e));
return Err($crate::routes::Error::from(e));
}
Err(e) => {
tracing::error!("{}", e);
return Err(crate::routes::Error::CriticalFailure);
return Err($crate::routes::Error::CriticalFailure);
}
}
}};

View File

@ -274,7 +274,7 @@ pub(crate) async fn create_order(
zip,
}) => order_manager::OrderAddressInput::Address(order_manager::CreateOrderAddress {
name,
email: email.clone(),
email,
phone,
street,
city,

View File

@ -15,11 +15,11 @@ macro_rules! public_send_db {
Ok(Ok(res)) => Ok(HttpResponse::Ok().json(res)),
Ok(Err(e)) => {
tracing::error!("{}", e);
Err(crate::routes::Error::Public(PublicError::Database(e)))
Err($crate::routes::Error::Public(PublicError::Database(e)))
}
Err(e) => {
tracing::error!("{}", e);
Err(crate::routes::Error::Public(
Err($crate::routes::Error::Public(
PublicError::DatabaseConnection,
))
}

View File

@ -22,10 +22,10 @@ async fn create_product(
database_manager::CreateProduct {
name: ProductName::from(String::from(name)),
short_description: short_desc
.map(|s| model::ProductShortDesc::new(s))
.map(model::ProductShortDesc::new)
.unwrap_or_else(|| Faker.fake()),
long_description: long_desc
.map(|s| model::ProductLongDesc::new(s))
.map(model::ProductLongDesc::new)
.unwrap_or_else(|| Faker.fake()),
category: Some(ProductCategory::new(category)),
price: Faker.fake(),

View File

@ -37,7 +37,7 @@ impl<T> fake::Dummy<T> for ProductLongDesc {
.into_iter()
.map(|_| {
let words: Vec<String> = Paragraphs(4..8).fake();
words.join(" ").to_string()
words.join(" ")
})
.collect();
Self(words.join("\n"))

View File

@ -127,7 +127,7 @@ pub const CATEGORIES: [Category; 9] = [
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(rename_all = "snake_case"))]
#[derive(Copy, Clone, Debug, Hash, PartialEq, Display, Deserialize, Serialize)]
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Display, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum OrderStatus {
#[display(fmt = "Potwierdzone")]
@ -147,7 +147,7 @@ pub enum OrderStatus {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(rename_all = "snake_case"))]
#[derive(Copy, Clone, Debug, Hash, PartialEq, Display, Deserialize, Serialize)]
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Display, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum Role {
#[display(fmt = "Adminitrator")]
@ -173,7 +173,7 @@ impl Role {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[derive(Copy, Clone, Debug, PartialEq, Hash, Display, Deserialize, Serialize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Display, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum QuantityUnit {
#[cfg_attr(feature = "db", sqlx(rename = "g"))]
@ -209,7 +209,7 @@ impl QuantityUnit {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(rename_all = "snake_case"))]
#[derive(Copy, Clone, Debug, Hash, PartialEq, Display, Deserialize, Serialize)]
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Display, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum PaymentMethod {
PayU,
@ -225,7 +225,7 @@ impl Default for PaymentMethod {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(rename_all = "snake_case"))]
#[derive(Copy, Clone, Debug, Hash, PartialEq, Display, Deserialize, Serialize)]
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Display, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum ShoppingCartState {
Active,
@ -235,7 +235,7 @@ pub enum ShoppingCartState {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(rename_all = "snake_case"))]
#[derive(Copy, Clone, Debug, Hash, Display, Deserialize, Serialize, PartialEq)]
#[derive(Copy, Clone, Debug, Hash, Display, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum Audience {
Web,
@ -264,7 +264,7 @@ impl Audience {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(rename_all = "snake_case"))]
#[derive(Copy, Clone, Debug, Display, Deserialize, Serialize, PartialEq)]
#[derive(Copy, Clone, Debug, Display, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum AccountState {
Active,
@ -281,7 +281,18 @@ impl Default for Audience {
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(
Default, Debug, Copy, Clone, Hash, PartialOrd, PartialEq, Serialize, Deserialize, Deref, From,
Default,
Debug,
Copy,
Clone,
Hash,
PartialOrd,
PartialEq,
Eq,
Serialize,
Deserialize,
Deref,
From,
)]
#[serde(transparent)]
pub struct Price(NonNegative);
@ -303,7 +314,7 @@ impl ops::Mul<Quantity> for Price {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Copy, Clone, Hash, Deref, From)]
#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Copy, Clone, Hash, Deref, From)]
#[serde(transparent)]
pub struct Quantity(NonNegative);
@ -339,7 +350,7 @@ impl TryFrom<i32> for Quantity {
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Deref, From, Display)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Deref, From, Display)]
#[serde(transparent)]
pub struct Login(String);
@ -352,7 +363,7 @@ impl Login {
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(
Serialize, Debug, Clone, Default, PartialOrd, PartialEq, Deref, DerefMut, From, Display,
Serialize, Debug, Clone, Default, PartialOrd, PartialEq, Eq, Deref, DerefMut, From, Display,
)]
#[serde(transparent)]
pub struct Email(String);
@ -377,6 +388,7 @@ impl Email {
Default,
PartialOrd,
PartialEq,
Eq,
Deref,
DerefMut,
From,
@ -438,7 +450,9 @@ impl<'de> serde::Deserialize<'de> for Email {
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Default, Debug, PartialEq, PartialOrd, Copy, Clone, Hash, Serialize, Deref, Display)]
#[derive(
Default, Debug, PartialEq, Eq, PartialOrd, Copy, Clone, Hash, Serialize, Deref, Display,
)]
#[serde(transparent)]
pub struct NonNegative(i32);
@ -537,7 +551,7 @@ impl<'de> serde::Deserialize<'de> for NonNegative {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[derive(
Debug, Copy, Clone, Hash, PartialOrd, PartialEq, Serialize, Deserialize, Display, From,
Debug, Copy, Clone, Hash, PartialOrd, PartialEq, Eq, Serialize, Deserialize, Display, From,
)]
#[serde(rename_all = "lowercase")]
pub enum Day {
@ -608,7 +622,7 @@ impl TryFrom<i32> for Day {
}
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[derive(Hash, Debug, PartialOrd, PartialEq, Serialize, Deserialize)]
#[derive(Hash, Debug, PartialOrd, PartialEq, Eq, Serialize, Deserialize)]
#[serde(transparent)]
pub struct Days(pub Vec<Day>);
@ -719,7 +733,7 @@ impl PasswordConfirmation {
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Serialize, Deserialize, Debug, PartialEq, Deref, From, Display)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Deref, From, Display)]
#[serde(transparent)]
pub struct PassHash(String);
@ -739,14 +753,14 @@ impl PartialEq<PasswordConfirmation> for Password {
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(
Serialize, Deserialize, Copy, Clone, Debug, PartialOrd, PartialEq, Deref, Display, From,
Serialize, Deserialize, Copy, Clone, Debug, PartialOrd, PartialEq, Eq, Deref, Display, From,
)]
#[serde(transparent)]
pub struct AccountId(RecordId);
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
pub struct FullAccount {
pub id: AccountId,
pub email: Email,
@ -807,7 +821,7 @@ impl Display for ProductId {
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Debug, Clone, Hash, PartialEq, Serialize, Deserialize, Deref, Display, From)]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
#[serde(transparent)]
pub struct ProductName(String);
@ -823,7 +837,7 @@ impl ProductName {
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Debug, Clone, Hash, PartialEq, Serialize, Deserialize, Deref, Display, From)]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
#[serde(transparent)]
pub struct ProductShortDesc(String);
@ -839,7 +853,7 @@ impl ProductShortDesc {
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Debug, Clone, Hash, PartialEq, Serialize, Deserialize, Deref, Display, From)]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
#[serde(transparent)]
pub struct ProductLongDesc(String);
@ -858,7 +872,7 @@ impl ProductLongDesc {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Debug, Clone, Hash, PartialEq, Serialize, Deserialize, Deref, Display, From)]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
#[serde(transparent)]
pub struct ProductCategory(String);
@ -870,7 +884,7 @@ impl ProductCategory {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Debug, Hash, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct Product {
pub id: ProductId,
pub name: ProductName,
@ -884,13 +898,13 @@ pub struct Product {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Debug, PartialEq, Copy, Clone, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Copy, Clone, Serialize, Deserialize)]
#[serde(transparent)]
pub struct StockId(pub RecordId);
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Stock {
pub id: StockId,
pub product_id: ProductId,
@ -931,7 +945,7 @@ impl ExtOrderId {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Order {
pub id: OrderId,
/// Optional customer account id
@ -984,12 +998,12 @@ impl From<Order> for PublicOrder {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Deref)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Deref)]
pub struct OrderItemId(pub RecordId);
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrderItem {
pub id: OrderItemId,
pub product_id: ProductId,
@ -1001,13 +1015,13 @@ pub struct OrderItem {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Serialize, Deserialize, PartialEq, Copy, Clone, Debug, Deref, Display)]
#[derive(Serialize, Deserialize, PartialEq, Eq, Copy, Clone, Debug, Deref, Display)]
#[serde(transparent)]
pub struct ShoppingCartId(pub RecordId);
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ShoppingCart {
pub id: ShoppingCartId,
pub buyer_id: AccountId,
@ -1019,12 +1033,12 @@ pub struct ShoppingCart {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(PartialEq, Copy, Clone, Debug, Serialize, Deserialize, Deref, Display)]
#[derive(PartialEq, Eq, Copy, Clone, Debug, Serialize, Deserialize, Deref, Display)]
#[serde(transparent)]
pub struct ShoppingCartItemId(RecordId);
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ShoppingCartItem {
pub id: ShoppingCartItemId,
pub product_id: ProductId,
@ -1042,13 +1056,13 @@ impl ShoppingCartItem {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Deref, Display, Debug)]
#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Eq, Deref, Display, Debug)]
#[serde(transparent)]
pub struct TokenId(RecordId);
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Token {
pub id: TokenId,
pub customer_id: uuid::Uuid,
@ -1081,7 +1095,7 @@ impl Token {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Deref, Display, From)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct AccessTokenString(String);
impl AccessTokenString {
@ -1099,7 +1113,7 @@ impl From<RefreshTokenString> for AccessTokenString {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Deref, Display, From)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct RefreshTokenString(String);
impl From<AccessTokenString> for RefreshTokenString {
@ -1117,7 +1131,7 @@ impl RefreshTokenString {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Debug, Hash, PartialEq, Serialize, Deserialize, Deref, Display, From)]
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct LocalPath(String);
impl LocalPath {
@ -1129,7 +1143,7 @@ impl LocalPath {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Debug, Hash, PartialEq, Serialize, Deserialize, Deref, Display, From)]
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct UniqueName(String);
impl UniqueName {
@ -1141,7 +1155,7 @@ impl UniqueName {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Debug, Hash, PartialEq, Serialize, Deserialize, Deref, Display, From)]
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct FileName(String);
impl FileName {
@ -1154,19 +1168,30 @@ impl FileName {
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(
Debug, Copy, Clone, Hash, PartialOrd, PartialEq, Serialize, Deserialize, Deref, Display, From,
Debug,
Copy,
Clone,
Hash,
PartialOrd,
PartialEq,
Eq,
Serialize,
Deserialize,
Deref,
Display,
From,
)]
pub struct PhotoId(RecordId);
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(Debug, Hash, Copy, Clone, PartialEq, Serialize, Deserialize, Deref, Display, From)]
#[derive(Debug, Hash, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Deref, Display, From)]
pub struct ProductPhotoId(RecordId);
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Debug, Hash, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct Photo {
pub id: PhotoId,
pub local_path: LocalPath,
@ -1176,7 +1201,7 @@ pub struct Photo {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Debug, Hash, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProductLinkedPhoto {
pub photo_id: PhotoId,
pub local_path: LocalPath,
@ -1187,7 +1212,7 @@ pub struct ProductLinkedPhoto {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProductPhoto {
pub id: ProductPhotoId,
pub product_id: ProductId,
@ -1209,7 +1234,18 @@ pub enum ShippingMethod {
#[cfg_attr(feature = "db", derive(sqlx::Type))]
#[cfg_attr(feature = "db", sqlx(transparent))]
#[derive(
Serialize, Deserialize, Debug, Copy, Clone, Hash, PartialOrd, PartialEq, Deref, Display, From,
Serialize,
Deserialize,
Debug,
Copy,
Clone,
Hash,
PartialOrd,
PartialEq,
Eq,
Deref,
Display,
From,
)]
pub struct AddressId(RecordId);
@ -1229,6 +1265,7 @@ impl AddressId {
Default,
PartialOrd,
PartialEq,
Eq,
Deref,
DerefMut,
From,
@ -1253,6 +1290,7 @@ impl Name {
Default,
PartialOrd,
PartialEq,
Eq,
Deref,
DerefMut,
From,
@ -1277,6 +1315,7 @@ impl Street {
Default,
PartialOrd,
PartialEq,
Eq,
Deref,
DerefMut,
From,
@ -1301,6 +1340,7 @@ impl City {
Default,
PartialOrd,
PartialEq,
Eq,
Deref,
DerefMut,
From,
@ -1325,6 +1365,7 @@ impl Country {
Default,
PartialOrd,
PartialEq,
Eq,
Deref,
DerefMut,
From,
@ -1341,7 +1382,7 @@ impl Zip {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Serialize, Deserialize, PartialEq, Debug)]
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
pub struct AccountAddress {
pub id: AddressId,
pub name: Name,
@ -1357,7 +1398,7 @@ pub struct AccountAddress {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[cfg_attr(feature = "db", derive(sqlx::FromRow))]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct OrderAddress {
pub id: OrderAddressId,
pub name: Name,

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BlikAlias {
/// alias generated in merchant system (unique for each customer)
#[serde(rename = "value", skip_serializing_if = "Option::is_none")]

View File

@ -10,7 +10,7 @@
/// BlikAliasResponse : Array containing list of banks associated with this alias
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BlikAliasResponse {
/// Alias user friendly name saved at mobile app (blik request label parameter)
#[serde(rename = "applicationName", skip_serializing_if = "Option::is_none")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BlikFields {
/// Transaction title
#[serde(rename = "title")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BlikResponse {
/// Attention! result: 1 does not indicate transfer of funds! This is successful user app popup indicator.
#[serde(rename = "result", skip_serializing_if = "Option::is_none")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct CheckFields {
/// API password.
#[serde(rename = "api_password", skip_serializing_if = "Option::is_none")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct CheckResponse {
#[serde(rename = "result", skip_serializing_if = "Option::is_none")]
pub result: Option<crate::models::Result>,

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct DeregisterFields {
/// Client token
#[serde(rename = "cli_auth")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GetFields {
/// Transaction title
#[serde(rename = "title")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct MasspaymentAuthorizeFields {
/// ID of created pack using method create.
#[serde(rename = "pack_id")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct MasspaymentAuthorizeResponse {
#[serde(rename = "result", skip_serializing_if = "Option::is_none")]
pub result: Option<crate::models::Result>,

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct MasspaymentCreateFields {
/// Transfers list encoded with base64. Format has been described in metchod description
#[serde(rename = "csv")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct MasspaymentPacksFields {
/// ID of created pack using method create.
#[serde(rename = "pack_id", skip_serializing_if = "Option::is_none")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct MasspaymentTransfersFields {
/// ID of created pack using method create.
#[serde(rename = "pack_id", skip_serializing_if = "Option::is_none")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaymentAttempts {
/// Time of payment attempt
#[serde(rename = "date", skip_serializing_if = "Option::is_none")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct RefundAnyResponse {
/// Request result (digit; 1 correct, 0 - incorrect)
#[serde(rename = "result")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct RefundTransactionFields {
/// Transaction title
#[serde(rename = "title")]

View File

@ -10,7 +10,7 @@
/// RegisterSaleResponse : Successful response schema
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct RegisterSaleResponse {
#[serde(rename = "result", skip_serializing_if = "Option::is_none")]
pub result: Option<crate::models::Result>,

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ReportFields {
/// start range of generated report
#[serde(rename = "from_date")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ReportResponse {
#[serde(rename = "result", skip_serializing_if = "Option::is_none")]
pub result: Option<crate::models::Result>,

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct SaleFields {
/// Client token
#[serde(rename = "cli_auth")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct VcFinishFields {
/// API password.
#[serde(rename = "api_password")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct VcPrepareFields {
/// API password.
#[serde(rename = "api_password")]

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct VcPrepareResponse {
#[serde(rename = "result", skip_serializing_if = "Option::is_none")]
pub result: Option<crate::models::Result>,

View File

@ -23,21 +23,21 @@ use crate::session::SessionMsg;
macro_rules! fetch_page {
(public $model: expr, $page: ident, $ret: expr) => {{
let p = match &mut $model.page {
crate::pages::Page::Public(p) => p,
$crate::pages::Page::Public(p) => p,
_ => return $ret,
};
match p {
crate::pages::PublicPage::$page(p) => p,
$crate::pages::PublicPage::$page(p) => p,
_ => return $ret,
}
}};
(admin $model: expr, $page: ident, $ret: expr) => {{
let p = match &mut $model.page {
crate::pages::Page::Admin(p) => p,
$crate::pages::Page::Admin(p) => p,
_ => return $ret,
};
match p {
crate::pages::AdminPage::$page(p) => p,
$crate::pages::AdminPage::$page(p) => p,
_ => return $ret,
}
}};