// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: games.gamesgamesgamesgames.org.putProfile
//
// 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::blob::BlobRef;
use jacquard_common::types::string::{AtUri, Datetime};
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
use crate::app_bsky::richtext::facet::Facet;
use crate::games_gamesgamesgamesgames::MediaItem;
use crate::games_gamesgamesgamesgames::Website;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct PutProfile<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub avatar: Option<BlobRef<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub country: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub description: Option<CowStr<'a>>,
    ///Annotations of text (mentions, URLs, hashtags, etc)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub description_facets: Option<Vec<Facet<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub display_name: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub founded_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub media: Option<Vec<MediaItem<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub parent: Option<AtUri<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub status: Option<PutProfileStatus<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub websites: Option<Vec<Website<'a>>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum PutProfileStatus<'a> {
    Active,
    Inactive,
    Merged,
    Acquired,
    Defunct,
    Other(CowStr<'a>),
}

impl<'a> PutProfileStatus<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Active => "active",
            Self::Inactive => "inactive",
            Self::Merged => "merged",
            Self::Acquired => "acquired",
            Self::Defunct => "defunct",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for PutProfileStatus<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "active" => Self::Active,
            "inactive" => Self::Inactive,
            "merged" => Self::Merged,
            "acquired" => Self::Acquired,
            "defunct" => Self::Defunct,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for PutProfileStatus<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "active" => Self::Active,
            "inactive" => Self::Inactive,
            "merged" => Self::Merged,
            "acquired" => Self::Acquired,
            "defunct" => Self::Defunct,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for PutProfileStatus<'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 PutProfileStatus<'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 PutProfileStatus<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for PutProfileStatus<'_> {
    type Output = PutProfileStatus<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            PutProfileStatus::Active => PutProfileStatus::Active,
            PutProfileStatus::Inactive => PutProfileStatus::Inactive,
            PutProfileStatus::Merged => PutProfileStatus::Merged,
            PutProfileStatus::Acquired => PutProfileStatus::Acquired,
            PutProfileStatus::Defunct => PutProfileStatus::Defunct,
            PutProfileStatus::Other(v) => PutProfileStatus::Other(v.into_static()),
        }
    }
}


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

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

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

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