// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: com.atproto.admin.getSubjectStatus
//
// 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, AtUri, Cid};
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;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetSubjectStatus<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub blob: Option<Cid<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub did: Option<Did<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub uri: Option<AtUri<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetSubjectStatusOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub deactivated: Option<StatusAttr<'a>>,
    #[serde(borrow)]
    pub subject: GetSubjectStatusOutputSubject<'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 GetSubjectStatusOutputSubject<'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.getSubjectStatus
pub struct GetSubjectStatusResponse;
impl jacquard_common::xrpc::XrpcResp for GetSubjectStatusResponse {
    const NSID: &'static str = "com.atproto.admin.getSubjectStatus";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GetSubjectStatusOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for GetSubjectStatus<'a> {
    const NSID: &'static str = "com.atproto.admin.getSubjectStatus";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetSubjectStatusResponse;
}

/// Endpoint type for com.atproto.admin.getSubjectStatus
pub struct GetSubjectStatusRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetSubjectStatusRequest {
    const PATH: &'static str = "/xrpc/com.atproto.admin.getSubjectStatus";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetSubjectStatus<'de>;
    type Response = GetSubjectStatusResponse;
}

pub mod get_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 {}
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {}
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {}
}

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

impl<'a> GetSubjectStatus<'a> {
    /// Create a new builder for this type
    pub fn new() -> GetSubjectStatusBuilder<'a, get_subject_status_state::Empty> {
        GetSubjectStatusBuilder::new()
    }
}

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

impl<'a, S: get_subject_status_state::State> GetSubjectStatusBuilder<'a, S> {
    /// Set the `blob` field (optional)
    pub fn blob(mut self, value: impl Into<Option<Cid<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `blob` field to an Option value (optional)
    pub fn maybe_blob(mut self, value: Option<Cid<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: get_subject_status_state::State> GetSubjectStatusBuilder<'a, S> {
    /// Set the `did` field (optional)
    pub fn did(mut self, value: impl Into<Option<Did<'a>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `did` field to an Option value (optional)
    pub fn maybe_did(mut self, value: Option<Did<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: get_subject_status_state::State> GetSubjectStatusBuilder<'a, S> {
    /// Set the `uri` field (optional)
    pub fn uri(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `uri` field to an Option value (optional)
    pub fn maybe_uri(mut self, value: Option<AtUri<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S> GetSubjectStatusBuilder<'a, S>
where
    S: get_subject_status_state::State,
{
    /// Build the final struct
    pub fn build(self) -> GetSubjectStatus<'a> {
        GetSubjectStatus {
            blob: self._fields.0,
            did: self._fields.1,
            uri: self._fields.2,
        }
    }
}