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#[jacquard_derive::lexicon]
9#[derive(
10    serde::Serialize,
11    serde::Deserialize,
12    Debug,
13    Clone,
14    PartialEq,
15    Eq,
16    bon::Builder,
17    jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20#[builder(start_fn = new)]
21pub struct UpdateWebhook<'a> {
22    ///Whether this webhook should be active.
23    #[serde(skip_serializing_if = "std::option::Option::is_none")]
24    pub active: std::option::Option<bool>,
25    ///A description of what this webhook is used for.
26    #[serde(skip_serializing_if = "std::option::Option::is_none")]
27    #[serde(borrow)]
28    #[builder(into)]
29    pub description: std::option::Option<jacquard_common::CowStr<'a>>,
30    ///The types of events this webhook should receive.
31    #[serde(skip_serializing_if = "std::option::Option::is_none")]
32    #[serde(borrow)]
33    pub events: std::option::Option<Vec<jacquard_common::CowStr<'a>>>,
34    ///The ID of the webhook to update.
35    #[serde(borrow)]
36    #[builder(into)]
37    pub id: jacquard_common::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 = "std::option::Option::is_none")]
40    #[serde(borrow)]
41    pub mute_words: std::option::Option<Vec<jacquard_common::CowStr<'a>>>,
42    ///A user-friendly name for this webhook.
43    #[serde(skip_serializing_if = "std::option::Option::is_none")]
44    #[serde(borrow)]
45    #[builder(into)]
46    pub name: std::option::Option<jacquard_common::CowStr<'a>>,
47    ///Text to prepend to webhook messages.
48    #[serde(skip_serializing_if = "std::option::Option::is_none")]
49    #[serde(borrow)]
50    #[builder(into)]
51    pub prefix: std::option::Option<jacquard_common::CowStr<'a>>,
52    ///Text replacement rules for webhook messages.
53    #[serde(skip_serializing_if = "std::option::Option::is_none")]
54    #[serde(borrow)]
55    pub rewrite: std::option::Option<Vec<crate::place_stream::server::RewriteRule<'a>>>,
56    ///Text to append to webhook messages.
57    #[serde(skip_serializing_if = "std::option::Option::is_none")]
58    #[serde(borrow)]
59    #[builder(into)]
60    pub suffix: std::option::Option<jacquard_common::CowStr<'a>>,
61    ///The webhook URL where events will be sent.
62    #[serde(skip_serializing_if = "std::option::Option::is_none")]
63    #[serde(borrow)]
64    pub url: std::option::Option<jacquard_common::types::string::Uri<'a>>,
65    #[serde(flatten)]
66    #[serde(borrow)]
67    #[builder(default)]
68    pub extra_data: ::std::collections::BTreeMap<
69        ::jacquard_common::smol_str::SmolStr,
70        ::jacquard_common::types::value::Data<'a>,
71    >,
72}
73
74#[jacquard_derive::lexicon]
75#[derive(
76    serde::Serialize,
77    serde::Deserialize,
78    Debug,
79    Clone,
80    PartialEq,
81    Eq,
82    jacquard_derive::IntoStatic
83)]
84#[serde(rename_all = "camelCase")]
85pub struct UpdateWebhookOutput<'a> {
86    #[serde(borrow)]
87    pub webhook: crate::place_stream::server::Webhook<'a>,
88}
89
90#[jacquard_derive::open_union]
91#[derive(
92    serde::Serialize,
93    serde::Deserialize,
94    Debug,
95    Clone,
96    PartialEq,
97    Eq,
98    thiserror::Error,
99    miette::Diagnostic,
100    jacquard_derive::IntoStatic
101)]
102#[serde(tag = "error", content = "message")]
103#[serde(bound(deserialize = "'de: 'a"))]
104pub enum UpdateWebhookError<'a> {
105    ///The specified webhook was not found.
106    #[serde(rename = "WebhookNotFound")]
107    WebhookNotFound(std::option::Option<String>),
108    ///The authenticated user does not have access to this webhook.
109    #[serde(rename = "Unauthorized")]
110    Unauthorized(std::option::Option<String>),
111    ///The provided webhook URL is invalid or unreachable.
112    #[serde(rename = "InvalidUrl")]
113    InvalidUrl(std::option::Option<String>),
114    ///A webhook with this URL already exists for this user.
115    #[serde(rename = "DuplicateWebhook")]
116    DuplicateWebhook(std::option::Option<String>),
117}
118
119impl std::fmt::Display for UpdateWebhookError<'_> {
120    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
121        match self {
122            Self::WebhookNotFound(msg) => {
123                write!(f, "WebhookNotFound")?;
124                if let Some(msg) = msg {
125                    write!(f, ": {}", msg)?;
126                }
127                Ok(())
128            }
129            Self::Unauthorized(msg) => {
130                write!(f, "Unauthorized")?;
131                if let Some(msg) = msg {
132                    write!(f, ": {}", msg)?;
133                }
134                Ok(())
135            }
136            Self::InvalidUrl(msg) => {
137                write!(f, "InvalidUrl")?;
138                if let Some(msg) = msg {
139                    write!(f, ": {}", msg)?;
140                }
141                Ok(())
142            }
143            Self::DuplicateWebhook(msg) => {
144                write!(f, "DuplicateWebhook")?;
145                if let Some(msg) = msg {
146                    write!(f, ": {}", msg)?;
147                }
148                Ok(())
149            }
150            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
151        }
152    }
153}
154
155///Response type for
156///place.stream.server.updateWebhook
157pub struct UpdateWebhookResponse;
158impl jacquard_common::xrpc::XrpcResp for UpdateWebhookResponse {
159    const NSID: &'static str = "place.stream.server.updateWebhook";
160    const ENCODING: &'static str = "application/json";
161    type Output<'de> = UpdateWebhookOutput<'de>;
162    type Err<'de> = UpdateWebhookError<'de>;
163}
164
165impl<'a> jacquard_common::xrpc::XrpcRequest for UpdateWebhook<'a> {
166    const NSID: &'static str = "place.stream.server.updateWebhook";
167    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
168        "application/json",
169    );
170    type Response = UpdateWebhookResponse;
171}
172
173///Endpoint type for
174///place.stream.server.updateWebhook
175pub struct UpdateWebhookRequest;
176impl jacquard_common::xrpc::XrpcEndpoint for UpdateWebhookRequest {
177    const PATH: &'static str = "/xrpc/place.stream.server.updateWebhook";
178    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
179        "application/json",
180    );
181    type Request<'de> = UpdateWebhook<'de>;
182    type Response = UpdateWebhookResponse;
183}