alchemy_api/api/notify/
update_webhook.rs

1use crate::cores::endpoint::Endpoint;
2use derive_builder::Builder;
3use http::Method;
4use serde::{Deserialize, Serialize};
5use serde_with::{serde_as, skip_serializing_none};
6
7/// Allows you to set status of webhooks to active or inactive.
8#[serde_as]
9#[skip_serializing_none]
10#[derive(Builder, Default, Debug, Clone, Serialize, Deserialize)]
11#[builder(setter(into))]
12pub struct UpdateWebhook {
13    /// ID of the address activity webhook.
14    webhook_id: String,
15    /// true - set webhook to active state
16    /// false - set webhook to inactive state
17    is_active: bool,
18}
19
20impl UpdateWebhook {
21    /// Create a builder for the endpoint.
22    pub fn builder() -> UpdateWebhookBuilder {
23        UpdateWebhookBuilder::default()
24    }
25}
26
27impl Endpoint for UpdateWebhook {
28    fn method(&self) -> http::Method {
29        Method::PUT
30    }
31
32    fn endpoint(&self) -> std::borrow::Cow<'static, str> {
33        "api/update-webhook".into()
34    }
35
36    fn body(&self) -> anyhow::Result<Option<(&'static str, Vec<u8>)>> {
37        let body = serde_json::to_vec(self)?;
38        Ok(Some(("application/json", body)))
39    }
40}