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