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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct UpdateActorAccess<'a> {
    #[serde(borrow)]
    pub actor: Did<'a>,
    pub allow_access: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub r#ref: Option<CowStr<'a>>,
}

/// Response type for chat.bsky.moderation.updateActorAccess
pub struct UpdateActorAccessResponse;
impl jacquard_common::xrpc::XrpcResp for UpdateActorAccessResponse {
    const NSID: &'static str = "chat.bsky.moderation.updateActorAccess";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = ();
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for UpdateActorAccess<'a> {
    const NSID: &'static str = "chat.bsky.moderation.updateActorAccess";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = UpdateActorAccessResponse;
}

/// Endpoint type for chat.bsky.moderation.updateActorAccess
pub struct UpdateActorAccessRequest;
impl jacquard_common::xrpc::XrpcEndpoint for UpdateActorAccessRequest {
    const PATH: &'static str = "/xrpc/chat.bsky.moderation.updateActorAccess";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<'de> = UpdateActorAccess<'de>;
    type Response = UpdateActorAccessResponse;
}

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

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

impl<'a> UpdateActorAccess<'a> {
    /// Create a new builder for this type
    pub fn new() -> UpdateActorAccessBuilder<'a, update_actor_access_state::Empty> {
        UpdateActorAccessBuilder::new()
    }
}

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

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

impl<'a, S> UpdateActorAccessBuilder<'a, S>
where
    S: update_actor_access_state::State,
    S::AllowAccess: update_actor_access_state::IsUnset,
{
    /// Set the `allowAccess` field (required)
    pub fn allow_access(
        mut self,
        value: impl Into<bool>,
    ) -> UpdateActorAccessBuilder<'a, update_actor_access_state::SetAllowAccess<S>> {
        self._fields.1 = Option::Some(value.into());
        UpdateActorAccessBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: update_actor_access_state::State> UpdateActorAccessBuilder<'a, S> {
    /// Set the `ref` field (optional)
    pub fn r#ref(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `ref` field to an Option value (optional)
    pub fn maybe_ref(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S> UpdateActorAccessBuilder<'a, S>
where
    S: update_actor_access_state::State,
    S::AllowAccess: update_actor_access_state::IsSet,
    S::Actor: update_actor_access_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> UpdateActorAccess<'a> {
        UpdateActorAccess {
            actor: self._fields.0.unwrap(),
            allow_access: self._fields.1.unwrap(),
            r#ref: self._fields.2,
            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>,
        >,
    ) -> UpdateActorAccess<'a> {
        UpdateActorAccess {
            actor: self._fields.0.unwrap(),
            allow_access: self._fields.1.unwrap(),
            r#ref: self._fields.2,
            extra_data: Some(extra_data),
        }
    }
}