// @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_common::{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::com_atproto::admin::RepoBlobRef;
use crate::com_atproto::admin::RepoRef;
use crate::com_atproto::admin::StatusAttr;
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 UpdateSubjectStatus<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub deactivated: Option<StatusAttr<S>>,
    pub subject: UpdateSubjectStatusSubject<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub takedown: Option<StatusAttr<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 UpdateSubjectStatusSubject<S: BosStr = DefaultStr> {
    #[serde(rename = "com.atproto.admin.defs#repoRef")]
    RepoRef(Box<RepoRef<S>>),
    #[serde(rename = "com.atproto.repo.strongRef")]
    StrongRef(Box<StrongRef<S>>),
    #[serde(rename = "com.atproto.admin.defs#repoBlobRef")]
    RepoBlobRef(Box<RepoBlobRef<S>>),
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct UpdateSubjectStatusOutput<S: BosStr = DefaultStr> {
    pub subject: UpdateSubjectStatusOutputSubject<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub takedown: Option<StatusAttr<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 UpdateSubjectStatusOutputSubject<S: BosStr = DefaultStr> {
    #[serde(rename = "com.atproto.admin.defs#repoRef")]
    RepoRef(Box<RepoRef<S>>),
    #[serde(rename = "com.atproto.repo.strongRef")]
    StrongRef(Box<StrongRef<S>>),
    #[serde(rename = "com.atproto.admin.defs#repoBlobRef")]
    RepoBlobRef(Box<RepoBlobRef<S>>),
}

/** Response marker for the `com.atproto.admin.updateSubjectStatus` procedure.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `UpdateSubjectStatusOutput<S>` for this endpoint.*/
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<S: BosStr> = UpdateSubjectStatusOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for UpdateSubjectStatus<S> {
    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 marker for the `com.atproto.admin.updateSubjectStatus` procedure.

Path: `/xrpc/com.atproto.admin.updateSubjectStatus`. The request payload type is `UpdateSubjectStatus<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
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<S: BosStr> = UpdateSubjectStatus<S>;
    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<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSubject<St> {}
    impl<St: State> State for SetSubject<St> {
        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<
    St: update_subject_status_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<StatusAttr<S>>,
        Option<UpdateSubjectStatusSubject<S>>,
        Option<StatusAttr<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

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

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

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

impl<
    St: update_subject_status_state::State,
    S: BosStr,
> UpdateSubjectStatusBuilder<St, S> {
    /// Set the `deactivated` field (optional)
    pub fn deactivated(mut self, value: impl Into<Option<StatusAttr<S>>>) -> 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<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

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

impl<
    St: update_subject_status_state::State,
    S: BosStr,
> UpdateSubjectStatusBuilder<St, S> {
    /// Set the `takedown` field (optional)
    pub fn takedown(mut self, value: impl Into<Option<StatusAttr<S>>>) -> 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<S>>) -> Self {
        self._fields.2 = value;
        self
    }
}

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