// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: com.atproto.admin.updateSubjectStatus
//
// 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_derive::{IntoStatic, lexicon, open_union};
use serde::{Serialize, Deserialize};
use crate::com_atproto::admin::RepoBlobRef;
use crate::com_atproto::admin::RepoRef;
use crate::com_atproto::admin::StatusAttr;
use crate::com_atproto::repo::strong_ref::StrongRef;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct UpdateSubjectStatus<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub deactivated: Option<StatusAttr<'a>>,
    #[serde(borrow)]
    pub subject: UpdateSubjectStatusSubject<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub takedown: Option<StatusAttr<'a>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum UpdateSubjectStatusSubject<'a> {
    #[serde(rename = "com.atproto.admin.defs#repoRef")]
    RepoRef(Box<RepoRef<'a>>),
    #[serde(rename = "com.atproto.repo.strongRef")]
    StrongRef(Box<StrongRef<'a>>),
    #[serde(rename = "com.atproto.admin.defs#repoBlobRef")]
    RepoBlobRef(Box<RepoBlobRef<'a>>),
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct UpdateSubjectStatusOutput<'a> {
    #[serde(borrow)]
    pub subject: UpdateSubjectStatusOutputSubject<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub takedown: Option<StatusAttr<'a>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum UpdateSubjectStatusOutputSubject<'a> {
    #[serde(rename = "com.atproto.admin.defs#repoRef")]
    RepoRef(Box<RepoRef<'a>>),
    #[serde(rename = "com.atproto.repo.strongRef")]
    StrongRef(Box<StrongRef<'a>>),
    #[serde(rename = "com.atproto.admin.defs#repoBlobRef")]
    RepoBlobRef(Box<RepoBlobRef<'a>>),
}

/// Response type for com.atproto.admin.updateSubjectStatus
pub struct UpdateSubjectStatusResponse;
impl jacquard_common::xrpc::XrpcResp for UpdateSubjectStatusResponse {
    const NSID: &'static str = "com.atproto.admin.updateSubjectStatus";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = UpdateSubjectStatusOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for UpdateSubjectStatus<'a> {
    const NSID: &'static str = "com.atproto.admin.updateSubjectStatus";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = UpdateSubjectStatusResponse;
}

/// Endpoint type for com.atproto.admin.updateSubjectStatus
pub struct UpdateSubjectStatusRequest;
impl jacquard_common::xrpc::XrpcEndpoint for UpdateSubjectStatusRequest {
    const PATH: &'static str = "/xrpc/com.atproto.admin.updateSubjectStatus";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<'de> = UpdateSubjectStatus<'de>;
    type Response = UpdateSubjectStatusResponse;
}

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

/// Builder for constructing an instance of this type
pub struct UpdateSubjectStatusBuilder<'a, S: update_subject_status_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<StatusAttr<'a>>,
        Option<UpdateSubjectStatusSubject<'a>>,
        Option<StatusAttr<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> UpdateSubjectStatus<'a> {
    /// Create a new builder for this type
    pub fn new() -> UpdateSubjectStatusBuilder<'a, update_subject_status_state::Empty> {
        UpdateSubjectStatusBuilder::new()
    }
}

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

impl<'a, S: update_subject_status_state::State> UpdateSubjectStatusBuilder<'a, S> {
    /// Set the `deactivated` field (optional)
    pub fn deactivated(mut self, value: impl Into<Option<StatusAttr<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `deactivated` field to an Option value (optional)
    pub fn maybe_deactivated(mut self, value: Option<StatusAttr<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> UpdateSubjectStatusBuilder<'a, S>
where
    S: update_subject_status_state::State,
    S::Subject: update_subject_status_state::IsUnset,
{
    /// Set the `subject` field (required)
    pub fn subject(
        mut self,
        value: impl Into<UpdateSubjectStatusSubject<'a>>,
    ) -> UpdateSubjectStatusBuilder<'a, update_subject_status_state::SetSubject<S>> {
        self._fields.1 = Option::Some(value.into());
        UpdateSubjectStatusBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: update_subject_status_state::State> UpdateSubjectStatusBuilder<'a, S> {
    /// Set the `takedown` field (optional)
    pub fn takedown(mut self, value: impl Into<Option<StatusAttr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `takedown` field to an Option value (optional)
    pub fn maybe_takedown(mut self, value: Option<StatusAttr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S> UpdateSubjectStatusBuilder<'a, S>
where
    S: update_subject_status_state::State,
    S::Subject: update_subject_status_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> UpdateSubjectStatus<'a> {
        UpdateSubjectStatus {
            deactivated: self._fields.0,
            subject: self._fields.1.unwrap(),
            takedown: 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>,
        >,
    ) -> UpdateSubjectStatus<'a> {
        UpdateSubjectStatus {
            deactivated: self._fields.0,
            subject: self._fields.1.unwrap(),
            takedown: self._fields.2,
            extra_data: Some(extra_data),
        }
    }
}