Skip to main content

thunkmetrc_client/services/
webhooks.rs

1use 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    /// DELETE DeleteWebhooksBySubscriptionId
11    /// 
12    /// Parameters:
13    /// - subscription_id (str): Path parameter subscriptionId
14    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    /// GET GetWebhooks
20    /// 
21    /// Parameters:
22    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    /// PUT UpdateDisableBySubscriptionId
28    /// 
29    /// Parameters:
30    /// - subscription_id (str): Path parameter subscriptionId
31    /// - body (Option<&Value>): Request body
32    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    /// PUT UpdateEnableBySubscriptionId
38    /// 
39    /// Parameters:
40    /// - subscription_id (str): Path parameter subscriptionId
41    /// - body (Option<&Value>): Request body
42    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    /// PUT UpdateWebhooks
48    /// 
49    /// Parameters:
50    /// - body (Option<&Value>): Request body
51    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