// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: chat.bsky.convo.getConvoForMembers
//
// 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::types::string::Did;
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
use crate::chat_bsky::convo::ConvoView;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetConvoForMembers<'a> {
    #[serde(borrow)]
    pub members: Vec<Did<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetConvoForMembersOutput<'a> {
    #[serde(borrow)]
    pub convo: ConvoView<'a>,
}

/// Response type for chat.bsky.convo.getConvoForMembers
pub struct GetConvoForMembersResponse;
impl jacquard_common::xrpc::XrpcResp for GetConvoForMembersResponse {
    const NSID: &'static str = "chat.bsky.convo.getConvoForMembers";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GetConvoForMembersOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for GetConvoForMembers<'a> {
    const NSID: &'static str = "chat.bsky.convo.getConvoForMembers";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetConvoForMembersResponse;
}

/// Endpoint type for chat.bsky.convo.getConvoForMembers
pub struct GetConvoForMembersRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetConvoForMembersRequest {
    const PATH: &'static str = "/xrpc/chat.bsky.convo.getConvoForMembers";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetConvoForMembers<'de>;
    type Response = GetConvoForMembersResponse;
}

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

/// Builder for constructing an instance of this type
pub struct GetConvoForMembersBuilder<'a, S: get_convo_for_members_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<Did<'a>>>,),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> GetConvoForMembers<'a> {
    /// Create a new builder for this type
    pub fn new() -> GetConvoForMembersBuilder<'a, get_convo_for_members_state::Empty> {
        GetConvoForMembersBuilder::new()
    }
}

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

impl<'a, S> GetConvoForMembersBuilder<'a, S>
where
    S: get_convo_for_members_state::State,
    S::Members: get_convo_for_members_state::IsUnset,
{
    /// Set the `members` field (required)
    pub fn members(
        mut self,
        value: impl Into<Vec<Did<'a>>>,
    ) -> GetConvoForMembersBuilder<'a, get_convo_for_members_state::SetMembers<S>> {
        self._fields.0 = Option::Some(value.into());
        GetConvoForMembersBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> GetConvoForMembersBuilder<'a, S>
where
    S: get_convo_for_members_state::State,
    S::Members: get_convo_for_members_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> GetConvoForMembers<'a> {
        GetConvoForMembers {
            members: self._fields.0.unwrap(),
        }
    }
}