Skip to main content

jacquard_api/place_stream/server/
update_webhook.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.server.updateWebhook
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_common::types::string::UriValue;
15use jacquard_derive::{IntoStatic, lexicon, open_union};
16use serde::{Serialize, Deserialize};
17use crate::place_stream::server::RewriteRule;
18use crate::place_stream::server::Webhook;
19
20#[lexicon]
21#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
22#[serde(rename_all = "camelCase")]
23pub struct UpdateWebhook<'a> {
24    ///Whether this webhook should be active.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub active: Option<bool>,
27    ///A description of what this webhook is used for.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    #[serde(borrow)]
30    pub description: Option<CowStr<'a>>,
31    ///The types of events this webhook should receive.
32    #[serde(skip_serializing_if = "Option::is_none")]
33    #[serde(borrow)]
34    pub events: Option<Vec<CowStr<'a>>>,
35    ///The ID of the webhook to update.
36    #[serde(borrow)]
37    pub id: CowStr<'a>,
38    ///Words to filter out from chat messages. Messages containing any of these words will not be forwarded.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    #[serde(borrow)]
41    pub mute_words: Option<Vec<CowStr<'a>>>,
42    ///A user-friendly name for this webhook.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    #[serde(borrow)]
45    pub name: Option<CowStr<'a>>,
46    ///Text to prepend to webhook messages.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    #[serde(borrow)]
49    pub prefix: Option<CowStr<'a>>,
50    ///Text replacement rules for webhook messages.
51    #[serde(skip_serializing_if = "Option::is_none")]
52    #[serde(borrow)]
53    pub rewrite: Option<Vec<RewriteRule<'a>>>,
54    ///Text to append to webhook messages.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    #[serde(borrow)]
57    pub suffix: Option<CowStr<'a>>,
58    ///The webhook URL where events will be sent.
59    #[serde(skip_serializing_if = "Option::is_none")]
60    #[serde(borrow)]
61    pub url: Option<UriValue<'a>>,
62}
63
64
65#[lexicon]
66#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
67#[serde(rename_all = "camelCase")]
68pub struct UpdateWebhookOutput<'a> {
69    #[serde(borrow)]
70    pub webhook: Webhook<'a>,
71}
72
73
74#[open_union]
75#[derive(
76    Serialize,
77    Deserialize,
78    Debug,
79    Clone,
80    PartialEq,
81    Eq,
82    thiserror::Error,
83    miette::Diagnostic,
84    IntoStatic
85)]
86
87#[serde(tag = "error", content = "message")]
88#[serde(bound(deserialize = "'de: 'a"))]
89pub enum UpdateWebhookError<'a> {
90    /// The specified webhook was not found.
91    #[serde(rename = "WebhookNotFound")]
92    WebhookNotFound(Option<CowStr<'a>>),
93    /// The authenticated user does not have access to this webhook.
94    #[serde(rename = "Unauthorized")]
95    Unauthorized(Option<CowStr<'a>>),
96    /// The provided webhook URL is invalid or unreachable.
97    #[serde(rename = "InvalidUrl")]
98    InvalidUrl(Option<CowStr<'a>>),
99    /// A webhook with this URL already exists for this user.
100    #[serde(rename = "DuplicateWebhook")]
101    DuplicateWebhook(Option<CowStr<'a>>),
102}
103
104impl core::fmt::Display for UpdateWebhookError<'_> {
105    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
106        match self {
107            Self::WebhookNotFound(msg) => {
108                write!(f, "WebhookNotFound")?;
109                if let Some(msg) = msg {
110                    write!(f, ": {}", msg)?;
111                }
112                Ok(())
113            }
114            Self::Unauthorized(msg) => {
115                write!(f, "Unauthorized")?;
116                if let Some(msg) = msg {
117                    write!(f, ": {}", msg)?;
118                }
119                Ok(())
120            }
121            Self::InvalidUrl(msg) => {
122                write!(f, "InvalidUrl")?;
123                if let Some(msg) = msg {
124                    write!(f, ": {}", msg)?;
125                }
126                Ok(())
127            }
128            Self::DuplicateWebhook(msg) => {
129                write!(f, "DuplicateWebhook")?;
130                if let Some(msg) = msg {
131                    write!(f, ": {}", msg)?;
132                }
133                Ok(())
134            }
135            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
136        }
137    }
138}
139
140/// Response type for place.stream.server.updateWebhook
141pub struct UpdateWebhookResponse;
142impl jacquard_common::xrpc::XrpcResp for UpdateWebhookResponse {
143    const NSID: &'static str = "place.stream.server.updateWebhook";
144    const ENCODING: &'static str = "application/json";
145    type Output<'de> = UpdateWebhookOutput<'de>;
146    type Err<'de> = UpdateWebhookError<'de>;
147}
148
149impl<'a> jacquard_common::xrpc::XrpcRequest for UpdateWebhook<'a> {
150    const NSID: &'static str = "place.stream.server.updateWebhook";
151    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
152        "application/json",
153    );
154    type Response = UpdateWebhookResponse;
155}
156
157/// Endpoint type for place.stream.server.updateWebhook
158pub struct UpdateWebhookRequest;
159impl jacquard_common::xrpc::XrpcEndpoint for UpdateWebhookRequest {
160    const PATH: &'static str = "/xrpc/place.stream.server.updateWebhook";
161    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
162        "application/json",
163    );
164    type Request<'de> = UpdateWebhook<'de>;
165    type Response = UpdateWebhookResponse;
166}