// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: games.gamesgamesgamesgames.migrateClaim
//
// 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::AtUri;
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::migrate_claim;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct MigrateClaim<S: BosStr = DefaultStr> {
    pub claim: AtUri<S>,
    pub claim_review: AtUri<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 MigrateClaimOutput<S: BosStr = DefaultStr> {
    pub results: Vec<migrate_claim::MigrationResult<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 MigrationResult<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<S>,
    pub game_uri: AtUri<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub new_uri: Option<AtUri<S>>,
    pub status: MigrationResultStatus<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 MigrationResultStatus<S: BosStr = DefaultStr> {
    Success,
    Failed,
    Skipped,
    Other(S),
}

impl<S: BosStr> MigrationResultStatus<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Success => "success",
            Self::Failed => "failed",
            Self::Skipped => "skipped",
            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() {
            "success" => Self::Success,
            "failed" => Self::Failed,
            "skipped" => Self::Skipped,
            _ => Self::Other(s),
        }
    }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

impl<S: BosStr> MigrateClaim<S> {
    /// Create a new builder for this type
    pub fn builder() -> MigrateClaimBuilder<migrate_claim_state::Empty, S> {
        MigrateClaimBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> MigrateClaimBuilder<St, S>
where
    St: migrate_claim_state::State,
    St::Claim: migrate_claim_state::IsUnset,
{
    /// Set the `claim` field (required)
    pub fn claim(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> MigrateClaimBuilder<migrate_claim_state::SetClaim<St>, S> {
        self._fields.0 = Option::Some(value.into());
        MigrateClaimBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> MigrateClaimBuilder<St, S>
where
    St: migrate_claim_state::State,
    St::ClaimReview: migrate_claim_state::IsUnset,
{
    /// Set the `claimReview` field (required)
    pub fn claim_review(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> MigrateClaimBuilder<migrate_claim_state::SetClaimReview<St>, S> {
        self._fields.1 = Option::Some(value.into());
        MigrateClaimBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> MigrateClaimBuilder<St, S>
where
    St: migrate_claim_state::State,
    St::Claim: migrate_claim_state::IsSet,
    St::ClaimReview: migrate_claim_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> MigrateClaim<S> {
        MigrateClaim {
            claim: self._fields.0.unwrap(),
            claim_review: self._fields.1.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>>,
    ) -> MigrateClaim<S> {
        MigrateClaim {
            claim: self._fields.0.unwrap(),
            claim_review: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> MigrationResult<S> {
    /// Create a new builder for this type
    pub fn builder() -> MigrationResultBuilder<migration_result_state::Empty, S> {
        MigrationResultBuilder::builder()
    }
}

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

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

impl<St: migration_result_state::State, S: BosStr> MigrationResultBuilder<St, S> {
    /// Set the `error` field (optional)
    pub fn error(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `error` field to an Option value (optional)
    pub fn maybe_error(mut self, value: Option<S>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> MigrationResultBuilder<St, S>
where
    St: migration_result_state::State,
    St::GameUri: migration_result_state::IsUnset,
{
    /// Set the `gameUri` field (required)
    pub fn game_uri(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> MigrationResultBuilder<migration_result_state::SetGameUri<St>, S> {
        self._fields.1 = Option::Some(value.into());
        MigrationResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: migration_result_state::State, S: BosStr> MigrationResultBuilder<St, S> {
    /// Set the `newUri` field (optional)
    pub fn new_uri(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `newUri` field to an Option value (optional)
    pub fn maybe_new_uri(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> MigrationResultBuilder<St, S>
where
    St: migration_result_state::State,
    St::Status: migration_result_state::IsUnset,
{
    /// Set the `status` field (required)
    pub fn status(
        mut self,
        value: impl Into<MigrationResultStatus<S>>,
    ) -> MigrationResultBuilder<migration_result_state::SetStatus<St>, S> {
        self._fields.3 = Option::Some(value.into());
        MigrationResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> MigrationResultBuilder<St, S>
where
    St: migration_result_state::State,
    St::GameUri: migration_result_state::IsSet,
    St::Status: migration_result_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> MigrationResult<S> {
        MigrationResult {
            error: self._fields.0,
            game_uri: self._fields.1.unwrap(),
            new_uri: self._fields.2,
            status: self._fields.3.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>>,
    ) -> MigrationResult<S> {
        MigrationResult {
            error: self._fields.0,
            game_uri: self._fields.1.unwrap(),
            new_uri: self._fields.2,
            status: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_games_gamesgamesgamesgames_migrateClaim() -> 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.migrateClaim"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcProcedure(LexXrpcProcedure {
                    input: Some(LexXrpcBody {
                        encoding: CowStr::new_static("application/json"),
                        schema: Some(
                            LexXrpcBodySchema::Object(LexObject {
                                required: Some(
                                    vec![
                                        SmolStr::new_static("claim"),
                                        SmolStr::new_static("claimReview")
                                    ],
                                ),
                                properties: {
                                    #[allow(unused_mut)]
                                    let mut map = BTreeMap::new();
                                    map.insert(
                                        SmolStr::new_static("claim"),
                                        LexObjectProperty::String(LexString {
                                            format: Some(LexStringFormat::AtUri),
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("claimReview"),
                                        LexObjectProperty::String(LexString {
                                            format: Some(LexStringFormat::AtUri),
                                            ..Default::default()
                                        }),
                                    );
                                    map
                                },
                                ..Default::default()
                            }),
                        ),
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("migrationResult"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("gameUri"), SmolStr::new_static("status")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("error"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("gameUri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("newUri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}