use serde::Deserialize; #[derive(Debug, Default, Clone, Deserialize)] pub struct Config { /// Allowed tokens for access pub allowed_tokens: Vec, /// Webhook Config pub webhook: Option, } pub fn get_config() -> Config { if let Ok(content) = std::fs::read_to_string("./config.toml") { return toml::from_str(&content).unwrap(); } Config::default() } #[derive(Debug, Clone, Deserialize)] pub struct Webhook { pub item_below_minimum: Option, pub transaction_added: Option, pub transaction_consumed: Option, } impl Webhook { pub async fn send(url: &str, data: &serde_json::Value) { let client = reqwest::Client::new(); client.post(url).json(data).send().await.unwrap(); } }