use crate as github;
use git_next_core::{git, WebhookId};
pub async fn unregister(
github: &github::Github,
webhook_id: &WebhookId,
) -> git::forge::webhook::Result<()> {
let net = &github.net;
let repo_details = &github.repo_details;
let hostname = repo_details.forge.hostname();
net.delete(format!(
"https://api.{hostname}/repos/{}/hooks/{}",
repo_details.repo_path, webhook_id
))
.headers(github::webhook::headers(repo_details.forge.token()))
.send()
.await
.map_err(|e| git::forge::webhook::Error::FailedToRegister(e.to_string()))
.map(|_| ())
}