// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: tools.ozone.moderation.queryEvents
//
// 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_common::types::string::{Did, Nsid, Datetime, UriValue};
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
use crate::tools_ozone::moderation::ModEventView;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct QueryEvents<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub added_labels: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub added_tags: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub age_assurance_state: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub batch_id: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub collections: Option<Vec<Nsid<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub comment: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_after: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_before: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub created_by: Option<Did<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cursor: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub has_comment: Option<bool>,
    /// Defaults to `false`.
    #[serde(default = "_default_include_all_user_records")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_all_user_records: Option<bool>,
    ///Defaults to `50`. Min: 1. Max: 100.
    #[serde(default = "_default_limit")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub mod_tool: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub policies: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub removed_labels: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub removed_tags: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub report_types: Option<Vec<CowStr<'a>>>,
    ///Defaults to `"desc"`.
    #[serde(default = "_default_sort_direction")]
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub sort_direction: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub subject: Option<UriValue<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub subject_type: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub types: Option<Vec<CowStr<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub with_strike: Option<bool>,
}


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

/// Response type for tools.ozone.moderation.queryEvents
pub struct QueryEventsResponse;
impl jacquard_common::xrpc::XrpcResp for QueryEventsResponse {
    const NSID: &'static str = "tools.ozone.moderation.queryEvents";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = QueryEventsOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for QueryEvents<'a> {
    const NSID: &'static str = "tools.ozone.moderation.queryEvents";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = QueryEventsResponse;
}

/// Endpoint type for tools.ozone.moderation.queryEvents
pub struct QueryEventsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for QueryEventsRequest {
    const PATH: &'static str = "/xrpc/tools.ozone.moderation.queryEvents";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = QueryEvents<'de>;
    type Response = QueryEventsResponse;
}

fn _default_include_all_user_records() -> Option<bool> {
    Some(false)
}

fn _default_limit() -> Option<i64> {
    Some(50i64)
}

fn _default_sort_direction() -> Option<CowStr<'static>> {
    Some(CowStr::from("desc"))
}

