// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: com.atproto.server.describeServer
//
// 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::{Did, UriValue};
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::com_atproto::server::describe_server;

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


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Links<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub privacy_policy: Option<UriValue<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub terms_of_service: Option<UriValue<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct DescribeServerOutput<'a> {
    ///List of domain suffixes that can be used in account handles.
    #[serde(borrow)]
    pub available_user_domains: Vec<CowStr<'a>>,
    ///Contact information
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub contact: Option<describe_server::Contact<'a>>,
    #[serde(borrow)]
    pub did: Did<'a>,
    ///If true, an invite code must be supplied to create an account on this instance.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub invite_code_required: Option<bool>,
    ///URLs of service policy documents.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub links: Option<describe_server::Links<'a>>,
    ///If true, a phone verification token must be supplied to create an account on this instance.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub phone_verification_required: Option<bool>,
}

impl<'a> LexiconSchema for Contact<'a> {
    fn nsid() -> &'static str {
        "com.atproto.server.describeServer"
    }
    fn def_name() -> &'static str {
        "contact"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_atproto_server_describeServer()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for Links<'a> {
    fn nsid() -> &'static str {
        "com.atproto.server.describeServer"
    }
    fn def_name() -> &'static str {
        "links"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_atproto_server_describeServer()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/// XRPC request marker type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
pub struct DescribeServer;
/// Response type for com.atproto.server.describeServer
pub struct DescribeServerResponse;
impl jacquard_common::xrpc::XrpcResp for DescribeServerResponse {
    const NSID: &'static str = "com.atproto.server.describeServer";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = DescribeServerOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl jacquard_common::xrpc::XrpcRequest for DescribeServer {
    const NSID: &'static str = "com.atproto.server.describeServer";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = DescribeServerResponse;
}

/// Endpoint type for com.atproto.server.describeServer
pub struct DescribeServerRequest;
impl jacquard_common::xrpc::XrpcEndpoint for DescribeServerRequest {
    const PATH: &'static str = "/xrpc/com.atproto.server.describeServer";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = DescribeServer;
    type Response = DescribeServerResponse;
}

fn lexicon_doc_com_atproto_server_describeServer() -> 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("com.atproto.server.describeServer"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("contact"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("email"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("links"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("privacyPolicy"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("termsOfService"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: None,
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}