// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: chat.bsky.convo.getLog
//
// 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_derive::{IntoStatic, lexicon, open_union};
use serde::{Serialize, Deserialize};
use crate::chat_bsky::convo::LogAcceptConvo;
use crate::chat_bsky::convo::LogAddReaction;
use crate::chat_bsky::convo::LogBeginConvo;
use crate::chat_bsky::convo::LogCreateMessage;
use crate::chat_bsky::convo::LogDeleteMessage;
use crate::chat_bsky::convo::LogLeaveConvo;
use crate::chat_bsky::convo::LogMuteConvo;
use crate::chat_bsky::convo::LogReadMessage;
use crate::chat_bsky::convo::LogRemoveReaction;
use crate::chat_bsky::convo::LogUnmuteConvo;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetLog<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cursor: Option<CowStr<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetLogOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cursor: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub logs: Vec<GetLogOutputLogsItem<'a>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum GetLogOutputLogsItem<'a> {
    #[serde(rename = "chat.bsky.convo.defs#logBeginConvo")]
    LogBeginConvo(Box<LogBeginConvo<'a>>),
    #[serde(rename = "chat.bsky.convo.defs#logAcceptConvo")]
    LogAcceptConvo(Box<LogAcceptConvo<'a>>),
    #[serde(rename = "chat.bsky.convo.defs#logLeaveConvo")]
    LogLeaveConvo(Box<LogLeaveConvo<'a>>),
    #[serde(rename = "chat.bsky.convo.defs#logMuteConvo")]
    LogMuteConvo(Box<LogMuteConvo<'a>>),
    #[serde(rename = "chat.bsky.convo.defs#logUnmuteConvo")]
    LogUnmuteConvo(Box<LogUnmuteConvo<'a>>),
    #[serde(rename = "chat.bsky.convo.defs#logCreateMessage")]
    LogCreateMessage(Box<LogCreateMessage<'a>>),
    #[serde(rename = "chat.bsky.convo.defs#logDeleteMessage")]
    LogDeleteMessage(Box<LogDeleteMessage<'a>>),
    #[serde(rename = "chat.bsky.convo.defs#logReadMessage")]
    LogReadMessage(Box<LogReadMessage<'a>>),
    #[serde(rename = "chat.bsky.convo.defs#logAddReaction")]
    LogAddReaction(Box<LogAddReaction<'a>>),
    #[serde(rename = "chat.bsky.convo.defs#logRemoveReaction")]
    LogRemoveReaction(Box<LogRemoveReaction<'a>>),
}

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

impl<'a> jacquard_common::xrpc::XrpcRequest for GetLog<'a> {
    const NSID: &'static str = "chat.bsky.convo.getLog";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetLogResponse;
}

/// Endpoint type for chat.bsky.convo.getLog
pub struct GetLogRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetLogRequest {
    const PATH: &'static str = "/xrpc/chat.bsky.convo.getLog";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetLog<'de>;
    type Response = GetLogResponse;
}

pub mod get_log_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 GetLogBuilder<'a, S: get_log_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>,),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> GetLog<'a> {
    /// Create a new builder for this type
    pub fn new() -> GetLogBuilder<'a, get_log_state::Empty> {
        GetLogBuilder::new()
    }
}

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

impl<'a, S: get_log_state::State> GetLogBuilder<'a, S> {
    /// Set the `cursor` field (optional)
    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `cursor` field to an Option value (optional)
    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> GetLogBuilder<'a, S>
where
    S: get_log_state::State,
{
    /// Build the final struct
    pub fn build(self) -> GetLog<'a> {
        GetLog { cursor: self._fields.0 }
    }
}