// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: place.stream.getLikes
//
// 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::ProfileViewBasic;
use crate::place_stream::get_likes;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LikeView<S: BosStr = DefaultStr> {
    pub author: ProfileViewBasic<S>,
    pub cid: Cid<S>,
    pub indexed_at: Datetime,
    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>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetLikes<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>,
    pub subject: AtUri<S>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetLikesOutput<S: BosStr = DefaultStr> {
    ///Total number of likes for this subject.
    pub count: i64,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cursor: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub likes: Option<Vec<get_likes::LikeView<S>>>,
    pub subject: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for LikeView<S> {
    fn nsid() -> &'static str {
        "place.stream.getLikes"
    }
    fn def_name() -> &'static str {
        "likeView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_place_stream_getLikes()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/** Response marker for the `place.stream.getLikes` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetLikesOutput<S>` for this endpoint.*/
pub struct GetLikesResponse;
impl jacquard_common::xrpc::XrpcResp for GetLikesResponse {
    const NSID: &'static str = "place.stream.getLikes";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = GetLikesOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetLikes<S> {
    const NSID: &'static str = "place.stream.getLikes";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetLikesResponse;
}

/** Endpoint marker for the `place.stream.getLikes` query.

Path: `/xrpc/place.stream.getLikes`. The request payload type is `GetLikes<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
pub struct GetLikesRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetLikesRequest {
    const PATH: &'static str = "/xrpc/place.stream.getLikes";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<S: BosStr> = GetLikes<S>;
    type Response = GetLikesResponse;
}

pub mod like_view_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 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 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 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 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 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 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 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 `record` field
        pub struct record(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct LikeViewBuilder<St: like_view_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<ProfileViewBasic<S>>,
        Option<Cid<S>>,
        Option<Datetime>,
        Option<Data<S>>,
        Option<AtUri<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> LikeView<S> {
    /// Create a new builder for this type
    pub fn builder() -> LikeViewBuilder<like_view_state::Empty, S> {
        LikeViewBuilder::builder()
    }
}

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

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

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

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

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

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

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

impl<St, S: BosStr> LikeViewBuilder<St, S>
where
    St: like_view_state::State,
    St::Author: like_view_state::IsSet,
    St::Cid: like_view_state::IsSet,
    St::IndexedAt: like_view_state::IsSet,
    St::Record: like_view_state::IsSet,
    St::Uri: like_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> LikeView<S> {
        LikeView {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            indexed_at: self._fields.2.unwrap(),
            record: self._fields.3.unwrap(),
            uri: self._fields.4.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>>) -> LikeView<S> {
        LikeView {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            indexed_at: self._fields.2.unwrap(),
            record: self._fields.3.unwrap(),
            uri: self._fields.4.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_place_stream_getLikes() -> 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("place.stream.getLikes"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("likeView"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("author"), SmolStr::new_static("record"),
                            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#profileViewBasic",
                                ),
                                ..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("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.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(
                        LexXrpcQueryParameter::Params(LexXrpcParameters {
                            required: Some(vec![SmolStr::new_static("subject")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("cursor"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static("Optional pagination cursor."),
                                        ),
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("limit"),
                                    LexXrpcParametersProperty::Integer(LexInteger {
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("subject"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static(
                                                "AT-URI of the subject (video or comment).",
                                            ),
                                        ),
                                        format: Some(LexStringFormat::AtUri),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

pub mod get_likes_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 Subject;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Subject = Unset;
    }
    ///State transition - sets the `subject` field to Set
    pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubject<St> {}
    impl<St: State> State for SetSubject<St> {
        type Subject = Set<members::subject>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `subject` field
        pub struct subject(());
    }
}

/// Builder for constructing an instance of this type.
pub struct GetLikesBuilder<St: get_likes_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<S>, Option<i64>, Option<AtUri<S>>),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> GetLikes<S> {
    /// Create a new builder for this type
    pub fn builder() -> GetLikesBuilder<get_likes_state::Empty, S> {
        GetLikesBuilder::builder()
    }
}

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

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

impl<St: get_likes_state::State, S: BosStr> GetLikesBuilder<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: get_likes_state::State, S: BosStr> GetLikesBuilder<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, S: BosStr> GetLikesBuilder<St, S>
where
    St: get_likes_state::State,
    St::Subject: get_likes_state::IsUnset,
{
    /// Set the `subject` field (required)
    pub fn subject(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> GetLikesBuilder<get_likes_state::SetSubject<St>, S> {
        self._fields.2 = Option::Some(value.into());
        GetLikesBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> GetLikesBuilder<St, S>
where
    St: get_likes_state::State,
    St::Subject: get_likes_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> GetLikes<S> {
        GetLikes {
            cursor: self._fields.0,
            limit: self._fields.1,
            subject: self._fields.2.unwrap(),
        }
    }
}