jacquard_api/place_stream/server/
update_webhook.rs1#[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 #[serde(skip_serializing_if = "std::option::Option::is_none")]
24 pub active: std::option::Option<bool>,
25 #[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 #[serde(skip_serializing_if = "std::option::Option::is_none")]
32 #[serde(borrow)]
33 pub events: std::option::Option<Vec<jacquard_common::CowStr<'a>>>,
34 #[serde(borrow)]
36 #[builder(into)]
37 pub id: jacquard_common::CowStr<'a>,
38 #[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 #[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 #[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 #[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 #[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 #[serde(rename = "WebhookNotFound")]
102 WebhookNotFound(std::option::Option<String>),
103 #[serde(rename = "Unauthorized")]
105 Unauthorized(std::option::Option<String>),
106 #[serde(rename = "InvalidUrl")]
108 InvalidUrl(std::option::Option<String>),
109 #[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
173pub 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
191pub 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}