diff --git a/src/model/subscriber.rs b/src/model/subscriber.rs index c9ee41f2419bdfbdf3dd14dafee76fbac9090e8f..5c24e36078e0b930bd9cd7fc3c85f9a5c012be83 100644 --- a/src/model/subscriber.rs +++ b/src/model/subscriber.rs @@ -11,4 +11,24 @@ 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