use std::sync::Arc;
use crate::error::Result;
use crate::http::Config;
use crate::types::{
list_query, CreateWebhookOptions, CreateWebhookResponse, DeleteWebhookResponse, List,
ListOptions, UpdateWebhookOptions, Webhook, WebhookId,
};
#[derive(Clone)]
pub struct Webhooks(pub(crate) Arc<Config>);
impl Webhooks {
pub async fn create(&self, webhook: &CreateWebhookOptions) -> Result<CreateWebhookResponse> {
self.0.post(&["webhooks"], webhook).await
}
pub async fn get(&self, id: &str) -> Result<Webhook> {
self.0.get(&["webhooks", id], &[]).await
}
pub async fn list(&self, options: Option<&ListOptions>) -> Result<List<Webhook>> {
self.0.get(&["webhooks"], &list_query(options)).await
}
pub async fn update(&self, id: &str, changes: &UpdateWebhookOptions) -> Result<WebhookId> {
self.0.patch(&["webhooks", id], changes).await
}
pub async fn delete(&self, id: &str) -> Result<DeleteWebhookResponse> {
self.0.delete(&["webhooks", id]).await
}
}