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    jacquard_derive::IntoStatic
97)]
98#[serde(tag = "error", content = "message")]
99#[serde(bound(deserialize = "'de: 'a"))]
100pub enum UpdateWebhookError<'a> {
101    ///The specified webhook was not found.
102    #[serde(rename = "WebhookNotFound")]
103    WebhookNotFound(std::option::Option<String>),
104    ///The authenticated user does not have access to this webhook.
105    #[serde(rename = "Unauthorized")]
106    Unauthorized(std::option::Option<String>),
107    ///The provided webhook URL is invalid or unreachable.
108    #[serde(rename = "InvalidUrl")]
109    InvalidUrl(std::option::Option<String>),
110    ///A webhook with this URL already exists for this user.
111    #[serde(rename = "DuplicateWebhook")]
112    DuplicateWebhook(std::option::Option<String>),
113}
114
115impl std::fmt::Display for UpdateWebhookError<'_> {
116    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
117        match self {
118            Self::WebhookNotFound(msg) => {
119                write!(f, "WebhookNotFound")?;
120                if let Some(msg) = msg {
121                    write!(f, ": {}", msg)?;
122                }
123                Ok(())
124            }
125            Self::Unauthorized(msg) => {
126                write!(f, "Unauthorized")?;
127                if let Some(msg) = msg {
128                    write!(f, ": {}", msg)?;
129                }
130                Ok(())
131            }
132            Self::InvalidUrl(msg) => {
133                write!(f, "InvalidUrl")?;
134                if let Some(msg) = msg {
135                    write!(f, ": {}", msg)?;
136                }
137                Ok(())
138            }
139            Self::DuplicateWebhook(msg) => {
140                write!(f, "DuplicateWebhook")?;
141                if let Some(msg) = msg {
142                    write!(f, ": {}", msg)?;
143                }
144                Ok(())
145            }
146            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
147        }
148    }
149}
150
151///Response type for
152///place.stream.server.updateWebhook
153pub struct UpdateWebhookResponse;
154impl jacquard_common::xrpc::XrpcResp for UpdateWebhookResponse {
155    const NSID: &'static str = "place.stream.server.updateWebhook";
156    const ENCODING: &'static str = "application/json";
157    type Output<'de> = UpdateWebhookOutput<'de>;
158    type Err<'de> = UpdateWebhookError<'de>;
159}
160
161impl<'de> jacquard_common::xrpc::XrpcRequest<'de> for UpdateWebhook<'de> {
162    const NSID: &'static str = "place.stream.server.updateWebhook";
163    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
164        "application/json",
165    );
166    type Response = UpdateWebhookResponse;
167}
168
169///Endpoint type for
170///place.stream.server.updateWebhook
171pub struct UpdateWebhookRequest;
172impl jacquard_common::xrpc::XrpcEndpoint for UpdateWebhookRequest {
173    const PATH: &'static str = "/xrpc/place.stream.server.updateWebhook";
174    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
175        "application/json",
176    );
177    type Request<'de> = UpdateWebhook<'de>;
178    type Response = UpdateWebhookResponse;
179}