jacquard-api 0.12.0-beta.2

Generated AT Protocol API bindings for Jacquard
Documentation
// @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;

use crate::app_bsky::richtext::facet::Facet;
use crate::games_gamesgamesgamesgames::MediaItem;
use crate::games_gamesgamesgamesgames::Website;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::string::{AtUri, Datetime};
use jacquard_common::types::value::Data;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
use jacquard_derive::IntoStatic;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
    rename_all = "camelCase",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct PutProfile<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub avatar: Option<BlobRef<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub country: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    ///Annotations of text (mentions, URLs, hashtags, etc)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description_facets: Option<Vec<Facet<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub display_name: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub founded_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub media: Option<Vec<MediaItem<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent: Option<AtUri<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<PutProfileStatus<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(Debug, Clone, PartialEq, Eq, Hash)]
pub enum PutProfileStatus<S: BosStr = DefaultStr> {
    Active,
    Inactive,
    Merged,
    Acquired,
    Defunct,
    Other(S),
}

impl<S: BosStr> PutProfileStatus<S> {
    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(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "active" => Self::Active,
            "inactive" => Self::Inactive,
            "merged" => Self::Merged,
            "acquired" => Self::Acquired,
            "defunct" => Self::Defunct,
            _ => Self::Other(s),
        }
    }
}

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

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

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

impl<S: BosStr> jacquard_common::IntoStatic for PutProfileStatus<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = PutProfileStatus<S::Output>;
    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()),
        }
    }
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct PutProfileOutput<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 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<S: BosStr> = PutProfileOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for PutProfile<S> {
    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<S: BosStr> = PutProfile<S>;
    type Response = PutProfileResponse;
}