// @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;

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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RevokeVerifications<'a> {
    ///Reason for revoking the verification. This is optional and can be omitted if not needed.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub revoke_reason: Option<CowStr<'a>>,
    ///Array of verification record uris to revoke
    #[serde(borrow)]
    pub uris: Vec<AtUri<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RevokeVerificationsOutput<'a> {
    ///List of verification uris that couldn't be revoked, including failure reasons
    #[serde(borrow)]
    pub failed_revocations: Vec<revoke_verifications::RevokeError<'a>>,
    ///List of verification uris successfully revoked
    #[serde(borrow)]
    pub revoked_verifications: Vec<AtUri<'a>>,
}

/// Error object for failed revocations

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RevokeError<'a> {
    ///Description of the error that occurred during revocation.
    #[serde(borrow)]
    pub error: CowStr<'a>,
    ///The AT-URI of the verification record that failed to revoke.
    #[serde(borrow)]
    pub uri: AtUri<'a>,
}

/// Response type for tools.ozone.verification.revokeVerifications
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<'de> = RevokeVerificationsOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for RevokeVerifications<'a> {
    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 type for tools.ozone.verification.revokeVerifications
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<'de> = RevokeVerifications<'de>;
    type Response = RevokeVerificationsResponse;
}

impl<'a> LexiconSchema for RevokeError<'a> {
    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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUris<S> {}
    impl<S: State> State for SetUris<S> {
        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<'a, S: revoke_verifications_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<Vec<AtUri<'a>>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S> RevokeVerificationsBuilder<'a, S>
where
    S: revoke_verifications_state::State,
    S::Uris: revoke_verifications_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> RevokeVerifications<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> RevokeVerifications<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetError<S> {}
    impl<S: State> State for SetError<S> {
        type Error = Set<members::error>;
        type Uri = S::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type Error = S::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<'a, S: revoke_error_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<AtUri<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S> RevokeErrorBuilder<'a, S>
where
    S: revoke_error_state::State,
    S::Error: revoke_error_state::IsSet,
    S::Uri: revoke_error_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> RevokeError<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> RevokeError<'a> {
        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()
    }
}