// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: place.stream.branding.getBranding
//
// 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::place_stream::branding::get_branding;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct BrandingAsset<S: BosStr = DefaultStr> {
    ///Inline data for text assets
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data: Option<S>,
    ///Image height in pixels (optional, for images only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<i64>,
    ///Asset key identifier
    pub key: S,
    ///MIME type of the asset
    pub mime_type: S,
    ///URL to fetch the asset blob (for images)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<S>,
    ///Image width in pixels (optional, for images only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<i64>,
    #[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 GetBranding<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub broadcaster: Option<Did<S>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetBrandingOutput<S: BosStr = DefaultStr> {
    ///List of available branding assets
    pub assets: Vec<get_branding::BrandingAsset<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,
    thiserror::Error,
    miette::Diagnostic
)]

#[serde(tag = "error", content = "message")]
pub enum GetBrandingError {
    /// Catch-all for unknown error codes.
    #[serde(untagged)]
    Other { error: SmolStr, message: Option<SmolStr> },
}

impl core::fmt::Display for GetBrandingError {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::Other { error, message } => {
                write!(f, "{}", error)?;
                if let Some(msg) = message {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
        }
    }
}

impl<S: BosStr> LexiconSchema for BrandingAsset<S> {
    fn nsid() -> &'static str {
        "place.stream.branding.getBranding"
    }
    fn def_name() -> &'static str {
        "brandingAsset"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_place_stream_branding_getBranding()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/** Response marker for the `place.stream.branding.getBranding` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetBrandingOutput<S>` for this endpoint.*/
pub struct GetBrandingResponse;
impl jacquard_common::xrpc::XrpcResp for GetBrandingResponse {
    const NSID: &'static str = "place.stream.branding.getBranding";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = GetBrandingOutput<S>;
    type Err = GetBrandingError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetBranding<S> {
    const NSID: &'static str = "place.stream.branding.getBranding";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetBrandingResponse;
}

/** Endpoint marker for the `place.stream.branding.getBranding` query.

Path: `/xrpc/place.stream.branding.getBranding`. The request payload type is `GetBranding<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
pub struct GetBrandingRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetBrandingRequest {
    const PATH: &'static str = "/xrpc/place.stream.branding.getBranding";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<S: BosStr> = GetBranding<S>;
    type Response = GetBrandingResponse;
}

fn lexicon_doc_place_stream_branding_getBranding() -> 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("place.stream.branding.getBranding"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("brandingAsset"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("key"), SmolStr::new_static("mimeType")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("data"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Inline data for text assets"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("height"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("key"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Asset key identifier"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("mimeType"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("MIME type of the asset"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("url"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "URL to fetch the asset blob (for images)",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("width"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(
                        LexXrpcQueryParameter::Params(LexXrpcParameters {
                            required: Some(vec![]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("broadcaster"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static(
                                                "DID of the broadcaster. If not provided, uses the server's default broadcaster.",
                                            ),
                                        ),
                                        format: Some(LexStringFormat::Did),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod get_branding_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 {}
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {}
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {}
}

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

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

impl<S: BosStr> GetBranding<S> {
    /// Create a new builder for this type
    pub fn builder() -> GetBrandingBuilder<get_branding_state::Empty, S> {
        GetBrandingBuilder::builder()
    }
}

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

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

impl<St: get_branding_state::State, S: BosStr> GetBrandingBuilder<St, S> {
    /// Set the `broadcaster` field (optional)
    pub fn broadcaster(mut self, value: impl Into<Option<Did<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `broadcaster` field to an Option value (optional)
    pub fn maybe_broadcaster(mut self, value: Option<Did<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> GetBrandingBuilder<St, S>
where
    St: get_branding_state::State,
{
    /// Build the final struct.
    pub fn build(self) -> GetBranding<S> {
        GetBranding {
            broadcaster: self._fields.0,
        }
    }
}