// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: games.gamesgamesgamesgames.feed.describeFeedGenerator
//
// 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, 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::string::{Did, AtUri};
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::feed::describe_feed_generator;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Feed<S: BosStr = DefaultStr> {
    pub uri: AtUri<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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Links<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub privacy_policy: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub terms_of_service: Option<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 DescribeFeedGeneratorOutput<S: BosStr = DefaultStr> {
    pub did: Did<S>,
    pub feeds: Vec<describe_feed_generator::Feed<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub links: Option<describe_feed_generator::Links<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for Feed<S> {
    fn nsid() -> &'static str {
        "games.gamesgamesgamesgames.feed.describeFeedGenerator"
    }
    fn def_name() -> &'static str {
        "feed"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_games_gamesgamesgamesgames_feed_describeFeedGenerator()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Links<S> {
    fn nsid() -> &'static str {
        "games.gamesgamesgamesgames.feed.describeFeedGenerator"
    }
    fn def_name() -> &'static str {
        "links"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_games_gamesgamesgamesgames_feed_describeFeedGenerator()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/** Request marker for the `games.gamesgamesgamesgames.feed.describeFeedGenerator` query.

This endpoint has no request parameters or input body; send this marker with `jacquard::Client`.*/

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
pub struct DescribeFeedGenerator;
/** Response marker for the `games.gamesgamesgamesgames.feed.describeFeedGenerator` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `DescribeFeedGeneratorOutput<S>` for this endpoint.*/
pub struct DescribeFeedGeneratorResponse;
impl jacquard_common::xrpc::XrpcResp for DescribeFeedGeneratorResponse {
    const NSID: &'static str = "games.gamesgamesgamesgames.feed.describeFeedGenerator";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = DescribeFeedGeneratorOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl jacquard_common::xrpc::XrpcRequest for DescribeFeedGenerator {
    const NSID: &'static str = "games.gamesgamesgamesgames.feed.describeFeedGenerator";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = DescribeFeedGeneratorResponse;
}

/** Endpoint marker for the `games.gamesgamesgamesgames.feed.describeFeedGenerator` query.

Path: `/xrpc/games.gamesgamesgamesgames.feed.describeFeedGenerator`. The request payload type is `DescribeFeedGenerator`; use this marker with lower-level `XrpcEndpoint` APIs when you need endpoint metadata.*/
pub struct DescribeFeedGeneratorRequest;
impl jacquard_common::xrpc::XrpcEndpoint for DescribeFeedGeneratorRequest {
    const PATH: &'static str = "/xrpc/games.gamesgamesgamesgames.feed.describeFeedGenerator";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<S: BosStr> = DescribeFeedGenerator;
    type Response = DescribeFeedGeneratorResponse;
}

pub mod feed_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 Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Uri = Unset;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct FeedBuilder<St: feed_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<AtUri<S>>,),
    _type: PhantomData<fn() -> S>,
}

impl Feed<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> FeedBuilder<feed_state::Empty, DefaultStr> {
        FeedBuilder::new()
    }
}

impl<S: BosStr> Feed<S> {
    /// Create a new builder for this type
    pub fn builder() -> FeedBuilder<feed_state::Empty, S> {
        FeedBuilder::builder()
    }
}

impl FeedBuilder<feed_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        FeedBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> FeedBuilder<feed_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        FeedBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FeedBuilder<St, S>
where
    St: feed_state::State,
    St::Uri: feed_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> FeedBuilder<feed_state::SetUri<St>, S> {
        self._fields.0 = Option::Some(value.into());
        FeedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FeedBuilder<St, S>
where
    St: feed_state::State,
    St::Uri: feed_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Feed<S> {
        Feed {
            uri: self._fields.0.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Feed<S> {
        Feed {
            uri: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_games_gamesgamesgamesgames_feed_describeFeedGenerator() -> 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.feed.describeFeedGenerator"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("feed"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("uri")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("links"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("privacyPolicy"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("termsOfService"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: None,
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}