use std::sync::Arc;
use ruststream::memory::prelude::*;
use crate::notifications::{MailError, Mailer};
use crate::payments::Gateway;
const CARD_LIMIT_CENTS: u64 = 100_000;
const CHARGES_PER_SECOND: u32 = 50;
#[derive(Clone, FromRef)]
pub(crate) struct Shop {
pub(crate) gateway: Arc<Gateway>,
pub(crate) mailer: Arc<Mailer>,
}
impl Shop {
pub(crate) async fn open() -> Result<Self, MailError> {
Ok(Self {
gateway: Arc::new(Gateway::new(CARD_LIMIT_CENTS, CHARGES_PER_SECOND)),
mailer: Arc::new(Mailer::connect("smtp://mail.internal:25").await?),
})
}
}