jacquard_api/place_stream/server/
get_webhook.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.server.getWebhook
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 GetWebhook<'a> {
19    #[serde(borrow)]
20    pub id: jacquard_common::CowStr<'a>,
21}
22
23pub mod get_webhook_state {
24
25    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
26    #[allow(unused)]
27    use ::core::marker::PhantomData;
28    mod sealed {
29        pub trait Sealed {}
30    }
31    /// State trait tracking which required fields have been set
32    pub trait State: sealed::Sealed {
33        type Id;
34    }
35    /// Empty state - all required fields are unset
36    pub struct Empty(());
37    impl sealed::Sealed for Empty {}
38    impl State for Empty {
39        type Id = Unset;
40    }
41    ///State transition - sets the `id` field to Set
42    pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
43    impl<S: State> sealed::Sealed for SetId<S> {}
44    impl<S: State> State for SetId<S> {
45        type Id = Set<members::id>;
46    }
47    /// Marker types for field names
48    #[allow(non_camel_case_types)]
49    pub mod members {
50        ///Marker type for the `id` field
51        pub struct id(());
52    }
53}
54
55/// Builder for constructing an instance of this type
56pub struct GetWebhookBuilder<'a, S: get_webhook_state::State> {
57    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
58    __unsafe_private_named: (::core::option::Option<jacquard_common::CowStr<'a>>,),
59    _phantom: ::core::marker::PhantomData<&'a ()>,
60}
61
62impl<'a> GetWebhook<'a> {
63    /// Create a new builder for this type
64    pub fn new() -> GetWebhookBuilder<'a, get_webhook_state::Empty> {
65        GetWebhookBuilder::new()
66    }
67}
68
69impl<'a> GetWebhookBuilder<'a, get_webhook_state::Empty> {
70    /// Create a new builder with all fields unset
71    pub fn new() -> Self {
72        GetWebhookBuilder {
73            _phantom_state: ::core::marker::PhantomData,
74            __unsafe_private_named: (None,),
75            _phantom: ::core::marker::PhantomData,
76        }
77    }
78}
79
80impl<'a, S> GetWebhookBuilder<'a, S>
81where
82    S: get_webhook_state::State,
83    S::Id: get_webhook_state::IsUnset,
84{
85    /// Set the `id` field (required)
86    pub fn id(
87        mut self,
88        value: impl Into<jacquard_common::CowStr<'a>>,
89    ) -> GetWebhookBuilder<'a, get_webhook_state::SetId<S>> {
90        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
91        GetWebhookBuilder {
92            _phantom_state: ::core::marker::PhantomData,
93            __unsafe_private_named: self.__unsafe_private_named,
94            _phantom: ::core::marker::PhantomData,
95        }
96    }
97}
98
99impl<'a, S> GetWebhookBuilder<'a, S>
100where
101    S: get_webhook_state::State,
102    S::Id: get_webhook_state::IsSet,
103{
104    /// Build the final struct
105    pub fn build(self) -> GetWebhook<'a> {
106        GetWebhook {
107            id: self.__unsafe_private_named.0.unwrap(),
108        }
109    }
110}
111
112#[jacquard_derive::lexicon]
113#[derive(
114    serde::Serialize,
115    serde::Deserialize,
116    Debug,
117    Clone,
118    PartialEq,
119    Eq,
120    jacquard_derive::IntoStatic
121)]
122#[serde(rename_all = "camelCase")]
123pub struct GetWebhookOutput<'a> {
124    #[serde(borrow)]
125    pub webhook: crate::place_stream::server::Webhook<'a>,
126}
127
128#[jacquard_derive::open_union]
129#[derive(
130    serde::Serialize,
131    serde::Deserialize,
132    Debug,
133    Clone,
134    PartialEq,
135    Eq,
136    thiserror::Error,
137    miette::Diagnostic,
138    jacquard_derive::IntoStatic
139)]
140#[serde(tag = "error", content = "message")]
141#[serde(bound(deserialize = "'de: 'a"))]
142pub enum GetWebhookError<'a> {
143    /// The specified webhook was not found.
144    #[serde(rename = "WebhookNotFound")]
145    WebhookNotFound(std::option::Option<String>),
146    /// The authenticated user does not have access to this webhook.
147    #[serde(rename = "Unauthorized")]
148    Unauthorized(std::option::Option<String>),
149}
150
151impl std::fmt::Display for GetWebhookError<'_> {
152    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
153        match self {
154            Self::WebhookNotFound(msg) => {
155                write!(f, "WebhookNotFound")?;
156                if let Some(msg) = msg {
157                    write!(f, ": {}", msg)?;
158                }
159                Ok(())
160            }
161            Self::Unauthorized(msg) => {
162                write!(f, "Unauthorized")?;
163                if let Some(msg) = msg {
164                    write!(f, ": {}", msg)?;
165                }
166                Ok(())
167            }
168            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
169        }
170    }
171}
172
173/// Response type for
174///place.stream.server.getWebhook
175pub struct GetWebhookResponse;
176impl jacquard_common::xrpc::XrpcResp for GetWebhookResponse {
177    const NSID: &'static str = "place.stream.server.getWebhook";
178    const ENCODING: &'static str = "application/json";
179    type Output<'de> = GetWebhookOutput<'de>;
180    type Err<'de> = GetWebhookError<'de>;
181}
182
183impl<'a> jacquard_common::xrpc::XrpcRequest for GetWebhook<'a> {
184    const NSID: &'static str = "place.stream.server.getWebhook";
185    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
186    type Response = GetWebhookResponse;
187}
188
189/// Endpoint type for
190///place.stream.server.getWebhook
191pub struct GetWebhookRequest;
192impl jacquard_common::xrpc::XrpcEndpoint for GetWebhookRequest {
193    const PATH: &'static str = "/xrpc/place.stream.server.getWebhook";
194    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
195    type Request<'de> = GetWebhook<'de>;
196    type Response = GetWebhookResponse;
197}