// @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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::ident::AtIdentifier;
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::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")]
pub struct GetStarterPacksWithMembership<'a> {
    #[serde(borrow)]
    pub actor: AtIdentifier<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cursor: Option<CowStr<'a>>,
    ///Defaults to `50`. Min: 1. Max: 100.
    #[serde(default = "_default_limit")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetStarterPacksWithMembershipOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cursor: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub starter_packs_with_membership: Vec<
        get_starter_packs_with_membership::StarterPackWithMembership<'a>,
    >,
}

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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct StarterPackWithMembership<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub list_item: Option<ListItemView<'a>>,
    #[serde(borrow)]
    pub starter_pack: StarterPackView<'a>,
}

/// Response type for app.bsky.graph.getStarterPacksWithMembership
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<'de> = GetStarterPacksWithMembershipOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

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

/// Endpoint type for app.bsky.graph.getStarterPacksWithMembership
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<'de> = GetStarterPacksWithMembership<'de>;
    type Response = GetStarterPacksWithMembershipResponse;
}

impl<'a> LexiconSchema for StarterPackWithMembership<'a> {
    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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetActor<S> {}
    impl<S: State> State for SetActor<S> {
        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<
    'a,
    S: get_starter_packs_with_membership_state::State,
> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<AtIdentifier<'a>>, Option<CowStr<'a>>, Option<i64>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<
    'a,
    S: get_starter_packs_with_membership_state::State,
> GetStarterPacksWithMembershipBuilder<'a, 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<'a, S> GetStarterPacksWithMembershipBuilder<'a, S>
where
    S: get_starter_packs_with_membership_state::State,
    S::Actor: get_starter_packs_with_membership_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> GetStarterPacksWithMembership<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetStarterPack<S> {}
    impl<S: State> State for SetStarterPack<S> {
        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<
    'a,
    S: starter_pack_with_membership_state::State,
> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<ListItemView<'a>>, Option<StarterPackView<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

impl<
    'a,
    S: starter_pack_with_membership_state::State,
> StarterPackWithMembershipBuilder<'a, S> {
    /// Set the `listItem` field (optional)
    pub fn list_item(mut self, value: impl Into<Option<ListItemView<'a>>>) -> 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<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

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

impl<'a, S> StarterPackWithMembershipBuilder<'a, S>
where
    S: starter_pack_with_membership_state::State,
    S::StarterPack: starter_pack_with_membership_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> StarterPackWithMembership<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> StarterPackWithMembership<'a> {
        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()
    }
}