// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: games.gamesgamesgamesgames.getContributionStats
//
// 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::Did;
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::get_contribution_stats;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Badge<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    pub id: S,
    pub name: 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 ContributionStats<S: BosStr = DefaultStr> {
    pub additions: i64,
    pub corrections: i64,
    pub new_games: i64,
    pub owner_accepted: i64,
    pub total_contributions: i64,
    pub unique_entities: 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 GetContributionStats<S: BosStr = DefaultStr> {
    pub did: Did<S>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetContributionStatsOutput<S: BosStr = DefaultStr> {
    pub badges: Vec<get_contribution_stats::Badge<S>>,
    pub stats: get_contribution_stats::ContributionStats<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for Badge<S> {
    fn nsid() -> &'static str {
        "games.gamesgamesgamesgames.getContributionStats"
    }
    fn def_name() -> &'static str {
        "badge"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_games_gamesgamesgamesgames_getContributionStats()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ContributionStats<S> {
    fn nsid() -> &'static str {
        "games.gamesgamesgamesgames.getContributionStats"
    }
    fn def_name() -> &'static str {
        "contributionStats"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_games_gamesgamesgamesgames_getContributionStats()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/** Response marker for the `games.gamesgamesgamesgames.getContributionStats` query.

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

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

/** Endpoint marker for the `games.gamesgamesgamesgames.getContributionStats` query.

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

fn lexicon_doc_games_gamesgamesgamesgames_getContributionStats() -> 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.getContributionStats"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("badge"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("id"), SmolStr::new_static("name")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("contributionStats"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("totalContributions"),
                            SmolStr::new_static("corrections"),
                            SmolStr::new_static("additions"),
                            SmolStr::new_static("newGames"),
                            SmolStr::new_static("uniqueEntities"),
                            SmolStr::new_static("ownerAccepted")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("additions"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("corrections"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("newGames"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("ownerAccepted"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("totalContributions"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uniqueEntities"),
                            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 {
                                        format: Some(LexStringFormat::Did),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod contribution_stats_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 Additions;
        type Corrections;
        type NewGames;
        type OwnerAccepted;
        type TotalContributions;
        type UniqueEntities;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Additions = Unset;
        type Corrections = Unset;
        type NewGames = Unset;
        type OwnerAccepted = Unset;
        type TotalContributions = Unset;
        type UniqueEntities = Unset;
    }
    ///State transition - sets the `additions` field to Set
    pub struct SetAdditions<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAdditions<St> {}
    impl<St: State> State for SetAdditions<St> {
        type Additions = Set<members::additions>;
        type Corrections = St::Corrections;
        type NewGames = St::NewGames;
        type OwnerAccepted = St::OwnerAccepted;
        type TotalContributions = St::TotalContributions;
        type UniqueEntities = St::UniqueEntities;
    }
    ///State transition - sets the `corrections` field to Set
    pub struct SetCorrections<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCorrections<St> {}
    impl<St: State> State for SetCorrections<St> {
        type Additions = St::Additions;
        type Corrections = Set<members::corrections>;
        type NewGames = St::NewGames;
        type OwnerAccepted = St::OwnerAccepted;
        type TotalContributions = St::TotalContributions;
        type UniqueEntities = St::UniqueEntities;
    }
    ///State transition - sets the `new_games` field to Set
    pub struct SetNewGames<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetNewGames<St> {}
    impl<St: State> State for SetNewGames<St> {
        type Additions = St::Additions;
        type Corrections = St::Corrections;
        type NewGames = Set<members::new_games>;
        type OwnerAccepted = St::OwnerAccepted;
        type TotalContributions = St::TotalContributions;
        type UniqueEntities = St::UniqueEntities;
    }
    ///State transition - sets the `owner_accepted` field to Set
    pub struct SetOwnerAccepted<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOwnerAccepted<St> {}
    impl<St: State> State for SetOwnerAccepted<St> {
        type Additions = St::Additions;
        type Corrections = St::Corrections;
        type NewGames = St::NewGames;
        type OwnerAccepted = Set<members::owner_accepted>;
        type TotalContributions = St::TotalContributions;
        type UniqueEntities = St::UniqueEntities;
    }
    ///State transition - sets the `total_contributions` field to Set
    pub struct SetTotalContributions<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTotalContributions<St> {}
    impl<St: State> State for SetTotalContributions<St> {
        type Additions = St::Additions;
        type Corrections = St::Corrections;
        type NewGames = St::NewGames;
        type OwnerAccepted = St::OwnerAccepted;
        type TotalContributions = Set<members::total_contributions>;
        type UniqueEntities = St::UniqueEntities;
    }
    ///State transition - sets the `unique_entities` field to Set
    pub struct SetUniqueEntities<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUniqueEntities<St> {}
    impl<St: State> State for SetUniqueEntities<St> {
        type Additions = St::Additions;
        type Corrections = St::Corrections;
        type NewGames = St::NewGames;
        type OwnerAccepted = St::OwnerAccepted;
        type TotalContributions = St::TotalContributions;
        type UniqueEntities = Set<members::unique_entities>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `additions` field
        pub struct additions(());
        ///Marker type for the `corrections` field
        pub struct corrections(());
        ///Marker type for the `new_games` field
        pub struct new_games(());
        ///Marker type for the `owner_accepted` field
        pub struct owner_accepted(());
        ///Marker type for the `total_contributions` field
        pub struct total_contributions(());
        ///Marker type for the `unique_entities` field
        pub struct unique_entities(());
    }
}

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

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

impl<S: BosStr> ContributionStats<S> {
    /// Create a new builder for this type
    pub fn builder() -> ContributionStatsBuilder<contribution_stats_state::Empty, S> {
        ContributionStatsBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> ContributionStatsBuilder<St, S>
where
    St: contribution_stats_state::State,
    St::Corrections: contribution_stats_state::IsUnset,
{
    /// Set the `corrections` field (required)
    pub fn corrections(
        mut self,
        value: impl Into<i64>,
    ) -> ContributionStatsBuilder<contribution_stats_state::SetCorrections<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ContributionStatsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ContributionStatsBuilder<St, S>
where
    St: contribution_stats_state::State,
    St::NewGames: contribution_stats_state::IsUnset,
{
    /// Set the `newGames` field (required)
    pub fn new_games(
        mut self,
        value: impl Into<i64>,
    ) -> ContributionStatsBuilder<contribution_stats_state::SetNewGames<St>, S> {
        self._fields.2 = Option::Some(value.into());
        ContributionStatsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ContributionStatsBuilder<St, S>
where
    St: contribution_stats_state::State,
    St::OwnerAccepted: contribution_stats_state::IsUnset,
{
    /// Set the `ownerAccepted` field (required)
    pub fn owner_accepted(
        mut self,
        value: impl Into<i64>,
    ) -> ContributionStatsBuilder<contribution_stats_state::SetOwnerAccepted<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ContributionStatsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ContributionStatsBuilder<St, S>
where
    St: contribution_stats_state::State,
    St::TotalContributions: contribution_stats_state::IsUnset,
{
    /// Set the `totalContributions` field (required)
    pub fn total_contributions(
        mut self,
        value: impl Into<i64>,
    ) -> ContributionStatsBuilder<
        contribution_stats_state::SetTotalContributions<St>,
        S,
    > {
        self._fields.4 = Option::Some(value.into());
        ContributionStatsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ContributionStatsBuilder<St, S>
where
    St: contribution_stats_state::State,
    St::UniqueEntities: contribution_stats_state::IsUnset,
{
    /// Set the `uniqueEntities` field (required)
    pub fn unique_entities(
        mut self,
        value: impl Into<i64>,
    ) -> ContributionStatsBuilder<contribution_stats_state::SetUniqueEntities<St>, S> {
        self._fields.5 = Option::Some(value.into());
        ContributionStatsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ContributionStatsBuilder<St, S>
where
    St: contribution_stats_state::State,
    St::Additions: contribution_stats_state::IsSet,
    St::Corrections: contribution_stats_state::IsSet,
    St::NewGames: contribution_stats_state::IsSet,
    St::OwnerAccepted: contribution_stats_state::IsSet,
    St::TotalContributions: contribution_stats_state::IsSet,
    St::UniqueEntities: contribution_stats_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ContributionStats<S> {
        ContributionStats {
            additions: self._fields.0.unwrap(),
            corrections: self._fields.1.unwrap(),
            new_games: self._fields.2.unwrap(),
            owner_accepted: self._fields.3.unwrap(),
            total_contributions: self._fields.4.unwrap(),
            unique_entities: self._fields.5.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>>,
    ) -> ContributionStats<S> {
        ContributionStats {
            additions: self._fields.0.unwrap(),
            corrections: self._fields.1.unwrap(),
            new_games: self._fields.2.unwrap(),
            owner_accepted: self._fields.3.unwrap(),
            total_contributions: self._fields.4.unwrap(),
            unique_entities: self._fields.5.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod get_contribution_stats_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 GetContributionStatsBuilder<
    St: get_contribution_stats_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<Did<S>>,),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> GetContributionStats<S> {
    /// Create a new builder for this type
    pub fn builder() -> GetContributionStatsBuilder<
        get_contribution_stats_state::Empty,
        S,
    > {
        GetContributionStatsBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> GetContributionStatsBuilder<St, S>
where
    St: get_contribution_stats_state::State,
    St::Did: get_contribution_stats_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> GetContributionStats<S> {
        GetContributionStats {
            did: self._fields.0.unwrap(),
        }
    }
}