Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit bd6079f0 authored by Andrew4Coding's avatar Andrew4Coding
Browse files

Implement update method in Subscriber model to send notification HTTP requests.

parent 3cc375ec
Branches
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment