use std::sync::Arc;
use crate::client::HttpCore;
use crate::error::Result;
use crate::types::*;
#[derive(Debug, Clone)]
pub struct Webhooks {
pub(crate) core: Arc<HttpCore>,
}
impl Webhooks {
pub async fn list(&self) -> Result<WebhookListResponse> {
self.core.get("/webhooks", &()).await
}
pub async fn create(&self, params: &WebhookCreateParams) -> Result<Webhook> {
self.core.post_json("/webhooks", params).await
}
pub async fn update(
&self,
id: i64,
params: &WebhookUpdateParams,
) -> Result<Webhook> {
self.core
.patch_json(&format!("/webhooks/{}", id), params)
.await
}
pub async fn delete(&self, id: i64) -> Result<WebhookDeleteResponse> {
self.core.delete(&format!("/webhooks/{}", id)).await
}
pub async fn test(&self, webhook_id: i64) -> Result<serde_json::Value> {
let body = serde_json::json!({ "webhook_id": webhook_id });
self.core.post_json("/webhooks/test", &body).await
}
}