1use log::{info, warn};
2use notifica_common::configuration::WebhookDto;
3use reqwest::StatusCode;
4use serde_json::json;
5use uuid::Uuid;
6
7pub struct Notifica;
8
9impl Notifica {
10 pub async fn send_message(body: WebhookDto, event: &str, tenant_id: Uuid) {
11 info!("[NOTIFICA-SDK] Tenant '{tenant_id}' event '{event}'");
12 let client = reqwest::Client::new();
13 let response: reqwest::Response = client
14 .post(format!(
15 "https://notifica.flippi.co/webhook/{tenant_id}/{event}"
16 ))
17 .json(&json!(body))
18 .send()
19 .await
20 .unwrap();
21
22 if response.status() == StatusCode::OK {
23 info!("[NOTIFICA-SDK] Request has been accepted");
24 } else {
25 warn!("[NOTIFICA-SDK] Request hasnt been accepted");
26 }
27 }
28}