// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.bsky.notification.listNotifications
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_bsky::actor::ProfileView;
use crate::com_atproto::label::Label;
use crate::app_bsky::notification::list_notifications;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ListNotifications<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cursor: Option<CowStr<'a>>,
    ///Defaults to `50`. Min: 1. Max: 100.
    #[serde(default = "_default_limit")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub priority: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub reasons: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub seen_at: Option<Datetime>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ListNotificationsOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cursor: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub notifications: Vec<list_notifications::Notification<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub priority: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub seen_at: Option<Datetime>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Notification<'a> {
    #[serde(borrow)]
    pub author: ProfileView<'a>,
    #[serde(borrow)]
    pub cid: Cid<'a>,
    pub indexed_at: Datetime,
    pub is_read: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub labels: Option<Vec<Label<'a>>>,
    ///The reason why this notification was delivered - e.g. your post was liked, or you received a new follower.
    #[serde(borrow)]
    pub reason: NotificationReason<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub reason_subject: Option<AtUri<'a>>,
    #[serde(borrow)]
    pub record: Data<'a>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
}

/// The reason why this notification was delivered - e.g. your post was liked, or you received a new follower.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum NotificationReason<'a> {
    Like,
    Repost,
    Follow,
    Mention,
    Reply,
    Quote,
    StarterpackJoined,
    Verified,
    Unverified,
    LikeViaRepost,
    RepostViaRepost,
    SubscribedPost,
    ContactMatch,
    Other(CowStr<'a>),
}

impl<'a> NotificationReason<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Like => "like",
            Self::Repost => "repost",
            Self::Follow => "follow",
            Self::Mention => "mention",
            Self::Reply => "reply",
            Self::Quote => "quote",
            Self::StarterpackJoined => "starterpack-joined",
            Self::Verified => "verified",
            Self::Unverified => "unverified",
            Self::LikeViaRepost => "like-via-repost",
            Self::RepostViaRepost => "repost-via-repost",
            Self::SubscribedPost => "subscribed-post",
            Self::ContactMatch => "contact-match",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for NotificationReason<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "like" => Self::Like,
            "repost" => Self::Repost,
            "follow" => Self::Follow,
            "mention" => Self::Mention,
            "reply" => Self::Reply,
            "quote" => Self::Quote,
            "starterpack-joined" => Self::StarterpackJoined,
            "verified" => Self::Verified,
            "unverified" => Self::Unverified,
            "like-via-repost" => Self::LikeViaRepost,
            "repost-via-repost" => Self::RepostViaRepost,
            "subscribed-post" => Self::SubscribedPost,
            "contact-match" => Self::ContactMatch,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for NotificationReason<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "like" => Self::Like,
            "repost" => Self::Repost,
            "follow" => Self::Follow,
            "mention" => Self::Mention,
            "reply" => Self::Reply,
            "quote" => Self::Quote,
            "starterpack-joined" => Self::StarterpackJoined,
            "verified" => Self::Verified,
            "unverified" => Self::Unverified,
            "like-via-repost" => Self::LikeViaRepost,
            "repost-via-repost" => Self::RepostViaRepost,
            "subscribed-post" => Self::SubscribedPost,
            "contact-match" => Self::ContactMatch,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> core::fmt::Display for NotificationReason<'a> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<'a> AsRef<str> for NotificationReason<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<'a> serde::Serialize for NotificationReason<'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 NotificationReason<'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 NotificationReason<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for NotificationReason<'_> {
    type Output = NotificationReason<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            NotificationReason::Like => NotificationReason::Like,
            NotificationReason::Repost => NotificationReason::Repost,
            NotificationReason::Follow => NotificationReason::Follow,
            NotificationReason::Mention => NotificationReason::Mention,
            NotificationReason::Reply => NotificationReason::Reply,
            NotificationReason::Quote => NotificationReason::Quote,
            NotificationReason::StarterpackJoined => {
                NotificationReason::StarterpackJoined
            }
            NotificationReason::Verified => NotificationReason::Verified,
            NotificationReason::Unverified => NotificationReason::Unverified,
            NotificationReason::LikeViaRepost => NotificationReason::LikeViaRepost,
            NotificationReason::RepostViaRepost => NotificationReason::RepostViaRepost,
            NotificationReason::SubscribedPost => NotificationReason::SubscribedPost,
            NotificationReason::ContactMatch => NotificationReason::ContactMatch,
            NotificationReason::Other(v) => NotificationReason::Other(v.into_static()),
        }
    }
}