pub mod query_events_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 QueryEventsBuilder<'a, S: query_events_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<Vec<Nsid<'a>>>,
        Option<CowStr<'a>>,
        Option<Datetime>,
        Option<Datetime>,
        Option<Did<'a>>,
        Option<CowStr<'a>>,
        Option<bool>,
        Option<bool>,
        Option<i64>,
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<CowStr<'a>>,
        Option<UriValue<'a>>,
        Option<CowStr<'a>>,
        Option<Vec<CowStr<'a>>>,
        Option<bool>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> QueryEvents<'a> {
    /// Create a new builder for this type
    pub fn new() -> QueryEventsBuilder<'a, query_events_state::Empty> {
        QueryEventsBuilder::new()
    }
}

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

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `addedLabels` field (optional)
    pub fn added_labels(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `addedLabels` field to an Option value (optional)
    pub fn maybe_added_labels(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `addedTags` field (optional)
    pub fn added_tags(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `addedTags` field to an Option value (optional)
    pub fn maybe_added_tags(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `ageAssuranceState` field (optional)
    pub fn age_assurance_state(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `ageAssuranceState` field to an Option value (optional)
    pub fn maybe_age_assurance_state(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `batchId` field (optional)
    pub fn batch_id(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `batchId` field to an Option value (optional)
    pub fn maybe_batch_id(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `collections` field (optional)
    pub fn collections(mut self, value: impl Into<Option<Vec<Nsid<'a>>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `collections` field to an Option value (optional)
    pub fn maybe_collections(mut self, value: Option<Vec<Nsid<'a>>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `comment` field (optional)
    pub fn comment(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `comment` field to an Option value (optional)
    pub fn maybe_comment(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `createdAfter` field (optional)
    pub fn created_after(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `createdAfter` field to an Option value (optional)
    pub fn maybe_created_after(mut self, value: Option<Datetime>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `createdBefore` field (optional)
    pub fn created_before(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `createdBefore` field to an Option value (optional)
    pub fn maybe_created_before(mut self, value: Option<Datetime>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `createdBy` field (optional)
    pub fn created_by(mut self, value: impl Into<Option<Did<'a>>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `createdBy` field to an Option value (optional)
    pub fn maybe_created_by(mut self, value: Option<Did<'a>>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `cursor` field (optional)
    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.9 = 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.9 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `hasComment` field (optional)
    pub fn has_comment(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `hasComment` field to an Option value (optional)
    pub fn maybe_has_comment(mut self, value: Option<bool>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `includeAllUserRecords` field (optional)
    pub fn include_all_user_records(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `includeAllUserRecords` field to an Option value (optional)
    pub fn maybe_include_all_user_records(mut self, value: Option<bool>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `limit` field (optional)
    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `limit` field to an Option value (optional)
    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `modTool` field (optional)
    pub fn mod_tool(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `modTool` field to an Option value (optional)
    pub fn maybe_mod_tool(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `policies` field (optional)
    pub fn policies(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `policies` field to an Option value (optional)
    pub fn maybe_policies(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `removedLabels` field (optional)
    pub fn removed_labels(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.15 = value.into();
        self
    }
    /// Set the `removedLabels` field to an Option value (optional)
    pub fn maybe_removed_labels(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.15 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `removedTags` field (optional)
    pub fn removed_tags(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.16 = value.into();
        self
    }
    /// Set the `removedTags` field to an Option value (optional)
    pub fn maybe_removed_tags(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.16 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `reportTypes` field (optional)
    pub fn report_types(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.17 = value.into();
        self
    }
    /// Set the `reportTypes` field to an Option value (optional)
    pub fn maybe_report_types(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.17 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `sortDirection` field (optional)
    pub fn sort_direction(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.18 = value.into();
        self
    }
    /// Set the `sortDirection` field to an Option value (optional)
    pub fn maybe_sort_direction(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.18 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `subject` field (optional)
    pub fn subject(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
        self._fields.19 = value.into();
        self
    }
    /// Set the `subject` field to an Option value (optional)
    pub fn maybe_subject(mut self, value: Option<UriValue<'a>>) -> Self {
        self._fields.19 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `subjectType` field (optional)
    pub fn subject_type(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.20 = value.into();
        self
    }
    /// Set the `subjectType` field to an Option value (optional)
    pub fn maybe_subject_type(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.20 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `types` field (optional)
    pub fn types(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
        self._fields.21 = value.into();
        self
    }
    /// Set the `types` field to an Option value (optional)
    pub fn maybe_types(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
        self._fields.21 = value;
        self
    }
}

impl<'a, S: query_events_state::State> QueryEventsBuilder<'a, S> {
    /// Set the `withStrike` field (optional)
    pub fn with_strike(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.22 = value.into();
        self
    }
    /// Set the `withStrike` field to an Option value (optional)
    pub fn maybe_with_strike(mut self, value: Option<bool>) -> Self {
        self._fields.22 = value;
        self
    }
}

impl<'a, S> QueryEventsBuilder<'a, S>
where
    S: query_events_state::State,
{
    /// Build the final struct
    pub fn build(self) -> QueryEvents<'a> {
        QueryEvents {
            added_labels: self._fields.0,
            added_tags: self._fields.1,
            age_assurance_state: self._fields.2,
            batch_id: self._fields.3,
            collections: self._fields.4,
            comment: self._fields.5,
            created_after: self._fields.6,
            created_before: self._fields.7,
            created_by: self._fields.8,
            cursor: self._fields.9,
            has_comment: self._fields.10,
            include_all_user_records: self._fields.11,
            limit: self._fields.12,
            mod_tool: self._fields.13,
            policies: self._fields.14,
            removed_labels: self._fields.15,
            removed_tags: self._fields.16,
            report_types: self._fields.17,
            sort_direction: self._fields.18,
            subject: self._fields.19,
            subject_type: self._fields.20,
            types: self._fields.21,
            with_strike: self._fields.22,
        }
    }
}