#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
use jacquard_common::types::string::UriValue;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use serde::{Serialize, Deserialize};
use crate::place_stream::server::RewriteRule;
use crate::place_stream::server::Webhook;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct UpdateWebhook<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub active: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub events: Option<Vec<CowStr<'a>>>,
#[serde(borrow)]
pub id: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub mute_words: Option<Vec<CowStr<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub name: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub prefix: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub rewrite: Option<Vec<RewriteRule<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub suffix: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub url: Option<UriValue<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct UpdateWebhookOutput<'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 UpdateWebhookError<'a> {
#[serde(rename = "WebhookNotFound")]
WebhookNotFound(Option<CowStr<'a>>),
#[serde(rename = "Unauthorized")]
Unauthorized(Option<CowStr<'a>>),
#[serde(rename = "InvalidUrl")]
InvalidUrl(Option<CowStr<'a>>),
#[serde(rename = "DuplicateWebhook")]
DuplicateWebhook(Option<CowStr<'a>>),
}
impl core::fmt::Display for UpdateWebhookError<'_> {
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::InvalidUrl(msg) => {
write!(f, "InvalidUrl")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::DuplicateWebhook(msg) => {
write!(f, "DuplicateWebhook")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
}
}
}
pub struct UpdateWebhookResponse;
impl jacquard_common::xrpc::XrpcResp for UpdateWebhookResponse {
const NSID: &'static str = "place.stream.server.updateWebhook";
const ENCODING: &'static str = "application/json";
type Output<'de> = UpdateWebhookOutput<'de>;
type Err<'de> = UpdateWebhookError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for UpdateWebhook<'a> {
const NSID: &'static str = "place.stream.server.updateWebhook";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = UpdateWebhookResponse;
}
pub struct UpdateWebhookRequest;
impl jacquard_common::xrpc::XrpcEndpoint for UpdateWebhookRequest {
const PATH: &'static str = "/xrpc/place.stream.server.updateWebhook";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<'de> = UpdateWebhook<'de>;
type Response = UpdateWebhookResponse;
}