jacquard_api/place_stream/server/
list_webhooks.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_derive::{IntoStatic, lexicon, open_union};
15use serde::{Serialize, Deserialize};
16use crate::place_stream::server::Webhook;
17
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct ListWebhooks<'a> {
21 #[serde(skip_serializing_if = "Option::is_none")]
22 pub active: Option<bool>,
23 #[serde(skip_serializing_if = "Option::is_none")]
24 #[serde(borrow)]
25 pub cursor: Option<CowStr<'a>>,
26 #[serde(skip_serializing_if = "Option::is_none")]
27 #[serde(borrow)]
28 pub event: Option<CowStr<'a>>,
29 #[serde(default = "_default_limit")]
31 #[serde(skip_serializing_if = "Option::is_none")]
32 pub limit: Option<i64>,
33}
34
35
36#[lexicon]
37#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
38#[serde(rename_all = "camelCase")]
39pub struct ListWebhooksOutput<'a> {
40 #[serde(skip_serializing_if = "Option::is_none")]
42 #[serde(borrow)]
43 pub cursor: Option<CowStr<'a>>,
44 #[serde(borrow)]
45 pub webhooks: Vec<Webhook<'a>>,
46}
47
48
49#[open_union]
50#[derive(
51 Serialize,
52 Deserialize,
53 Debug,
54 Clone,
55 PartialEq,
56 Eq,
57 thiserror::Error,
58 miette::Diagnostic,
59 IntoStatic
60)]
61
62#[serde(tag = "error", content = "message")]
63#[serde(bound(deserialize = "'de: 'a"))]
64pub enum ListWebhooksError<'a> {
65 #[serde(rename = "InvalidCursor")]
67 InvalidCursor(Option<CowStr<'a>>),
68}
69
70impl core::fmt::Display for ListWebhooksError<'_> {
71 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
72 match self {
73 Self::InvalidCursor(msg) => {
74 write!(f, "InvalidCursor")?;
75 if let Some(msg) = msg {
76 write!(f, ": {}", msg)?;
77 }
78 Ok(())
79 }
80 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
81 }
82 }
83}
84
85pub struct ListWebhooksResponse;
87impl jacquard_common::xrpc::XrpcResp for ListWebhooksResponse {
88 const NSID: &'static str = "place.stream.server.listWebhooks";
89 const ENCODING: &'static str = "application/json";
90 type Output<'de> = ListWebhooksOutput<'de>;
91 type Err<'de> = ListWebhooksError<'de>;
92}
93
94impl<'a> jacquard_common::xrpc::XrpcRequest for ListWebhooks<'a> {
95 const NSID: &'static str = "place.stream.server.listWebhooks";
96 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
97 type Response = ListWebhooksResponse;
98}
99
100pub struct ListWebhooksRequest;
102impl jacquard_common::xrpc::XrpcEndpoint for ListWebhooksRequest {
103 const PATH: &'static str = "/xrpc/place.stream.server.listWebhooks";
104 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
105 type Request<'de> = ListWebhooks<'de>;
106 type Response = ListWebhooksResponse;
107}
108
109fn _default_limit() -> Option<i64> {
110 Some(50i64)
111}
112
113pub mod list_webhooks_state {
114
115 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
116 #[allow(unused)]
117 use ::core::marker::PhantomData;
118 mod sealed {
119 pub trait Sealed {}
120 }
121 pub trait State: sealed::Sealed {}
123 pub struct Empty(());
125 impl sealed::Sealed for Empty {}
126 impl State for Empty {}
127 #[allow(non_camel_case_types)]
129 pub mod members {}
130}
131
132pub struct ListWebhooksBuilder<'a, S: list_webhooks_state::State> {
134 _state: PhantomData<fn() -> S>,
135 _fields: (Option<bool>, Option<CowStr<'a>>, Option<CowStr<'a>>, Option<i64>),
136 _lifetime: PhantomData<&'a ()>,
137}
138
139impl<'a> ListWebhooks<'a> {
140 pub fn new() -> ListWebhooksBuilder<'a, list_webhooks_state::Empty> {
142 ListWebhooksBuilder::new()
143 }
144}
145
146impl<'a> ListWebhooksBuilder<'a, list_webhooks_state::Empty> {
147 pub fn new() -> Self {
149 ListWebhooksBuilder {
150 _state: PhantomData,
151 _fields: (None, None, None, None),
152 _lifetime: PhantomData,
153 }
154 }
155}
156
157impl<'a, S: list_webhooks_state::State> ListWebhooksBuilder<'a, S> {
158 pub fn active(mut self, value: impl Into<Option<bool>>) -> Self {
160 self._fields.0 = value.into();
161 self
162 }
163 pub fn maybe_active(mut self, value: Option<bool>) -> Self {
165 self._fields.0 = value;
166 self
167 }
168}
169
170impl<'a, S: list_webhooks_state::State> ListWebhooksBuilder<'a, S> {
171 pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
173 self._fields.1 = value.into();
174 self
175 }
176 pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
178 self._fields.1 = value;
179 self
180 }
181}
182
183impl<'a, S: list_webhooks_state::State> ListWebhooksBuilder<'a, S> {
184 pub fn event(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
186 self._fields.2 = value.into();
187 self
188 }
189 pub fn maybe_event(mut self, value: Option<CowStr<'a>>) -> Self {
191 self._fields.2 = value;
192 self
193 }
194}
195
196impl<'a, S: list_webhooks_state::State> ListWebhooksBuilder<'a, S> {
197 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
199 self._fields.3 = value.into();
200 self
201 }
202 pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
204 self._fields.3 = value;
205 self
206 }
207}
208
209impl<'a, S> ListWebhooksBuilder<'a, S>
210where
211 S: list_webhooks_state::State,
212{
213 pub fn build(self) -> ListWebhooks<'a> {
215 ListWebhooks {
216 active: self._fields.0,
217 cursor: self._fields.1,
218 event: self._fields.2,
219 limit: self._fields.3,
220 }
221 }
222}