slack_rust/block/
block_elements.rs

1//! Slack Block elements  
2use crate::block::block_object::{
3    ConfirmationBlockObject, DispatchActionConfig, OptionBlockObject, OptionGroupBlockObject,
4    TextBlockObject,
5};
6use serde::{Deserialize, Serialize};
7use serde_with::skip_serializing_none;
8
9/// See: <https://api.slack.com/reference/block-kit/block-elements>
10#[derive(Deserialize, Serialize, Debug, PartialEq)]
11#[serde(tag = "type")]
12pub enum BlockElement {
13    #[serde(rename = "button")]
14    ButtonElement(ButtonElement),
15    #[serde(rename = "checkboxes")]
16    CheckboxGroupsBlockElement(CheckboxGroupsBlockElement),
17    #[serde(rename = "datepicker")]
18    DatePickerBlockElement(DatePickerBlockElement),
19    #[serde(rename = "image")]
20    ImageBlockElement(ImageBlockElement),
21    #[serde(rename = "multi_static_select")]
22    MultiSelectBlockElement(MultiSelectBlockElement),
23    #[serde(rename = "overflow")]
24    OverflowBlockElement(OverflowBlockElement),
25    #[serde(rename = "plain_text_input")]
26    PlainTextInputBlockElement(PlainTextInputBlockElement),
27    #[serde(rename = "radio_buttons")]
28    RadioButtonsBlockElement(RadioButtonsBlockElement),
29    #[serde(rename = "static_select")]
30    SelectBlockElement(SelectBlockElement),
31    #[serde(rename = "timepicker")]
32    TimePickerBlockElement(TimePickerBlockElement),
33    #[serde(skip)]
34    None,
35}
36
37impl BlockElement {
38    pub fn block_type(&self) -> BlockElementType {
39        match self {
40            BlockElement::ButtonElement(ButtonElement { .. }) => BlockElementType::Button,
41            BlockElement::CheckboxGroupsBlockElement(CheckboxGroupsBlockElement { .. }) => {
42                BlockElementType::Checkboxes
43            }
44            BlockElement::DatePickerBlockElement(DatePickerBlockElement { .. }) => {
45                BlockElementType::Datepicker
46            }
47            BlockElement::ImageBlockElement(ImageBlockElement { .. }) => BlockElementType::Image,
48            BlockElement::MultiSelectBlockElement(MultiSelectBlockElement { .. }) => {
49                BlockElementType::MultiStaticSelect
50            }
51            BlockElement::OverflowBlockElement(OverflowBlockElement { .. }) => {
52                BlockElementType::Overflow
53            }
54            BlockElement::PlainTextInputBlockElement(PlainTextInputBlockElement { .. }) => {
55                BlockElementType::PlainTextInput
56            }
57            BlockElement::RadioButtonsBlockElement(RadioButtonsBlockElement { .. }) => {
58                BlockElementType::RadioButtons
59            }
60            BlockElement::SelectBlockElement(SelectBlockElement { .. }) => {
61                BlockElementType::StaticSelect
62            }
63            BlockElement::TimePickerBlockElement(TimePickerBlockElement { .. }) => {
64                BlockElementType::Timepicker
65            }
66            BlockElement::None => BlockElementType::None,
67        }
68    }
69}
70
71impl Default for BlockElement {
72    fn default() -> Self {
73        BlockElement::None
74    }
75}
76
77#[derive(Deserialize, Serialize, Debug, PartialEq)]
78#[serde(tag = "type")]
79pub enum MixedElement {
80    #[serde(rename = "image")]
81    ImageBlockElement(ImageBlockElement),
82    #[serde(rename = "plain_text")]
83    PlainTextBlockObject {
84        text: String,
85        emoji: Option<bool>,
86        verbatim: Option<bool>,
87    },
88    #[serde(rename = "mrkdwn")]
89    MarkdownBlockObject {
90        text: String,
91        emoji: Option<bool>,
92        verbatim: Option<bool>,
93    },
94    #[serde(skip)]
95    None,
96}
97
98#[derive(Deserialize, Serialize, Debug, PartialEq)]
99#[serde(rename_all = "snake_case")]
100pub enum MixedElementType {
101    Image,
102    PlainText,
103    Mrkdwn,
104    #[serde(skip)]
105    None,
106}
107
108impl MixedElement {
109    pub fn block_type(&self) -> MixedElementType {
110        match self {
111            MixedElement::ImageBlockElement(ImageBlockElement { .. }) => MixedElementType::Image,
112            MixedElement::PlainTextBlockObject { .. } => MixedElementType::PlainText,
113            MixedElement::MarkdownBlockObject { .. } => MixedElementType::Mrkdwn,
114            MixedElement::None => MixedElementType::None,
115        }
116    }
117}
118
119impl Default for MixedElement {
120    fn default() -> Self {
121        MixedElement::None
122    }
123}
124
125#[derive(Deserialize, Serialize, Debug, PartialEq)]
126#[serde(rename_all = "snake_case")]
127pub enum BlockElementType {
128    Button,
129    Checkboxes,
130    Datepicker,
131    Image,
132    MultiStaticSelect,
133    Overflow,
134    PlainTextInput,
135    RadioButtons,
136    StaticSelect,
137    Timepicker,
138    #[serde(skip)]
139    None,
140}
141
142impl Default for BlockElementType {
143    fn default() -> Self {
144        BlockElementType::None
145    }
146}
147
148/// An interactive component that inserts a button.  
149/// See: <https://api.slack.com/reference/block-kit/block-elements#button>
150#[skip_serializing_none]
151#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
152pub struct ButtonElement {
153    pub text: TextBlockObject,
154    pub action_id: String,
155    pub url: Option<String>,
156    pub value: Option<String>,
157    pub style: Option<String>,
158    pub confirm: Option<ConfirmationBlockObject>,
159}
160
161impl ButtonElement {
162    pub fn builder(text: TextBlockObject, action_id: String) -> ButtonElementBuilder {
163        ButtonElementBuilder::new(text, action_id)
164    }
165}
166
167#[derive(Debug, Default)]
168pub struct ButtonElementBuilder {
169    pub text: TextBlockObject,
170    pub action_id: String,
171    pub url: Option<String>,
172    pub value: Option<String>,
173    pub style: Option<String>,
174    pub confirm: Option<ConfirmationBlockObject>,
175}
176
177impl ButtonElementBuilder {
178    pub fn new(text: TextBlockObject, action_id: String) -> ButtonElementBuilder {
179        ButtonElementBuilder {
180            text,
181            action_id,
182            ..Default::default()
183        }
184    }
185    pub fn url(mut self, url: String) -> ButtonElementBuilder {
186        self.url = Some(url);
187        self
188    }
189    pub fn value(mut self, value: String) -> ButtonElementBuilder {
190        self.value = Some(value);
191        self
192    }
193    pub fn style(mut self, style: String) -> ButtonElementBuilder {
194        self.style = Some(style);
195        self
196    }
197    pub fn confirm(mut self, confirm: ConfirmationBlockObject) -> ButtonElementBuilder {
198        self.confirm = Some(confirm);
199        self
200    }
201    pub fn build(self) -> ButtonElement {
202        ButtonElement {
203            text: self.text,
204            action_id: self.action_id,
205            url: self.url,
206            value: self.value,
207            style: self.style,
208            confirm: self.confirm,
209        }
210    }
211}
212
213/// A checkbox group that allows a user to choose multiple items from a list of possible options.  
214/// See: <https://api.slack.com/reference/block-kit/block-elements#checkboxes>
215#[skip_serializing_none]
216#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
217pub struct CheckboxGroupsBlockElement {
218    pub action_id: String,
219    pub options: Vec<OptionBlockObject>,
220    pub initial_options: Option<Vec<OptionBlockObject>>,
221    pub confirm: Option<ConfirmationBlockObject>,
222    pub focus_on_load: Option<bool>,
223}
224
225impl CheckboxGroupsBlockElement {
226    pub fn builder(
227        action_id: String,
228        options: Vec<OptionBlockObject>,
229    ) -> CheckboxGroupsBlockElementBuilder {
230        CheckboxGroupsBlockElementBuilder::new(action_id, options)
231    }
232}
233
234#[derive(Debug, Default)]
235pub struct CheckboxGroupsBlockElementBuilder {
236    pub action_id: String,
237    pub options: Vec<OptionBlockObject>,
238    pub initial_options: Option<Vec<OptionBlockObject>>,
239    pub confirm: Option<ConfirmationBlockObject>,
240    pub focus_on_load: Option<bool>,
241}
242
243impl CheckboxGroupsBlockElementBuilder {
244    pub fn new(
245        action_id: String,
246        options: Vec<OptionBlockObject>,
247    ) -> CheckboxGroupsBlockElementBuilder {
248        CheckboxGroupsBlockElementBuilder {
249            action_id,
250            options,
251            ..Default::default()
252        }
253    }
254    pub fn initial_options(
255        mut self,
256        initial_options: Vec<OptionBlockObject>,
257    ) -> CheckboxGroupsBlockElementBuilder {
258        self.initial_options = Some(initial_options);
259        self
260    }
261    pub fn confirm(
262        mut self,
263        confirm: ConfirmationBlockObject,
264    ) -> CheckboxGroupsBlockElementBuilder {
265        self.confirm = Some(confirm);
266        self
267    }
268    pub fn focus_on_load(mut self, focus_on_load: bool) -> CheckboxGroupsBlockElementBuilder {
269        self.focus_on_load = Some(focus_on_load);
270        self
271    }
272    pub fn build(self) -> CheckboxGroupsBlockElement {
273        CheckboxGroupsBlockElement {
274            action_id: self.action_id,
275            options: self.options,
276            initial_options: self.initial_options,
277            confirm: self.confirm,
278            focus_on_load: self.focus_on_load,
279        }
280    }
281}
282
283/// An element which lets users easily select a date from a calendar style UI.  
284/// See: <https://api.slack.com/reference/block-kit/block-elements#datepicker>
285#[skip_serializing_none]
286#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
287pub struct DatePickerBlockElement {
288    pub action_id: String,
289    pub placeholder: Option<TextBlockObject>,
290    pub initial_date: Option<String>,
291    pub confirm: Option<ConfirmationBlockObject>,
292    pub focus_on_load: Option<bool>,
293}
294
295impl DatePickerBlockElement {
296    pub fn builder(action_id: String) -> DatePickerBlockElementBuilder {
297        DatePickerBlockElementBuilder::new(action_id)
298    }
299}
300
301#[derive(Debug, Default)]
302pub struct DatePickerBlockElementBuilder {
303    pub action_id: String,
304    pub placeholder: Option<TextBlockObject>,
305    pub initial_date: Option<String>,
306    pub confirm: Option<ConfirmationBlockObject>,
307    pub focus_on_load: Option<bool>,
308}
309
310impl DatePickerBlockElementBuilder {
311    pub fn new(action_id: String) -> DatePickerBlockElementBuilder {
312        DatePickerBlockElementBuilder {
313            action_id,
314            ..Default::default()
315        }
316    }
317    pub fn placeholder(mut self, placeholder: TextBlockObject) -> DatePickerBlockElementBuilder {
318        self.placeholder = Some(placeholder);
319        self
320    }
321    pub fn initial_date(mut self, initial_date: String) -> DatePickerBlockElementBuilder {
322        self.initial_date = Some(initial_date);
323        self
324    }
325    pub fn confirm(mut self, confirm: ConfirmationBlockObject) -> DatePickerBlockElementBuilder {
326        self.confirm = Some(confirm);
327        self
328    }
329    pub fn focus_on_load(mut self, focus_on_load: bool) -> DatePickerBlockElementBuilder {
330        self.focus_on_load = Some(focus_on_load);
331        self
332    }
333    pub fn build(self) -> DatePickerBlockElement {
334        DatePickerBlockElement {
335            action_id: self.action_id,
336            placeholder: self.placeholder,
337            initial_date: self.initial_date,
338            confirm: self.confirm,
339            focus_on_load: self.focus_on_load,
340        }
341    }
342}
343
344/// An element to insert an image as part of a larger block of content.  
345/// See: <https://api.slack.com/reference/block-kit/block-elements#image>
346#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
347pub struct ImageBlockElement {
348    pub image_url: String,
349    pub alt_text: String,
350}
351
352impl ImageBlockElement {
353    pub fn new(image_url: String, alt_text: String) -> ImageBlockElement {
354        ImageBlockElement {
355            image_url,
356            alt_text,
357        }
358    }
359}
360
361/// A multi-select menu allows a user to select multiple items from a list of options.  
362/// See: <https://api.slack.com/reference/block-kit/block-elements#multi_select>
363#[skip_serializing_none]
364#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
365pub struct MultiSelectBlockElement {
366    pub placeholder: TextBlockObject,
367    pub action_id: String,
368    pub options: Vec<OptionBlockObject>,
369    pub option_groups: Option<Vec<OptionGroupBlockObject>>,
370    pub initial_option: Option<OptionBlockObject>,
371    pub initial_users: Option<Vec<String>>,
372    pub initial_conversations: Option<Vec<String>>,
373    pub initial_channels: Option<Vec<String>>,
374    pub confirm: Option<ConfirmationBlockObject>,
375    pub min_query_length: Option<i32>,
376    pub max_selected_items: Option<i32>,
377    pub focus_on_load: Option<bool>,
378}
379
380impl MultiSelectBlockElement {
381    pub fn builder(
382        placeholder: TextBlockObject,
383        action_id: String,
384        options: Vec<OptionBlockObject>,
385    ) -> MultiSelectBlockElementBuilder {
386        MultiSelectBlockElementBuilder::new(placeholder, action_id, options)
387    }
388}
389
390#[derive(Debug, Default)]
391pub struct MultiSelectBlockElementBuilder {
392    pub placeholder: TextBlockObject,
393    pub action_id: String,
394    pub options: Vec<OptionBlockObject>,
395    pub option_groups: Option<Vec<OptionGroupBlockObject>>,
396    pub initial_option: Option<OptionBlockObject>,
397    pub initial_users: Option<Vec<String>>,
398    pub initial_conversations: Option<Vec<String>>,
399    pub initial_channels: Option<Vec<String>>,
400    pub confirm: Option<ConfirmationBlockObject>,
401    pub min_query_length: Option<i32>,
402    pub max_selected_items: Option<i32>,
403    pub focus_on_load: Option<bool>,
404}
405
406impl MultiSelectBlockElementBuilder {
407    pub fn new(
408        placeholder: TextBlockObject,
409        action_id: String,
410        options: Vec<OptionBlockObject>,
411    ) -> MultiSelectBlockElementBuilder {
412        MultiSelectBlockElementBuilder {
413            placeholder,
414            action_id,
415            options,
416            ..Default::default()
417        }
418    }
419    pub fn option_groups(
420        mut self,
421        option_groups: Vec<OptionGroupBlockObject>,
422    ) -> MultiSelectBlockElementBuilder {
423        self.option_groups = Some(option_groups);
424        self
425    }
426    pub fn initial_option(
427        mut self,
428        initial_option: OptionBlockObject,
429    ) -> MultiSelectBlockElementBuilder {
430        self.initial_option = Some(initial_option);
431        self
432    }
433    pub fn initial_users(mut self, initial_users: Vec<String>) -> MultiSelectBlockElementBuilder {
434        self.initial_users = Some(initial_users);
435        self
436    }
437    pub fn initial_conversations(
438        mut self,
439        initial_conversations: Vec<String>,
440    ) -> MultiSelectBlockElementBuilder {
441        self.initial_conversations = Some(initial_conversations);
442        self
443    }
444    pub fn initial_channels(
445        mut self,
446        initial_channels: Vec<String>,
447    ) -> MultiSelectBlockElementBuilder {
448        self.initial_channels = Some(initial_channels);
449        self
450    }
451    pub fn confirm(mut self, confirm: ConfirmationBlockObject) -> MultiSelectBlockElementBuilder {
452        self.confirm = Some(confirm);
453        self
454    }
455    pub fn min_query_length(mut self, min_query_length: i32) -> MultiSelectBlockElementBuilder {
456        self.min_query_length = Some(min_query_length);
457        self
458    }
459    pub fn max_selected_items(mut self, max_selected_items: i32) -> MultiSelectBlockElementBuilder {
460        self.max_selected_items = Some(max_selected_items);
461        self
462    }
463    pub fn focus_on_load(mut self, focus_on_load: bool) -> MultiSelectBlockElementBuilder {
464        self.focus_on_load = Some(focus_on_load);
465        self
466    }
467    pub fn build(self) -> MultiSelectBlockElementBuilder {
468        MultiSelectBlockElementBuilder {
469            placeholder: self.placeholder,
470            action_id: self.action_id,
471            options: self.options,
472            option_groups: self.option_groups,
473            initial_option: self.initial_option,
474            initial_users: self.initial_users,
475            initial_conversations: self.initial_conversations,
476            initial_channels: self.initial_channels,
477            confirm: self.confirm,
478            min_query_length: self.min_query_length,
479            max_selected_items: self.max_selected_items,
480            focus_on_load: self.focus_on_load,
481        }
482    }
483}
484
485/// This is like a cross between a button and a select menu.  
486/// See: <https://api.slack.com/reference/block-kit/block-elements#overflow>
487#[skip_serializing_none]
488#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
489pub struct OverflowBlockElement {
490    pub action_id: String,
491    pub options: Vec<OptionBlockObject>,
492    pub confirm: Option<ConfirmationBlockObject>,
493}
494
495impl OverflowBlockElement {
496    pub fn builder(
497        action_id: String,
498        options: Vec<OptionBlockObject>,
499    ) -> OverflowBlockElementBuilder {
500        OverflowBlockElementBuilder::new(action_id, options)
501    }
502}
503
504#[derive(Debug, Default)]
505pub struct OverflowBlockElementBuilder {
506    pub action_id: String,
507    pub options: Vec<OptionBlockObject>,
508    pub confirm: Option<ConfirmationBlockObject>,
509}
510
511impl OverflowBlockElementBuilder {
512    pub fn new(action_id: String, options: Vec<OptionBlockObject>) -> OverflowBlockElementBuilder {
513        OverflowBlockElementBuilder {
514            action_id,
515            options,
516            ..Default::default()
517        }
518    }
519    pub fn confirm(mut self, confirm: ConfirmationBlockObject) -> OverflowBlockElementBuilder {
520        self.confirm = Some(confirm);
521        self
522    }
523    pub fn build(self) -> OverflowBlockElement {
524        OverflowBlockElement {
525            action_id: self.action_id,
526            options: self.options,
527            confirm: self.confirm,
528        }
529    }
530}
531
532/// A plain-text input, similar to the HTML <input> tag, creates a field where a user can enter freeform data.  
533/// See: <https://api.slack.com/reference/block-kit/block-elements#input>
534#[skip_serializing_none]
535#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
536pub struct PlainTextInputBlockElement {
537    pub action_id: String,
538    pub placeholder: Option<TextBlockObject>,
539    pub initial_value: Option<String>,
540    pub multiline: Option<bool>,
541    pub min_length: Option<i32>,
542    pub max_length: Option<i32>,
543    pub dispatch_action_config: Option<DispatchActionConfig>,
544    pub focus_on_load: Option<bool>,
545}
546
547impl PlainTextInputBlockElement {
548    pub fn builder(action_id: String) -> PlainTextInputBlockElementBuilder {
549        PlainTextInputBlockElementBuilder::new(action_id)
550    }
551}
552
553#[derive(Debug, Default)]
554pub struct PlainTextInputBlockElementBuilder {
555    pub action_id: String,
556    pub placeholder: Option<TextBlockObject>,
557    pub initial_value: Option<String>,
558    pub multiline: Option<bool>,
559    pub min_length: Option<i32>,
560    pub max_length: Option<i32>,
561    pub dispatch_action_config: Option<DispatchActionConfig>,
562    pub focus_on_load: Option<bool>,
563}
564
565impl PlainTextInputBlockElementBuilder {
566    pub fn new(action_id: String) -> PlainTextInputBlockElementBuilder {
567        PlainTextInputBlockElementBuilder {
568            action_id,
569            ..Default::default()
570        }
571    }
572    pub fn placeholder(
573        mut self,
574        placeholder: TextBlockObject,
575    ) -> PlainTextInputBlockElementBuilder {
576        self.placeholder = Some(placeholder);
577        self
578    }
579    pub fn initial_value(mut self, initial_value: String) -> PlainTextInputBlockElementBuilder {
580        self.initial_value = Some(initial_value);
581        self
582    }
583    pub fn multiline(mut self, multiline: bool) -> PlainTextInputBlockElementBuilder {
584        self.multiline = Some(multiline);
585        self
586    }
587    pub fn min_length(mut self, min_length: i32) -> PlainTextInputBlockElementBuilder {
588        self.min_length = Some(min_length);
589        self
590    }
591    pub fn max_length(mut self, max_length: i32) -> PlainTextInputBlockElementBuilder {
592        self.max_length = Some(max_length);
593        self
594    }
595    pub fn dispatch_action_config(
596        mut self,
597        dispatch_action_config: DispatchActionConfig,
598    ) -> PlainTextInputBlockElementBuilder {
599        self.dispatch_action_config = Some(dispatch_action_config);
600        self
601    }
602    pub fn focus_on_load(mut self, focus_on_load: bool) -> PlainTextInputBlockElementBuilder {
603        self.focus_on_load = Some(focus_on_load);
604        self
605    }
606    pub fn build(self) -> PlainTextInputBlockElement {
607        PlainTextInputBlockElement {
608            action_id: self.action_id,
609            placeholder: self.placeholder,
610            initial_value: self.initial_value,
611            multiline: self.multiline,
612            min_length: self.min_length,
613            max_length: self.max_length,
614            dispatch_action_config: self.dispatch_action_config,
615            focus_on_load: self.focus_on_load,
616        }
617    }
618}
619
620/// A radio button group that allows a user to choose one item from a list of possible options.  
621/// See: <https://api.slack.com/reference/block-kit/block-elements#radio>
622#[skip_serializing_none]
623#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
624pub struct RadioButtonsBlockElement {
625    pub action_id: String,
626    pub options: Vec<OptionBlockObject>,
627    pub initial_option: Option<OptionBlockObject>,
628    pub confirm: Option<ConfirmationBlockObject>,
629}
630
631impl RadioButtonsBlockElement {
632    pub fn builder(
633        action_id: String,
634        options: Vec<OptionBlockObject>,
635    ) -> RadioButtonsBlockElementBuilder {
636        RadioButtonsBlockElementBuilder::new(action_id, options)
637    }
638}
639
640#[derive(Debug, Default)]
641pub struct RadioButtonsBlockElementBuilder {
642    pub action_id: String,
643    pub options: Vec<OptionBlockObject>,
644    pub initial_option: Option<OptionBlockObject>,
645    pub confirm: Option<ConfirmationBlockObject>,
646}
647
648impl RadioButtonsBlockElementBuilder {
649    pub fn new(
650        action_id: String,
651        options: Vec<OptionBlockObject>,
652    ) -> RadioButtonsBlockElementBuilder {
653        RadioButtonsBlockElementBuilder {
654            action_id,
655            options,
656            ..Default::default()
657        }
658    }
659    pub fn initial_option(
660        mut self,
661        initial_option: OptionBlockObject,
662    ) -> RadioButtonsBlockElementBuilder {
663        self.initial_option = Some(initial_option);
664        self
665    }
666    pub fn confirm(mut self, confirm: ConfirmationBlockObject) -> RadioButtonsBlockElementBuilder {
667        self.confirm = Some(confirm);
668        self
669    }
670    pub fn build(self) -> RadioButtonsBlockElement {
671        RadioButtonsBlockElement {
672            action_id: self.action_id,
673            options: self.options,
674            initial_option: self.initial_option,
675            confirm: self.confirm,
676        }
677    }
678}
679
680/// A select menu, just as with a standard HTML <select> tag, creates a drop down menu with a list of options for a user to choose.  
681/// See: <https://api.slack.com/reference/block-kit/block-elements#select>
682#[skip_serializing_none]
683#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
684pub struct SelectBlockElement {
685    pub placeholder: TextBlockObject,
686    pub action_id: String,
687    pub options: Vec<OptionBlockObject>,
688    pub option_groups: Option<Vec<OptionGroupBlockObject>>,
689    pub initial_option: Option<OptionBlockObject>,
690    pub initial_users: Option<Vec<String>>,
691    pub initial_conversations: Option<Vec<String>>,
692    pub initial_channels: Option<Vec<String>>,
693    pub confirm: Option<ConfirmationBlockObject>,
694    pub min_query_length: Option<i32>,
695    pub max_selected_items: Option<i32>,
696    pub focus_on_load: Option<bool>,
697}
698
699impl SelectBlockElement {
700    pub fn builder(
701        placeholder: TextBlockObject,
702        action_id: String,
703        options: Vec<OptionBlockObject>,
704    ) -> SelectBlockElementBuilder {
705        SelectBlockElementBuilder::new(placeholder, action_id, options)
706    }
707}
708
709#[derive(Debug, Default)]
710pub struct SelectBlockElementBuilder {
711    pub placeholder: TextBlockObject,
712    pub action_id: String,
713    pub options: Vec<OptionBlockObject>,
714    pub option_groups: Option<Vec<OptionGroupBlockObject>>,
715    pub initial_option: Option<OptionBlockObject>,
716    pub initial_users: Option<Vec<String>>,
717    pub initial_conversations: Option<Vec<String>>,
718    pub initial_channels: Option<Vec<String>>,
719    pub confirm: Option<ConfirmationBlockObject>,
720    pub min_query_length: Option<i32>,
721    pub max_selected_items: Option<i32>,
722    pub focus_on_load: Option<bool>,
723}
724
725impl SelectBlockElementBuilder {
726    pub fn new(
727        placeholder: TextBlockObject,
728        action_id: String,
729        options: Vec<OptionBlockObject>,
730    ) -> SelectBlockElementBuilder {
731        SelectBlockElementBuilder {
732            placeholder,
733            action_id,
734            options,
735            ..Default::default()
736        }
737    }
738    pub fn option_groups(
739        mut self,
740        option_groups: Vec<OptionGroupBlockObject>,
741    ) -> SelectBlockElementBuilder {
742        self.option_groups = Some(option_groups);
743        self
744    }
745    pub fn initial_option(
746        mut self,
747        initial_option: OptionBlockObject,
748    ) -> SelectBlockElementBuilder {
749        self.initial_option = Some(initial_option);
750        self
751    }
752    pub fn initial_users(mut self, initial_users: Vec<String>) -> SelectBlockElementBuilder {
753        self.initial_users = Some(initial_users);
754        self
755    }
756    pub fn initial_conversations(
757        mut self,
758        initial_conversations: Vec<String>,
759    ) -> SelectBlockElementBuilder {
760        self.initial_conversations = Some(initial_conversations);
761        self
762    }
763    pub fn initial_channels(mut self, initial_channels: Vec<String>) -> SelectBlockElementBuilder {
764        self.initial_channels = Some(initial_channels);
765        self
766    }
767    pub fn confirm(mut self, confirm: ConfirmationBlockObject) -> SelectBlockElementBuilder {
768        self.confirm = Some(confirm);
769        self
770    }
771    pub fn min_query_lengths(mut self, min_query_length: i32) -> SelectBlockElementBuilder {
772        self.min_query_length = Some(min_query_length);
773        self
774    }
775    pub fn max_selected_items(mut self, max_selected_items: i32) -> SelectBlockElementBuilder {
776        self.max_selected_items = Some(max_selected_items);
777        self
778    }
779    pub fn focus_on_load(mut self, focus_on_load: bool) -> SelectBlockElementBuilder {
780        self.focus_on_load = Some(focus_on_load);
781        self
782    }
783    pub fn build(self) -> SelectBlockElement {
784        SelectBlockElement {
785            placeholder: self.placeholder,
786            action_id: self.action_id,
787            options: self.options,
788            option_groups: self.option_groups,
789            initial_option: self.initial_option,
790            initial_users: self.initial_users,
791            initial_conversations: self.initial_conversations,
792            initial_channels: self.initial_channels,
793            confirm: self.confirm,
794            min_query_length: self.min_query_length,
795            max_selected_items: self.max_selected_items,
796            focus_on_load: self.focus_on_load,
797        }
798    }
799}
800
801/// An element which allows selection of a time of day.  
802/// See: <https://api.slack.com/reference/block-kit/block-elements#timepicker>
803#[skip_serializing_none]
804#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
805pub struct TimePickerBlockElement {
806    pub action_id: String,
807    pub placeholder: Option<TextBlockObject>,
808    pub initial_time: Option<String>,
809    pub confirm: Option<ConfirmationBlockObject>,
810}
811
812impl TimePickerBlockElement {
813    pub fn builder(action_id: String) -> TimePickerBlockElementBuilder {
814        TimePickerBlockElementBuilder::new(action_id)
815    }
816}
817
818#[derive(Debug, Default)]
819pub struct TimePickerBlockElementBuilder {
820    pub action_id: String,
821    pub placeholder: Option<TextBlockObject>,
822    pub initial_time: Option<String>,
823    pub confirm: Option<ConfirmationBlockObject>,
824}
825
826impl TimePickerBlockElementBuilder {
827    pub fn new(action_id: String) -> TimePickerBlockElementBuilder {
828        TimePickerBlockElementBuilder {
829            action_id,
830            ..Default::default()
831        }
832    }
833    pub fn placeholder(mut self, placeholder: TextBlockObject) -> TimePickerBlockElementBuilder {
834        self.placeholder = Some(placeholder);
835        self
836    }
837    pub fn initial_time(mut self, initial_time: String) -> TimePickerBlockElementBuilder {
838        self.initial_time = Some(initial_time);
839        self
840    }
841    pub fn confirm(mut self, confirm: ConfirmationBlockObject) -> TimePickerBlockElementBuilder {
842        self.confirm = Some(confirm);
843        self
844    }
845    pub fn build(self) -> TimePickerBlockElementBuilder {
846        TimePickerBlockElementBuilder {
847            action_id: self.action_id,
848            placeholder: self.placeholder,
849            initial_time: self.initial_time,
850            confirm: self.confirm,
851        }
852    }
853}