// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: place.stream.graph.getFollowingUser
//
// 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::{BosStr, DefaultStr, FromStaticStr};
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Did;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use serde::{Serialize, Deserialize};
use crate::com_atproto::repo::strong_ref::StrongRef;

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


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

/** Response marker for the `place.stream.graph.getFollowingUser` query.

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

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetFollowingUser<S> {
    const NSID: &'static str = "place.stream.graph.getFollowingUser";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetFollowingUserResponse;
}

/** Endpoint marker for the `place.stream.graph.getFollowingUser` query.

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

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

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

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

impl<S: BosStr> GetFollowingUser<S> {
    /// Create a new builder for this type
    pub fn builder() -> GetFollowingUserBuilder<get_following_user_state::Empty, S> {
        GetFollowingUserBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> GetFollowingUserBuilder<St, S>
where
    St: get_following_user_state::State,
    St::SubjectDid: get_following_user_state::IsUnset,
{
    /// Set the `subjectDID` field (required)
    pub fn subject_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> GetFollowingUserBuilder<get_following_user_state::SetSubjectDid<St>, S> {
        self._fields.0 = Option::Some(value.into());
        GetFollowingUserBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> GetFollowingUserBuilder<St, S>
where
    St: get_following_user_state::State,
    St::UserDid: get_following_user_state::IsUnset,
{
    /// Set the `userDID` field (required)
    pub fn user_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> GetFollowingUserBuilder<get_following_user_state::SetUserDid<St>, S> {
        self._fields.1 = Option::Some(value.into());
        GetFollowingUserBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> GetFollowingUserBuilder<St, S>
where
    St: get_following_user_state::State,
    St::SubjectDid: get_following_user_state::IsSet,
    St::UserDid: get_following_user_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> GetFollowingUser<S> {
        GetFollowingUser {
            subject_did: self._fields.0.unwrap(),
            user_did: self._fields.1.unwrap(),
        }
    }
}