diff --git a/src/service/notification.rs b/src/service/notification.rs index 92d28be28891b9ba602b517a6e236dd13670513e..1f7562f463a5064a4592fd4c25c6fec531e7272e 100644 --- a/src/service/notification.rs +++ b/src/service/notification.rs @@ -17,4 +17,17 @@ impl NotificationService { return Ok(subscriber_result); } + pub fn unsubscribe(product_type: &str, url: &str) -> Result<Subscriber> { + let product_type_upper: String = product_type.to_uppercase(); + let product_type_str: &str = product_type_upper.as_str(); + let result: Option<Subscriber> = SubscriberRepository::delete(product_type_str, url); + if result.is_none() { + return Err(compose_error_response( + Status::NotFound, + String::from("Subscriber not found.") + )); + } + return Ok(result.unwrap()); + } + }