diff --git a/src/model/subscriber.rs b/src/model/subscriber.rs index dfdc8c5b692d219e94922c73a8920aa5420037c0..b2e52f77671626aeb3de927bdc087b3eee525852 100644 --- a/src/model/subscriber.rs +++ b/src/model/subscriber.rs @@ -10,4 +10,20 @@ use crate::model::notification::Notification; pub struct Subscriber { pub url: String, pub name:String, -} \ No newline at end of file +} + +impl Subscriber { + #[tokio::main] + pub async fn update(&self, payload: Notification) { + REQWEST_CLIENT + .post(&self.url) + .header("Content-Type", "JSON") + .body(to_string(&payload).unwrap()) + .send().await.ok(); + + log::warn_!( + "Sent {} notification of: [{}] {} to: {}", + payload.status, payload.product_type, payload.product_title, self.url + ); + } +}