#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Did;
use jacquard_common::types::value::Data;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
use jacquard_derive::IntoStatic;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct UnregisterPush<S: BosStr = DefaultStr> {
pub app_id: S,
pub platform: UnregisterPushPlatform<S>,
pub service_did: Did<S>,
pub token: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum UnregisterPushPlatform<S: BosStr = DefaultStr> {
Ios,
Android,
Web,
Other(S),
}
impl<S: BosStr> UnregisterPushPlatform<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Ios => "ios",
Self::Android => "android",
Self::Web => "web",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"ios" => Self::Ios,
"android" => Self::Android,
"web" => Self::Web,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for UnregisterPushPlatform<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for UnregisterPushPlatform<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for UnregisterPushPlatform<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for UnregisterPushPlatform<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for UnregisterPushPlatform<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for UnregisterPushPlatform<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = UnregisterPushPlatform<S::Output>;
fn into_static(self) -> Self::Output {
match self {
UnregisterPushPlatform::Ios => UnregisterPushPlatform::Ios,
UnregisterPushPlatform::Android => UnregisterPushPlatform::Android,
UnregisterPushPlatform::Web => UnregisterPushPlatform::Web,
UnregisterPushPlatform::Other(v) => UnregisterPushPlatform::Other(v.into_static()),
}
}
}
pub struct UnregisterPushResponse;
impl jacquard_common::xrpc::XrpcResp for UnregisterPushResponse {
const NSID: &'static str = "app.bsky.notification.unregisterPush";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ();
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for UnregisterPush<S> {
const NSID: &'static str = "app.bsky.notification.unregisterPush";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Response = UnregisterPushResponse;
}
pub struct UnregisterPushRequest;
impl jacquard_common::xrpc::XrpcEndpoint for UnregisterPushRequest {
const PATH: &'static str = "/xrpc/app.bsky.notification.unregisterPush";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Request<S: BosStr> = UnregisterPush<S>;
type Response = UnregisterPushResponse;
}
pub mod unregister_push_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Token;
type Platform;
type AppId;
type ServiceDid;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Token = Unset;
type Platform = Unset;
type AppId = Unset;
type ServiceDid = Unset;
}
pub struct SetToken<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetToken<St> {}
impl<St: State> State for SetToken<St> {
type Token = Set<members::token>;
type Platform = St::Platform;
type AppId = St::AppId;
type ServiceDid = St::ServiceDid;
}
pub struct SetPlatform<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPlatform<St> {}
impl<St: State> State for SetPlatform<St> {
type Token = St::Token;
type Platform = Set<members::platform>;
type AppId = St::AppId;
type ServiceDid = St::ServiceDid;
}
pub struct SetAppId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAppId<St> {}
impl<St: State> State for SetAppId<St> {
type Token = St::Token;
type Platform = St::Platform;
type AppId = Set<members::app_id>;
type ServiceDid = St::ServiceDid;
}
pub struct SetServiceDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetServiceDid<St> {}
impl<St: State> State for SetServiceDid<St> {
type Token = St::Token;
type Platform = St::Platform;
type AppId = St::AppId;
type ServiceDid = Set<members::service_did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct token(());
pub struct platform(());
pub struct app_id(());
pub struct service_did(());
}
}
pub struct UnregisterPushBuilder<S: BosStr, St: unregister_push_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<UnregisterPushPlatform<S>>,
Option<Did<S>>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> UnregisterPush<S> {
pub fn new() -> UnregisterPushBuilder<S, unregister_push_state::Empty> {
UnregisterPushBuilder::new()
}
}
impl<S: BosStr> UnregisterPushBuilder<S, unregister_push_state::Empty> {
pub fn new() -> Self {
UnregisterPushBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UnregisterPushBuilder<S, St>
where
St: unregister_push_state::State,
St::AppId: unregister_push_state::IsUnset,
{
pub fn app_id(
mut self,
value: impl Into<S>,
) -> UnregisterPushBuilder<S, unregister_push_state::SetAppId<St>> {
self._fields.0 = Option::Some(value.into());
UnregisterPushBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UnregisterPushBuilder<S, St>
where
St: unregister_push_state::State,
St::Platform: unregister_push_state::IsUnset,
{
pub fn platform(
mut self,
value: impl Into<UnregisterPushPlatform<S>>,
) -> UnregisterPushBuilder<S, unregister_push_state::SetPlatform<St>> {
self._fields.1 = Option::Some(value.into());
UnregisterPushBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UnregisterPushBuilder<S, St>
where
St: unregister_push_state::State,
St::ServiceDid: unregister_push_state::IsUnset,
{
pub fn service_did(
mut self,
value: impl Into<Did<S>>,
) -> UnregisterPushBuilder<S, unregister_push_state::SetServiceDid<St>> {
self._fields.2 = Option::Some(value.into());
UnregisterPushBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UnregisterPushBuilder<S, St>
where
St: unregister_push_state::State,
St::Token: unregister_push_state::IsUnset,
{
pub fn token(
mut self,
value: impl Into<S>,
) -> UnregisterPushBuilder<S, unregister_push_state::SetToken<St>> {
self._fields.3 = Option::Some(value.into());
UnregisterPushBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> UnregisterPushBuilder<S, St>
where
St: unregister_push_state::State,
St::Token: unregister_push_state::IsSet,
St::Platform: unregister_push_state::IsSet,
St::AppId: unregister_push_state::IsSet,
St::ServiceDid: unregister_push_state::IsSet,
{
pub fn build(self) -> UnregisterPush<S> {
UnregisterPush {
app_id: self._fields.0.unwrap(),
platform: self._fields.1.unwrap(),
service_did: self._fields.2.unwrap(),
token: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> UnregisterPush<S> {
UnregisterPush {
app_id: self._fields.0.unwrap(),
platform: self._fields.1.unwrap(),
service_did: self._fields.2.unwrap(),
token: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}