// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: games.gamesgamesgamesgames.listGames
//
// 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};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Did;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use serde::{Serialize, Deserialize};
use crate::games_gamesgamesgamesgames::GameSummaryView;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListGames<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub age_ratings: Option<Vec<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub application_types: Option<Vec<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cursor: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub did: Option<Did<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub genres: Option<Vec<S>>,
    ///  Defaults to `false`.
    #[serde(default = "_default_include_cancelled")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_cancelled: Option<bool>,
    ///  Defaults to `false`.
    #[serde(default = "_default_include_unrated")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_unrated: Option<bool>,
    /// Defaults to `20`. 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 modes: Option<Vec<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub player_perspectives: Option<Vec<S>>,
    /// Defaults to `"indexed_at"`.
    #[serde(default = "_default_sort")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sort: Option<S>,
    /// Defaults to `"desc"`.
    #[serde(default = "_default_sort_direction")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sort_direction: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub themes: Option<Vec<S>>,
}


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

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

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

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

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

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

fn _default_include_cancelled() -> Option<bool> {
    Some(false)
}

fn _default_include_unrated() -> Option<bool> {
    Some(false)
}

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

fn _default_sort<S: jacquard_common::FromStaticStr>() -> Option<S> {
    Some(S::from_static("indexed_at"))
}

fn _default_sort_direction<S: jacquard_common::FromStaticStr>() -> Option<S> {
    Some(S::from_static("desc"))
}

pub mod list_games_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 ListGamesBuilder<St: list_games_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Vec<S>>,
        Option<Vec<S>>,
        Option<S>,
        Option<Did<S>>,
        Option<Vec<S>>,
        Option<bool>,
        Option<bool>,
        Option<i64>,
        Option<Vec<S>>,
        Option<Vec<S>>,
        Option<S>,
        Option<S>,
        Option<Vec<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ListGames<S> {
    /// Create a new builder for this type
    pub fn builder() -> ListGamesBuilder<list_games_state::Empty, S> {
        ListGamesBuilder::builder()
    }
}

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

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

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `ageRatings` field (optional)
    pub fn age_ratings(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `ageRatings` field to an Option value (optional)
    pub fn maybe_age_ratings(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `applicationTypes` field (optional)
    pub fn application_types(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `applicationTypes` field to an Option value (optional)
    pub fn maybe_application_types(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `did` field (optional)
    pub fn did(mut self, value: impl Into<Option<Did<S>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `did` field to an Option value (optional)
    pub fn maybe_did(mut self, value: Option<Did<S>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `genres` field (optional)
    pub fn genres(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `genres` field to an Option value (optional)
    pub fn maybe_genres(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `includeCancelled` field (optional)
    pub fn include_cancelled(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `includeCancelled` field to an Option value (optional)
    pub fn maybe_include_cancelled(mut self, value: Option<bool>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `includeUnrated` field (optional)
    pub fn include_unrated(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `includeUnrated` field to an Option value (optional)
    pub fn maybe_include_unrated(mut self, value: Option<bool>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `limit` field (optional)
    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `limit` field to an Option value (optional)
    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `modes` field (optional)
    pub fn modes(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `modes` field to an Option value (optional)
    pub fn maybe_modes(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `playerPerspectives` field (optional)
    pub fn player_perspectives(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `playerPerspectives` field to an Option value (optional)
    pub fn maybe_player_perspectives(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `sort` field (optional)
    pub fn sort(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `sort` field to an Option value (optional)
    pub fn maybe_sort(mut self, value: Option<S>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `sortDirection` field (optional)
    pub fn sort_direction(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `sortDirection` field to an Option value (optional)
    pub fn maybe_sort_direction(mut self, value: Option<S>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St: list_games_state::State, S: BosStr> ListGamesBuilder<St, S> {
    /// Set the `themes` field (optional)
    pub fn themes(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `themes` field to an Option value (optional)
    pub fn maybe_themes(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<St, S: BosStr> ListGamesBuilder<St, S>
where
    St: list_games_state::State,
{
    /// Build the final struct.
    pub fn build(self) -> ListGames<S> {
        ListGames {
            age_ratings: self._fields.0,
            application_types: self._fields.1,
            cursor: self._fields.2,
            did: self._fields.3,
            genres: self._fields.4,
            include_cancelled: self._fields.5,
            include_unrated: self._fields.6,
            limit: self._fields.7,
            modes: self._fields.8,
            player_perspectives: self._fields.9,
            sort: self._fields.10,
            sort_direction: self._fields.11,
            themes: self._fields.12,
        }
    }
}