// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.bsky.unspecced.getConfig
//
// 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;
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::app_bsky::unspecced::get_config;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LiveNowConfig<'a> {
    #[serde(borrow)]
    pub did: Did<'a>,
    #[serde(borrow)]
    pub domains: Vec<CowStr<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetConfigOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub check_email_confirmed: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub live_now: Option<Vec<get_config::LiveNowConfig<'a>>>,
}

impl<'a> LexiconSchema for LiveNowConfig<'a> {
    fn nsid() -> &'static str {
        "app.bsky.unspecced.getConfig"
    }
    fn def_name() -> &'static str {
        "liveNowConfig"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_bsky_unspecced_getConfig()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/// XRPC request marker type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
pub struct GetConfig;
/// Response type for app.bsky.unspecced.getConfig
pub struct GetConfigResponse;
impl jacquard_common::xrpc::XrpcResp for GetConfigResponse {
    const NSID: &'static str = "app.bsky.unspecced.getConfig";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GetConfigOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl jacquard_common::xrpc::XrpcRequest for GetConfig {
    const NSID: &'static str = "app.bsky.unspecced.getConfig";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetConfigResponse;
}

/// Endpoint type for app.bsky.unspecced.getConfig
pub struct GetConfigRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetConfigRequest {
    const PATH: &'static str = "/xrpc/app.bsky.unspecced.getConfig";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetConfig;
    type Response = GetConfigResponse;
}

pub mod live_now_config_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 Did;
        type Domains;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Did = Unset;
        type Domains = Unset;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDid<S> {}
    impl<S: State> State for SetDid<S> {
        type Did = Set<members::did>;
        type Domains = S::Domains;
    }
    ///State transition - sets the `domains` field to Set
    pub struct SetDomains<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDomains<S> {}
    impl<S: State> State for SetDomains<S> {
        type Did = S::Did;
        type Domains = Set<members::domains>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `domains` field
        pub struct domains(());
    }
}

/// Builder for constructing an instance of this type
pub struct LiveNowConfigBuilder<'a, S: live_now_config_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Did<'a>>, Option<Vec<CowStr<'a>>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> LiveNowConfig<'a> {
    /// Create a new builder for this type
    pub fn new() -> LiveNowConfigBuilder<'a, live_now_config_state::Empty> {
        LiveNowConfigBuilder::new()
    }
}

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

impl<'a, S> LiveNowConfigBuilder<'a, S>
where
    S: live_now_config_state::State,
    S::Did: live_now_config_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<Did<'a>>,
    ) -> LiveNowConfigBuilder<'a, live_now_config_state::SetDid<S>> {
        self._fields.0 = Option::Some(value.into());
        LiveNowConfigBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> LiveNowConfigBuilder<'a, S>
where
    S: live_now_config_state::State,
    S::Domains: live_now_config_state::IsUnset,
{
    /// Set the `domains` field (required)
    pub fn domains(
        mut self,
        value: impl Into<Vec<CowStr<'a>>>,
    ) -> LiveNowConfigBuilder<'a, live_now_config_state::SetDomains<S>> {
        self._fields.1 = Option::Some(value.into());
        LiveNowConfigBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> LiveNowConfigBuilder<'a, S>
where
    S: live_now_config_state::State,
    S::Did: live_now_config_state::IsSet,
    S::Domains: live_now_config_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> LiveNowConfig<'a> {
        LiveNowConfig {
            did: self._fields.0.unwrap(),
            domains: 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>,
        >,
    ) -> LiveNowConfig<'a> {
        LiveNowConfig {
            did: self._fields.0.unwrap(),
            domains: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_bsky_unspecced_getConfig() -> 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("app.bsky.unspecced.getConfig"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("liveNowConfig"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("did"), SmolStr::new_static("domains")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("domains"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: None,
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}