// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: chat.bsky.moderation.getActorMetadata
//
// 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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::Did;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::chat_bsky::moderation::get_actor_metadata;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetActorMetadata<'a> {
    #[serde(borrow)]
    pub actor: Did<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetActorMetadataOutput<'a> {
    #[serde(borrow)]
    pub all: get_actor_metadata::Metadata<'a>,
    #[serde(borrow)]
    pub day: get_actor_metadata::Metadata<'a>,
    #[serde(borrow)]
    pub month: get_actor_metadata::Metadata<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Metadata<'a> {
    pub convos: i64,
    pub convos_started: i64,
    pub messages_received: i64,
    pub messages_sent: i64,
}

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

impl<'a> jacquard_common::xrpc::XrpcRequest for GetActorMetadata<'a> {
    const NSID: &'static str = "chat.bsky.moderation.getActorMetadata";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetActorMetadataResponse;
}

/// Endpoint type for chat.bsky.moderation.getActorMetadata
pub struct GetActorMetadataRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetActorMetadataRequest {
    const PATH: &'static str = "/xrpc/chat.bsky.moderation.getActorMetadata";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetActorMetadata<'de>;
    type Response = GetActorMetadataResponse;
}

impl<'a> LexiconSchema for Metadata<'a> {
    fn nsid() -> &'static str {
        "chat.bsky.moderation.getActorMetadata"
    }
    fn def_name() -> &'static str {
        "metadata"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_chat_bsky_moderation_getActorMetadata()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

impl<'a> GetActorMetadata<'a> {
    /// Create a new builder for this type
    pub fn new() -> GetActorMetadataBuilder<'a, get_actor_metadata_state::Empty> {
        GetActorMetadataBuilder::new()
    }
}

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

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

impl<'a, S> GetActorMetadataBuilder<'a, S>
where
    S: get_actor_metadata_state::State,
    S::Actor: get_actor_metadata_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> GetActorMetadata<'a> {
        GetActorMetadata {
            actor: self._fields.0.unwrap(),
        }
    }
}

pub mod metadata_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 MessagesReceived;
        type MessagesSent;
        type Convos;
        type ConvosStarted;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type MessagesReceived = Unset;
        type MessagesSent = Unset;
        type Convos = Unset;
        type ConvosStarted = Unset;
    }
    ///State transition - sets the `messages_received` field to Set
    pub struct SetMessagesReceived<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMessagesReceived<S> {}
    impl<S: State> State for SetMessagesReceived<S> {
        type MessagesReceived = Set<members::messages_received>;
        type MessagesSent = S::MessagesSent;
        type Convos = S::Convos;
        type ConvosStarted = S::ConvosStarted;
    }
    ///State transition - sets the `messages_sent` field to Set
    pub struct SetMessagesSent<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMessagesSent<S> {}
    impl<S: State> State for SetMessagesSent<S> {
        type MessagesReceived = S::MessagesReceived;
        type MessagesSent = Set<members::messages_sent>;
        type Convos = S::Convos;
        type ConvosStarted = S::ConvosStarted;
    }
    ///State transition - sets the `convos` field to Set
    pub struct SetConvos<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetConvos<S> {}
    impl<S: State> State for SetConvos<S> {
        type MessagesReceived = S::MessagesReceived;
        type MessagesSent = S::MessagesSent;
        type Convos = Set<members::convos>;
        type ConvosStarted = S::ConvosStarted;
    }
    ///State transition - sets the `convos_started` field to Set
    pub struct SetConvosStarted<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetConvosStarted<S> {}
    impl<S: State> State for SetConvosStarted<S> {
        type MessagesReceived = S::MessagesReceived;
        type MessagesSent = S::MessagesSent;
        type Convos = S::Convos;
        type ConvosStarted = Set<members::convos_started>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `messages_received` field
        pub struct messages_received(());
        ///Marker type for the `messages_sent` field
        pub struct messages_sent(());
        ///Marker type for the `convos` field
        pub struct convos(());
        ///Marker type for the `convos_started` field
        pub struct convos_started(());
    }
}

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

impl<'a> Metadata<'a> {
    /// Create a new builder for this type
    pub fn new() -> MetadataBuilder<'a, metadata_state::Empty> {
        MetadataBuilder::new()
    }
}

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

impl<'a, S> MetadataBuilder<'a, S>
where
    S: metadata_state::State,
    S::Convos: metadata_state::IsUnset,
{
    /// Set the `convos` field (required)
    pub fn convos(
        mut self,
        value: impl Into<i64>,
    ) -> MetadataBuilder<'a, metadata_state::SetConvos<S>> {
        self._fields.0 = Option::Some(value.into());
        MetadataBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> MetadataBuilder<'a, S>
where
    S: metadata_state::State,
    S::ConvosStarted: metadata_state::IsUnset,
{
    /// Set the `convosStarted` field (required)
    pub fn convos_started(
        mut self,
        value: impl Into<i64>,
    ) -> MetadataBuilder<'a, metadata_state::SetConvosStarted<S>> {
        self._fields.1 = Option::Some(value.into());
        MetadataBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> MetadataBuilder<'a, S>
where
    S: metadata_state::State,
    S::MessagesReceived: metadata_state::IsUnset,
{
    /// Set the `messagesReceived` field (required)
    pub fn messages_received(
        mut self,
        value: impl Into<i64>,
    ) -> MetadataBuilder<'a, metadata_state::SetMessagesReceived<S>> {
        self._fields.2 = Option::Some(value.into());
        MetadataBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> MetadataBuilder<'a, S>
where
    S: metadata_state::State,
    S::MessagesSent: metadata_state::IsUnset,
{
    /// Set the `messagesSent` field (required)
    pub fn messages_sent(
        mut self,
        value: impl Into<i64>,
    ) -> MetadataBuilder<'a, metadata_state::SetMessagesSent<S>> {
        self._fields.3 = Option::Some(value.into());
        MetadataBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> MetadataBuilder<'a, S>
where
    S: metadata_state::State,
    S::MessagesReceived: metadata_state::IsSet,
    S::MessagesSent: metadata_state::IsSet,
    S::Convos: metadata_state::IsSet,
    S::ConvosStarted: metadata_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Metadata<'a> {
        Metadata {
            convos: self._fields.0.unwrap(),
            convos_started: self._fields.1.unwrap(),
            messages_received: self._fields.2.unwrap(),
            messages_sent: self._fields.3.unwrap(),
            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>,
        >,
    ) -> Metadata<'a> {
        Metadata {
            convos: self._fields.0.unwrap(),
            convos_started: self._fields.1.unwrap(),
            messages_received: self._fields.2.unwrap(),
            messages_sent: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_chat_bsky_moderation_getActorMetadata() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("chat.bsky.moderation.getActorMetadata"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(
                        LexXrpcQueryParameter::Params(LexXrpcParameters {
                            required: Some(vec![SmolStr::new_static("actor")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("actor"),
                                    LexXrpcParametersProperty::String(LexString {
                                        format: Some(LexStringFormat::Did),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("metadata"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("messagesSent"),
                            SmolStr::new_static("messagesReceived"),
                            SmolStr::new_static("convos"),
                            SmolStr::new_static("convosStarted")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("convos"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("convosStarted"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("messagesReceived"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("messagesSent"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}