// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: chat.bsky.group.getJoinLinkPreviews
//
// 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};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use serde::{Serialize, Deserialize};
use crate::chat_bsky::group::DisabledJoinLinkPreviewView;
use crate::chat_bsky::group::InvalidJoinLinkPreviewView;
use crate::chat_bsky::group::JoinLinkPreviewView;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetJoinLinkPreviews<S: BosStr = DefaultStr> {
    pub codes: Vec<S>,
}


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


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum GetJoinLinkPreviewsOutputJoinLinkPreviewsItem<S: BosStr = DefaultStr> {
    #[serde(rename = "chat.bsky.group.defs#joinLinkPreviewView")]
    JoinLinkPreviewView(Box<JoinLinkPreviewView<S>>),
    #[serde(rename = "chat.bsky.group.defs#disabledJoinLinkPreviewView")]
    DisabledJoinLinkPreviewView(Box<DisabledJoinLinkPreviewView<S>>),
    #[serde(rename = "chat.bsky.group.defs#invalidJoinLinkPreviewView")]
    InvalidJoinLinkPreviewView(Box<InvalidJoinLinkPreviewView<S>>),
}

/** Response marker for the `chat.bsky.group.getJoinLinkPreviews` query.

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

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetJoinLinkPreviews<S> {
    const NSID: &'static str = "chat.bsky.group.getJoinLinkPreviews";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetJoinLinkPreviewsResponse;
}

/** Endpoint marker for the `chat.bsky.group.getJoinLinkPreviews` query.

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

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

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

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

impl<S: BosStr> GetJoinLinkPreviews<S> {
    /// Create a new builder for this type
    pub fn builder() -> GetJoinLinkPreviewsBuilder<
        get_join_link_previews_state::Empty,
        S,
    > {
        GetJoinLinkPreviewsBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> GetJoinLinkPreviewsBuilder<St, S>
where
    St: get_join_link_previews_state::State,
    St::Codes: get_join_link_previews_state::IsUnset,
{
    /// Set the `codes` field (required)
    pub fn codes(
        mut self,
        value: impl Into<Vec<S>>,
    ) -> GetJoinLinkPreviewsBuilder<get_join_link_previews_state::SetCodes<St>, S> {
        self._fields.0 = Option::Some(value.into());
        GetJoinLinkPreviewsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> GetJoinLinkPreviewsBuilder<St, S>
where
    St: get_join_link_previews_state::State,
    St::Codes: get_join_link_previews_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> GetJoinLinkPreviews<S> {
        GetJoinLinkPreviews {
            codes: self._fields.0.unwrap(),
        }
    }
}