alchemy_api/api/notify/webhook_addresses/
replace.rs

1use crate::cores::endpoint::Endpoint;
2use derive_builder::Builder;
3use ethers_core::types::Address;
4use http::Method;
5use serde::{Deserialize, Serialize};
6
7/// Replace entire list of addresses tracked in a given webhook.
8#[derive(Default, Debug, Builder, Clone, Serialize, Deserialize)]
9#[builder(default, setter(into))]
10pub struct ReplaceWebhookAddresses {
11    /// ID of the address activity webhook.
12    #[builder(setter)]
13    webhook_id: String,
14    /// New list of addresses to track. This replaces any existing addresses.
15    addresses: Vec<Address>,
16}
17
18impl ReplaceWebhookAddresses {
19    /// Create a builder for the endpoint.
20    pub fn builder() -> ReplaceWebhookAddressesBuilder {
21        ReplaceWebhookAddressesBuilder::default()
22    }
23}
24
25impl Endpoint for ReplaceWebhookAddresses {
26    fn method(&self) -> http::Method {
27        Method::PUT
28    }
29
30    fn endpoint(&self) -> std::borrow::Cow<'static, str> {
31        "api/update-webhook-addresses".into()
32    }
33
34    fn body(&self) -> anyhow::Result<Option<(&'static str, Vec<u8>)>> {
35        let body = serde_json::to_vec(self)?;
36        Ok(Some(("application/json", body)))
37    }
38}