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