// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: games.gamesgamesgamesgames.reviewClaim
//
// 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;
use jacquard_common::types::string::AtUri;
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
use crate::com_atproto::repo::strong_ref::StrongRef;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ReviewClaim<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub approved_games: Option<Vec<AtUri<'a>>>,
    #[serde(borrow)]
    pub claim: StrongRef<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub reason: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub status: ReviewClaimStatus<'a>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ReviewClaimStatus<'a> {
    Approved,
    Denied,
    Other(CowStr<'a>),
}

impl<'a> ReviewClaimStatus<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Approved => "approved",
            Self::Denied => "denied",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for ReviewClaimStatus<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "approved" => Self::Approved,
            "denied" => Self::Denied,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for ReviewClaimStatus<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "approved" => Self::Approved,
            "denied" => Self::Denied,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

impl<'a> AsRef<str> for ReviewClaimStatus<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<'a> serde::Serialize for ReviewClaimStatus<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for ReviewClaimStatus<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for ReviewClaimStatus<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for ReviewClaimStatus<'_> {
    type Output = ReviewClaimStatus<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            ReviewClaimStatus::Approved => ReviewClaimStatus::Approved,
            ReviewClaimStatus::Denied => ReviewClaimStatus::Denied,
            ReviewClaimStatus::Other(v) => ReviewClaimStatus::Other(v.into_static()),
        }
    }
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ReviewClaimOutput<'a> {
    #[serde(borrow)]
    pub uri: AtUri<'a>,
}

/// Response type for games.gamesgamesgamesgames.reviewClaim
pub struct ReviewClaimResponse;
impl jacquard_common::xrpc::XrpcResp for ReviewClaimResponse {
    const NSID: &'static str = "games.gamesgamesgamesgames.reviewClaim";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = ReviewClaimOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for ReviewClaim<'a> {
    const NSID: &'static str = "games.gamesgamesgamesgames.reviewClaim";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = ReviewClaimResponse;
}

/// Endpoint type for games.gamesgamesgamesgames.reviewClaim
pub struct ReviewClaimRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ReviewClaimRequest {
    const PATH: &'static str = "/xrpc/games.gamesgamesgamesgames.reviewClaim";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<'de> = ReviewClaim<'de>;
    type Response = ReviewClaimResponse;
}

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

/// Builder for constructing an instance of this type
pub struct ReviewClaimBuilder<'a, S: review_claim_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Vec<AtUri<'a>>>,
        Option<StrongRef<'a>>,
        Option<CowStr<'a>>,
        Option<ReviewClaimStatus<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> ReviewClaim<'a> {
    /// Create a new builder for this type
    pub fn new() -> ReviewClaimBuilder<'a, review_claim_state::Empty> {
        ReviewClaimBuilder::new()
    }
}

impl<'a> ReviewClaimBuilder<'a, review_claim_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        ReviewClaimBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: review_claim_state::State> ReviewClaimBuilder<'a, S> {
    /// Set the `approvedGames` field (optional)
    pub fn approved_games(mut self, value: impl Into<Option<Vec<AtUri<'a>>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `approvedGames` field to an Option value (optional)
    pub fn maybe_approved_games(mut self, value: Option<Vec<AtUri<'a>>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> ReviewClaimBuilder<'a, S>
where
    S: review_claim_state::State,
    S::Claim: review_claim_state::IsUnset,
{
    /// Set the `claim` field (required)
    pub fn claim(
        mut self,
        value: impl Into<StrongRef<'a>>,
    ) -> ReviewClaimBuilder<'a, review_claim_state::SetClaim<S>> {
        self._fields.1 = Option::Some(value.into());
        ReviewClaimBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: review_claim_state::State> ReviewClaimBuilder<'a, S> {
    /// Set the `reason` field (optional)
    pub fn reason(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `reason` field to an Option value (optional)
    pub fn maybe_reason(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S> ReviewClaimBuilder<'a, S>
where
    S: review_claim_state::State,
    S::Status: review_claim_state::IsUnset,
{
    /// Set the `status` field (required)
    pub fn status(
        mut self,
        value: impl Into<ReviewClaimStatus<'a>>,
    ) -> ReviewClaimBuilder<'a, review_claim_state::SetStatus<S>> {
        self._fields.3 = Option::Some(value.into());
        ReviewClaimBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ReviewClaimBuilder<'a, S>
where
    S: review_claim_state::State,
    S::Status: review_claim_state::IsSet,
    S::Claim: review_claim_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ReviewClaim<'a> {
        ReviewClaim {
            approved_games: self._fields.0,
            claim: self._fields.1.unwrap(),
            reason: 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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> ReviewClaim<'a> {
        ReviewClaim {
            approved_games: self._fields.0,
            claim: self._fields.1.unwrap(),
            reason: self._fields.2,
            status: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}