// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: tools.ozone.communication.defs
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

//! Generated bindings for the `tools.ozone.communication` Lexicon namespace/module.
pub mod create_template;
pub mod delete_template;
pub mod list_templates;
pub mod update_template;


#[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, Datetime, Language};
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};

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct TemplateView<S: BosStr = DefaultStr> {
    ///Subject of the message, used in emails.
    pub content_markdown: S,
    pub created_at: Datetime,
    pub disabled: bool,
    pub id: S,
    ///Message language.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lang: Option<Language>,
    ///DID of the user who last updated the template.
    pub last_updated_by: Did<S>,
    ///Name of the template.
    pub name: S,
    ///Content of the template, can contain markdown and variable placeholders.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub subject: Option<S>,
    pub updated_at: Datetime,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for TemplateView<S> {
    fn nsid() -> &'static str {
        "tools.ozone.communication.defs"
    }
    fn def_name() -> &'static str {
        "templateView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_communication_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod template_view_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 ContentMarkdown;
        type CreatedAt;
        type Disabled;
        type Id;
        type LastUpdatedBy;
        type Name;
        type UpdatedAt;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type ContentMarkdown = Unset;
        type CreatedAt = Unset;
        type Disabled = Unset;
        type Id = Unset;
        type LastUpdatedBy = Unset;
        type Name = Unset;
        type UpdatedAt = Unset;
    }
    ///State transition - sets the `content_markdown` field to Set
    pub struct SetContentMarkdown<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetContentMarkdown<St> {}
    impl<St: State> State for SetContentMarkdown<St> {
        type ContentMarkdown = Set<members::content_markdown>;
        type CreatedAt = St::CreatedAt;
        type Disabled = St::Disabled;
        type Id = St::Id;
        type LastUpdatedBy = St::LastUpdatedBy;
        type Name = St::Name;
        type UpdatedAt = St::UpdatedAt;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type ContentMarkdown = St::ContentMarkdown;
        type CreatedAt = Set<members::created_at>;
        type Disabled = St::Disabled;
        type Id = St::Id;
        type LastUpdatedBy = St::LastUpdatedBy;
        type Name = St::Name;
        type UpdatedAt = St::UpdatedAt;
    }
    ///State transition - sets the `disabled` field to Set
    pub struct SetDisabled<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDisabled<St> {}
    impl<St: State> State for SetDisabled<St> {
        type ContentMarkdown = St::ContentMarkdown;
        type CreatedAt = St::CreatedAt;
        type Disabled = Set<members::disabled>;
        type Id = St::Id;
        type LastUpdatedBy = St::LastUpdatedBy;
        type Name = St::Name;
        type UpdatedAt = St::UpdatedAt;
    }
    ///State transition - sets the `id` field to Set
    pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetId<St> {}
    impl<St: State> State for SetId<St> {
        type ContentMarkdown = St::ContentMarkdown;
        type CreatedAt = St::CreatedAt;
        type Disabled = St::Disabled;
        type Id = Set<members::id>;
        type LastUpdatedBy = St::LastUpdatedBy;
        type Name = St::Name;
        type UpdatedAt = St::UpdatedAt;
    }
    ///State transition - sets the `last_updated_by` field to Set
    pub struct SetLastUpdatedBy<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLastUpdatedBy<St> {}
    impl<St: State> State for SetLastUpdatedBy<St> {
        type ContentMarkdown = St::ContentMarkdown;
        type CreatedAt = St::CreatedAt;
        type Disabled = St::Disabled;
        type Id = St::Id;
        type LastUpdatedBy = Set<members::last_updated_by>;
        type Name = St::Name;
        type UpdatedAt = St::UpdatedAt;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type ContentMarkdown = St::ContentMarkdown;
        type CreatedAt = St::CreatedAt;
        type Disabled = St::Disabled;
        type Id = St::Id;
        type LastUpdatedBy = St::LastUpdatedBy;
        type Name = Set<members::name>;
        type UpdatedAt = St::UpdatedAt;
    }
    ///State transition - sets the `updated_at` field to Set
    pub struct SetUpdatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUpdatedAt<St> {}
    impl<St: State> State for SetUpdatedAt<St> {
        type ContentMarkdown = St::ContentMarkdown;
        type CreatedAt = St::CreatedAt;
        type Disabled = St::Disabled;
        type Id = St::Id;
        type LastUpdatedBy = St::LastUpdatedBy;
        type Name = St::Name;
        type UpdatedAt = Set<members::updated_at>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `content_markdown` field
        pub struct content_markdown(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `disabled` field
        pub struct disabled(());
        ///Marker type for the `id` field
        pub struct id(());
        ///Marker type for the `last_updated_by` field
        pub struct last_updated_by(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `updated_at` field
        pub struct updated_at(());
    }
}

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

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

impl<S: BosStr> TemplateView<S> {
    /// Create a new builder for this type
    pub fn builder() -> TemplateViewBuilder<template_view_state::Empty, S> {
        TemplateViewBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> TemplateViewBuilder<St, S>
where
    St: template_view_state::State,
    St::ContentMarkdown: template_view_state::IsUnset,
{
    /// Set the `contentMarkdown` field (required)
    pub fn content_markdown(
        mut self,
        value: impl Into<S>,
    ) -> TemplateViewBuilder<template_view_state::SetContentMarkdown<St>, S> {
        self._fields.0 = Option::Some(value.into());
        TemplateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> TemplateViewBuilder<St, S>
where
    St: template_view_state::State,
    St::CreatedAt: template_view_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> TemplateViewBuilder<template_view_state::SetCreatedAt<St>, S> {
        self._fields.1 = Option::Some(value.into());
        TemplateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> TemplateViewBuilder<St, S>
where
    St: template_view_state::State,
    St::Disabled: template_view_state::IsUnset,
{
    /// Set the `disabled` field (required)
    pub fn disabled(
        mut self,
        value: impl Into<bool>,
    ) -> TemplateViewBuilder<template_view_state::SetDisabled<St>, S> {
        self._fields.2 = Option::Some(value.into());
        TemplateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> TemplateViewBuilder<St, S>
where
    St: template_view_state::State,
    St::Id: template_view_state::IsUnset,
{
    /// Set the `id` field (required)
    pub fn id(
        mut self,
        value: impl Into<S>,
    ) -> TemplateViewBuilder<template_view_state::SetId<St>, S> {
        self._fields.3 = Option::Some(value.into());
        TemplateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: template_view_state::State, S: BosStr> TemplateViewBuilder<St, S> {
    /// Set the `lang` field (optional)
    pub fn lang(mut self, value: impl Into<Option<Language>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `lang` field to an Option value (optional)
    pub fn maybe_lang(mut self, value: Option<Language>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> TemplateViewBuilder<St, S>
where
    St: template_view_state::State,
    St::LastUpdatedBy: template_view_state::IsUnset,
{
    /// Set the `lastUpdatedBy` field (required)
    pub fn last_updated_by(
        mut self,
        value: impl Into<Did<S>>,
    ) -> TemplateViewBuilder<template_view_state::SetLastUpdatedBy<St>, S> {
        self._fields.5 = Option::Some(value.into());
        TemplateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> TemplateViewBuilder<St, S>
where
    St: template_view_state::State,
    St::Name: template_view_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<S>,
    ) -> TemplateViewBuilder<template_view_state::SetName<St>, S> {
        self._fields.6 = Option::Some(value.into());
        TemplateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: template_view_state::State, S: BosStr> TemplateViewBuilder<St, S> {
    /// Set the `subject` field (optional)
    pub fn subject(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `subject` field to an Option value (optional)
    pub fn maybe_subject(mut self, value: Option<S>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St, S: BosStr> TemplateViewBuilder<St, S>
where
    St: template_view_state::State,
    St::UpdatedAt: template_view_state::IsUnset,
{
    /// Set the `updatedAt` field (required)
    pub fn updated_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> TemplateViewBuilder<template_view_state::SetUpdatedAt<St>, S> {
        self._fields.8 = Option::Some(value.into());
        TemplateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> TemplateViewBuilder<St, S>
where
    St: template_view_state::State,
    St::ContentMarkdown: template_view_state::IsSet,
    St::CreatedAt: template_view_state::IsSet,
    St::Disabled: template_view_state::IsSet,
    St::Id: template_view_state::IsSet,
    St::LastUpdatedBy: template_view_state::IsSet,
    St::Name: template_view_state::IsSet,
    St::UpdatedAt: template_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> TemplateView<S> {
        TemplateView {
            content_markdown: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            disabled: self._fields.2.unwrap(),
            id: self._fields.3.unwrap(),
            lang: self._fields.4,
            last_updated_by: self._fields.5.unwrap(),
            name: self._fields.6.unwrap(),
            subject: self._fields.7,
            updated_at: self._fields.8.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>>,
    ) -> TemplateView<S> {
        TemplateView {
            content_markdown: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            disabled: self._fields.2.unwrap(),
            id: self._fields.3.unwrap(),
            lang: self._fields.4,
            last_updated_by: self._fields.5.unwrap(),
            name: self._fields.6.unwrap(),
            subject: self._fields.7,
            updated_at: self._fields.8.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_tools_ozone_communication_defs() -> 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.communication.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("templateView"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("id"), SmolStr::new_static("name"),
                            SmolStr::new_static("contentMarkdown"),
                            SmolStr::new_static("disabled"),
                            SmolStr::new_static("lastUpdatedBy"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("updatedAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("contentMarkdown"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Subject of the message, used in emails.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("disabled"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("lang"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Message language.")),
                                format: Some(LexStringFormat::Language),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lastUpdatedBy"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "DID of the user who last updated the template.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Name of the template."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("subject"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Content of the template, can contain markdown and variable placeholders.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("updatedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}