diff --git a/src/service/notification.rs b/src/service/notification.rs index a48c4cefc99ba9c014305162d29a6a38a55e0221..b4e89396a31c3929dc2acb502d8e29e3b4949c21 100644 --- a/src/service/notification.rs +++ b/src/service/notification.rs @@ -15,4 +15,17 @@ impl NotificationService { let subscriber_result = SubscriberRepository::add(product_type_str, subscriber); return Ok(subscriber_result); } + + pub fn unsubscribe(product_type: &str, url: &str) -> Result<Subscriber> { + let product_type_upper = product_type.to_uppercase(); + let product_type_str = product_type_upper.as_str(); + let result = SubscriberRepository::delete(product_type_str, url); + if result.is_none() { + return Err(compose_error_response( + Status::NotFound, + "Subscriber not found".to_string(), + )); + } + return Ok(result.unwrap()); + } } \ No newline at end of file