// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.bsky.unspecced.getTaggedSuggestions
//
// 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::UriValue;
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::unspecced::get_tagged_suggestions;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetTaggedSuggestions;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetTaggedSuggestionsOutput<S: BosStr = DefaultStr> {
    pub suggestions: Vec<get_tagged_suggestions::Suggestion<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 Suggestion<S: BosStr = DefaultStr> {
    pub subject: UriValue<S>,
    pub subject_type: SuggestionSubjectType<S>,
    pub tag: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SuggestionSubjectType<S: BosStr = DefaultStr> {
    Actor,
    Feed,
    Other(S),
}

impl<S: BosStr> SuggestionSubjectType<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Actor => "actor",
            Self::Feed => "feed",
            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() {
            "actor" => Self::Actor,
            "feed" => Self::Feed,
            _ => Self::Other(s),
        }
    }
}

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

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

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

impl<S: BosStr> jacquard_common::IntoStatic for SuggestionSubjectType<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = SuggestionSubjectType<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            SuggestionSubjectType::Actor => SuggestionSubjectType::Actor,
            SuggestionSubjectType::Feed => SuggestionSubjectType::Feed,
            SuggestionSubjectType::Other(v) => {
                SuggestionSubjectType::Other(v.into_static())
            }
        }
    }
}

/** Response marker for the `app.bsky.unspecced.getTaggedSuggestions` query.

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

impl jacquard_common::xrpc::XrpcRequest for GetTaggedSuggestions {
    const NSID: &'static str = "app.bsky.unspecced.getTaggedSuggestions";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetTaggedSuggestionsResponse;
}

/** Endpoint marker for the `app.bsky.unspecced.getTaggedSuggestions` query.

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

impl<S: BosStr> LexiconSchema for Suggestion<S> {
    fn nsid() -> &'static str {
        "app.bsky.unspecced.getTaggedSuggestions"
    }
    fn def_name() -> &'static str {
        "suggestion"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_unspecced_getTaggedSuggestions()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

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

impl<S: BosStr> Suggestion<S> {
    /// Create a new builder for this type
    pub fn builder() -> SuggestionBuilder<suggestion_state::Empty, S> {
        SuggestionBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> SuggestionBuilder<St, S>
where
    St: suggestion_state::State,
    St::Subject: suggestion_state::IsUnset,
{
    /// Set the `subject` field (required)
    pub fn subject(
        mut self,
        value: impl Into<UriValue<S>>,
    ) -> SuggestionBuilder<suggestion_state::SetSubject<St>, S> {
        self._fields.0 = Option::Some(value.into());
        SuggestionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SuggestionBuilder<St, S>
where
    St: suggestion_state::State,
    St::SubjectType: suggestion_state::IsUnset,
{
    /// Set the `subjectType` field (required)
    pub fn subject_type(
        mut self,
        value: impl Into<SuggestionSubjectType<S>>,
    ) -> SuggestionBuilder<suggestion_state::SetSubjectType<St>, S> {
        self._fields.1 = Option::Some(value.into());
        SuggestionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SuggestionBuilder<St, S>
where
    St: suggestion_state::State,
    St::Tag: suggestion_state::IsUnset,
{
    /// Set the `tag` field (required)
    pub fn tag(
        mut self,
        value: impl Into<S>,
    ) -> SuggestionBuilder<suggestion_state::SetTag<St>, S> {
        self._fields.2 = Option::Some(value.into());
        SuggestionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SuggestionBuilder<St, S>
where
    St: suggestion_state::State,
    St::Subject: suggestion_state::IsSet,
    St::SubjectType: suggestion_state::IsSet,
    St::Tag: suggestion_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Suggestion<S> {
        Suggestion {
            subject: self._fields.0.unwrap(),
            subject_type: self._fields.1.unwrap(),
            tag: self._fields.2.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>>,
    ) -> Suggestion<S> {
        Suggestion {
            subject: self._fields.0.unwrap(),
            subject_type: self._fields.1.unwrap(),
            tag: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_bsky_unspecced_getTaggedSuggestions() -> 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.unspecced.getTaggedSuggestions"),
        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
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("suggestion"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("tag"),
                            SmolStr::new_static("subjectType"),
                            SmolStr::new_static("subject")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("subject"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("subjectType"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("tag"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}