// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: games.gamesgamesgamesgames.actor.getTasteProfile
//
// 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::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::games_gamesgamesgamesgames::GameView;
use crate::games_gamesgamesgamesgames::actor::get_taste_profile;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GenrePreference<S: BosStr = DefaultStr> {
    pub count: i64,
    pub genre: S,
    pub percentage: i64,
    #[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 GetTasteProfile<S: BosStr = DefaultStr> {
    pub did: S,
    /// Defaults to `6`. Min: 1. Max: 12.
    #[serde(default = "_default_favorite_limit")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub favorite_limit: Option<i64>,
    /// Defaults to `5`. Min: 1. Max: 20.
    #[serde(default = "_default_genre_limit")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub genre_limit: Option<i64>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetTasteProfileOutput<S: BosStr = DefaultStr> {
    pub favorites: Vec<GameView<S>>,
    pub genres: Vec<get_taste_profile::GenrePreference<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for GenrePreference<S> {
    fn nsid() -> &'static str {
        "games.gamesgamesgamesgames.actor.getTasteProfile"
    }
    fn def_name() -> &'static str {
        "genrePreference"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_games_gamesgamesgamesgames_actor_getTasteProfile()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/** Response marker for the `games.gamesgamesgamesgames.actor.getTasteProfile` query.

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

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetTasteProfile<S> {
    const NSID: &'static str = "games.gamesgamesgamesgames.actor.getTasteProfile";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetTasteProfileResponse;
}

/** Endpoint marker for the `games.gamesgamesgamesgames.actor.getTasteProfile` query.

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

pub mod genre_preference_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 Count;
        type Genre;
        type Percentage;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Count = Unset;
        type Genre = Unset;
        type Percentage = Unset;
    }
    ///State transition - sets the `count` field to Set
    pub struct SetCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCount<St> {}
    impl<St: State> State for SetCount<St> {
        type Count = Set<members::count>;
        type Genre = St::Genre;
        type Percentage = St::Percentage;
    }
    ///State transition - sets the `genre` field to Set
    pub struct SetGenre<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetGenre<St> {}
    impl<St: State> State for SetGenre<St> {
        type Count = St::Count;
        type Genre = Set<members::genre>;
        type Percentage = St::Percentage;
    }
    ///State transition - sets the `percentage` field to Set
    pub struct SetPercentage<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPercentage<St> {}
    impl<St: State> State for SetPercentage<St> {
        type Count = St::Count;
        type Genre = St::Genre;
        type Percentage = Set<members::percentage>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `count` field
        pub struct count(());
        ///Marker type for the `genre` field
        pub struct genre(());
        ///Marker type for the `percentage` field
        pub struct percentage(());
    }
}

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

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

impl<S: BosStr> GenrePreference<S> {
    /// Create a new builder for this type
    pub fn builder() -> GenrePreferenceBuilder<genre_preference_state::Empty, S> {
        GenrePreferenceBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> GenrePreferenceBuilder<St, S>
where
    St: genre_preference_state::State,
    St::Count: genre_preference_state::IsUnset,
{
    /// Set the `count` field (required)
    pub fn count(
        mut self,
        value: impl Into<i64>,
    ) -> GenrePreferenceBuilder<genre_preference_state::SetCount<St>, S> {
        self._fields.0 = Option::Some(value.into());
        GenrePreferenceBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> GenrePreferenceBuilder<St, S>
where
    St: genre_preference_state::State,
    St::Genre: genre_preference_state::IsUnset,
{
    /// Set the `genre` field (required)
    pub fn genre(
        mut self,
        value: impl Into<S>,
    ) -> GenrePreferenceBuilder<genre_preference_state::SetGenre<St>, S> {
        self._fields.1 = Option::Some(value.into());
        GenrePreferenceBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> GenrePreferenceBuilder<St, S>
where
    St: genre_preference_state::State,
    St::Percentage: genre_preference_state::IsUnset,
{
    /// Set the `percentage` field (required)
    pub fn percentage(
        mut self,
        value: impl Into<i64>,
    ) -> GenrePreferenceBuilder<genre_preference_state::SetPercentage<St>, S> {
        self._fields.2 = Option::Some(value.into());
        GenrePreferenceBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> GenrePreferenceBuilder<St, S>
where
    St: genre_preference_state::State,
    St::Count: genre_preference_state::IsSet,
    St::Genre: genre_preference_state::IsSet,
    St::Percentage: genre_preference_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> GenrePreference<S> {
        GenrePreference {
            count: self._fields.0.unwrap(),
            genre: self._fields.1.unwrap(),
            percentage: 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>>,
    ) -> GenrePreference<S> {
        GenrePreference {
            count: self._fields.0.unwrap(),
            genre: self._fields.1.unwrap(),
            percentage: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_games_gamesgamesgamesgames_actor_getTasteProfile() -> 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("games.gamesgamesgamesgames.actor.getTasteProfile"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("genrePreference"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("genre"), SmolStr::new_static("count"),
                            SmolStr::new_static("percentage")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("count"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("genre"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("percentage"),
                            LexObjectProperty::Integer(LexInteger {
                                ..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("did")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("did"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static(
                                                "The DID of the user whose taste profile to retrieve.",
                                            ),
                                        ),
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("favoriteLimit"),
                                    LexXrpcParametersProperty::Integer(LexInteger {
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("genreLimit"),
                                    LexXrpcParametersProperty::Integer(LexInteger {
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

fn _default_favorite_limit() -> Option<i64> {
    Some(6i64)
}

fn _default_genre_limit() -> Option<i64> {
    Some(5i64)
}

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

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

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

impl<S: BosStr> GetTasteProfile<S> {
    /// Create a new builder for this type
    pub fn builder() -> GetTasteProfileBuilder<get_taste_profile_state::Empty, S> {
        GetTasteProfileBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> GetTasteProfileBuilder<St, S>
where
    St: get_taste_profile_state::State,
    St::Did: get_taste_profile_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<S>,
    ) -> GetTasteProfileBuilder<get_taste_profile_state::SetDid<St>, S> {
        self._fields.0 = Option::Some(value.into());
        GetTasteProfileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: get_taste_profile_state::State, S: BosStr> GetTasteProfileBuilder<St, S> {
    /// Set the `favoriteLimit` field (optional)
    pub fn favorite_limit(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `favoriteLimit` field to an Option value (optional)
    pub fn maybe_favorite_limit(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: get_taste_profile_state::State, S: BosStr> GetTasteProfileBuilder<St, S> {
    /// Set the `genreLimit` field (optional)
    pub fn genre_limit(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `genreLimit` field to an Option value (optional)
    pub fn maybe_genre_limit(mut self, value: Option<i64>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> GetTasteProfileBuilder<St, S>
where
    St: get_taste_profile_state::State,
    St::Did: get_taste_profile_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> GetTasteProfile<S> {
        GetTasteProfile {
            did: self._fields.0.unwrap(),
            favorite_limit: self._fields.1,
            genre_limit: self._fields.2,
        }
    }
}