// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.bsky.graph.getStarterPacksWithMembership
//
// 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::ident::AtIdentifier;
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::app_bsky::graph::ListItemView;
use crate::app_bsky::graph::StarterPackView;
use crate::app_bsky::graph::get_starter_packs_with_membership;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetStarterPacksWithMembership<S: BosStr = DefaultStr> {
    pub actor: AtIdentifier<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cursor: Option<S>,
    /// Defaults to `50`. Min: 1. Max: 100.
    #[serde(default = "_default_limit")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetStarterPacksWithMembershipOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cursor: Option<S>,
    pub starter_packs_with_membership: Vec<
        get_starter_packs_with_membership::StarterPackWithMembership<S>,
    >,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A starter pack and an optional list item indicating membership of a target user to that starter pack.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct StarterPackWithMembership<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub list_item: Option<ListItemView<S>>,
    pub starter_pack: StarterPackView<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/** Response marker for the `app.bsky.graph.getStarterPacksWithMembership` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetStarterPacksWithMembershipOutput<S>` for this endpoint.*/
pub struct GetStarterPacksWithMembershipResponse;
impl jacquard_common::xrpc::XrpcResp for GetStarterPacksWithMembershipResponse {
    const NSID: &'static str = "app.bsky.graph.getStarterPacksWithMembership";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = GetStarterPacksWithMembershipOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetStarterPacksWithMembership<S> {
    const NSID: &'static str = "app.bsky.graph.getStarterPacksWithMembership";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetStarterPacksWithMembershipResponse;
}

/** Endpoint marker for the `app.bsky.graph.getStarterPacksWithMembership` query.

Path: `/xrpc/app.bsky.graph.getStarterPacksWithMembership`. The request payload type is `GetStarterPacksWithMembership<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
pub struct GetStarterPacksWithMembershipRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetStarterPacksWithMembershipRequest {
    const PATH: &'static str = "/xrpc/app.bsky.graph.getStarterPacksWithMembership";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<S: BosStr> = GetStarterPacksWithMembership<S>;
    type Response = GetStarterPacksWithMembershipResponse;
}

impl<S: BosStr> LexiconSchema for StarterPackWithMembership<S> {
    fn nsid() -> &'static str {
        "app.bsky.graph.getStarterPacksWithMembership"
    }
    fn def_name() -> &'static str {
        "starterPackWithMembership"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_graph_getStarterPacksWithMembership()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn _default_limit() -> Option<i64> {
    Some(50i64)
}

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

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

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

impl<S: BosStr> GetStarterPacksWithMembership<S> {
    /// Create a new builder for this type
    pub fn builder() -> GetStarterPacksWithMembershipBuilder<
        get_starter_packs_with_membership_state::Empty,
        S,
    > {
        GetStarterPacksWithMembershipBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> GetStarterPacksWithMembershipBuilder<St, S>
where
    St: get_starter_packs_with_membership_state::State,
    St::Actor: get_starter_packs_with_membership_state::IsUnset,
{
    /// Set the `actor` field (required)
    pub fn actor(
        mut self,
        value: impl Into<AtIdentifier<S>>,
    ) -> GetStarterPacksWithMembershipBuilder<
        get_starter_packs_with_membership_state::SetActor<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        GetStarterPacksWithMembershipBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<
    St: get_starter_packs_with_membership_state::State,
    S: BosStr,
> GetStarterPacksWithMembershipBuilder<St, S> {
    /// Set the `cursor` field (optional)
    pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `cursor` field to an Option value (optional)
    pub fn maybe_cursor(mut self, value: Option<S>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<
    St: get_starter_packs_with_membership_state::State,
    S: BosStr,
> GetStarterPacksWithMembershipBuilder<St, S> {
    /// Set the `limit` field (optional)
    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `limit` field to an Option value (optional)
    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> GetStarterPacksWithMembershipBuilder<St, S>
where
    St: get_starter_packs_with_membership_state::State,
    St::Actor: get_starter_packs_with_membership_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> GetStarterPacksWithMembership<S> {
        GetStarterPacksWithMembership {
            actor: self._fields.0.unwrap(),
            cursor: self._fields.1,
            limit: self._fields.2,
        }
    }
}

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

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

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

impl<S: BosStr> StarterPackWithMembership<S> {
    /// Create a new builder for this type
    pub fn builder() -> StarterPackWithMembershipBuilder<
        starter_pack_with_membership_state::Empty,
        S,
    > {
        StarterPackWithMembershipBuilder::builder()
    }
}

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

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

impl<
    St: starter_pack_with_membership_state::State,
    S: BosStr,
> StarterPackWithMembershipBuilder<St, S> {
    /// Set the `listItem` field (optional)
    pub fn list_item(mut self, value: impl Into<Option<ListItemView<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `listItem` field to an Option value (optional)
    pub fn maybe_list_item(mut self, value: Option<ListItemView<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> StarterPackWithMembershipBuilder<St, S>
where
    St: starter_pack_with_membership_state::State,
    St::StarterPack: starter_pack_with_membership_state::IsUnset,
{
    /// Set the `starterPack` field (required)
    pub fn starter_pack(
        mut self,
        value: impl Into<StarterPackView<S>>,
    ) -> StarterPackWithMembershipBuilder<
        starter_pack_with_membership_state::SetStarterPack<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        StarterPackWithMembershipBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> StarterPackWithMembershipBuilder<St, S>
where
    St: starter_pack_with_membership_state::State,
    St::StarterPack: starter_pack_with_membership_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> StarterPackWithMembership<S> {
        StarterPackWithMembership {
            list_item: self._fields.0,
            starter_pack: self._fields.1.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>>,
    ) -> StarterPackWithMembership<S> {
        StarterPackWithMembership {
            list_item: self._fields.0,
            starter_pack: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_bsky_graph_getStarterPacksWithMembership() -> 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("app.bsky.graph.getStarterPacksWithMembership"),
        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("actor")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("actor"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static(
                                                "The account (actor) to check for membership.",
                                            ),
                                        ),
                                        format: Some(LexStringFormat::AtIdentifier),
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("cursor"),
                                    LexXrpcParametersProperty::String(LexString {
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("limit"),
                                    LexXrpcParametersProperty::Integer(LexInteger {
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("starterPackWithMembership"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A starter pack and an optional list item indicating membership of a target user to that starter pack.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("starterPack")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("listItem"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.graph.defs#listItemView",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("starterPack"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.graph.defs#starterPackView",
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}