// @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, 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::Did;
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::app_bsky::unspecced::get_config;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LiveNowConfig<S: BosStr = DefaultStr> {
    pub did: Did<S>,
    pub domains: Vec<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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetConfigOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub check_email_confirmed: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub live_now: Option<Vec<get_config::LiveNowConfig<S>>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for LiveNowConfig<S> {
    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(())
    }
}

/** Request marker for the `app.bsky.unspecced.getConfig` query.

This endpoint has no request parameters or input body; send this marker with `jacquard::Client`.*/

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
pub struct GetConfig;
/** Response marker for the `app.bsky.unspecced.getConfig` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetConfigOutput<S>` for this endpoint.*/
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<S: BosStr> = GetConfigOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

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 marker for the `app.bsky.unspecced.getConfig` query.

Path: `/xrpc/app.bsky.unspecced.getConfig`. The request payload type is `GetConfig`; use this marker with lower-level `XrpcEndpoint` APIs when you need endpoint metadata.*/
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<S: BosStr> = 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<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDid<St> {}
    impl<St: State> State for SetDid<St> {
        type Did = Set<members::did>;
        type Domains = St::Domains;
    }
    ///State transition - sets the `domains` field to Set
    pub struct SetDomains<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDomains<St> {}
    impl<St: State> State for SetDomains<St> {
        type Did = St::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<
    St: live_now_config_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<Did<S>>, Option<Vec<S>>),
    _type: PhantomData<fn() -> S>,
}

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

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

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

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

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

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

impl<St, S: BosStr> LiveNowConfigBuilder<St, S>
where
    St: live_now_config_state::State,
    St::Did: live_now_config_state::IsSet,
    St::Domains: live_now_config_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> LiveNowConfig<S> {
        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<SmolStr, Data<S>>,
    ) -> LiveNowConfig<S> {
        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()
    }
}