thunkmetrc_client/services/
webhooks.rs1use crate::client::MetrcClient;
2use serde_json::Value;
3use std::error::Error;
4
5pub struct WebhooksClient<'a> {
6 pub(crate) client: &'a MetrcClient,
7}
8
9impl<'a> WebhooksClient<'a> {
10 pub async fn delete_webhooks_by_subscription_id(&self, subscription_id: &str, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
15 let path = format!("/webhooks/v2/{}", urlencoding::encode(subscription_id).as_ref());
16
17 self.client.send(reqwest::Method::DELETE, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
18 }
19 pub async fn get_webhooks(&self, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
23 let path = format!("/webhooks/v2");
24
25 self.client.send(reqwest::Method::GET, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
26 }
27 pub async fn update_webhooks_disable_by_subscription_id(&self, subscription_id: &str, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
33 let path = format!("/webhooks/v2/disable/{}", urlencoding::encode(subscription_id).as_ref());
34
35 self.client.send(reqwest::Method::PUT, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
36 }
37 pub async fn update_webhooks_enable_by_subscription_id(&self, subscription_id: &str, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
43 let path = format!("/webhooks/v2/enable/{}", urlencoding::encode(subscription_id).as_ref());
44
45 self.client.send(reqwest::Method::PUT, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
46 }
47 pub async fn update_webhooks(&self, body: Option<&Value>) -> Result<Option<Value>, Box<dyn Error + Send + Sync>> {
52 let path = format!("/webhooks/v2");
53
54 self.client.send(reqwest::Method::PUT, &path, body.map(|b| serde_json::to_value(b).unwrap()).as_ref()).await
55 }
56}
57