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#[derive(
9    serde::Serialize,
10    serde::Deserialize,
11    Debug,
12    Clone,
13    PartialEq,
14    Eq,
15    jacquard_derive::IntoStatic
16)]
17#[serde(rename_all = "camelCase")]
18pub struct ListWebhooks<'a> {
19    #[serde(skip_serializing_if = "std::option::Option::is_none")]
20    pub active: std::option::Option<bool>,
21    #[serde(skip_serializing_if = "std::option::Option::is_none")]
22    #[serde(borrow)]
23    pub cursor: std::option::Option<jacquard_common::CowStr<'a>>,
24    #[serde(skip_serializing_if = "std::option::Option::is_none")]
25    #[serde(borrow)]
26    pub event: std::option::Option<jacquard_common::CowStr<'a>>,
27    ///(default: 50, min: 1, max: 100)
28    #[serde(skip_serializing_if = "std::option::Option::is_none")]
29    pub limit: std::option::Option<i64>,
30}
31
32pub mod list_webhooks_state {
33
34    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
35    #[allow(unused)]
36    use ::core::marker::PhantomData;
37    mod sealed {
38        pub trait Sealed {}
39    }
40    /// State trait tracking which required fields have been set
41    pub trait State: sealed::Sealed {}
42    /// Empty state - all required fields are unset
43    pub struct Empty(());
44    impl sealed::Sealed for Empty {}
45    impl State for Empty {}
46    /// Marker types for field names
47    #[allow(non_camel_case_types)]
48    pub mod members {}
49}
50
51/// Builder for constructing an instance of this type
52pub struct ListWebhooksBuilder<'a, S: list_webhooks_state::State> {
53    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
54    __unsafe_private_named: (
55        ::core::option::Option<bool>,
56        ::core::option::Option<jacquard_common::CowStr<'a>>,
57        ::core::option::Option<jacquard_common::CowStr<'a>>,
58        ::core::option::Option<i64>,
59    ),
60    _phantom: ::core::marker::PhantomData<&'a ()>,
61}
62
63impl<'a> ListWebhooks<'a> {
64    /// Create a new builder for this type
65    pub fn new() -> ListWebhooksBuilder<'a, list_webhooks_state::Empty> {
66        ListWebhooksBuilder::new()
67    }
68}
69
70impl<'a> ListWebhooksBuilder<'a, list_webhooks_state::Empty> {
71    /// Create a new builder with all fields unset
72    pub fn new() -> Self {
73        ListWebhooksBuilder {
74            _phantom_state: ::core::marker::PhantomData,
75            __unsafe_private_named: (None, None, None, None),
76            _phantom: ::core::marker::PhantomData,
77        }
78    }
79}
80
81impl<'a, S: list_webhooks_state::State> ListWebhooksBuilder<'a, S> {
82    /// Set the `active` field (optional)
83    pub fn active(mut self, value: impl Into<Option<bool>>) -> Self {
84        self.__unsafe_private_named.0 = value.into();
85        self
86    }
87    /// Set the `active` field to an Option value (optional)
88    pub fn maybe_active(mut self, value: Option<bool>) -> Self {
89        self.__unsafe_private_named.0 = value;
90        self
91    }
92}
93
94impl<'a, S: list_webhooks_state::State> ListWebhooksBuilder<'a, S> {
95    /// Set the `cursor` field (optional)
96    pub fn cursor(
97        mut self,
98        value: impl Into<Option<jacquard_common::CowStr<'a>>>,
99    ) -> Self {
100        self.__unsafe_private_named.1 = value.into();
101        self
102    }
103    /// Set the `cursor` field to an Option value (optional)
104    pub fn maybe_cursor(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
105        self.__unsafe_private_named.1 = value;
106        self
107    }
108}
109
110impl<'a, S: list_webhooks_state::State> ListWebhooksBuilder<'a, S> {
111    /// Set the `event` field (optional)
112    pub fn event(
113        mut self,
114        value: impl Into<Option<jacquard_common::CowStr<'a>>>,
115    ) -> Self {
116        self.__unsafe_private_named.2 = value.into();
117        self
118    }
119    /// Set the `event` field to an Option value (optional)
120    pub fn maybe_event(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
121        self.__unsafe_private_named.2 = value;
122        self
123    }
124}
125
126impl<'a, S: list_webhooks_state::State> ListWebhooksBuilder<'a, S> {
127    /// Set the `limit` field (optional)
128    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
129        self.__unsafe_private_named.3 = value.into();
130        self
131    }
132    /// Set the `limit` field to an Option value (optional)
133    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
134        self.__unsafe_private_named.3 = value;
135        self
136    }
137}
138
139impl<'a, S> ListWebhooksBuilder<'a, S>
140where
141    S: list_webhooks_state::State,
142{
143    /// Build the final struct
144    pub fn build(self) -> ListWebhooks<'a> {
145        ListWebhooks {
146            active: self.__unsafe_private_named.0,
147            cursor: self.__unsafe_private_named.1,
148            event: self.__unsafe_private_named.2,
149            limit: self.__unsafe_private_named.3,
150        }
151    }
152}
153
154#[jacquard_derive::lexicon]
155#[derive(
156    serde::Serialize,
157    serde::Deserialize,
158    Debug,
159    Clone,
160    PartialEq,
161    Eq,
162    jacquard_derive::IntoStatic
163)]
164#[serde(rename_all = "camelCase")]
165pub struct ListWebhooksOutput<'a> {
166    /// A cursor for pagination, if there are more results.
167    #[serde(skip_serializing_if = "std::option::Option::is_none")]
168    #[serde(borrow)]
169    pub cursor: std::option::Option<jacquard_common::CowStr<'a>>,
170    #[serde(borrow)]
171    pub webhooks: Vec<crate::place_stream::server::Webhook<'a>>,
172}
173
174#[jacquard_derive::open_union]
175#[derive(
176    serde::Serialize,
177    serde::Deserialize,
178    Debug,
179    Clone,
180    PartialEq,
181    Eq,
182    thiserror::Error,
183    miette::Diagnostic,
184    jacquard_derive::IntoStatic
185)]
186#[serde(tag = "error", content = "message")]
187#[serde(bound(deserialize = "'de: 'a"))]
188pub enum ListWebhooksError<'a> {
189    /// The provided cursor is invalid or expired.
190    #[serde(rename = "InvalidCursor")]
191    InvalidCursor(std::option::Option<String>),
192}
193
194impl std::fmt::Display for ListWebhooksError<'_> {
195    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
196        match self {
197            Self::InvalidCursor(msg) => {
198                write!(f, "InvalidCursor")?;
199                if let Some(msg) = msg {
200                    write!(f, ": {}", msg)?;
201                }
202                Ok(())
203            }
204            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
205        }
206    }
207}
208
209/// Response type for
210///place.stream.server.listWebhooks
211pub struct ListWebhooksResponse;
212impl jacquard_common::xrpc::XrpcResp for ListWebhooksResponse {
213    const NSID: &'static str = "place.stream.server.listWebhooks";
214    const ENCODING: &'static str = "application/json";
215    type Output<'de> = ListWebhooksOutput<'de>;
216    type Err<'de> = ListWebhooksError<'de>;
217}
218
219impl<'a> jacquard_common::xrpc::XrpcRequest for ListWebhooks<'a> {
220    const NSID: &'static str = "place.stream.server.listWebhooks";
221    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
222    type Response = ListWebhooksResponse;
223}
224
225/// Endpoint type for
226///place.stream.server.listWebhooks
227pub struct ListWebhooksRequest;
228impl jacquard_common::xrpc::XrpcEndpoint for ListWebhooksRequest {
229    const PATH: &'static str = "/xrpc/place.stream.server.listWebhooks";
230    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
231    type Request<'de> = ListWebhooks<'de>;
232    type Response = ListWebhooksResponse;
233}