#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
use jacquard_common::types::string::Did;
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct UnregisterPush<'a> {
#[serde(borrow)]
pub app_id: CowStr<'a>,
#[serde(borrow)]
pub platform: UnregisterPushPlatform<'a>,
#[serde(borrow)]
pub service_did: Did<'a>,
#[serde(borrow)]
pub token: CowStr<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum UnregisterPushPlatform<'a> {
Ios,
Android,
Web,
Other(CowStr<'a>),
}
impl<'a> UnregisterPushPlatform<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Ios => "ios",
Self::Android => "android",
Self::Web => "web",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for UnregisterPushPlatform<'a> {
fn from(s: &'a str) -> Self {
match s {
"ios" => Self::Ios,
"android" => Self::Android,
"web" => Self::Web,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for UnregisterPushPlatform<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"ios" => Self::Ios,
"android" => Self::Android,
"web" => Self::Web,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for UnregisterPushPlatform<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for UnregisterPushPlatform<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for UnregisterPushPlatform<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for UnregisterPushPlatform<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for UnregisterPushPlatform<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for UnregisterPushPlatform<'_> {
type Output = UnregisterPushPlatform<'static>;
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<'de> = ();
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for UnregisterPush<'a> {
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<'de> = UnregisterPush<'de>;
type Response = UnregisterPushResponse;
}
pub mod unregister_push_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 ServiceDid;
type AppId;
type Platform;
type Token;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ServiceDid = Unset;
type AppId = Unset;
type Platform = Unset;
type Token = Unset;
}
pub struct SetServiceDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetServiceDid<S> {}
impl<S: State> State for SetServiceDid<S> {
type ServiceDid = Set<members::service_did>;
type AppId = S::AppId;
type Platform = S::Platform;
type Token = S::Token;
}
pub struct SetAppId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAppId<S> {}
impl<S: State> State for SetAppId<S> {
type ServiceDid = S::ServiceDid;
type AppId = Set<members::app_id>;
type Platform = S::Platform;
type Token = S::Token;
}
pub struct SetPlatform<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPlatform<S> {}
impl<S: State> State for SetPlatform<S> {
type ServiceDid = S::ServiceDid;
type AppId = S::AppId;
type Platform = Set<members::platform>;
type Token = S::Token;
}
pub struct SetToken<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetToken<S> {}
impl<S: State> State for SetToken<S> {
type ServiceDid = S::ServiceDid;
type AppId = S::AppId;
type Platform = S::Platform;
type Token = Set<members::token>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct service_did(());
pub struct app_id(());
pub struct platform(());
pub struct token(());
}
}
pub struct UnregisterPushBuilder<'a, S: unregister_push_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<UnregisterPushPlatform<'a>>,
Option<Did<'a>>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> UnregisterPush<'a> {
pub fn new() -> UnregisterPushBuilder<'a, unregister_push_state::Empty> {
UnregisterPushBuilder::new()
}
}
impl<'a> UnregisterPushBuilder<'a, unregister_push_state::Empty> {
pub fn new() -> Self {
UnregisterPushBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> UnregisterPushBuilder<'a, S>
where
S: unregister_push_state::State,
S::AppId: unregister_push_state::IsUnset,
{
pub fn app_id(
mut self,
value: impl Into<CowStr<'a>>,
) -> UnregisterPushBuilder<'a, unregister_push_state::SetAppId<S>> {
self._fields.0 = Option::Some(value.into());
UnregisterPushBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UnregisterPushBuilder<'a, S>
where
S: unregister_push_state::State,
S::Platform: unregister_push_state::IsUnset,
{
pub fn platform(
mut self,
value: impl Into<UnregisterPushPlatform<'a>>,
) -> UnregisterPushBuilder<'a, unregister_push_state::SetPlatform<S>> {
self._fields.1 = Option::Some(value.into());
UnregisterPushBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UnregisterPushBuilder<'a, S>
where
S: unregister_push_state::State,
S::ServiceDid: unregister_push_state::IsUnset,
{
pub fn service_did(
mut self,
value: impl Into<Did<'a>>,
) -> UnregisterPushBuilder<'a, unregister_push_state::SetServiceDid<S>> {
self._fields.2 = Option::Some(value.into());
UnregisterPushBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UnregisterPushBuilder<'a, S>
where
S: unregister_push_state::State,
S::Token: unregister_push_state::IsUnset,
{
pub fn token(
mut self,
value: impl Into<CowStr<'a>>,
) -> UnregisterPushBuilder<'a, unregister_push_state::SetToken<S>> {
self._fields.3 = Option::Some(value.into());
UnregisterPushBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> UnregisterPushBuilder<'a, S>
where
S: unregister_push_state::State,
S::ServiceDid: unregister_push_state::IsSet,
S::AppId: unregister_push_state::IsSet,
S::Platform: unregister_push_state::IsSet,
S::Token: unregister_push_state::IsSet,
{
pub fn build(self) -> UnregisterPush<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> UnregisterPush<'a> {
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),
}
}
}