diff --git a/src/model/subscriber.rs b/src/model/subscriber.rs index 759f458e610540bd7200799575b94147a1c66105..51b0f656d2435338a59397b2f381c4c25d37c2ef 100644 --- a/src/model/subscriber.rs +++ b/src/model/subscriber.rs @@ -10,4 +10,17 @@ use crate::model::notification::Notification; pub struct Subscriber { pub url: String, pub name: String, +} + +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); + } } \ No newline at end of file