use crate::client::LnBot;
use crate::errors::LnBotError;
use crate::types::*;
pub struct WebhooksResource<'a> {
pub(crate) client: &'a LnBot,
pub(crate) prefix: &'a str,
}
impl WebhooksResource<'_> {
pub async fn create(
&self,
req: &CreateWebhookRequest,
) -> Result<CreateWebhookResponse, LnBotError> {
self.client
.post(&format!("{}/webhooks", self.prefix), Some(req))
.await
}
pub async fn list(&self) -> Result<Vec<WebhookResponse>, LnBotError> {
self.client
.get(&format!("{}/webhooks", self.prefix))
.await
}
pub async fn delete(&self, id: &str) -> Result<(), LnBotError> {
self.client
.delete(&format!(
"{}/webhooks/{}",
self.prefix,
urlencoding::encode(id)
))
.await
}
}