// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: tools.ozone.verification.revokeVerifications
//
// 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};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::AtUri;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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::tools_ozone::verification::revoke_verifications;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct RevokeVerifications<S: BosStr = DefaultStr> {
    ///Reason for revoking the verification. This is optional and can be omitted if not needed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub revoke_reason: Option<S>,
    ///Array of verification record uris to revoke
    pub uris: Vec<AtUri<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct RevokeVerificationsOutput<S: BosStr = DefaultStr> {
    ///List of verification uris that couldn't be revoked, including failure reasons
    pub failed_revocations: Vec<revoke_verifications::RevokeError<S>>,
    ///List of verification uris successfully revoked
    pub revoked_verifications: Vec<AtUri<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Error object for failed revocations

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct RevokeError<S: BosStr = DefaultStr> {
    ///Description of the error that occurred during revocation.
    pub error: S,
    ///The AT-URI of the verification record that failed to revoke.
    pub uri: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/** Response marker for the `tools.ozone.verification.revokeVerifications` procedure.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `RevokeVerificationsOutput<S>` for this endpoint.*/
pub struct RevokeVerificationsResponse;
impl jacquard_common::xrpc::XrpcResp for RevokeVerificationsResponse {
    const NSID: &'static str = "tools.ozone.verification.revokeVerifications";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = RevokeVerificationsOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for RevokeVerifications<S> {
    const NSID: &'static str = "tools.ozone.verification.revokeVerifications";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = RevokeVerificationsResponse;
}

/** Endpoint marker for the `tools.ozone.verification.revokeVerifications` procedure.

Path: `/xrpc/tools.ozone.verification.revokeVerifications`. The request payload type is `RevokeVerifications<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
pub struct RevokeVerificationsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for RevokeVerificationsRequest {
    const PATH: &'static str = "/xrpc/tools.ozone.verification.revokeVerifications";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<S: BosStr> = RevokeVerifications<S>;
    type Response = RevokeVerificationsResponse;
}

impl<S: BosStr> LexiconSchema for RevokeError<S> {
    fn nsid() -> &'static str {
        "tools.ozone.verification.revokeVerifications"
    }
    fn def_name() -> &'static str {
        "revokeError"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_verification_revokeVerifications()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod revoke_verifications_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 Uris;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Uris = Unset;
    }
    ///State transition - sets the `uris` field to Set
    pub struct SetUris<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUris<St> {}
    impl<St: State> State for SetUris<St> {
        type Uris = Set<members::uris>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `uris` field
        pub struct uris(());
    }
}

/// Builder for constructing an instance of this type.
pub struct RevokeVerificationsBuilder<
    St: revoke_verifications_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<S>, Option<Vec<AtUri<S>>>),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> RevokeVerifications<S> {
    /// Create a new builder for this type
    pub fn builder() -> RevokeVerificationsBuilder<
        revoke_verifications_state::Empty,
        S,
    > {
        RevokeVerificationsBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> RevokeVerificationsBuilder<St, S>
where
    St: revoke_verifications_state::State,
    St::Uris: revoke_verifications_state::IsUnset,
{
    /// Set the `uris` field (required)
    pub fn uris(
        mut self,
        value: impl Into<Vec<AtUri<S>>>,
    ) -> RevokeVerificationsBuilder<revoke_verifications_state::SetUris<St>, S> {
        self._fields.1 = Option::Some(value.into());
        RevokeVerificationsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RevokeVerificationsBuilder<St, S>
where
    St: revoke_verifications_state::State,
    St::Uris: revoke_verifications_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> RevokeVerifications<S> {
        RevokeVerifications {
            revoke_reason: self._fields.0,
            uris: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> RevokeVerifications<S> {
        RevokeVerifications {
            revoke_reason: self._fields.0,
            uris: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod revoke_error_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 Error;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Error = Unset;
        type Uri = Unset;
    }
    ///State transition - sets the `error` field to Set
    pub struct SetError<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetError<St> {}
    impl<St: State> State for SetError<St> {
        type Error = Set<members::error>;
        type Uri = St::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Error = St::Error;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `error` field
        pub struct error(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct RevokeErrorBuilder<St: revoke_error_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<S>, Option<AtUri<S>>),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> RevokeError<S> {
    /// Create a new builder for this type
    pub fn builder() -> RevokeErrorBuilder<revoke_error_state::Empty, S> {
        RevokeErrorBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> RevokeErrorBuilder<St, S>
where
    St: revoke_error_state::State,
    St::Error: revoke_error_state::IsUnset,
{
    /// Set the `error` field (required)
    pub fn error(
        mut self,
        value: impl Into<S>,
    ) -> RevokeErrorBuilder<revoke_error_state::SetError<St>, S> {
        self._fields.0 = Option::Some(value.into());
        RevokeErrorBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RevokeErrorBuilder<St, S>
where
    St: revoke_error_state::State,
    St::Uri: revoke_error_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> RevokeErrorBuilder<revoke_error_state::SetUri<St>, S> {
        self._fields.1 = Option::Some(value.into());
        RevokeErrorBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RevokeErrorBuilder<St, S>
where
    St: revoke_error_state::State,
    St::Error: revoke_error_state::IsSet,
    St::Uri: revoke_error_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> RevokeError<S> {
        RevokeError {
            error: self._fields.0.unwrap(),
            uri: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> RevokeError<S> {
        RevokeError {
            error: self._fields.0.unwrap(),
            uri: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_tools_ozone_verification_revokeVerifications() -> 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("tools.ozone.verification.revokeVerifications"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcProcedure(LexXrpcProcedure {
                    input: Some(LexXrpcBody {
                        encoding: CowStr::new_static("application/json"),
                        schema: Some(
                            LexXrpcBodySchema::Object(LexObject {
                                required: Some(vec![SmolStr::new_static("uris")]),
                                properties: {
                                    #[allow(unused_mut)]
                                    let mut map = BTreeMap::new();
                                    map.insert(
                                        SmolStr::new_static("revokeReason"),
                                        LexObjectProperty::String(LexString {
                                            description: Some(
                                                CowStr::new_static(
                                                    "Reason for revoking the verification. This is optional and can be omitted if not needed.",
                                                ),
                                            ),
                                            max_length: Some(1000usize),
                                            ..Default::default()
                                        }),
                                    );
                                    map.insert(
                                        SmolStr::new_static("uris"),
                                        LexObjectProperty::Array(LexArray {
                                            description: Some(
                                                CowStr::new_static(
                                                    "Array of verification record uris to revoke",
                                                ),
                                            ),
                                            items: LexArrayItem::String(LexString {
                                                description: Some(
                                                    CowStr::new_static(
                                                        "The AT-URI of the verification record to revoke.",
                                                    ),
                                                ),
                                                format: Some(LexStringFormat::AtUri),
                                                ..Default::default()
                                            }),
                                            max_length: Some(100usize),
                                            ..Default::default()
                                        }),
                                    );
                                    map
                                },
                                ..Default::default()
                            }),
                        ),
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("revokeError"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Error object for failed revocations"),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("uri"), SmolStr::new_static("error")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("error"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Description of the error that occurred during revocation.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The AT-URI of the verification record that failed to revoke.",
                                    ),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}