Skip to main content

jacquard_api/place_stream/server/
list_webhooks.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.server.listWebhooks
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[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    ///Defaults to `50`. Min: 1. Max: 100.
30    #[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    ///A cursor for pagination, if there are more results.
41    #[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    /// The provided cursor is invalid or expired.
66    #[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
85/// Response type for place.stream.server.listWebhooks
86pub 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
100/// Endpoint type for place.stream.server.listWebhooks
101pub 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    /// State trait tracking which required fields have been set
122    pub trait State: sealed::Sealed {}
123    /// Empty state - all required fields are unset
124    pub struct Empty(());
125    impl sealed::Sealed for Empty {}
126    impl State for Empty {}
127    /// Marker types for field names
128    #[allow(non_camel_case_types)]
129    pub mod members {}
130}
131
132/// Builder for constructing an instance of this type
133pub 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    /// Create a new builder for this type
141    pub fn new() -> ListWebhooksBuilder<'a, list_webhooks_state::Empty> {
142        ListWebhooksBuilder::new()
143    }
144}
145
146impl<'a> ListWebhooksBuilder<'a, list_webhooks_state::Empty> {
147    /// Create a new builder with all fields unset
148    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    /// Set the `active` field (optional)
159    pub fn active(mut self, value: impl Into<Option<bool>>) -> Self {
160        self._fields.0 = value.into();
161        self
162    }
163    /// Set the `active` field to an Option value (optional)
164    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    /// Set the `cursor` field (optional)
172    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
173        self._fields.1 = value.into();
174        self
175    }
176    /// Set the `cursor` field to an Option value (optional)
177    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    /// Set the `event` field (optional)
185    pub fn event(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
186        self._fields.2 = value.into();
187        self
188    }
189    /// Set the `event` field to an Option value (optional)
190    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    /// Set the `limit` field (optional)
198    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
199        self._fields.3 = value.into();
200        self
201    }
202    /// Set the `limit` field to an Option value (optional)
203    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    /// Build the final struct
214    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}