// @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.

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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Did, Datetime, Language};
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};

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

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

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

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

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

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

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

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

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

impl<'a, S: template_view_state::State> TemplateViewBuilder<'a, 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<'a, S> TemplateViewBuilder<'a, S>
where
    S: template_view_state::State,
    S::LastUpdatedBy: template_view_state::IsUnset,
{
    /// Set the `lastUpdatedBy` field (required)
    pub fn last_updated_by(
        mut self,
        value: impl Into<Did<'a>>,
    ) -> TemplateViewBuilder<'a, template_view_state::SetLastUpdatedBy<S>> {
        self._fields.5 = Option::Some(value.into());
        TemplateViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

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

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

impl<'a, S> TemplateViewBuilder<'a, S>
where
    S: template_view_state::State,
    S::ContentMarkdown: template_view_state::IsSet,
    S::Name: template_view_state::IsSet,
    S::Disabled: template_view_state::IsSet,
    S::LastUpdatedBy: template_view_state::IsSet,
    S::UpdatedAt: template_view_state::IsSet,
    S::CreatedAt: template_view_state::IsSet,
    S::Id: template_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> TemplateView<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> TemplateView<'a> {
        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()
    }
}