#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Did, AtUri, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, lexicon};
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::get_reviews;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetReviews<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cursor: Option<CowStr<'a>>,
#[serde(default = "_default_limit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(borrow)]
pub uri: AtUri<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetReviewsOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cursor: Option<CowStr<'a>>,
#[serde(borrow)]
pub reviews: Vec<get_reviews::PopfeedReview<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct PopfeedReview<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub contains_spoilers: Option<bool>,
pub created_at: Datetime,
#[serde(borrow)]
pub did: Did<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub facets: Option<Vec<Data<'a>>>,
pub rating: i64,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub tags: Option<Vec<CowStr<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub text: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub title: Option<CowStr<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
}
pub struct GetReviewsResponse;
impl jacquard_common::xrpc::XrpcResp for GetReviewsResponse {
const NSID: &'static str = "games.gamesgamesgamesgames.getReviews";
const ENCODING: &'static str = "application/json";
type Output<'de> = GetReviewsOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetReviews<'a> {
const NSID: &'static str = "games.gamesgamesgamesgames.getReviews";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetReviewsResponse;
}
pub struct GetReviewsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetReviewsRequest {
const PATH: &'static str = "/xrpc/games.gamesgamesgamesgames.getReviews";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = GetReviews<'de>;
type Response = GetReviewsResponse;
}
impl<'a> LexiconSchema for PopfeedReview<'a> {
fn nsid() -> &'static str {
"games.gamesgamesgamesgames.getReviews"
}
fn def_name() -> &'static str {
"popfeedReview"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_games_gamesgamesgamesgames_getReviews()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.rating;
if *value > 10i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("rating"),
max: 10i64,
actual: *value,
});
}
}
{
let value = &self.rating;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("rating"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
fn _default_limit() -> Option<i64> {
Some(20i64)
}
pub mod get_reviews_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 Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
}
pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct GetReviewsBuilder<'a, S: get_reviews_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<i64>, Option<AtUri<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GetReviews<'a> {
pub fn new() -> GetReviewsBuilder<'a, get_reviews_state::Empty> {
GetReviewsBuilder::new()
}
}
impl<'a> GetReviewsBuilder<'a, get_reviews_state::Empty> {
pub fn new() -> Self {
GetReviewsBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: get_reviews_state::State> GetReviewsBuilder<'a, S> {
pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: get_reviews_state::State> GetReviewsBuilder<'a, S> {
pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> GetReviewsBuilder<'a, S>
where
S: get_reviews_state::State,
S::Uri: get_reviews_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<'a>>,
) -> GetReviewsBuilder<'a, get_reviews_state::SetUri<S>> {
self._fields.2 = Option::Some(value.into());
GetReviewsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetReviewsBuilder<'a, S>
where
S: get_reviews_state::State,
S::Uri: get_reviews_state::IsSet,
{
pub fn build(self) -> GetReviews<'a> {
GetReviews {
cursor: self._fields.0,
limit: self._fields.1,
uri: self._fields.2.unwrap(),
}
}
}
pub mod popfeed_review_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 Uri;
type Did;
type Rating;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
type Did = Unset;
type Rating = Unset;
type CreatedAt = Unset;
}
pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Uri = Set<members::uri>;
type Did = S::Did;
type Rating = S::Rating;
type CreatedAt = S::CreatedAt;
}
pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDid<S> {}
impl<S: State> State for SetDid<S> {
type Uri = S::Uri;
type Did = Set<members::did>;
type Rating = S::Rating;
type CreatedAt = S::CreatedAt;
}
pub struct SetRating<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRating<S> {}
impl<S: State> State for SetRating<S> {
type Uri = S::Uri;
type Did = S::Did;
type Rating = Set<members::rating>;
type CreatedAt = S::CreatedAt;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type Uri = S::Uri;
type Did = S::Did;
type Rating = S::Rating;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
pub struct did(());
pub struct rating(());
pub struct created_at(());
}
}
pub struct PopfeedReviewBuilder<'a, S: popfeed_review_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<bool>,
Option<Datetime>,
Option<Did<'a>>,
Option<Vec<Data<'a>>>,
Option<i64>,
Option<Vec<CowStr<'a>>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<AtUri<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> PopfeedReview<'a> {
pub fn new() -> PopfeedReviewBuilder<'a, popfeed_review_state::Empty> {
PopfeedReviewBuilder::new()
}
}
impl<'a> PopfeedReviewBuilder<'a, popfeed_review_state::Empty> {
pub fn new() -> Self {
PopfeedReviewBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: popfeed_review_state::State> PopfeedReviewBuilder<'a, S> {
pub fn contains_spoilers(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_contains_spoilers(mut self, value: Option<bool>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> PopfeedReviewBuilder<'a, S>
where
S: popfeed_review_state::State,
S::CreatedAt: popfeed_review_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> PopfeedReviewBuilder<'a, popfeed_review_state::SetCreatedAt<S>> {
self._fields.1 = Option::Some(value.into());
PopfeedReviewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PopfeedReviewBuilder<'a, S>
where
S: popfeed_review_state::State,
S::Did: popfeed_review_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<'a>>,
) -> PopfeedReviewBuilder<'a, popfeed_review_state::SetDid<S>> {
self._fields.2 = Option::Some(value.into());
PopfeedReviewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: popfeed_review_state::State> PopfeedReviewBuilder<'a, S> {
pub fn facets(mut self, value: impl Into<Option<Vec<Data<'a>>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_facets(mut self, value: Option<Vec<Data<'a>>>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S> PopfeedReviewBuilder<'a, S>
where
S: popfeed_review_state::State,
S::Rating: popfeed_review_state::IsUnset,
{
pub fn rating(
mut self,
value: impl Into<i64>,
) -> PopfeedReviewBuilder<'a, popfeed_review_state::SetRating<S>> {
self._fields.4 = Option::Some(value.into());
PopfeedReviewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: popfeed_review_state::State> PopfeedReviewBuilder<'a, S> {
pub fn tags(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_tags(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S: popfeed_review_state::State> PopfeedReviewBuilder<'a, S> {
pub fn text(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_text(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S: popfeed_review_state::State> PopfeedReviewBuilder<'a, S> {
pub fn title(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_title(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.7 = value;
self
}
}
impl<'a, S> PopfeedReviewBuilder<'a, S>
where
S: popfeed_review_state::State,
S::Uri: popfeed_review_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<'a>>,
) -> PopfeedReviewBuilder<'a, popfeed_review_state::SetUri<S>> {
self._fields.8 = Option::Some(value.into());
PopfeedReviewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PopfeedReviewBuilder<'a, S>
where
S: popfeed_review_state::State,
S::Uri: popfeed_review_state::IsSet,
S::Did: popfeed_review_state::IsSet,
S::Rating: popfeed_review_state::IsSet,
S::CreatedAt: popfeed_review_state::IsSet,
{
pub fn build(self) -> PopfeedReview<'a> {
PopfeedReview {
contains_spoilers: self._fields.0,
created_at: self._fields.1.unwrap(),
did: self._fields.2.unwrap(),
facets: self._fields.3,
rating: self._fields.4.unwrap(),
tags: self._fields.5,
text: self._fields.6,
title: self._fields.7,
uri: self._fields.8.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> PopfeedReview<'a> {
PopfeedReview {
contains_spoilers: self._fields.0,
created_at: self._fields.1.unwrap(),
did: self._fields.2.unwrap(),
facets: self._fields.3,
rating: self._fields.4.unwrap(),
tags: self._fields.5,
text: self._fields.6,
title: self._fields.7,
uri: self._fields.8.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_games_gamesgamesgamesgames_getReviews() -> 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.getReviews"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(
LexXrpcQueryParameter::Params(LexXrpcParameters {
required: Some(vec![SmolStr::new_static("uri")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cursor"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static("Pagination cursor (offset)."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("limit"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static("AT URI of the game record."),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("popfeedReview"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("uri"), SmolStr::new_static("did"),
SmolStr::new_static("rating"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("containsSpoilers"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("facets"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("social.popfeed.richtext.facet"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rating"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
maximum: Some(10i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tags"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}