// @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, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListNotifications<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cursor: Option<S>,
    /// 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")]
    pub reasons: Option<Vec<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub seen_at: Option<Datetime>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListNotificationsOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cursor: Option<S>,
    pub notifications: Vec<list_notifications::Notification<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub priority: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub seen_at: Option<Datetime>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


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

/// 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<S: BosStr = DefaultStr> {
    Like,
    Repost,
    Follow,
    Mention,
    Reply,
    Quote,
    StarterpackJoined,
    Verified,
    Unverified,
    LikeViaRepost,
    RepostViaRepost,
    SubscribedPost,
    ContactMatch,
    Other(S),
}

impl<S: BosStr> NotificationReason<S> {
    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(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "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(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for NotificationReason<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<S: BosStr> jacquard_common::IntoStatic for NotificationReason<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = NotificationReason<S::Output>;
    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 marker for the `app.bsky.notification.listNotifications` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `ListNotificationsOutput<S>` for this endpoint.*/
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<S: BosStr> = ListNotificationsOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

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

/** Endpoint marker for the `app.bsky.notification.listNotifications` query.

Path: `/xrpc/app.bsky.notification.listNotifications`. The request payload type is `ListNotifications<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
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<S: BosStr> = ListNotifications<S>;
    type Response = ListNotificationsResponse;
}

impl<S: BosStr> LexiconSchema for Notification<S> {
    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<
    St: list_notifications_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<S>, Option<i64>, Option<bool>, Option<Vec<S>>, Option<Datetime>),
    _type: PhantomData<fn() -> S>,
}

impl ListNotifications<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> ListNotificationsBuilder<
        list_notifications_state::Empty,
        DefaultStr,
    > {
        ListNotificationsBuilder::new()
    }
}

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

impl ListNotificationsBuilder<list_notifications_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        ListNotificationsBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

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

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

impl<St: list_notifications_state::State, S: BosStr> ListNotificationsBuilder<St, 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<St: list_notifications_state::State, S: BosStr> ListNotificationsBuilder<St, 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<St: list_notifications_state::State, S: BosStr> ListNotificationsBuilder<St, S> {
    /// Set the `reasons` field (optional)
    pub fn reasons(mut self, value: impl Into<Option<Vec<S>>>) -> 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<S>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: list_notifications_state::State, S: BosStr> ListNotificationsBuilder<St, 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<St, S: BosStr> ListNotificationsBuilder<St, S>
where
    St: list_notifications_state::State,
{
    /// Build the final struct.
    pub fn build(self) -> ListNotifications<S> {
        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 Author;
        type Cid;
        type IndexedAt;
        type IsRead;
        type Reason;
        type Record;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Author = Unset;
        type Cid = Unset;
        type IndexedAt = Unset;
        type IsRead = Unset;
        type Reason = Unset;
        type Record = Unset;
        type Uri = Unset;
    }
    ///State transition - sets the `author` field to Set
    pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAuthor<St> {}
    impl<St: State> State for SetAuthor<St> {
        type Author = Set<members::author>;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type IsRead = St::IsRead;
        type Reason = St::Reason;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCid<St> {}
    impl<St: State> State for SetCid<St> {
        type Author = St::Author;
        type Cid = Set<members::cid>;
        type IndexedAt = St::IndexedAt;
        type IsRead = St::IsRead;
        type Reason = St::Reason;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
    impl<St: State> State for SetIndexedAt<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = Set<members::indexed_at>;
        type IsRead = St::IsRead;
        type Reason = St::Reason;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `is_read` field to Set
    pub struct SetIsRead<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIsRead<St> {}
    impl<St: State> State for SetIsRead<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type IsRead = Set<members::is_read>;
        type Reason = St::Reason;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `reason` field to Set
    pub struct SetReason<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetReason<St> {}
    impl<St: State> State for SetReason<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type IsRead = St::IsRead;
        type Reason = Set<members::reason>;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `record` field to Set
    pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRecord<St> {}
    impl<St: State> State for SetRecord<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type IsRead = St::IsRead;
        type Reason = St::Reason;
        type Record = Set<members::record>;
        type Uri = St::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type IsRead = St::IsRead;
        type Reason = St::Reason;
        type Record = St::Record;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `author` field
        pub struct author(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
        ///Marker type for the `is_read` field
        pub struct is_read(());
        ///Marker type for the `reason` field
        pub struct reason(());
        ///Marker type for the `record` field
        pub struct record(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct NotificationBuilder<St: notification_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<ProfileView<S>>,
        Option<Cid<S>>,
        Option<Datetime>,
        Option<bool>,
        Option<Vec<Label<S>>>,
        Option<NotificationReason<S>>,
        Option<AtUri<S>>,
        Option<Data<S>>,
        Option<AtUri<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl Notification<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> NotificationBuilder<notification_state::Empty, DefaultStr> {
        NotificationBuilder::new()
    }
}

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

impl NotificationBuilder<notification_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        NotificationBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

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

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

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

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

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

impl<St: notification_state::State, S: BosStr> NotificationBuilder<St, S> {
    /// Set the `labels` field (optional)
    pub fn labels(mut self, value: impl Into<Option<Vec<Label<S>>>>) -> 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<S>>>) -> Self {
        self._fields.4 = value;
        self
    }
}

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

impl<St: notification_state::State, S: BosStr> NotificationBuilder<St, S> {
    /// Set the `reasonSubject` field (optional)
    pub fn reason_subject(mut self, value: impl Into<Option<AtUri<S>>>) -> 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<S>>) -> Self {
        self._fields.6 = value;
        self
    }
}

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

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

impl<St, S: BosStr> NotificationBuilder<St, S>
where
    St: notification_state::State,
    St::Author: notification_state::IsSet,
    St::Cid: notification_state::IsSet,
    St::IndexedAt: notification_state::IsSet,
    St::IsRead: notification_state::IsSet,
    St::Reason: notification_state::IsSet,
    St::Record: notification_state::IsSet,
    St::Uri: notification_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Notification<S> {
        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<SmolStr, Data<S>>,
    ) -> Notification<S> {
        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()
    }
}