#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use serde::{Serialize, Deserialize};
use crate::place_stream::server::Webhook;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetWebhook<'a> {
#[serde(borrow)]
pub id: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetWebhookOutput<'a> {
#[serde(borrow)]
pub webhook: Webhook<'a>,
}
#[open_union]
#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
Eq,
thiserror::Error,
miette::Diagnostic,
IntoStatic
)]
#[serde(tag = "error", content = "message")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum GetWebhookError<'a> {
#[serde(rename = "WebhookNotFound")]
WebhookNotFound(Option<CowStr<'a>>),
#[serde(rename = "Unauthorized")]
Unauthorized(Option<CowStr<'a>>),
}
impl core::fmt::Display for GetWebhookError<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::WebhookNotFound(msg) => {
write!(f, "WebhookNotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Unauthorized(msg) => {
write!(f, "Unauthorized")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
}
}
}
pub struct GetWebhookResponse;
impl jacquard_common::xrpc::XrpcResp for GetWebhookResponse {
const NSID: &'static str = "place.stream.server.getWebhook";
const ENCODING: &'static str = "application/json";
type Output<'de> = GetWebhookOutput<'de>;
type Err<'de> = GetWebhookError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetWebhook<'a> {
const NSID: &'static str = "place.stream.server.getWebhook";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetWebhookResponse;
}
pub struct GetWebhookRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetWebhookRequest {
const PATH: &'static str = "/xrpc/place.stream.server.getWebhook";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = GetWebhook<'de>;
type Response = GetWebhookResponse;
}
pub mod get_webhook_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Id;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Id = Unset;
}
pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetId<S> {}
impl<S: State> State for SetId<S> {
type Id = Set<members::id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct id(());
}
}
pub struct GetWebhookBuilder<'a, S: get_webhook_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GetWebhook<'a> {
pub fn new() -> GetWebhookBuilder<'a, get_webhook_state::Empty> {
GetWebhookBuilder::new()
}
}
impl<'a> GetWebhookBuilder<'a, get_webhook_state::Empty> {
pub fn new() -> Self {
GetWebhookBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetWebhookBuilder<'a, S>
where
S: get_webhook_state::State,
S::Id: get_webhook_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<CowStr<'a>>,
) -> GetWebhookBuilder<'a, get_webhook_state::SetId<S>> {
self._fields.0 = Option::Some(value.into());
GetWebhookBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetWebhookBuilder<'a, S>
where
S: get_webhook_state::State,
S::Id: get_webhook_state::IsSet,
{
pub fn build(self) -> GetWebhook<'a> {
GetWebhook {
id: self._fields.0.unwrap(),
}
}
}