Skip to main content

neptunium_http/endpoints/webhooks/
get_webhook_with_token.rs

1use bon::Builder;
2use neptunium_model::{
3    id::{
4        Id,
5        marker::{ChannelMarker, GuildMarker, WebhookMarker},
6    },
7    misc::ImageHash,
8};
9use reqwest::Method;
10use serde::Deserialize;
11use zeroize::Zeroizing;
12
13use crate::{endpoints::Endpoint, request::Request};
14
15#[derive(Builder, Clone, Debug)]
16pub struct GetWebhookWithToken {
17    pub webhook_id: Id<WebhookMarker>,
18    #[builder(into)]
19    pub token: Zeroizing<String>,
20}
21
22/// A `Webhook` struct without the creator user data.
23#[derive(Deserialize, Clone, Debug)]
24pub struct GetWebhookWithTokenResponse {
25    pub id: Id<WebhookMarker>,
26    pub guild_id: Id<GuildMarker>,
27    pub channel_id: Id<ChannelMarker>,
28    /// The display name.
29    pub name: String,
30    pub token: Zeroizing<String>,
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub avatar: Option<ImageHash>,
33}
34
35impl Endpoint for GetWebhookWithToken {
36    type Response = GetWebhookWithTokenResponse;
37
38    fn into_request(self) -> crate::request::Request {
39        Request::builder()
40            .method(Method::GET)
41            .use_authorization_token(false)
42            .path(format!("/webhooks/{}/{}", self.webhook_id, *self.token))
43            .build()
44    }
45}