// @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, 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::chat_bsky::convo::LogAcceptConvo;
use crate::chat_bsky::convo::LogAddMember;
use crate::chat_bsky::convo::LogAddReaction;
use crate::chat_bsky::convo::LogApproveJoinRequest;
use crate::chat_bsky::convo::LogBeginConvo;
use crate::chat_bsky::convo::LogCreateJoinLink;
use crate::chat_bsky::convo::LogCreateMessage;
use crate::chat_bsky::convo::LogDeleteMessage;
use crate::chat_bsky::convo::LogDisableJoinLink;
use crate::chat_bsky::convo::LogEditGroup;
use crate::chat_bsky::convo::LogEditJoinLink;
use crate::chat_bsky::convo::LogEnableJoinLink;
use crate::chat_bsky::convo::LogIncomingJoinRequest;
use crate::chat_bsky::convo::LogLeaveConvo;
use crate::chat_bsky::convo::LogLockConvo;
use crate::chat_bsky::convo::LogLockConvoPermanently;
use crate::chat_bsky::convo::LogMemberJoin;
use crate::chat_bsky::convo::LogMemberLeave;
use crate::chat_bsky::convo::LogMuteConvo;
use crate::chat_bsky::convo::LogOutgoingJoinRequest;
use crate::chat_bsky::convo::LogReadConvo;
use crate::chat_bsky::convo::LogReadJoinRequests;
use crate::chat_bsky::convo::LogReadMessage;
use crate::chat_bsky::convo::LogRejectJoinRequest;
use crate::chat_bsky::convo::LogRemoveMember;
use crate::chat_bsky::convo::LogRemoveReaction;
use crate::chat_bsky::convo::LogUnlockConvo;
use crate::chat_bsky::convo::LogUnmuteConvo;
use crate::chat_bsky::convo::LogWithdrawIncomingJoinRequest;
use crate::chat_bsky::convo::LogWithdrawOutgoingJoinRequest;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetLog<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cursor: Option<S>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetLogOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cursor: Option<S>,
    pub logs: Vec<GetLogOutputLogsItem<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 GetLogOutputLogsItem<S: BosStr = DefaultStr> {
    #[serde(rename = "chat.bsky.convo.defs#logBeginConvo")]
    LogBeginConvo(Box<LogBeginConvo<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logAcceptConvo")]
    LogAcceptConvo(Box<LogAcceptConvo<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logLeaveConvo")]
    LogLeaveConvo(Box<LogLeaveConvo<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logMuteConvo")]
    LogMuteConvo(Box<LogMuteConvo<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logUnmuteConvo")]
    LogUnmuteConvo(Box<LogUnmuteConvo<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logCreateMessage")]
    LogCreateMessage(Box<LogCreateMessage<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logDeleteMessage")]
    LogDeleteMessage(Box<LogDeleteMessage<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logReadMessage")]
    LogReadMessage(Box<LogReadMessage<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logAddReaction")]
    LogAddReaction(Box<LogAddReaction<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logRemoveReaction")]
    LogRemoveReaction(Box<LogRemoveReaction<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logReadConvo")]
    LogReadConvo(Box<LogReadConvo<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logAddMember")]
    LogAddMember(Box<LogAddMember<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logRemoveMember")]
    LogRemoveMember(Box<LogRemoveMember<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logMemberJoin")]
    LogMemberJoin(Box<LogMemberJoin<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logMemberLeave")]
    LogMemberLeave(Box<LogMemberLeave<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logLockConvo")]
    LogLockConvo(Box<LogLockConvo<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logUnlockConvo")]
    LogUnlockConvo(Box<LogUnlockConvo<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logLockConvoPermanently")]
    LogLockConvoPermanently(Box<LogLockConvoPermanently<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logEditGroup")]
    LogEditGroup(Box<LogEditGroup<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logCreateJoinLink")]
    LogCreateJoinLink(Box<LogCreateJoinLink<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logEditJoinLink")]
    LogEditJoinLink(Box<LogEditJoinLink<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logEnableJoinLink")]
    LogEnableJoinLink(Box<LogEnableJoinLink<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logDisableJoinLink")]
    LogDisableJoinLink(Box<LogDisableJoinLink<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logIncomingJoinRequest")]
    LogIncomingJoinRequest(Box<LogIncomingJoinRequest<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logApproveJoinRequest")]
    LogApproveJoinRequest(Box<LogApproveJoinRequest<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logRejectJoinRequest")]
    LogRejectJoinRequest(Box<LogRejectJoinRequest<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logOutgoingJoinRequest")]
    LogOutgoingJoinRequest(Box<LogOutgoingJoinRequest<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logWithdrawIncomingJoinRequest")]
    LogWithdrawIncomingJoinRequest(Box<LogWithdrawIncomingJoinRequest<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logWithdrawOutgoingJoinRequest")]
    LogWithdrawOutgoingJoinRequest(Box<LogWithdrawOutgoingJoinRequest<S>>),
    #[serde(rename = "chat.bsky.convo.defs#logReadJoinRequests")]
    LogReadJoinRequests(Box<LogReadJoinRequests<S>>),
}

/** Response marker for the `chat.bsky.convo.getLog` query.

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

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

/** Endpoint marker for the `chat.bsky.convo.getLog` query.

Path: `/xrpc/chat.bsky.convo.getLog`. The request payload type is `GetLog<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
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<S: BosStr> = GetLog<S>;
    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<St: get_log_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<S>,),
    _type: PhantomData<fn() -> S>,
}

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

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

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

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

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

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