/// Response type for app.bsky.notification.listNotifications
pub struct ListNotificationsResponse;
impl jacquard_common::xrpc::XrpcResp for ListNotificationsResponse {
    const NSID: &'static str = "app.bsky.notification.listNotifications";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = ListNotificationsOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for ListNotifications<'a> {
    const NSID: &'static str = "app.bsky.notification.listNotifications";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = ListNotificationsResponse;
}

/// Endpoint type for app.bsky.notification.listNotifications
pub struct ListNotificationsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ListNotificationsRequest {
    const PATH: &'static str = "/xrpc/app.bsky.notification.listNotifications";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = ListNotifications<'de>;
    type Response = ListNotificationsResponse;
}

impl<'a> LexiconSchema for Notification<'a> {
    fn nsid() -> &'static str {
        "app.bsky.notification.listNotifications"
    }
    fn def_name() -> &'static str {
        "notification"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_notification_listNotifications()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn _default_limit() -> Option<i64> {
    Some(50i64)
}

pub mod list_notifications_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {}
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {}
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {}
}

/// Builder for constructing an instance of this type
pub struct ListNotificationsBuilder<'a, S: list_notifications_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<CowStr<'a>>,
        Option<i64>,
        Option<bool>,
        Option<Vec<CowStr<'a>>>,
        Option<Datetime>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> ListNotifications<'a> {
    /// Create a new builder for this type
    pub fn new() -> ListNotificationsBuilder<'a, list_notifications_state::Empty> {
        ListNotificationsBuilder::new()
    }
}

