Skip to main content

jacquard_api/tools_ozone/
communication.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: tools.ozone.communication.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod create_template;
9pub mod delete_template;
10pub mod list_templates;
11pub mod update_template;
12
13
14#[allow(unused_imports)]
15use alloc::collections::BTreeMap;
16
17#[allow(unused_imports)]
18use core::marker::PhantomData;
19use jacquard_common::CowStr;
20
21#[allow(unused_imports)]
22use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
23use jacquard_common::types::string::{Did, Datetime, Language};
24use jacquard_derive::{IntoStatic, lexicon};
25use jacquard_lexicon::lexicon::LexiconDoc;
26use jacquard_lexicon::schema::LexiconSchema;
27
28#[allow(unused_imports)]
29use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
30use serde::{Serialize, Deserialize};
31
32#[lexicon]
33#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
34#[serde(rename_all = "camelCase")]
35pub struct TemplateView<'a> {
36    ///Subject of the message, used in emails.
37    #[serde(borrow)]
38    pub content_markdown: CowStr<'a>,
39    pub created_at: Datetime,
40    pub disabled: bool,
41    #[serde(borrow)]
42    pub id: CowStr<'a>,
43    ///Message language.
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub lang: Option<Language>,
46    ///DID of the user who last updated the template.
47    #[serde(borrow)]
48    pub last_updated_by: Did<'a>,
49    ///Name of the template.
50    #[serde(borrow)]
51    pub name: CowStr<'a>,
52    ///Content of the template, can contain markdown and variable placeholders.
53    #[serde(skip_serializing_if = "Option::is_none")]
54    #[serde(borrow)]
55    pub subject: Option<CowStr<'a>>,
56    pub updated_at: Datetime,
57}
58
59impl<'a> LexiconSchema for TemplateView<'a> {
60    fn nsid() -> &'static str {
61        "tools.ozone.communication.defs"
62    }
63    fn def_name() -> &'static str {
64        "templateView"
65    }
66    fn lexicon_doc() -> LexiconDoc<'static> {
67        lexicon_doc_tools_ozone_communication_defs()
68    }
69    fn validate(&self) -> Result<(), ConstraintError> {
70        Ok(())
71    }
72}
73
74pub mod template_view_state {
75
76    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
77    #[allow(unused)]
78    use ::core::marker::PhantomData;
79    mod sealed {
80        pub trait Sealed {}
81    }
82    /// State trait tracking which required fields have been set
83    pub trait State: sealed::Sealed {
84        type CreatedAt;
85        type UpdatedAt;
86        type Name;
87        type Id;
88        type Disabled;
89        type LastUpdatedBy;
90        type ContentMarkdown;
91    }
92    /// Empty state - all required fields are unset
93    pub struct Empty(());
94    impl sealed::Sealed for Empty {}
95    impl State for Empty {
96        type CreatedAt = Unset;
97        type UpdatedAt = Unset;
98        type Name = Unset;
99        type Id = Unset;
100        type Disabled = Unset;
101        type LastUpdatedBy = Unset;
102        type ContentMarkdown = Unset;
103    }
104    ///State transition - sets the `created_at` field to Set
105    pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
106    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
107    impl<S: State> State for SetCreatedAt<S> {
108        type CreatedAt = Set<members::created_at>;
109        type UpdatedAt = S::UpdatedAt;
110        type Name = S::Name;
111        type Id = S::Id;
112        type Disabled = S::Disabled;
113        type LastUpdatedBy = S::LastUpdatedBy;
114        type ContentMarkdown = S::ContentMarkdown;
115    }
116    ///State transition - sets the `updated_at` field to Set
117    pub struct SetUpdatedAt<S: State = Empty>(PhantomData<fn() -> S>);
118    impl<S: State> sealed::Sealed for SetUpdatedAt<S> {}
119    impl<S: State> State for SetUpdatedAt<S> {
120        type CreatedAt = S::CreatedAt;
121        type UpdatedAt = Set<members::updated_at>;
122        type Name = S::Name;
123        type Id = S::Id;
124        type Disabled = S::Disabled;
125        type LastUpdatedBy = S::LastUpdatedBy;
126        type ContentMarkdown = S::ContentMarkdown;
127    }
128    ///State transition - sets the `name` field to Set
129    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
130    impl<S: State> sealed::Sealed for SetName<S> {}
131    impl<S: State> State for SetName<S> {
132        type CreatedAt = S::CreatedAt;
133        type UpdatedAt = S::UpdatedAt;
134        type Name = Set<members::name>;
135        type Id = S::Id;
136        type Disabled = S::Disabled;
137        type LastUpdatedBy = S::LastUpdatedBy;
138        type ContentMarkdown = S::ContentMarkdown;
139    }
140    ///State transition - sets the `id` field to Set
141    pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
142    impl<S: State> sealed::Sealed for SetId<S> {}
143    impl<S: State> State for SetId<S> {
144        type CreatedAt = S::CreatedAt;
145        type UpdatedAt = S::UpdatedAt;
146        type Name = S::Name;
147        type Id = Set<members::id>;
148        type Disabled = S::Disabled;
149        type LastUpdatedBy = S::LastUpdatedBy;
150        type ContentMarkdown = S::ContentMarkdown;
151    }
152    ///State transition - sets the `disabled` field to Set
153    pub struct SetDisabled<S: State = Empty>(PhantomData<fn() -> S>);
154    impl<S: State> sealed::Sealed for SetDisabled<S> {}
155    impl<S: State> State for SetDisabled<S> {
156        type CreatedAt = S::CreatedAt;
157        type UpdatedAt = S::UpdatedAt;
158        type Name = S::Name;
159        type Id = S::Id;
160        type Disabled = Set<members::disabled>;
161        type LastUpdatedBy = S::LastUpdatedBy;
162        type ContentMarkdown = S::ContentMarkdown;
163    }
164    ///State transition - sets the `last_updated_by` field to Set
165    pub struct SetLastUpdatedBy<S: State = Empty>(PhantomData<fn() -> S>);
166    impl<S: State> sealed::Sealed for SetLastUpdatedBy<S> {}
167    impl<S: State> State for SetLastUpdatedBy<S> {
168        type CreatedAt = S::CreatedAt;
169        type UpdatedAt = S::UpdatedAt;
170        type Name = S::Name;
171        type Id = S::Id;
172        type Disabled = S::Disabled;
173        type LastUpdatedBy = Set<members::last_updated_by>;
174        type ContentMarkdown = S::ContentMarkdown;
175    }
176    ///State transition - sets the `content_markdown` field to Set
177    pub struct SetContentMarkdown<S: State = Empty>(PhantomData<fn() -> S>);
178    impl<S: State> sealed::Sealed for SetContentMarkdown<S> {}
179    impl<S: State> State for SetContentMarkdown<S> {
180        type CreatedAt = S::CreatedAt;
181        type UpdatedAt = S::UpdatedAt;
182        type Name = S::Name;
183        type Id = S::Id;
184        type Disabled = S::Disabled;
185        type LastUpdatedBy = S::LastUpdatedBy;
186        type ContentMarkdown = Set<members::content_markdown>;
187    }
188    /// Marker types for field names
189    #[allow(non_camel_case_types)]
190    pub mod members {
191        ///Marker type for the `created_at` field
192        pub struct created_at(());
193        ///Marker type for the `updated_at` field
194        pub struct updated_at(());
195        ///Marker type for the `name` field
196        pub struct name(());
197        ///Marker type for the `id` field
198        pub struct id(());
199        ///Marker type for the `disabled` field
200        pub struct disabled(());
201        ///Marker type for the `last_updated_by` field
202        pub struct last_updated_by(());
203        ///Marker type for the `content_markdown` field
204        pub struct content_markdown(());
205    }
206}
207
208/// Builder for constructing an instance of this type
209pub struct TemplateViewBuilder<'a, S: template_view_state::State> {
210    _state: PhantomData<fn() -> S>,
211    _fields: (
212        Option<CowStr<'a>>,
213        Option<Datetime>,
214        Option<bool>,
215        Option<CowStr<'a>>,
216        Option<Language>,
217        Option<Did<'a>>,
218        Option<CowStr<'a>>,
219        Option<CowStr<'a>>,
220        Option<Datetime>,
221    ),
222    _lifetime: PhantomData<&'a ()>,
223}
224
225impl<'a> TemplateView<'a> {
226    /// Create a new builder for this type
227    pub fn new() -> TemplateViewBuilder<'a, template_view_state::Empty> {
228        TemplateViewBuilder::new()
229    }
230}
231
232impl<'a> TemplateViewBuilder<'a, template_view_state::Empty> {
233    /// Create a new builder with all fields unset
234    pub fn new() -> Self {
235        TemplateViewBuilder {
236            _state: PhantomData,
237            _fields: (None, None, None, None, None, None, None, None, None),
238            _lifetime: PhantomData,
239        }
240    }
241}
242
243impl<'a, S> TemplateViewBuilder<'a, S>
244where
245    S: template_view_state::State,
246    S::ContentMarkdown: template_view_state::IsUnset,
247{
248    /// Set the `contentMarkdown` field (required)
249    pub fn content_markdown(
250        mut self,
251        value: impl Into<CowStr<'a>>,
252    ) -> TemplateViewBuilder<'a, template_view_state::SetContentMarkdown<S>> {
253        self._fields.0 = Option::Some(value.into());
254        TemplateViewBuilder {
255            _state: PhantomData,
256            _fields: self._fields,
257            _lifetime: PhantomData,
258        }
259    }
260}
261
262impl<'a, S> TemplateViewBuilder<'a, S>
263where
264    S: template_view_state::State,
265    S::CreatedAt: template_view_state::IsUnset,
266{
267    /// Set the `createdAt` field (required)
268    pub fn created_at(
269        mut self,
270        value: impl Into<Datetime>,
271    ) -> TemplateViewBuilder<'a, template_view_state::SetCreatedAt<S>> {
272        self._fields.1 = Option::Some(value.into());
273        TemplateViewBuilder {
274            _state: PhantomData,
275            _fields: self._fields,
276            _lifetime: PhantomData,
277        }
278    }
279}
280
281impl<'a, S> TemplateViewBuilder<'a, S>
282where
283    S: template_view_state::State,
284    S::Disabled: template_view_state::IsUnset,
285{
286    /// Set the `disabled` field (required)
287    pub fn disabled(
288        mut self,
289        value: impl Into<bool>,
290    ) -> TemplateViewBuilder<'a, template_view_state::SetDisabled<S>> {
291        self._fields.2 = Option::Some(value.into());
292        TemplateViewBuilder {
293            _state: PhantomData,
294            _fields: self._fields,
295            _lifetime: PhantomData,
296        }
297    }
298}
299
300impl<'a, S> TemplateViewBuilder<'a, S>
301where
302    S: template_view_state::State,
303    S::Id: template_view_state::IsUnset,
304{
305    /// Set the `id` field (required)
306    pub fn id(
307        mut self,
308        value: impl Into<CowStr<'a>>,
309    ) -> TemplateViewBuilder<'a, template_view_state::SetId<S>> {
310        self._fields.3 = Option::Some(value.into());
311        TemplateViewBuilder {
312            _state: PhantomData,
313            _fields: self._fields,
314            _lifetime: PhantomData,
315        }
316    }
317}
318
319impl<'a, S: template_view_state::State> TemplateViewBuilder<'a, S> {
320    /// Set the `lang` field (optional)
321    pub fn lang(mut self, value: impl Into<Option<Language>>) -> Self {
322        self._fields.4 = value.into();
323        self
324    }
325    /// Set the `lang` field to an Option value (optional)
326    pub fn maybe_lang(mut self, value: Option<Language>) -> Self {
327        self._fields.4 = value;
328        self
329    }
330}
331
332impl<'a, S> TemplateViewBuilder<'a, S>
333where
334    S: template_view_state::State,
335    S::LastUpdatedBy: template_view_state::IsUnset,
336{
337    /// Set the `lastUpdatedBy` field (required)
338    pub fn last_updated_by(
339        mut self,
340        value: impl Into<Did<'a>>,
341    ) -> TemplateViewBuilder<'a, template_view_state::SetLastUpdatedBy<S>> {
342        self._fields.5 = Option::Some(value.into());
343        TemplateViewBuilder {
344            _state: PhantomData,
345            _fields: self._fields,
346            _lifetime: PhantomData,
347        }
348    }
349}
350
351impl<'a, S> TemplateViewBuilder<'a, S>
352where
353    S: template_view_state::State,
354    S::Name: template_view_state::IsUnset,
355{
356    /// Set the `name` field (required)
357    pub fn name(
358        mut self,
359        value: impl Into<CowStr<'a>>,
360    ) -> TemplateViewBuilder<'a, template_view_state::SetName<S>> {
361        self._fields.6 = Option::Some(value.into());
362        TemplateViewBuilder {
363            _state: PhantomData,
364            _fields: self._fields,
365            _lifetime: PhantomData,
366        }
367    }
368}
369
370impl<'a, S: template_view_state::State> TemplateViewBuilder<'a, S> {
371    /// Set the `subject` field (optional)
372    pub fn subject(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
373        self._fields.7 = value.into();
374        self
375    }
376    /// Set the `subject` field to an Option value (optional)
377    pub fn maybe_subject(mut self, value: Option<CowStr<'a>>) -> Self {
378        self._fields.7 = value;
379        self
380    }
381}
382
383impl<'a, S> TemplateViewBuilder<'a, S>
384where
385    S: template_view_state::State,
386    S::UpdatedAt: template_view_state::IsUnset,
387{
388    /// Set the `updatedAt` field (required)
389    pub fn updated_at(
390        mut self,
391        value: impl Into<Datetime>,
392    ) -> TemplateViewBuilder<'a, template_view_state::SetUpdatedAt<S>> {
393        self._fields.8 = Option::Some(value.into());
394        TemplateViewBuilder {
395            _state: PhantomData,
396            _fields: self._fields,
397            _lifetime: PhantomData,
398        }
399    }
400}
401
402impl<'a, S> TemplateViewBuilder<'a, S>
403where
404    S: template_view_state::State,
405    S::CreatedAt: template_view_state::IsSet,
406    S::UpdatedAt: template_view_state::IsSet,
407    S::Name: template_view_state::IsSet,
408    S::Id: template_view_state::IsSet,
409    S::Disabled: template_view_state::IsSet,
410    S::LastUpdatedBy: template_view_state::IsSet,
411    S::ContentMarkdown: template_view_state::IsSet,
412{
413    /// Build the final struct
414    pub fn build(self) -> TemplateView<'a> {
415        TemplateView {
416            content_markdown: self._fields.0.unwrap(),
417            created_at: self._fields.1.unwrap(),
418            disabled: self._fields.2.unwrap(),
419            id: self._fields.3.unwrap(),
420            lang: self._fields.4,
421            last_updated_by: self._fields.5.unwrap(),
422            name: self._fields.6.unwrap(),
423            subject: self._fields.7,
424            updated_at: self._fields.8.unwrap(),
425            extra_data: Default::default(),
426        }
427    }
428    /// Build the final struct with custom extra_data
429    pub fn build_with_data(
430        self,
431        extra_data: BTreeMap<
432            jacquard_common::deps::smol_str::SmolStr,
433            jacquard_common::types::value::Data<'a>,
434        >,
435    ) -> TemplateView<'a> {
436        TemplateView {
437            content_markdown: self._fields.0.unwrap(),
438            created_at: self._fields.1.unwrap(),
439            disabled: self._fields.2.unwrap(),
440            id: self._fields.3.unwrap(),
441            lang: self._fields.4,
442            last_updated_by: self._fields.5.unwrap(),
443            name: self._fields.6.unwrap(),
444            subject: self._fields.7,
445            updated_at: self._fields.8.unwrap(),
446            extra_data: Some(extra_data),
447        }
448    }
449}
450
451fn lexicon_doc_tools_ozone_communication_defs() -> LexiconDoc<'static> {
452    #[allow(unused_imports)]
453    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
454    use jacquard_lexicon::lexicon::*;
455    use alloc::collections::BTreeMap;
456    LexiconDoc {
457        lexicon: Lexicon::Lexicon1,
458        id: CowStr::new_static("tools.ozone.communication.defs"),
459        defs: {
460            let mut map = BTreeMap::new();
461            map.insert(
462                SmolStr::new_static("templateView"),
463                LexUserType::Object(LexObject {
464                    required: Some(
465                        vec![
466                            SmolStr::new_static("id"), SmolStr::new_static("name"),
467                            SmolStr::new_static("contentMarkdown"),
468                            SmolStr::new_static("disabled"),
469                            SmolStr::new_static("lastUpdatedBy"),
470                            SmolStr::new_static("createdAt"),
471                            SmolStr::new_static("updatedAt")
472                        ],
473                    ),
474                    properties: {
475                        #[allow(unused_mut)]
476                        let mut map = BTreeMap::new();
477                        map.insert(
478                            SmolStr::new_static("contentMarkdown"),
479                            LexObjectProperty::String(LexString {
480                                description: Some(
481                                    CowStr::new_static(
482                                        "Subject of the message, used in emails.",
483                                    ),
484                                ),
485                                ..Default::default()
486                            }),
487                        );
488                        map.insert(
489                            SmolStr::new_static("createdAt"),
490                            LexObjectProperty::String(LexString {
491                                format: Some(LexStringFormat::Datetime),
492                                ..Default::default()
493                            }),
494                        );
495                        map.insert(
496                            SmolStr::new_static("disabled"),
497                            LexObjectProperty::Boolean(LexBoolean {
498                                ..Default::default()
499                            }),
500                        );
501                        map.insert(
502                            SmolStr::new_static("id"),
503                            LexObjectProperty::String(LexString { ..Default::default() }),
504                        );
505                        map.insert(
506                            SmolStr::new_static("lang"),
507                            LexObjectProperty::String(LexString {
508                                description: Some(CowStr::new_static("Message language.")),
509                                format: Some(LexStringFormat::Language),
510                                ..Default::default()
511                            }),
512                        );
513                        map.insert(
514                            SmolStr::new_static("lastUpdatedBy"),
515                            LexObjectProperty::String(LexString {
516                                description: Some(
517                                    CowStr::new_static(
518                                        "DID of the user who last updated the template.",
519                                    ),
520                                ),
521                                format: Some(LexStringFormat::Did),
522                                ..Default::default()
523                            }),
524                        );
525                        map.insert(
526                            SmolStr::new_static("name"),
527                            LexObjectProperty::String(LexString {
528                                description: Some(
529                                    CowStr::new_static("Name of the template."),
530                                ),
531                                ..Default::default()
532                            }),
533                        );
534                        map.insert(
535                            SmolStr::new_static("subject"),
536                            LexObjectProperty::String(LexString {
537                                description: Some(
538                                    CowStr::new_static(
539                                        "Content of the template, can contain markdown and variable placeholders.",
540                                    ),
541                                ),
542                                ..Default::default()
543                            }),
544                        );
545                        map.insert(
546                            SmolStr::new_static("updatedAt"),
547                            LexObjectProperty::String(LexString {
548                                format: Some(LexStringFormat::Datetime),
549                                ..Default::default()
550                            }),
551                        );
552                        map
553                    },
554                    ..Default::default()
555                }),
556            );
557            map
558        },
559        ..Default::default()
560    }
561}