use std::sync::Arc;
use octocrab::models::webhook_events::WebhookEventType;
use crate::{Context, Octofer, SerdeToString};
impl Octofer {
pub async fn on_project<F, Fut, E>(&mut self, handler: F, extra: Arc<E>) -> &Self
where
F: Fn(Context, Arc<E>) -> Fut + Send + Sync + 'static,
Fut: std::future::Future<Output = anyhow::Result<()>> + Send + 'static,
E: Send + Sync + 'static,
{
self.server
.on(WebhookEventType::Project.to_string(), handler, extra)
.await;
self
}
pub async fn on_project_card<F, Fut, E>(&mut self, handler: F, extra: Arc<E>) -> &Self
where
F: Fn(Context, Arc<E>) -> Fut + Send + Sync + 'static,
Fut: std::future::Future<Output = anyhow::Result<()>> + Send + 'static,
E: Send + Sync + 'static,
{
self.server
.on(WebhookEventType::ProjectCard.to_string(), handler, extra)
.await;
self
}
pub async fn on_project_column<F, Fut, E>(&mut self, handler: F, extra: Arc<E>) -> &Self
where
F: Fn(Context, Arc<E>) -> Fut + Send + Sync + 'static,
Fut: std::future::Future<Output = anyhow::Result<()>> + Send + 'static,
E: Send + Sync + 'static,
{
self.server
.on(WebhookEventType::ProjectColumn.to_string(), handler, extra)
.await;
self
}
pub async fn on_projects_v2<F, Fut, E>(&mut self, handler: F, extra: Arc<E>) -> &Self
where
F: Fn(Context, Arc<E>) -> Fut + Send + Sync + 'static,
Fut: std::future::Future<Output = anyhow::Result<()>> + Send + 'static,
E: Send + Sync + 'static,
{
self.server
.on(WebhookEventType::ProjectsV2.to_string(), handler, extra)
.await;
self
}
pub async fn on_projects_v2_item<F, Fut, E>(&mut self, handler: F, extra: Arc<E>) -> &Self
where
F: Fn(Context, Arc<E>) -> Fut + Send + Sync + 'static,
Fut: std::future::Future<Output = anyhow::Result<()>> + Send + 'static,
E: Send + Sync + 'static,
{
self.server
.on(WebhookEventType::ProjectsV2Item.to_string(), handler, extra)
.await;
self
}
}