// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: games.gamesgamesgamesgames.putGame
//
// 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::{AtUri, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use serde::{Serialize, Deserialize};
use crate::games_gamesgamesgamesgames::AgeRating;
use crate::games_gamesgamesgamesgames::AlternativeName;
use crate::games_gamesgamesgamesgames::ApplicationType;
use crate::games_gamesgamesgamesgames::ExternalVideo;
use crate::games_gamesgamesgamesgames::Genre;
use crate::games_gamesgamesgamesgames::LanguageSupport;
use crate::games_gamesgamesgamesgames::MediaItem;
use crate::games_gamesgamesgamesgames::Mode;
use crate::games_gamesgamesgamesgames::MultiplayerMode;
use crate::games_gamesgamesgamesgames::PlayerPerspective;
use crate::games_gamesgamesgamesgames::Release;
use crate::games_gamesgamesgamesgames::Theme;
use crate::games_gamesgamesgamesgames::TimeToBeat;
use crate::games_gamesgamesgamesgames::Website;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct PutGame<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub age_ratings: Option<Vec<AgeRating<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alternative_names: Option<Vec<AlternativeName<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub application_type: Option<ApplicationType<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub engines: Option<Vec<AtUri<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub genres: Option<Vec<Genre<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub keywords: Option<Vec<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub language_supports: Option<Vec<LanguageSupport<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub media: Option<Vec<MediaItem<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub modes: Option<Vec<Mode<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub multiplayer_modes: Option<Vec<MultiplayerMode<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent: Option<AtUri<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub player_perspectives: Option<Vec<PlayerPerspective<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub releases: Option<Vec<Release<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub should_publish: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub slug: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub storyline: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub summary: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub themes: Option<Vec<Theme<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub time_to_beat: Option<TimeToBeat<S>>,
    pub uri: AtUri<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub videos: Option<Vec<ExternalVideo<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub websites: Option<Vec<Website<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 PutGameOutput<S: BosStr = DefaultStr> {
    pub cid: S,
    pub uri: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/** Response marker for the `games.gamesgamesgamesgames.putGame` procedure.

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

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for PutGame<S> {
    const NSID: &'static str = "games.gamesgamesgamesgames.putGame";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = PutGameResponse;
}

/** Endpoint marker for the `games.gamesgamesgamesgames.putGame` procedure.

Path: `/xrpc/games.gamesgamesgamesgames.putGame`. The request payload type is `PutGame<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
pub struct PutGameRequest;
impl jacquard_common::xrpc::XrpcEndpoint for PutGameRequest {
    const PATH: &'static str = "/xrpc/games.gamesgamesgamesgames.putGame";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<S: BosStr> = PutGame<S>;
    type Response = PutGameResponse;
}

pub mod put_game_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 Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Uri = Unset;
    }
    ///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 Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct PutGameBuilder<St: put_game_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Vec<AgeRating<S>>>,
        Option<Vec<AlternativeName<S>>>,
        Option<ApplicationType<S>>,
        Option<Datetime>,
        Option<Vec<AtUri<S>>>,
        Option<Vec<Genre<S>>>,
        Option<Vec<S>>,
        Option<Vec<LanguageSupport<S>>>,
        Option<Vec<MediaItem<S>>>,
        Option<Vec<Mode<S>>>,
        Option<Vec<MultiplayerMode<S>>>,
        Option<S>,
        Option<AtUri<S>>,
        Option<Vec<PlayerPerspective<S>>>,
        Option<Vec<Release<S>>>,
        Option<bool>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<Vec<Theme<S>>>,
        Option<TimeToBeat<S>>,
        Option<AtUri<S>>,
        Option<Vec<ExternalVideo<S>>>,
        Option<Vec<Website<S>>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> PutGame<S> {
    /// Create a new builder for this type
    pub fn builder() -> PutGameBuilder<put_game_state::Empty, S> {
        PutGameBuilder::builder()
    }
}

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

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

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `ageRatings` field (optional)
    pub fn age_ratings(mut self, value: impl Into<Option<Vec<AgeRating<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<AgeRating<S>>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `alternativeNames` field (optional)
    pub fn alternative_names(
        mut self,
        value: impl Into<Option<Vec<AlternativeName<S>>>>,
    ) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `alternativeNames` field to an Option value (optional)
    pub fn maybe_alternative_names(
        mut self,
        value: Option<Vec<AlternativeName<S>>>,
    ) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `applicationType` field (optional)
    pub fn application_type(
        mut self,
        value: impl Into<Option<ApplicationType<S>>>,
    ) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `applicationType` field to an Option value (optional)
    pub fn maybe_application_type(mut self, value: Option<ApplicationType<S>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `createdAt` field (optional)
    pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `createdAt` field to an Option value (optional)
    pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.3 = value;
        self
    }
}

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

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

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `keywords` field (optional)
    pub fn keywords(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `keywords` field to an Option value (optional)
    pub fn maybe_keywords(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `languageSupports` field (optional)
    pub fn language_supports(
        mut self,
        value: impl Into<Option<Vec<LanguageSupport<S>>>>,
    ) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `languageSupports` field to an Option value (optional)
    pub fn maybe_language_supports(
        mut self,
        value: Option<Vec<LanguageSupport<S>>>,
    ) -> Self {
        self._fields.7 = value;
        self
    }
}

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

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

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `multiplayerModes` field (optional)
    pub fn multiplayer_modes(
        mut self,
        value: impl Into<Option<Vec<MultiplayerMode<S>>>>,
    ) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `multiplayerModes` field to an Option value (optional)
    pub fn maybe_multiplayer_modes(
        mut self,
        value: Option<Vec<MultiplayerMode<S>>>,
    ) -> Self {
        self._fields.10 = value;
        self
    }
}

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

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `parent` field (optional)
    pub fn parent(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `parent` field to an Option value (optional)
    pub fn maybe_parent(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.12 = value;
        self
    }
}

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

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `releases` field (optional)
    pub fn releases(mut self, value: impl Into<Option<Vec<Release<S>>>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `releases` field to an Option value (optional)
    pub fn maybe_releases(mut self, value: Option<Vec<Release<S>>>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `shouldPublish` field (optional)
    pub fn should_publish(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.15 = value.into();
        self
    }
    /// Set the `shouldPublish` field to an Option value (optional)
    pub fn maybe_should_publish(mut self, value: Option<bool>) -> Self {
        self._fields.15 = value;
        self
    }
}

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `slug` field (optional)
    pub fn slug(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.16 = value.into();
        self
    }
    /// Set the `slug` field to an Option value (optional)
    pub fn maybe_slug(mut self, value: Option<S>) -> Self {
        self._fields.16 = value;
        self
    }
}

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `storyline` field (optional)
    pub fn storyline(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.17 = value.into();
        self
    }
    /// Set the `storyline` field to an Option value (optional)
    pub fn maybe_storyline(mut self, value: Option<S>) -> Self {
        self._fields.17 = value;
        self
    }
}

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `summary` field (optional)
    pub fn summary(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.18 = value.into();
        self
    }
    /// Set the `summary` field to an Option value (optional)
    pub fn maybe_summary(mut self, value: Option<S>) -> Self {
        self._fields.18 = value;
        self
    }
}

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

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `timeToBeat` field (optional)
    pub fn time_to_beat(mut self, value: impl Into<Option<TimeToBeat<S>>>) -> Self {
        self._fields.20 = value.into();
        self
    }
    /// Set the `timeToBeat` field to an Option value (optional)
    pub fn maybe_time_to_beat(mut self, value: Option<TimeToBeat<S>>) -> Self {
        self._fields.20 = value;
        self
    }
}

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

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `videos` field (optional)
    pub fn videos(mut self, value: impl Into<Option<Vec<ExternalVideo<S>>>>) -> Self {
        self._fields.22 = value.into();
        self
    }
    /// Set the `videos` field to an Option value (optional)
    pub fn maybe_videos(mut self, value: Option<Vec<ExternalVideo<S>>>) -> Self {
        self._fields.22 = value;
        self
    }
}

impl<St: put_game_state::State, S: BosStr> PutGameBuilder<St, S> {
    /// Set the `websites` field (optional)
    pub fn websites(mut self, value: impl Into<Option<Vec<Website<S>>>>) -> Self {
        self._fields.23 = value.into();
        self
    }
    /// Set the `websites` field to an Option value (optional)
    pub fn maybe_websites(mut self, value: Option<Vec<Website<S>>>) -> Self {
        self._fields.23 = value;
        self
    }
}

impl<St, S: BosStr> PutGameBuilder<St, S>
where
    St: put_game_state::State,
    St::Uri: put_game_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> PutGame<S> {
        PutGame {
            age_ratings: self._fields.0,
            alternative_names: self._fields.1,
            application_type: self._fields.2,
            created_at: self._fields.3,
            engines: self._fields.4,
            genres: self._fields.5,
            keywords: self._fields.6,
            language_supports: self._fields.7,
            media: self._fields.8,
            modes: self._fields.9,
            multiplayer_modes: self._fields.10,
            name: self._fields.11,
            parent: self._fields.12,
            player_perspectives: self._fields.13,
            releases: self._fields.14,
            should_publish: self._fields.15,
            slug: self._fields.16,
            storyline: self._fields.17,
            summary: self._fields.18,
            themes: self._fields.19,
            time_to_beat: self._fields.20,
            uri: self._fields.21.unwrap(),
            videos: self._fields.22,
            websites: self._fields.23,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> PutGame<S> {
        PutGame {
            age_ratings: self._fields.0,
            alternative_names: self._fields.1,
            application_type: self._fields.2,
            created_at: self._fields.3,
            engines: self._fields.4,
            genres: self._fields.5,
            keywords: self._fields.6,
            language_supports: self._fields.7,
            media: self._fields.8,
            modes: self._fields.9,
            multiplayer_modes: self._fields.10,
            name: self._fields.11,
            parent: self._fields.12,
            player_perspectives: self._fields.13,
            releases: self._fields.14,
            should_publish: self._fields.15,
            slug: self._fields.16,
            storyline: self._fields.17,
            summary: self._fields.18,
            themes: self._fields.19,
            time_to_beat: self._fields.20,
            uri: self._fields.21.unwrap(),
            videos: self._fields.22,
            websites: self._fields.23,
            extra_data: Some(extra_data),
        }
    }
}