#[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::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::put_popularity;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GamePopularity<S: BosStr = DefaultStr> {
pub ccu: i64,
pub steam_id: 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 PutPopularity<S: BosStr = DefaultStr> {
pub games: Vec<put_popularity::GamePopularity<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 PutPopularityOutput<S: BosStr = DefaultStr> {
pub upserted: i64,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for GamePopularity<S> {
fn nsid() -> &'static str {
"games.gamesgamesgamesgames.putPopularity"
}
fn def_name() -> &'static str {
"gamePopularity"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_games_gamesgamesgamesgames_putPopularity()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.ccu;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("ccu"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
pub struct PutPopularityResponse;
impl jacquard_common::xrpc::XrpcResp for PutPopularityResponse {
const NSID: &'static str = "games.gamesgamesgamesgames.putPopularity";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = PutPopularityOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for PutPopularity<S> {
const NSID: &'static str = "games.gamesgamesgamesgames.putPopularity";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = PutPopularityResponse;
}
pub struct PutPopularityRequest;
impl jacquard_common::xrpc::XrpcEndpoint for PutPopularityRequest {
const PATH: &'static str = "/xrpc/games.gamesgamesgamesgames.putPopularity";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<S: BosStr> = PutPopularity<S>;
type Response = PutPopularityResponse;
}
pub mod game_popularity_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Ccu;
type SteamId;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Ccu = Unset;
type SteamId = Unset;
}
pub struct SetCcu<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCcu<St> {}
impl<St: State> State for SetCcu<St> {
type Ccu = Set<members::ccu>;
type SteamId = St::SteamId;
}
pub struct SetSteamId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSteamId<St> {}
impl<St: State> State for SetSteamId<St> {
type Ccu = St::Ccu;
type SteamId = Set<members::steam_id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct ccu(());
pub struct steam_id(());
}
}
pub struct GamePopularityBuilder<
St: game_popularity_state::State,
S: BosStr = DefaultStr,
> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl GamePopularity<DefaultStr> {
pub fn new() -> GamePopularityBuilder<game_popularity_state::Empty, DefaultStr> {
GamePopularityBuilder::new()
}
}
impl<S: BosStr> GamePopularity<S> {
pub fn builder() -> GamePopularityBuilder<game_popularity_state::Empty, S> {
GamePopularityBuilder::builder()
}
}
impl GamePopularityBuilder<game_popularity_state::Empty, DefaultStr> {
pub fn new() -> Self {
GamePopularityBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> GamePopularityBuilder<game_popularity_state::Empty, S> {
pub fn builder() -> Self {
GamePopularityBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> GamePopularityBuilder<St, S>
where
St: game_popularity_state::State,
St::Ccu: game_popularity_state::IsUnset,
{
pub fn ccu(
mut self,
value: impl Into<i64>,
) -> GamePopularityBuilder<game_popularity_state::SetCcu<St>, S> {
self._fields.0 = Option::Some(value.into());
GamePopularityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> GamePopularityBuilder<St, S>
where
St: game_popularity_state::State,
St::SteamId: game_popularity_state::IsUnset,
{
pub fn steam_id(
mut self,
value: impl Into<S>,
) -> GamePopularityBuilder<game_popularity_state::SetSteamId<St>, S> {
self._fields.1 = Option::Some(value.into());
GamePopularityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> GamePopularityBuilder<St, S>
where
St: game_popularity_state::State,
St::Ccu: game_popularity_state::IsSet,
St::SteamId: game_popularity_state::IsSet,
{
pub fn build(self) -> GamePopularity<S> {
GamePopularity {
ccu: self._fields.0.unwrap(),
steam_id: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> GamePopularity<S> {
GamePopularity {
ccu: self._fields.0.unwrap(),
steam_id: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_games_gamesgamesgamesgames_putPopularity() -> 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.putPopularity"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("gamePopularity"),
LexUserType::Object(LexObject {
required: Some(
vec![SmolStr::new_static("steamId"), SmolStr::new_static("ccu")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("ccu"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("steamId"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Steam app ID.")),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
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("games")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("games"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"List of games with popularity data to upsert.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#gamePopularity"),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod put_popularity_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Games;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Games = Unset;
}
pub struct SetGames<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetGames<St> {}
impl<St: State> State for SetGames<St> {
type Games = Set<members::games>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct games(());
}
}
pub struct PutPopularityBuilder<
St: put_popularity_state::State,
S: BosStr = DefaultStr,
> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<put_popularity::GamePopularity<S>>>,),
_type: PhantomData<fn() -> S>,
}
impl PutPopularity<DefaultStr> {
pub fn new() -> PutPopularityBuilder<put_popularity_state::Empty, DefaultStr> {
PutPopularityBuilder::new()
}
}
impl<S: BosStr> PutPopularity<S> {
pub fn builder() -> PutPopularityBuilder<put_popularity_state::Empty, S> {
PutPopularityBuilder::builder()
}
}
impl PutPopularityBuilder<put_popularity_state::Empty, DefaultStr> {
pub fn new() -> Self {
PutPopularityBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr> PutPopularityBuilder<put_popularity_state::Empty, S> {
pub fn builder() -> Self {
PutPopularityBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> PutPopularityBuilder<St, S>
where
St: put_popularity_state::State,
St::Games: put_popularity_state::IsUnset,
{
pub fn games(
mut self,
value: impl Into<Vec<put_popularity::GamePopularity<S>>>,
) -> PutPopularityBuilder<put_popularity_state::SetGames<St>, S> {
self._fields.0 = Option::Some(value.into());
PutPopularityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> PutPopularityBuilder<St, S>
where
St: put_popularity_state::State,
St::Games: put_popularity_state::IsSet,
{
pub fn build(self) -> PutPopularity<S> {
PutPopularity {
games: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> PutPopularity<S> {
PutPopularity {
games: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}