jacquard_api/place_stream/
server.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.server.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_webhook;
9pub mod delete_webhook;
10pub mod get_webhook;
11pub mod list_webhooks;
12pub mod settings;
13pub mod update_webhook;
14
15#[jacquard_derive::lexicon]
16#[derive(
17    serde::Serialize,
18    serde::Deserialize,
19    Debug,
20    Clone,
21    PartialEq,
22    Eq,
23    jacquard_derive::IntoStatic,
24    Default
25)]
26#[serde(rename_all = "camelCase")]
27pub struct RewriteRule<'a> {
28    /// Text to search for and replace.
29    #[serde(borrow)]
30    pub from: jacquard_common::CowStr<'a>,
31    /// Text to replace with.
32    #[serde(borrow)]
33    pub to: jacquard_common::CowStr<'a>,
34}
35
36fn lexicon_doc_place_stream_server_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc<
37    'static,
38> {
39    ::jacquard_lexicon::lexicon::LexiconDoc {
40        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
41        id: ::jacquard_common::CowStr::new_static("place.stream.server.defs"),
42        revision: None,
43        description: None,
44        defs: {
45            let mut map = ::std::collections::BTreeMap::new();
46            map.insert(
47                ::jacquard_common::smol_str::SmolStr::new_static("rewriteRule"),
48                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
49                    description: None,
50                    required: Some(
51                        vec![
52                            ::jacquard_common::smol_str::SmolStr::new_static("from"),
53                            ::jacquard_common::smol_str::SmolStr::new_static("to")
54                        ],
55                    ),
56                    nullable: None,
57                    properties: {
58                        #[allow(unused_mut)]
59                        let mut map = ::std::collections::BTreeMap::new();
60                        map.insert(
61                            ::jacquard_common::smol_str::SmolStr::new_static("from"),
62                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
63                                description: Some(
64                                    ::jacquard_common::CowStr::new_static(
65                                        "Text to search for and replace.",
66                                    ),
67                                ),
68                                format: None,
69                                default: None,
70                                min_length: Some(1usize),
71                                max_length: Some(100usize),
72                                min_graphemes: None,
73                                max_graphemes: None,
74                                r#enum: None,
75                                r#const: None,
76                                known_values: None,
77                            }),
78                        );
79                        map.insert(
80                            ::jacquard_common::smol_str::SmolStr::new_static("to"),
81                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
82                                description: Some(
83                                    ::jacquard_common::CowStr::new_static(
84                                        "Text to replace with.",
85                                    ),
86                                ),
87                                format: None,
88                                default: None,
89                                min_length: None,
90                                max_length: Some(100usize),
91                                min_graphemes: None,
92                                max_graphemes: None,
93                                r#enum: None,
94                                r#const: None,
95                                known_values: None,
96                            }),
97                        );
98                        map
99                    },
100                }),
101            );
102            map.insert(
103                ::jacquard_common::smol_str::SmolStr::new_static("webhook"),
104                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
105                    description: Some(
106                        ::jacquard_common::CowStr::new_static(
107                            "A webhook configuration for receiving Streamplace events.",
108                        ),
109                    ),
110                    required: Some(
111                        vec![
112                            ::jacquard_common::smol_str::SmolStr::new_static("id"),
113                            ::jacquard_common::smol_str::SmolStr::new_static("url"),
114                            ::jacquard_common::smol_str::SmolStr::new_static("events"),
115                            ::jacquard_common::smol_str::SmolStr::new_static("active"),
116                            ::jacquard_common::smol_str::SmolStr::new_static("createdAt")
117                        ],
118                    ),
119                    nullable: None,
120                    properties: {
121                        #[allow(unused_mut)]
122                        let mut map = ::std::collections::BTreeMap::new();
123                        map.insert(
124                            ::jacquard_common::smol_str::SmolStr::new_static("active"),
125                            ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
126                                description: None,
127                                default: None,
128                                r#const: None,
129                            }),
130                        );
131                        map.insert(
132                            ::jacquard_common::smol_str::SmolStr::new_static(
133                                "createdAt",
134                            ),
135                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
136                                description: Some(
137                                    ::jacquard_common::CowStr::new_static(
138                                        "When this webhook was created.",
139                                    ),
140                                ),
141                                format: Some(
142                                    ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
143                                ),
144                                default: None,
145                                min_length: None,
146                                max_length: None,
147                                min_graphemes: None,
148                                max_graphemes: None,
149                                r#enum: None,
150                                r#const: None,
151                                known_values: None,
152                            }),
153                        );
154                        map.insert(
155                            ::jacquard_common::smol_str::SmolStr::new_static(
156                                "description",
157                            ),
158                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
159                                description: Some(
160                                    ::jacquard_common::CowStr::new_static(
161                                        "A description of what this webhook is used for.",
162                                    ),
163                                ),
164                                format: None,
165                                default: None,
166                                min_length: None,
167                                max_length: Some(500usize),
168                                min_graphemes: None,
169                                max_graphemes: None,
170                                r#enum: None,
171                                r#const: None,
172                                known_values: None,
173                            }),
174                        );
175                        map.insert(
176                            ::jacquard_common::smol_str::SmolStr::new_static(
177                                "errorCount",
178                            ),
179                            ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
180                                description: None,
181                                default: None,
182                                minimum: None,
183                                maximum: None,
184                                r#enum: None,
185                                r#const: None,
186                            }),
187                        );
188                        map.insert(
189                            ::jacquard_common::smol_str::SmolStr::new_static("events"),
190                            ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
191                                description: Some(
192                                    ::jacquard_common::CowStr::new_static(
193                                        "The types of events this webhook should receive.",
194                                    ),
195                                ),
196                                items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
197                                    description: None,
198                                    format: None,
199                                    default: None,
200                                    min_length: None,
201                                    max_length: None,
202                                    min_graphemes: None,
203                                    max_graphemes: None,
204                                    r#enum: None,
205                                    r#const: None,
206                                    known_values: None,
207                                }),
208                                min_length: None,
209                                max_length: None,
210                            }),
211                        );
212                        map.insert(
213                            ::jacquard_common::smol_str::SmolStr::new_static("id"),
214                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
215                                description: Some(
216                                    ::jacquard_common::CowStr::new_static(
217                                        "Unique identifier for this webhook.",
218                                    ),
219                                ),
220                                format: None,
221                                default: None,
222                                min_length: None,
223                                max_length: None,
224                                min_graphemes: None,
225                                max_graphemes: None,
226                                r#enum: None,
227                                r#const: None,
228                                known_values: None,
229                            }),
230                        );
231                        map.insert(
232                            ::jacquard_common::smol_str::SmolStr::new_static(
233                                "lastTriggered",
234                            ),
235                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
236                                description: Some(
237                                    ::jacquard_common::CowStr::new_static(
238                                        "When this webhook was last triggered.",
239                                    ),
240                                ),
241                                format: Some(
242                                    ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
243                                ),
244                                default: None,
245                                min_length: None,
246                                max_length: None,
247                                min_graphemes: None,
248                                max_graphemes: None,
249                                r#enum: None,
250                                r#const: None,
251                                known_values: None,
252                            }),
253                        );
254                        map.insert(
255                            ::jacquard_common::smol_str::SmolStr::new_static(
256                                "muteWords",
257                            ),
258                            ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
259                                description: Some(
260                                    ::jacquard_common::CowStr::new_static(
261                                        "Words to filter out from chat messages. Messages containing any of these words will not be forwarded.",
262                                    ),
263                                ),
264                                items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
265                                    description: None,
266                                    format: None,
267                                    default: None,
268                                    min_length: None,
269                                    max_length: Some(100usize),
270                                    min_graphemes: None,
271                                    max_graphemes: None,
272                                    r#enum: None,
273                                    r#const: None,
274                                    known_values: None,
275                                }),
276                                min_length: None,
277                                max_length: None,
278                            }),
279                        );
280                        map.insert(
281                            ::jacquard_common::smol_str::SmolStr::new_static("name"),
282                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
283                                description: Some(
284                                    ::jacquard_common::CowStr::new_static(
285                                        "A user-friendly name for this webhook.",
286                                    ),
287                                ),
288                                format: None,
289                                default: None,
290                                min_length: None,
291                                max_length: Some(100usize),
292                                min_graphemes: None,
293                                max_graphemes: None,
294                                r#enum: None,
295                                r#const: None,
296                                known_values: None,
297                            }),
298                        );
299                        map.insert(
300                            ::jacquard_common::smol_str::SmolStr::new_static("prefix"),
301                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
302                                description: Some(
303                                    ::jacquard_common::CowStr::new_static(
304                                        "Text to prepend to webhook messages.",
305                                    ),
306                                ),
307                                format: None,
308                                default: None,
309                                min_length: None,
310                                max_length: Some(100usize),
311                                min_graphemes: None,
312                                max_graphemes: None,
313                                r#enum: None,
314                                r#const: None,
315                                known_values: None,
316                            }),
317                        );
318                        map.insert(
319                            ::jacquard_common::smol_str::SmolStr::new_static("rewrite"),
320                            ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
321                                description: Some(
322                                    ::jacquard_common::CowStr::new_static(
323                                        "Text replacement rules for webhook messages.",
324                                    ),
325                                ),
326                                items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
327                                    description: None,
328                                    r#ref: ::jacquard_common::CowStr::new_static("#rewriteRule"),
329                                }),
330                                min_length: None,
331                                max_length: None,
332                            }),
333                        );
334                        map.insert(
335                            ::jacquard_common::smol_str::SmolStr::new_static("suffix"),
336                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
337                                description: Some(
338                                    ::jacquard_common::CowStr::new_static(
339                                        "Text to append to webhook messages.",
340                                    ),
341                                ),
342                                format: None,
343                                default: None,
344                                min_length: None,
345                                max_length: Some(100usize),
346                                min_graphemes: None,
347                                max_graphemes: None,
348                                r#enum: None,
349                                r#const: None,
350                                known_values: None,
351                            }),
352                        );
353                        map.insert(
354                            ::jacquard_common::smol_str::SmolStr::new_static(
355                                "updatedAt",
356                            ),
357                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
358                                description: Some(
359                                    ::jacquard_common::CowStr::new_static(
360                                        "When this webhook was last updated.",
361                                    ),
362                                ),
363                                format: Some(
364                                    ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
365                                ),
366                                default: None,
367                                min_length: None,
368                                max_length: None,
369                                min_graphemes: None,
370                                max_graphemes: None,
371                                r#enum: None,
372                                r#const: None,
373                                known_values: None,
374                            }),
375                        );
376                        map.insert(
377                            ::jacquard_common::smol_str::SmolStr::new_static("url"),
378                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
379                                description: Some(
380                                    ::jacquard_common::CowStr::new_static(
381                                        "The webhook URL where events will be sent.",
382                                    ),
383                                ),
384                                format: Some(
385                                    ::jacquard_lexicon::lexicon::LexStringFormat::Uri,
386                                ),
387                                default: None,
388                                min_length: None,
389                                max_length: None,
390                                min_graphemes: None,
391                                max_graphemes: None,
392                                r#enum: None,
393                                r#const: None,
394                                known_values: None,
395                            }),
396                        );
397                        map
398                    },
399                }),
400            );
401            map
402        },
403    }
404}
405
406impl<'a> ::jacquard_lexicon::schema::LexiconSchema for RewriteRule<'a> {
407    fn nsid() -> &'static str {
408        "place.stream.server.defs"
409    }
410    fn def_name() -> &'static str {
411        "rewriteRule"
412    }
413    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
414        lexicon_doc_place_stream_server_defs()
415    }
416    fn validate(
417        &self,
418    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
419        {
420            let value = &self.from;
421            #[allow(unused_comparisons)]
422            if <str>::len(value.as_ref()) > 100usize {
423                return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
424                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
425                        "from",
426                    ),
427                    max: 100usize,
428                    actual: <str>::len(value.as_ref()),
429                });
430            }
431        }
432        {
433            let value = &self.from;
434            #[allow(unused_comparisons)]
435            if <str>::len(value.as_ref()) < 1usize {
436                return Err(::jacquard_lexicon::validation::ConstraintError::MinLength {
437                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
438                        "from",
439                    ),
440                    min: 1usize,
441                    actual: <str>::len(value.as_ref()),
442                });
443            }
444        }
445        {
446            let value = &self.to;
447            #[allow(unused_comparisons)]
448            if <str>::len(value.as_ref()) > 100usize {
449                return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
450                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
451                        "to",
452                    ),
453                    max: 100usize,
454                    actual: <str>::len(value.as_ref()),
455                });
456            }
457        }
458        Ok(())
459    }
460}
461
462/// A webhook configuration for receiving Streamplace events.
463#[jacquard_derive::lexicon]
464#[derive(
465    serde::Serialize,
466    serde::Deserialize,
467    Debug,
468    Clone,
469    PartialEq,
470    Eq,
471    jacquard_derive::IntoStatic
472)]
473#[serde(rename_all = "camelCase")]
474pub struct Webhook<'a> {
475    /// Whether this webhook is currently active.
476    pub active: bool,
477    /// When this webhook was created.
478    pub created_at: jacquard_common::types::string::Datetime,
479    /// A description of what this webhook is used for.
480    #[serde(skip_serializing_if = "std::option::Option::is_none")]
481    #[serde(borrow)]
482    pub description: Option<jacquard_common::CowStr<'a>>,
483    /// Number of consecutive errors for this webhook.
484    #[serde(skip_serializing_if = "std::option::Option::is_none")]
485    pub error_count: Option<i64>,
486    /// The types of events this webhook should receive.
487    #[serde(borrow)]
488    pub events: Vec<jacquard_common::CowStr<'a>>,
489    /// Unique identifier for this webhook.
490    #[serde(borrow)]
491    pub id: jacquard_common::CowStr<'a>,
492    /// When this webhook was last triggered.
493    #[serde(skip_serializing_if = "std::option::Option::is_none")]
494    pub last_triggered: Option<jacquard_common::types::string::Datetime>,
495    /// Words to filter out from chat messages. Messages containing any of these words will not be forwarded.
496    #[serde(skip_serializing_if = "std::option::Option::is_none")]
497    #[serde(borrow)]
498    pub mute_words: Option<Vec<jacquard_common::CowStr<'a>>>,
499    /// A user-friendly name for this webhook.
500    #[serde(skip_serializing_if = "std::option::Option::is_none")]
501    #[serde(borrow)]
502    pub name: Option<jacquard_common::CowStr<'a>>,
503    /// Text to prepend to webhook messages.
504    #[serde(skip_serializing_if = "std::option::Option::is_none")]
505    #[serde(borrow)]
506    pub prefix: Option<jacquard_common::CowStr<'a>>,
507    /// Text replacement rules for webhook messages.
508    #[serde(skip_serializing_if = "std::option::Option::is_none")]
509    #[serde(borrow)]
510    pub rewrite: Option<Vec<crate::place_stream::server::RewriteRule<'a>>>,
511    /// Text to append to webhook messages.
512    #[serde(skip_serializing_if = "std::option::Option::is_none")]
513    #[serde(borrow)]
514    pub suffix: Option<jacquard_common::CowStr<'a>>,
515    /// When this webhook was last updated.
516    #[serde(skip_serializing_if = "std::option::Option::is_none")]
517    pub updated_at: Option<jacquard_common::types::string::Datetime>,
518    /// The webhook URL where events will be sent.
519    #[serde(borrow)]
520    pub url: jacquard_common::types::string::Uri<'a>,
521}
522
523pub mod webhook_state {
524
525    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
526    #[allow(unused)]
527    use ::core::marker::PhantomData;
528    mod sealed {
529        pub trait Sealed {}
530    }
531    /// State trait tracking which required fields have been set
532    pub trait State: sealed::Sealed {
533        type Id;
534        type Url;
535        type Events;
536        type Active;
537        type CreatedAt;
538    }
539    /// Empty state - all required fields are unset
540    pub struct Empty(());
541    impl sealed::Sealed for Empty {}
542    impl State for Empty {
543        type Id = Unset;
544        type Url = Unset;
545        type Events = Unset;
546        type Active = Unset;
547        type CreatedAt = Unset;
548    }
549    ///State transition - sets the `id` field to Set
550    pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
551    impl<S: State> sealed::Sealed for SetId<S> {}
552    impl<S: State> State for SetId<S> {
553        type Id = Set<members::id>;
554        type Url = S::Url;
555        type Events = S::Events;
556        type Active = S::Active;
557        type CreatedAt = S::CreatedAt;
558    }
559    ///State transition - sets the `url` field to Set
560    pub struct SetUrl<S: State = Empty>(PhantomData<fn() -> S>);
561    impl<S: State> sealed::Sealed for SetUrl<S> {}
562    impl<S: State> State for SetUrl<S> {
563        type Id = S::Id;
564        type Url = Set<members::url>;
565        type Events = S::Events;
566        type Active = S::Active;
567        type CreatedAt = S::CreatedAt;
568    }
569    ///State transition - sets the `events` field to Set
570    pub struct SetEvents<S: State = Empty>(PhantomData<fn() -> S>);
571    impl<S: State> sealed::Sealed for SetEvents<S> {}
572    impl<S: State> State for SetEvents<S> {
573        type Id = S::Id;
574        type Url = S::Url;
575        type Events = Set<members::events>;
576        type Active = S::Active;
577        type CreatedAt = S::CreatedAt;
578    }
579    ///State transition - sets the `active` field to Set
580    pub struct SetActive<S: State = Empty>(PhantomData<fn() -> S>);
581    impl<S: State> sealed::Sealed for SetActive<S> {}
582    impl<S: State> State for SetActive<S> {
583        type Id = S::Id;
584        type Url = S::Url;
585        type Events = S::Events;
586        type Active = Set<members::active>;
587        type CreatedAt = S::CreatedAt;
588    }
589    ///State transition - sets the `created_at` field to Set
590    pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
591    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
592    impl<S: State> State for SetCreatedAt<S> {
593        type Id = S::Id;
594        type Url = S::Url;
595        type Events = S::Events;
596        type Active = S::Active;
597        type CreatedAt = Set<members::created_at>;
598    }
599    /// Marker types for field names
600    #[allow(non_camel_case_types)]
601    pub mod members {
602        ///Marker type for the `id` field
603        pub struct id(());
604        ///Marker type for the `url` field
605        pub struct url(());
606        ///Marker type for the `events` field
607        pub struct events(());
608        ///Marker type for the `active` field
609        pub struct active(());
610        ///Marker type for the `created_at` field
611        pub struct created_at(());
612    }
613}
614
615/// Builder for constructing an instance of this type
616pub struct WebhookBuilder<'a, S: webhook_state::State> {
617    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
618    __unsafe_private_named: (
619        ::core::option::Option<bool>,
620        ::core::option::Option<jacquard_common::types::string::Datetime>,
621        ::core::option::Option<jacquard_common::CowStr<'a>>,
622        ::core::option::Option<i64>,
623        ::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
624        ::core::option::Option<jacquard_common::CowStr<'a>>,
625        ::core::option::Option<jacquard_common::types::string::Datetime>,
626        ::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
627        ::core::option::Option<jacquard_common::CowStr<'a>>,
628        ::core::option::Option<jacquard_common::CowStr<'a>>,
629        ::core::option::Option<Vec<crate::place_stream::server::RewriteRule<'a>>>,
630        ::core::option::Option<jacquard_common::CowStr<'a>>,
631        ::core::option::Option<jacquard_common::types::string::Datetime>,
632        ::core::option::Option<jacquard_common::types::string::Uri<'a>>,
633    ),
634    _phantom: ::core::marker::PhantomData<&'a ()>,
635}
636
637impl<'a> Webhook<'a> {
638    /// Create a new builder for this type
639    pub fn new() -> WebhookBuilder<'a, webhook_state::Empty> {
640        WebhookBuilder::new()
641    }
642}
643
644impl<'a> WebhookBuilder<'a, webhook_state::Empty> {
645    /// Create a new builder with all fields unset
646    pub fn new() -> Self {
647        WebhookBuilder {
648            _phantom_state: ::core::marker::PhantomData,
649            __unsafe_private_named: (
650                None,
651                None,
652                None,
653                None,
654                None,
655                None,
656                None,
657                None,
658                None,
659                None,
660                None,
661                None,
662                None,
663                None,
664            ),
665            _phantom: ::core::marker::PhantomData,
666        }
667    }
668}
669
670impl<'a, S> WebhookBuilder<'a, S>
671where
672    S: webhook_state::State,
673    S::Active: webhook_state::IsUnset,
674{
675    /// Set the `active` field (required)
676    pub fn active(
677        mut self,
678        value: impl Into<bool>,
679    ) -> WebhookBuilder<'a, webhook_state::SetActive<S>> {
680        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
681        WebhookBuilder {
682            _phantom_state: ::core::marker::PhantomData,
683            __unsafe_private_named: self.__unsafe_private_named,
684            _phantom: ::core::marker::PhantomData,
685        }
686    }
687}
688
689impl<'a, S> WebhookBuilder<'a, S>
690where
691    S: webhook_state::State,
692    S::CreatedAt: webhook_state::IsUnset,
693{
694    /// Set the `createdAt` field (required)
695    pub fn created_at(
696        mut self,
697        value: impl Into<jacquard_common::types::string::Datetime>,
698    ) -> WebhookBuilder<'a, webhook_state::SetCreatedAt<S>> {
699        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
700        WebhookBuilder {
701            _phantom_state: ::core::marker::PhantomData,
702            __unsafe_private_named: self.__unsafe_private_named,
703            _phantom: ::core::marker::PhantomData,
704        }
705    }
706}
707
708impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> {
709    /// Set the `description` field (optional)
710    pub fn description(
711        mut self,
712        value: impl Into<Option<jacquard_common::CowStr<'a>>>,
713    ) -> Self {
714        self.__unsafe_private_named.2 = value.into();
715        self
716    }
717    /// Set the `description` field to an Option value (optional)
718    pub fn maybe_description(
719        mut self,
720        value: Option<jacquard_common::CowStr<'a>>,
721    ) -> Self {
722        self.__unsafe_private_named.2 = value;
723        self
724    }
725}
726
727impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> {
728    /// Set the `errorCount` field (optional)
729    pub fn error_count(mut self, value: impl Into<Option<i64>>) -> Self {
730        self.__unsafe_private_named.3 = value.into();
731        self
732    }
733    /// Set the `errorCount` field to an Option value (optional)
734    pub fn maybe_error_count(mut self, value: Option<i64>) -> Self {
735        self.__unsafe_private_named.3 = value;
736        self
737    }
738}
739
740impl<'a, S> WebhookBuilder<'a, S>
741where
742    S: webhook_state::State,
743    S::Events: webhook_state::IsUnset,
744{
745    /// Set the `events` field (required)
746    pub fn events(
747        mut self,
748        value: impl Into<Vec<jacquard_common::CowStr<'a>>>,
749    ) -> WebhookBuilder<'a, webhook_state::SetEvents<S>> {
750        self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
751        WebhookBuilder {
752            _phantom_state: ::core::marker::PhantomData,
753            __unsafe_private_named: self.__unsafe_private_named,
754            _phantom: ::core::marker::PhantomData,
755        }
756    }
757}
758
759impl<'a, S> WebhookBuilder<'a, S>
760where
761    S: webhook_state::State,
762    S::Id: webhook_state::IsUnset,
763{
764    /// Set the `id` field (required)
765    pub fn id(
766        mut self,
767        value: impl Into<jacquard_common::CowStr<'a>>,
768    ) -> WebhookBuilder<'a, webhook_state::SetId<S>> {
769        self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
770        WebhookBuilder {
771            _phantom_state: ::core::marker::PhantomData,
772            __unsafe_private_named: self.__unsafe_private_named,
773            _phantom: ::core::marker::PhantomData,
774        }
775    }
776}
777
778impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> {
779    /// Set the `lastTriggered` field (optional)
780    pub fn last_triggered(
781        mut self,
782        value: impl Into<Option<jacquard_common::types::string::Datetime>>,
783    ) -> Self {
784        self.__unsafe_private_named.6 = value.into();
785        self
786    }
787    /// Set the `lastTriggered` field to an Option value (optional)
788    pub fn maybe_last_triggered(
789        mut self,
790        value: Option<jacquard_common::types::string::Datetime>,
791    ) -> Self {
792        self.__unsafe_private_named.6 = value;
793        self
794    }
795}
796
797impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> {
798    /// Set the `muteWords` field (optional)
799    pub fn mute_words(
800        mut self,
801        value: impl Into<Option<Vec<jacquard_common::CowStr<'a>>>>,
802    ) -> Self {
803        self.__unsafe_private_named.7 = value.into();
804        self
805    }
806    /// Set the `muteWords` field to an Option value (optional)
807    pub fn maybe_mute_words(
808        mut self,
809        value: Option<Vec<jacquard_common::CowStr<'a>>>,
810    ) -> Self {
811        self.__unsafe_private_named.7 = value;
812        self
813    }
814}
815
816impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> {
817    /// Set the `name` field (optional)
818    pub fn name(
819        mut self,
820        value: impl Into<Option<jacquard_common::CowStr<'a>>>,
821    ) -> Self {
822        self.__unsafe_private_named.8 = value.into();
823        self
824    }
825    /// Set the `name` field to an Option value (optional)
826    pub fn maybe_name(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
827        self.__unsafe_private_named.8 = value;
828        self
829    }
830}
831
832impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> {
833    /// Set the `prefix` field (optional)
834    pub fn prefix(
835        mut self,
836        value: impl Into<Option<jacquard_common::CowStr<'a>>>,
837    ) -> Self {
838        self.__unsafe_private_named.9 = value.into();
839        self
840    }
841    /// Set the `prefix` field to an Option value (optional)
842    pub fn maybe_prefix(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
843        self.__unsafe_private_named.9 = value;
844        self
845    }
846}
847
848impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> {
849    /// Set the `rewrite` field (optional)
850    pub fn rewrite(
851        mut self,
852        value: impl Into<Option<Vec<crate::place_stream::server::RewriteRule<'a>>>>,
853    ) -> Self {
854        self.__unsafe_private_named.10 = value.into();
855        self
856    }
857    /// Set the `rewrite` field to an Option value (optional)
858    pub fn maybe_rewrite(
859        mut self,
860        value: Option<Vec<crate::place_stream::server::RewriteRule<'a>>>,
861    ) -> Self {
862        self.__unsafe_private_named.10 = value;
863        self
864    }
865}
866
867impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> {
868    /// Set the `suffix` field (optional)
869    pub fn suffix(
870        mut self,
871        value: impl Into<Option<jacquard_common::CowStr<'a>>>,
872    ) -> Self {
873        self.__unsafe_private_named.11 = value.into();
874        self
875    }
876    /// Set the `suffix` field to an Option value (optional)
877    pub fn maybe_suffix(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
878        self.__unsafe_private_named.11 = value;
879        self
880    }
881}
882
883impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> {
884    /// Set the `updatedAt` field (optional)
885    pub fn updated_at(
886        mut self,
887        value: impl Into<Option<jacquard_common::types::string::Datetime>>,
888    ) -> Self {
889        self.__unsafe_private_named.12 = value.into();
890        self
891    }
892    /// Set the `updatedAt` field to an Option value (optional)
893    pub fn maybe_updated_at(
894        mut self,
895        value: Option<jacquard_common::types::string::Datetime>,
896    ) -> Self {
897        self.__unsafe_private_named.12 = value;
898        self
899    }
900}
901
902impl<'a, S> WebhookBuilder<'a, S>
903where
904    S: webhook_state::State,
905    S::Url: webhook_state::IsUnset,
906{
907    /// Set the `url` field (required)
908    pub fn url(
909        mut self,
910        value: impl Into<jacquard_common::types::string::Uri<'a>>,
911    ) -> WebhookBuilder<'a, webhook_state::SetUrl<S>> {
912        self.__unsafe_private_named.13 = ::core::option::Option::Some(value.into());
913        WebhookBuilder {
914            _phantom_state: ::core::marker::PhantomData,
915            __unsafe_private_named: self.__unsafe_private_named,
916            _phantom: ::core::marker::PhantomData,
917        }
918    }
919}
920
921impl<'a, S> WebhookBuilder<'a, S>
922where
923    S: webhook_state::State,
924    S::Id: webhook_state::IsSet,
925    S::Url: webhook_state::IsSet,
926    S::Events: webhook_state::IsSet,
927    S::Active: webhook_state::IsSet,
928    S::CreatedAt: webhook_state::IsSet,
929{
930    /// Build the final struct
931    pub fn build(self) -> Webhook<'a> {
932        Webhook {
933            active: self.__unsafe_private_named.0.unwrap(),
934            created_at: self.__unsafe_private_named.1.unwrap(),
935            description: self.__unsafe_private_named.2,
936            error_count: self.__unsafe_private_named.3,
937            events: self.__unsafe_private_named.4.unwrap(),
938            id: self.__unsafe_private_named.5.unwrap(),
939            last_triggered: self.__unsafe_private_named.6,
940            mute_words: self.__unsafe_private_named.7,
941            name: self.__unsafe_private_named.8,
942            prefix: self.__unsafe_private_named.9,
943            rewrite: self.__unsafe_private_named.10,
944            suffix: self.__unsafe_private_named.11,
945            updated_at: self.__unsafe_private_named.12,
946            url: self.__unsafe_private_named.13.unwrap(),
947            extra_data: Default::default(),
948        }
949    }
950    /// Build the final struct with custom extra_data
951    pub fn build_with_data(
952        self,
953        extra_data: std::collections::BTreeMap<
954            jacquard_common::smol_str::SmolStr,
955            jacquard_common::types::value::Data<'a>,
956        >,
957    ) -> Webhook<'a> {
958        Webhook {
959            active: self.__unsafe_private_named.0.unwrap(),
960            created_at: self.__unsafe_private_named.1.unwrap(),
961            description: self.__unsafe_private_named.2,
962            error_count: self.__unsafe_private_named.3,
963            events: self.__unsafe_private_named.4.unwrap(),
964            id: self.__unsafe_private_named.5.unwrap(),
965            last_triggered: self.__unsafe_private_named.6,
966            mute_words: self.__unsafe_private_named.7,
967            name: self.__unsafe_private_named.8,
968            prefix: self.__unsafe_private_named.9,
969            rewrite: self.__unsafe_private_named.10,
970            suffix: self.__unsafe_private_named.11,
971            updated_at: self.__unsafe_private_named.12,
972            url: self.__unsafe_private_named.13.unwrap(),
973            extra_data: Some(extra_data),
974        }
975    }
976}
977
978impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Webhook<'a> {
979    fn nsid() -> &'static str {
980        "place.stream.server.defs"
981    }
982    fn def_name() -> &'static str {
983        "webhook"
984    }
985    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
986        lexicon_doc_place_stream_server_defs()
987    }
988    fn validate(
989        &self,
990    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
991        if let Some(ref value) = self.description {
992            #[allow(unused_comparisons)]
993            if <str>::len(value.as_ref()) > 500usize {
994                return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
995                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
996                        "description",
997                    ),
998                    max: 500usize,
999                    actual: <str>::len(value.as_ref()),
1000                });
1001            }
1002        }
1003        if let Some(ref value) = self.name {
1004            #[allow(unused_comparisons)]
1005            if <str>::len(value.as_ref()) > 100usize {
1006                return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1007                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1008                        "name",
1009                    ),
1010                    max: 100usize,
1011                    actual: <str>::len(value.as_ref()),
1012                });
1013            }
1014        }
1015        if let Some(ref value) = self.prefix {
1016            #[allow(unused_comparisons)]
1017            if <str>::len(value.as_ref()) > 100usize {
1018                return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1019                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1020                        "prefix",
1021                    ),
1022                    max: 100usize,
1023                    actual: <str>::len(value.as_ref()),
1024                });
1025            }
1026        }
1027        if let Some(ref value) = self.suffix {
1028            #[allow(unused_comparisons)]
1029            if <str>::len(value.as_ref()) > 100usize {
1030                return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1031                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1032                        "suffix",
1033                    ),
1034                    max: 100usize,
1035                    actual: <str>::len(value.as_ref()),
1036                });
1037            }
1038        }
1039        Ok(())
1040    }
1041}