impl<'a> ListNotificationsBuilder<'a, list_notifications_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        ListNotificationsBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: list_notifications_state::State> ListNotificationsBuilder<'a, S> {
    /// Set the `cursor` field (optional)
    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `cursor` field to an Option value (optional)
    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: list_notifications_state::State> ListNotificationsBuilder<'a, S> {
    /// Set the `limit` field (optional)
    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `limit` field to an Option value (optional)
    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: list_notifications_state::State> ListNotificationsBuilder<'a, S> {
    /// Set the `priority` field (optional)
    pub fn priority(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `priority` field to an Option value (optional)
    pub fn maybe_priority(mut self, value: Option<bool>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: list_notifications_state::State> ListNotificationsBuilder<'a, S> {
    /// Set the `reasons` field (optional)
    pub fn reasons(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `reasons` field to an Option value (optional)
    pub fn maybe_reasons(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: list_notifications_state::State> ListNotificationsBuilder<'a, S> {
    /// Set the `seenAt` field (optional)
    pub fn seen_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `seenAt` field to an Option value (optional)
    pub fn maybe_seen_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S> ListNotificationsBuilder<'a, S>
where
    S: list_notifications_state::State,
{
    /// Build the final struct
    pub fn build(self) -> ListNotifications<'a> {
        ListNotifications {
            cursor: self._fields.0,
            limit: self._fields.1,
            priority: self._fields.2,
            reasons: self._fields.3,
            seen_at: self._fields.4,
        }
    }
}

pub mod notification_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Uri;
        type Record;
        type IsRead;
        type Cid;
        type Author;
        type Reason;
        type IndexedAt;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Uri = Unset;
        type Record = Unset;
        type IsRead = Unset;
        type Cid = Unset;
        type Author = Unset;
        type Reason = Unset;
        type IndexedAt = Unset;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type Uri = Set<members::uri>;
        type Record = S::Record;
        type IsRead = S::IsRead;
        type Cid = S::Cid;
        type Author = S::Author;
        type Reason = S::Reason;
        type IndexedAt = S::IndexedAt;
    }
    ///State transition - sets the `record` field to Set
    pub struct SetRecord<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRecord<S> {}
    impl<S: State> State for SetRecord<S> {
        type Uri = S::Uri;
        type Record = Set<members::record>;
        type IsRead = S::IsRead;
        type Cid = S::Cid;
        type Author = S::Author;
        type Reason = S::Reason;
        type IndexedAt = S::IndexedAt;
    }
    ///State transition - sets the `is_read` field to Set
    pub struct SetIsRead<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetIsRead<S> {}
    impl<S: State> State for SetIsRead<S> {
        type Uri = S::Uri;
        type Record = S::Record;
        type IsRead = Set<members::is_read>;
        type Cid = S::Cid;
        type Author = S::Author;
        type Reason = S::Reason;
        type IndexedAt = S::IndexedAt;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCid<S> {}
    impl<S: State> State for SetCid<S> {
        type Uri = S::Uri;
        type Record = S::Record;
        type IsRead = S::IsRead;
        type Cid = Set<members::cid>;
        type Author = S::Author;
        type Reason = S::Reason;
        type IndexedAt = S::IndexedAt;
    }
    ///State transition - sets the `author` field to Set
    pub struct SetAuthor<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAuthor<S> {}
    impl<S: State> State for SetAuthor<S> {
        type Uri = S::Uri;
        type Record = S::Record;
        type IsRead = S::IsRead;
        type Cid = S::Cid;
        type Author = Set<members::author>;
        type Reason = S::Reason;
        type IndexedAt = S::IndexedAt;
    }
    ///State transition - sets the `reason` field to Set
    pub struct SetReason<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetReason<S> {}
    impl<S: State> State for SetReason<S> {
        type Uri = S::Uri;
        type Record = S::Record;
        type IsRead = S::IsRead;
        type Cid = S::Cid;
        type Author = S::Author;
        type Reason = Set<members::reason>;
        type IndexedAt = S::IndexedAt;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
    impl<S: State> State for SetIndexedAt<S> {
        type Uri = S::Uri;
        type Record = S::Record;
        type IsRead = S::IsRead;
        type Cid = S::Cid;
        type Author = S::Author;
        type Reason = S::Reason;
        type IndexedAt = Set<members::indexed_at>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `record` field
        pub struct record(());
        ///Marker type for the `is_read` field
        pub struct is_read(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `author` field
        pub struct author(());
        ///Marker type for the `reason` field
        pub struct reason(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
    }
}

/// Builder for constructing an instance of this type
pub struct NotificationBuilder<'a, S: notification_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<ProfileView<'a>>,
        Option<Cid<'a>>,
        Option<Datetime>,
        Option<bool>,
        Option<Vec<Label<'a>>>,
        Option<NotificationReason<'a>>,
        Option<AtUri<'a>>,
        Option<Data<'a>>,
        Option<AtUri<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Notification<'a> {
    /// Create a new builder for this type
    pub fn new() -> NotificationBuilder<'a, notification_state::Empty> {
        NotificationBuilder::new()
    }
}

impl<'a> NotificationBuilder<'a, notification_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        NotificationBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> NotificationBuilder<'a, S>
where
    S: notification_state::State,
    S::Author: notification_state::IsUnset,
{
    /// Set the `author` field (required)
    pub fn author(
        mut self,
        value: impl Into<ProfileView<'a>>,
    ) -> NotificationBuilder<'a, notification_state::SetAuthor<S>> {
        self._fields.0 = Option::Some(value.into());
        NotificationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> NotificationBuilder<'a, S>
where
    S: notification_state::State,
    S::Cid: notification_state::IsUnset,
{
    /// Set the `cid` field (required)
    pub fn cid(
        mut self,
        value: impl Into<Cid<'a>>,
    ) -> NotificationBuilder<'a, notification_state::SetCid<S>> {
        self._fields.1 = Option::Some(value.into());
        NotificationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> NotificationBuilder<'a, S>
where
    S: notification_state::State,
    S::IndexedAt: notification_state::IsUnset,
{
    /// Set the `indexedAt` field (required)
    pub fn indexed_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> NotificationBuilder<'a, notification_state::SetIndexedAt<S>> {
        self._fields.2 = Option::Some(value.into());
        NotificationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> NotificationBuilder<'a, S>
where
    S: notification_state::State,
    S::IsRead: notification_state::IsUnset,
{
    /// Set the `isRead` field (required)
    pub fn is_read(
        mut self,
        value: impl Into<bool>,
    ) -> NotificationBuilder<'a, notification_state::SetIsRead<S>> {
        self._fields.3 = Option::Some(value.into());
        NotificationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: notification_state::State> NotificationBuilder<'a, S> {
    /// Set the `labels` field (optional)
    pub fn labels(mut self, value: impl Into<Option<Vec<Label<'a>>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `labels` field to an Option value (optional)
    pub fn maybe_labels(mut self, value: Option<Vec<Label<'a>>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S> NotificationBuilder<'a, S>
where
    S: notification_state::State,
    S::Reason: notification_state::IsUnset,
{
    /// Set the `reason` field (required)
    pub fn reason(
        mut self,
        value: impl Into<NotificationReason<'a>>,
    ) -> NotificationBuilder<'a, notification_state::SetReason<S>> {
        self._fields.5 = Option::Some(value.into());
        NotificationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: notification_state::State> NotificationBuilder<'a, S> {
    /// Set the `reasonSubject` field (optional)
    pub fn reason_subject(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `reasonSubject` field to an Option value (optional)
    pub fn maybe_reason_subject(mut self, value: Option<AtUri<'a>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S> NotificationBuilder<'a, S>
where
    S: notification_state::State,
    S::Record: notification_state::IsUnset,
{
    /// Set the `record` field (required)
    pub fn record(
        mut self,
        value: impl Into<Data<'a>>,
    ) -> NotificationBuilder<'a, notification_state::SetRecord<S>> {
        self._fields.7 = Option::Some(value.into());
        NotificationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> NotificationBuilder<'a, S>
where
    S: notification_state::State,
    S::Uri: notification_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> NotificationBuilder<'a, notification_state::SetUri<S>> {
        self._fields.8 = Option::Some(value.into());
        NotificationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> NotificationBuilder<'a, S>
where
    S: notification_state::State,
    S::Uri: notification_state::IsSet,
    S::Record: notification_state::IsSet,
    S::IsRead: notification_state::IsSet,
    S::Cid: notification_state::IsSet,
    S::Author: notification_state::IsSet,
    S::Reason: notification_state::IsSet,
    S::IndexedAt: notification_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Notification<'a> {
        Notification {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            indexed_at: self._fields.2.unwrap(),
            is_read: self._fields.3.unwrap(),
            labels: self._fields.4,
            reason: self._fields.5.unwrap(),
            reason_subject: self._fields.6,
            record: self._fields.7.unwrap(),
            uri: self._fields.8.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> Notification<'a> {
        Notification {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            indexed_at: self._fields.2.unwrap(),
            is_read: self._fields.3.unwrap(),
            labels: self._fields.4,
            reason: self._fields.5.unwrap(),
            reason_subject: self._fields.6,
            record: self._fields.7.unwrap(),
            uri: self._fields.8.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_bsky_notification_listNotifications() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("app.bsky.notification.listNotifications"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(
                        LexXrpcQueryParameter::Params(LexXrpcParameters {
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("cursor"),
                                    LexXrpcParametersProperty::String(LexString {
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("limit"),
                                    LexXrpcParametersProperty::Integer(LexInteger {
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("priority"),
                                    LexXrpcParametersProperty::Boolean(LexBoolean {
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("reasons"),
                                    LexXrpcParametersProperty::Array(LexPrimitiveArray {
                                        items: LexPrimitiveArrayItem::String(LexString {
                                            description: Some(
                                                CowStr::new_static(
                                                    "A reason that matches the reason property of #notification.",
                                                ),
                                            ),
                                            ..Default::default()
                                        }),
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("seenAt"),
                                    LexXrpcParametersProperty::String(LexString {
                                        format: Some(LexStringFormat::Datetime),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("notification"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("author"), SmolStr::new_static("reason"),
                            SmolStr::new_static("record"), SmolStr::new_static("isRead"),
                            SmolStr::new_static("indexedAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("author"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.actor.defs#profileView",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("isRead"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("labels"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.label.defs#label"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("reason"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The reason why this notification was delivered - e.g. your post was liked, or you received a new follower.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("reasonSubject"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("record"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}