1use rsb_derive::Builder;
2use rvstruct::ValueStruct;
3use serde::{Deserialize, Serialize};
4use serde_with::skip_serializing_none;
5use url::Url;
6
7use crate::*;
8
9#[skip_serializing_none]
10#[derive(Debug, PartialEq, Clone, Eq, Hash, Serialize, Deserialize, ValueStruct)]
11pub struct SlackBlockId(pub String);
12
13#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
14#[serde(tag = "type")]
15pub enum SlackBlock {
16 #[serde(rename = "section")]
17 Section(SlackSectionBlock),
18 #[serde(rename = "header")]
19 Header(SlackHeaderBlock),
20 #[serde(rename = "divider")]
21 Divider(SlackDividerBlock),
22 #[serde(rename = "image")]
23 Image(SlackImageBlock),
24 #[serde(rename = "actions")]
25 Actions(SlackActionsBlock),
26 #[serde(rename = "context")]
27 Context(SlackContextBlock),
28 #[serde(rename = "input")]
29 Input(SlackInputBlock),
30 #[serde(rename = "file")]
31 File(SlackFileBlock),
32 #[serde(rename = "video")]
33 Video(SlackVideoBlock),
34 #[serde(rename = "markdown")]
35 Markdown(SlackMarkdownBlock),
36
37 #[serde(rename = "rich_text")]
39 RichText(serde_json::Value),
40 #[serde(rename = "event")]
41 Event(serde_json::Value),
42}
43
44#[skip_serializing_none]
45#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
46pub struct SlackSectionBlock {
47 pub block_id: Option<SlackBlockId>,
48 pub text: Option<SlackBlockText>,
49 pub fields: Option<Vec<SlackBlockText>>,
50 pub accessory: Option<SlackSectionBlockElement>,
51}
52
53impl From<SlackSectionBlock> for SlackBlock {
54 fn from(block: SlackSectionBlock) -> Self {
55 SlackBlock::Section(block)
56 }
57}
58
59#[skip_serializing_none]
60#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
61pub struct SlackHeaderBlock {
62 pub block_id: Option<SlackBlockId>,
63 pub text: SlackBlockPlainTextOnly,
64}
65
66impl From<SlackHeaderBlock> for SlackBlock {
67 fn from(block: SlackHeaderBlock) -> Self {
68 SlackBlock::Header(block)
69 }
70}
71
72#[skip_serializing_none]
73#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
74pub struct SlackDividerBlock {
75 pub block_id: Option<SlackBlockId>,
76}
77
78impl From<SlackDividerBlock> for SlackBlock {
79 fn from(block: SlackDividerBlock) -> Self {
80 SlackBlock::Divider(block)
81 }
82}
83
84#[skip_serializing_none]
85#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
86pub struct SlackImageBlock {
87 pub block_id: Option<SlackBlockId>,
88 pub image_url: Url,
89 pub alt_text: String,
90 pub title: Option<SlackBlockPlainTextOnly>,
91}
92
93impl From<SlackImageBlock> for SlackBlock {
94 fn from(block: SlackImageBlock) -> Self {
95 SlackBlock::Image(block)
96 }
97}
98
99#[skip_serializing_none]
100#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
101pub struct SlackActionsBlock {
102 pub block_id: Option<SlackBlockId>,
103 pub elements: Vec<SlackActionBlockElement>,
104}
105
106impl From<SlackActionsBlock> for SlackBlock {
107 fn from(block: SlackActionsBlock) -> Self {
108 SlackBlock::Actions(block)
109 }
110}
111
112#[skip_serializing_none]
113#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
114pub struct SlackContextBlock {
115 pub block_id: Option<SlackBlockId>,
116 pub elements: Vec<SlackContextBlockElement>,
117}
118
119impl From<SlackContextBlock> for SlackBlock {
120 fn from(block: SlackContextBlock) -> Self {
121 SlackBlock::Context(block)
122 }
123}
124
125#[skip_serializing_none]
126#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
127pub struct SlackInputBlock {
128 pub block_id: Option<SlackBlockId>,
129 pub label: SlackBlockPlainTextOnly,
130 pub element: SlackInputBlockElement,
131 pub hint: Option<SlackBlockPlainTextOnly>,
132 pub optional: Option<bool>,
133 pub dispatch_action: Option<bool>,
134}
135
136impl From<SlackInputBlock> for SlackBlock {
137 fn from(block: SlackInputBlock) -> Self {
138 SlackBlock::Input(block)
139 }
140}
141
142const SLACK_FILE_BLOCK_SOURCE_DEFAULT: &str = "remote";
143
144#[skip_serializing_none]
145#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
146pub struct SlackFileBlock {
147 pub block_id: Option<SlackBlockId>,
148 pub external_id: String,
149 #[default = "SLACK_FILE_BLOCK_SOURCE_DEFAULT.into()"]
150 pub source: String,
151}
152
153impl From<SlackFileBlock> for SlackBlock {
154 fn from(block: SlackFileBlock) -> Self {
155 SlackBlock::File(block)
156 }
157}
158
159#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
160#[serde(tag = "type")]
161pub enum SlackSectionBlockElement {
162 #[serde(rename = "image")]
163 Image(SlackBlockImageElement),
164 #[serde(rename = "button")]
165 Button(SlackBlockButtonElement),
166 #[serde(rename = "static_select")]
167 StaticSelect(SlackBlockStaticSelectElement),
168 #[serde(rename = "multi_static_select")]
169 MultiStaticSelect(SlackBlockMultiStaticSelectElement),
170 #[serde(rename = "external_select")]
171 ExternalSelect(SlackBlockExternalSelectElement),
172 #[serde(rename = "multi_external_select")]
173 MultiExternalSelect(SlackBlockMultiExternalSelectElement),
174 #[serde(rename = "users_select")]
175 UsersSelect(SlackBlockUsersSelectElement),
176 #[serde(rename = "multi_users_select")]
177 MultiUsersSelect(SlackBlockMultiUsersSelectElement),
178 #[serde(rename = "conversations_select")]
179 ConversationsSelect(SlackBlockConversationsSelectElement),
180 #[serde(rename = "multi_conversations_select")]
181 MultiConversationsSelect(SlackBlockMultiConversationsSelectElement),
182 #[serde(rename = "channels_select")]
183 ChannelsSelect(SlackBlockChannelsSelectElement),
184 #[serde(rename = "multi_channels_select")]
185 MultiChannelsSelect(SlackBlockMultiChannelsSelectElement),
186 #[serde(rename = "overflow")]
187 Overflow(SlackBlockOverflowElement),
188 #[serde(rename = "datepicker")]
189 DatePicker(SlackBlockDatePickerElement),
190 #[serde(rename = "timepicker")]
191 TimePicker(SlackBlockTimePickerElement),
192 #[serde(rename = "plain_text_input")]
193 PlainTextInput(SlackBlockPlainTextInputElement),
194 #[serde(rename = "number_input")]
195 NumberInput(SlackBlockNumberInputElement),
196 #[serde(rename = "url_text_input")]
197 UrlInput(SlackBlockUrlInputElement),
198 #[serde(rename = "radio_buttons")]
199 RadioButtons(SlackBlockRadioButtonsElement),
200 #[serde(rename = "checkboxes")]
201 Checkboxes(SlackBlockCheckboxesElement),
202}
203
204#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
205#[serde(tag = "type")]
206pub enum SlackActionBlockElement {
207 #[serde(rename = "button")]
208 Button(SlackBlockButtonElement),
209 #[serde(rename = "overflow")]
210 Overflow(SlackBlockOverflowElement),
211 #[serde(rename = "datepicker")]
212 DatePicker(SlackBlockDatePickerElement),
213 #[serde(rename = "timepicker")]
214 TimePicker(SlackBlockTimePickerElement),
215 #[serde(rename = "datetimepicker")]
216 DateTimePicker(SlackBlockDateTimePickerElement),
217 #[serde(rename = "plain_text_input")]
218 PlainTextInput(SlackBlockPlainTextInputElement),
219 #[serde(rename = "number_input")]
220 NumberInput(SlackBlockNumberInputElement),
221 #[serde(rename = "url_text_input")]
222 UrlInput(SlackBlockUrlInputElement),
223 #[serde(rename = "radio_buttons")]
224 RadioButtons(SlackBlockRadioButtonsElement),
225 #[serde(rename = "checkboxes")]
226 Checkboxes(SlackBlockCheckboxesElement),
227 #[serde(rename = "static_select")]
228 StaticSelect(SlackBlockStaticSelectElement),
229 #[serde(rename = "external_select")]
230 ExternalSelect(SlackBlockExternalSelectElement),
231 #[serde(rename = "users_select")]
232 UsersSelect(SlackBlockUsersSelectElement),
233 #[serde(rename = "conversations_select")]
234 ConversationsSelect(SlackBlockConversationsSelectElement),
235 #[serde(rename = "channels_select")]
236 ChannelsSelect(SlackBlockChannelsSelectElement),
237}
238
239#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
240#[serde(tag = "type")]
241pub enum SlackContextBlockElement {
242 #[serde(rename = "image")]
243 Image(SlackBlockImageElement),
244 #[serde(rename = "plain_text")]
245 Plain(SlackBlockPlainText),
246 #[serde(rename = "mrkdwn")]
247 MarkDown(SlackBlockMarkDownText),
248}
249
250#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
251#[serde(tag = "type")]
252pub enum SlackInputBlockElement {
253 #[serde(rename = "static_select")]
254 StaticSelect(SlackBlockStaticSelectElement),
255 #[serde(rename = "multi_static_select")]
256 MultiStaticSelect(SlackBlockMultiStaticSelectElement),
257 #[serde(rename = "external_select")]
258 ExternalSelect(SlackBlockExternalSelectElement),
259 #[serde(rename = "multi_external_select")]
260 MultiExternalSelect(SlackBlockMultiExternalSelectElement),
261 #[serde(rename = "users_select")]
262 UsersSelect(SlackBlockUsersSelectElement),
263 #[serde(rename = "multi_users_select")]
264 MultiUsersSelect(SlackBlockMultiUsersSelectElement),
265 #[serde(rename = "conversations_select")]
266 ConversationsSelect(SlackBlockConversationsSelectElement),
267 #[serde(rename = "multi_conversations_select")]
268 MultiConversationsSelect(SlackBlockMultiConversationsSelectElement),
269 #[serde(rename = "channels_select")]
270 ChannelsSelect(SlackBlockChannelsSelectElement),
271 #[serde(rename = "multi_channels_select")]
272 MultiChannelsSelect(SlackBlockMultiChannelsSelectElement),
273 #[serde(rename = "datepicker")]
274 DatePicker(SlackBlockDatePickerElement),
275 #[serde(rename = "timepicker")]
276 TimePicker(SlackBlockTimePickerElement),
277 #[serde(rename = "datetimepicker")]
278 DateTimePicker(SlackBlockDateTimePickerElement),
279 #[serde(rename = "plain_text_input")]
280 PlainTextInput(SlackBlockPlainTextInputElement),
281 #[serde(rename = "number_input")]
282 NumberInput(SlackBlockNumberInputElement),
283 #[serde(rename = "url_text_input")]
284 UrlInput(SlackBlockUrlInputElement),
285 #[serde(rename = "radio_buttons")]
286 RadioButtons(SlackBlockRadioButtonsElement),
287 #[serde(rename = "checkboxes")]
288 Checkboxes(SlackBlockCheckboxesElement),
289 #[serde(rename = "email_text_input")]
290 EmailInput(SlackBlockEmailInputElement),
291}
292
293#[skip_serializing_none]
294#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
295pub struct SlackBlockImageElement {
296 pub image_url: String,
297 pub alt_text: String,
298}
299
300impl From<SlackBlockImageElement> for SlackSectionBlockElement {
301 fn from(element: SlackBlockImageElement) -> Self {
302 SlackSectionBlockElement::Image(element)
303 }
304}
305
306impl From<SlackBlockImageElement> for SlackContextBlockElement {
307 fn from(element: SlackBlockImageElement) -> Self {
308 SlackContextBlockElement::Image(element)
309 }
310}
311
312#[skip_serializing_none]
313#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
314pub struct SlackBlockButtonElement {
315 pub action_id: SlackActionId,
316 pub text: SlackBlockPlainTextOnly,
317 pub url: Option<Url>,
318 pub value: Option<String>,
319 pub style: Option<String>,
320 pub confirm: Option<SlackBlockConfirmItem>,
321}
322
323impl From<SlackBlockButtonElement> for SlackSectionBlockElement {
324 fn from(element: SlackBlockButtonElement) -> Self {
325 SlackSectionBlockElement::Button(element)
326 }
327}
328
329impl From<SlackBlockButtonElement> for SlackActionBlockElement {
330 fn from(element: SlackBlockButtonElement) -> Self {
331 SlackActionBlockElement::Button(element)
332 }
333}
334
335#[skip_serializing_none]
336#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
337pub struct SlackBlockConfirmItem {
338 pub title: SlackBlockPlainTextOnly,
339 pub text: SlackBlockText,
340 pub confirm: SlackBlockPlainTextOnly,
341 pub deny: SlackBlockPlainTextOnly,
342 pub style: Option<String>,
343}
344
345#[skip_serializing_none]
346#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
347pub struct SlackBlockChoiceItem<T: Into<SlackBlockText>> {
348 pub text: T,
349 pub value: String,
350 pub url: Option<Url>,
351}
352
353#[skip_serializing_none]
354#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
355pub struct SlackBlockOptionGroup<T: Into<SlackBlockText>> {
356 pub label: SlackBlockPlainTextOnly,
357 pub options: Vec<SlackBlockChoiceItem<T>>,
358}
359
360#[skip_serializing_none]
361#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
362pub struct SlackBlockStaticSelectElement {
363 pub action_id: SlackActionId,
364 pub placeholder: Option<SlackBlockPlainTextOnly>,
365 pub options: Option<Vec<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>>,
366 pub option_groups: Option<Vec<SlackBlockOptionGroup<SlackBlockPlainTextOnly>>>,
367 pub initial_option: Option<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>,
368 pub confirm: Option<SlackBlockConfirmItem>,
369 pub focus_on_load: Option<bool>,
370}
371
372impl From<SlackBlockStaticSelectElement> for SlackSectionBlockElement {
373 fn from(element: SlackBlockStaticSelectElement) -> Self {
374 SlackSectionBlockElement::StaticSelect(element)
375 }
376}
377
378impl From<SlackBlockStaticSelectElement> for SlackInputBlockElement {
379 fn from(element: SlackBlockStaticSelectElement) -> Self {
380 SlackInputBlockElement::StaticSelect(element)
381 }
382}
383
384impl From<SlackBlockStaticSelectElement> for SlackActionBlockElement {
385 fn from(element: SlackBlockStaticSelectElement) -> Self {
386 SlackActionBlockElement::StaticSelect(element)
387 }
388}
389
390#[skip_serializing_none]
391#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
392pub struct SlackBlockMultiStaticSelectElement {
393 pub action_id: SlackActionId,
394 pub placeholder: Option<SlackBlockPlainTextOnly>,
395 pub options: Option<Vec<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>>,
396 pub option_groups: Option<Vec<SlackBlockOptionGroup<SlackBlockPlainTextOnly>>>,
397 pub initial_options: Option<Vec<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>>,
398 pub confirm: Option<SlackBlockConfirmItem>,
399 pub max_selected_items: Option<u64>,
400 pub focus_on_load: Option<bool>,
401}
402
403impl From<SlackBlockMultiStaticSelectElement> for SlackSectionBlockElement {
404 fn from(element: SlackBlockMultiStaticSelectElement) -> Self {
405 SlackSectionBlockElement::MultiStaticSelect(element)
406 }
407}
408
409impl From<SlackBlockMultiStaticSelectElement> for SlackInputBlockElement {
410 fn from(element: SlackBlockMultiStaticSelectElement) -> Self {
411 SlackInputBlockElement::MultiStaticSelect(element)
412 }
413}
414
415#[skip_serializing_none]
416#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
417pub struct SlackBlockExternalSelectElement {
418 pub action_id: SlackActionId,
419 pub placeholder: Option<SlackBlockPlainTextOnly>,
420 pub initial_option: Option<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>,
421 pub confirm: Option<SlackBlockConfirmItem>,
422 pub focus_on_load: Option<bool>,
423 pub min_query_length: Option<u64>,
424}
425
426impl From<SlackBlockExternalSelectElement> for SlackSectionBlockElement {
427 fn from(element: SlackBlockExternalSelectElement) -> Self {
428 SlackSectionBlockElement::ExternalSelect(element)
429 }
430}
431
432impl From<SlackBlockExternalSelectElement> for SlackInputBlockElement {
433 fn from(element: SlackBlockExternalSelectElement) -> Self {
434 SlackInputBlockElement::ExternalSelect(element)
435 }
436}
437
438impl From<SlackBlockExternalSelectElement> for SlackActionBlockElement {
439 fn from(element: SlackBlockExternalSelectElement) -> Self {
440 SlackActionBlockElement::ExternalSelect(element)
441 }
442}
443
444#[skip_serializing_none]
445#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
446pub struct SlackBlockMultiExternalSelectElement {
447 pub action_id: SlackActionId,
448 pub placeholder: Option<SlackBlockPlainTextOnly>,
449 pub initial_options: Option<Vec<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>>,
450 pub confirm: Option<SlackBlockConfirmItem>,
451 pub max_selected_items: Option<u64>,
452 pub focus_on_load: Option<bool>,
453 pub min_query_length: Option<u64>,
454}
455
456impl From<SlackBlockMultiExternalSelectElement> for SlackSectionBlockElement {
457 fn from(element: SlackBlockMultiExternalSelectElement) -> Self {
458 SlackSectionBlockElement::MultiExternalSelect(element)
459 }
460}
461
462impl From<SlackBlockMultiExternalSelectElement> for SlackInputBlockElement {
463 fn from(element: SlackBlockMultiExternalSelectElement) -> Self {
464 SlackInputBlockElement::MultiExternalSelect(element)
465 }
466}
467
468#[skip_serializing_none]
469#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
470pub struct SlackBlockUsersSelectElement {
471 pub action_id: SlackActionId,
472 pub placeholder: Option<SlackBlockPlainTextOnly>,
473 pub initial_user: Option<String>,
474 pub confirm: Option<SlackBlockConfirmItem>,
475 pub focus_on_load: Option<bool>,
476}
477
478impl From<SlackBlockUsersSelectElement> for SlackSectionBlockElement {
479 fn from(element: SlackBlockUsersSelectElement) -> Self {
480 SlackSectionBlockElement::UsersSelect(element)
481 }
482}
483
484impl From<SlackBlockUsersSelectElement> for SlackInputBlockElement {
485 fn from(element: SlackBlockUsersSelectElement) -> Self {
486 SlackInputBlockElement::UsersSelect(element)
487 }
488}
489
490impl From<SlackBlockUsersSelectElement> for SlackActionBlockElement {
491 fn from(element: SlackBlockUsersSelectElement) -> Self {
492 SlackActionBlockElement::UsersSelect(element)
493 }
494}
495
496#[skip_serializing_none]
497#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
498pub struct SlackBlockMultiUsersSelectElement {
499 pub action_id: SlackActionId,
500 pub placeholder: Option<SlackBlockPlainTextOnly>,
501 pub initial_users: Option<Vec<String>>,
502 pub confirm: Option<SlackBlockConfirmItem>,
503 pub max_selected_items: Option<u64>,
504 pub focus_on_load: Option<bool>,
505}
506
507impl From<SlackBlockMultiUsersSelectElement> for SlackSectionBlockElement {
508 fn from(element: SlackBlockMultiUsersSelectElement) -> Self {
509 SlackSectionBlockElement::MultiUsersSelect(element)
510 }
511}
512
513impl From<SlackBlockMultiUsersSelectElement> for SlackInputBlockElement {
514 fn from(element: SlackBlockMultiUsersSelectElement) -> Self {
515 SlackInputBlockElement::MultiUsersSelect(element)
516 }
517}
518
519#[skip_serializing_none]
520#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
521pub struct SlackBlockConversationsSelectElement {
522 pub action_id: SlackActionId,
523 pub placeholder: Option<SlackBlockPlainTextOnly>,
524 pub initial_conversation: Option<SlackConversationId>,
525 pub default_to_current_conversation: Option<bool>,
526 pub confirm: Option<SlackBlockConfirmItem>,
527 pub response_url_enabled: Option<bool>,
528 pub focus_on_load: Option<bool>,
529}
530
531impl From<SlackBlockConversationsSelectElement> for SlackSectionBlockElement {
532 fn from(element: SlackBlockConversationsSelectElement) -> Self {
533 SlackSectionBlockElement::ConversationsSelect(element)
534 }
535}
536
537impl From<SlackBlockConversationsSelectElement> for SlackInputBlockElement {
538 fn from(element: SlackBlockConversationsSelectElement) -> Self {
539 SlackInputBlockElement::ConversationsSelect(element)
540 }
541}
542
543impl From<SlackBlockConversationsSelectElement> for SlackActionBlockElement {
544 fn from(element: SlackBlockConversationsSelectElement) -> Self {
545 SlackActionBlockElement::ConversationsSelect(element)
546 }
547}
548
549#[skip_serializing_none]
550#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
551pub struct SlackBlockMultiConversationsSelectElement {
552 pub action_id: SlackActionId,
553 pub placeholder: Option<SlackBlockPlainTextOnly>,
554 pub initial_conversations: Option<Vec<SlackConversationId>>,
555 pub default_to_current_conversation: Option<bool>,
556 pub confirm: Option<SlackBlockConfirmItem>,
557 pub max_selected_items: Option<u64>,
558 pub focus_on_load: Option<bool>,
559}
560
561impl From<SlackBlockMultiConversationsSelectElement> for SlackSectionBlockElement {
562 fn from(element: SlackBlockMultiConversationsSelectElement) -> Self {
563 SlackSectionBlockElement::MultiConversationsSelect(element)
564 }
565}
566
567impl From<SlackBlockMultiConversationsSelectElement> for SlackInputBlockElement {
568 fn from(element: SlackBlockMultiConversationsSelectElement) -> Self {
569 SlackInputBlockElement::MultiConversationsSelect(element)
570 }
571}
572
573#[skip_serializing_none]
574#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
575pub struct SlackBlockChannelsSelectElement {
576 pub action_id: SlackActionId,
577 pub placeholder: Option<SlackBlockPlainTextOnly>,
578 pub initial_channel: Option<SlackChannelId>,
579 pub confirm: Option<SlackBlockConfirmItem>,
580 pub response_url_enabled: Option<bool>,
581 pub focus_on_load: Option<bool>,
582}
583
584impl From<SlackBlockChannelsSelectElement> for SlackSectionBlockElement {
585 fn from(element: SlackBlockChannelsSelectElement) -> Self {
586 SlackSectionBlockElement::ChannelsSelect(element)
587 }
588}
589
590impl From<SlackBlockChannelsSelectElement> for SlackInputBlockElement {
591 fn from(element: SlackBlockChannelsSelectElement) -> Self {
592 SlackInputBlockElement::ChannelsSelect(element)
593 }
594}
595
596impl From<SlackBlockChannelsSelectElement> for SlackActionBlockElement {
597 fn from(element: SlackBlockChannelsSelectElement) -> Self {
598 SlackActionBlockElement::ChannelsSelect(element)
599 }
600}
601
602#[skip_serializing_none]
603#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
604pub struct SlackBlockMultiChannelsSelectElement {
605 pub action_id: SlackActionId,
606 pub placeholder: Option<SlackBlockPlainTextOnly>,
607 pub initial_channels: Option<Vec<SlackChannelId>>,
608 pub confirm: Option<SlackBlockConfirmItem>,
609 pub max_selected_items: Option<u64>,
610 pub focus_on_load: Option<bool>,
611}
612
613impl From<SlackBlockMultiChannelsSelectElement> for SlackSectionBlockElement {
614 fn from(element: SlackBlockMultiChannelsSelectElement) -> Self {
615 SlackSectionBlockElement::MultiChannelsSelect(element)
616 }
617}
618
619impl From<SlackBlockMultiChannelsSelectElement> for SlackInputBlockElement {
620 fn from(element: SlackBlockMultiChannelsSelectElement) -> Self {
621 SlackInputBlockElement::MultiChannelsSelect(element)
622 }
623}
624
625#[skip_serializing_none]
626#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
627pub struct SlackBlockOverflowElement {
628 pub action_id: SlackActionId,
629 pub options: Vec<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>,
630 pub confirm: Option<SlackBlockConfirmItem>,
631}
632
633impl From<SlackBlockOverflowElement> for SlackSectionBlockElement {
634 fn from(element: SlackBlockOverflowElement) -> Self {
635 SlackSectionBlockElement::Overflow(element)
636 }
637}
638
639impl From<SlackBlockOverflowElement> for SlackActionBlockElement {
640 fn from(element: SlackBlockOverflowElement) -> Self {
641 SlackActionBlockElement::Overflow(element)
642 }
643}
644
645#[skip_serializing_none]
646#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
647pub struct SlackBlockDatePickerElement {
648 pub action_id: SlackActionId,
649 pub placeholder: Option<SlackBlockPlainTextOnly>,
650 pub initial_date: Option<String>,
651 pub confirm: Option<SlackBlockConfirmItem>,
652 pub focus_on_load: Option<bool>,
653}
654
655impl From<SlackBlockDatePickerElement> for SlackSectionBlockElement {
656 fn from(element: SlackBlockDatePickerElement) -> Self {
657 SlackSectionBlockElement::DatePicker(element)
658 }
659}
660
661impl From<SlackBlockDatePickerElement> for SlackInputBlockElement {
662 fn from(element: SlackBlockDatePickerElement) -> Self {
663 SlackInputBlockElement::DatePicker(element)
664 }
665}
666
667impl From<SlackBlockDatePickerElement> for SlackActionBlockElement {
668 fn from(element: SlackBlockDatePickerElement) -> Self {
669 SlackActionBlockElement::DatePicker(element)
670 }
671}
672
673#[skip_serializing_none]
674#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
675pub struct SlackBlockTimePickerElement {
676 pub action_id: SlackActionId,
677 pub initial_time: Option<String>,
678 pub confirm: Option<SlackBlockConfirmItem>,
679 pub focus_on_load: Option<bool>,
680 pub placeholder: Option<SlackBlockPlainTextOnly>,
681 pub timezone: Option<String>,
682}
683
684impl From<SlackBlockTimePickerElement> for SlackSectionBlockElement {
685 fn from(element: SlackBlockTimePickerElement) -> Self {
686 SlackSectionBlockElement::TimePicker(element)
687 }
688}
689
690impl From<SlackBlockTimePickerElement> for SlackInputBlockElement {
691 fn from(element: SlackBlockTimePickerElement) -> Self {
692 SlackInputBlockElement::TimePicker(element)
693 }
694}
695
696impl From<SlackBlockTimePickerElement> for SlackActionBlockElement {
697 fn from(element: SlackBlockTimePickerElement) -> Self {
698 SlackActionBlockElement::TimePicker(element)
699 }
700}
701
702#[skip_serializing_none]
703#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
704pub struct SlackBlockDateTimePickerElement {
705 pub action_id: SlackActionId,
706 pub initial_date_time: Option<SlackDateTime>,
707 pub confirm: Option<SlackBlockConfirmItem>,
708 pub focus_on_load: Option<bool>,
709}
710
711impl From<SlackBlockDateTimePickerElement> for SlackInputBlockElement {
712 fn from(element: SlackBlockDateTimePickerElement) -> Self {
713 SlackInputBlockElement::DateTimePicker(element)
714 }
715}
716
717impl From<SlackBlockDateTimePickerElement> for SlackActionBlockElement {
718 fn from(element: SlackBlockDateTimePickerElement) -> Self {
719 SlackActionBlockElement::DateTimePicker(element)
720 }
721}
722
723#[skip_serializing_none]
724#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
725pub struct SlackBlockPlainTextInputElement {
726 pub action_id: SlackActionId,
727 pub placeholder: Option<SlackBlockPlainTextOnly>,
728 pub initial_value: Option<String>,
729 pub multiline: Option<bool>,
730 pub min_length: Option<u64>,
731 pub max_length: Option<u64>,
732 pub focus_on_load: Option<bool>,
733}
734
735impl From<SlackBlockPlainTextInputElement> for SlackSectionBlockElement {
736 fn from(element: SlackBlockPlainTextInputElement) -> Self {
737 SlackSectionBlockElement::PlainTextInput(element)
738 }
739}
740
741impl From<SlackBlockPlainTextInputElement> for SlackInputBlockElement {
742 fn from(element: SlackBlockPlainTextInputElement) -> Self {
743 SlackInputBlockElement::PlainTextInput(element)
744 }
745}
746
747impl From<SlackBlockPlainTextInputElement> for SlackActionBlockElement {
748 fn from(element: SlackBlockPlainTextInputElement) -> Self {
749 SlackActionBlockElement::PlainTextInput(element)
750 }
751}
752
753#[skip_serializing_none]
754#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
755pub struct SlackBlockNumberInputElement {
756 pub action_id: SlackActionId,
757 pub is_decimal_allowed: bool,
758 pub focus_on_load: Option<bool>,
759 pub placeholder: Option<SlackBlockPlainTextOnly>,
760 pub initial_value: Option<String>,
761 pub min_value: Option<String>,
762 pub max_value: Option<String>,
763}
764
765impl From<SlackBlockNumberInputElement> for SlackSectionBlockElement {
766 fn from(element: SlackBlockNumberInputElement) -> Self {
767 SlackSectionBlockElement::NumberInput(element)
768 }
769}
770
771impl From<SlackBlockNumberInputElement> for SlackInputBlockElement {
772 fn from(element: SlackBlockNumberInputElement) -> Self {
773 SlackInputBlockElement::NumberInput(element)
774 }
775}
776
777impl From<SlackBlockNumberInputElement> for SlackActionBlockElement {
778 fn from(element: SlackBlockNumberInputElement) -> Self {
779 SlackActionBlockElement::NumberInput(element)
780 }
781}
782
783#[skip_serializing_none]
784#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
785pub struct SlackBlockUrlInputElement {
786 pub action_id: SlackActionId,
787 pub placeholder: Option<SlackBlockPlainTextOnly>,
788 pub initial_value: Option<String>,
789}
790
791impl From<SlackBlockUrlInputElement> for SlackSectionBlockElement {
792 fn from(element: SlackBlockUrlInputElement) -> Self {
793 SlackSectionBlockElement::UrlInput(element)
794 }
795}
796
797impl From<SlackBlockUrlInputElement> for SlackInputBlockElement {
798 fn from(element: SlackBlockUrlInputElement) -> Self {
799 SlackInputBlockElement::UrlInput(element)
800 }
801}
802
803impl From<SlackBlockUrlInputElement> for SlackActionBlockElement {
804 fn from(element: SlackBlockUrlInputElement) -> Self {
805 SlackActionBlockElement::UrlInput(element)
806 }
807}
808
809#[skip_serializing_none]
810#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
811pub struct SlackBlockEmailInputElement {
812 pub action_id: SlackActionId,
813 pub focus_on_load: Option<bool>,
814 pub placeholder: Option<SlackBlockPlainTextOnly>,
815 pub initial_value: Option<EmailAddress>,
816}
817
818impl From<SlackBlockEmailInputElement> for SlackInputBlockElement {
819 fn from(element: SlackBlockEmailInputElement) -> Self {
820 SlackInputBlockElement::EmailInput(element)
821 }
822}
823
824#[skip_serializing_none]
825#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
826pub struct SlackBlockRadioButtonsElement {
827 pub action_id: SlackActionId,
828 pub options: Vec<SlackBlockChoiceItem<SlackBlockText>>,
829 pub initial_option: Option<SlackBlockChoiceItem<SlackBlockText>>,
830 pub confirm: Option<SlackBlockConfirmItem>,
831 pub focus_on_load: Option<bool>,
832}
833
834impl From<SlackBlockRadioButtonsElement> for SlackSectionBlockElement {
835 fn from(element: SlackBlockRadioButtonsElement) -> Self {
836 SlackSectionBlockElement::RadioButtons(element)
837 }
838}
839
840impl From<SlackBlockRadioButtonsElement> for SlackInputBlockElement {
841 fn from(element: SlackBlockRadioButtonsElement) -> Self {
842 SlackInputBlockElement::RadioButtons(element)
843 }
844}
845
846impl From<SlackBlockRadioButtonsElement> for SlackActionBlockElement {
847 fn from(element: SlackBlockRadioButtonsElement) -> Self {
848 SlackActionBlockElement::RadioButtons(element)
849 }
850}
851
852#[skip_serializing_none]
853#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
854pub struct SlackBlockCheckboxesElement {
855 pub action_id: SlackActionId,
856 pub options: Vec<SlackBlockChoiceItem<SlackBlockText>>,
857 pub initial_options: Option<Vec<SlackBlockChoiceItem<SlackBlockText>>>,
858 pub confirm: Option<SlackBlockConfirmItem>,
859 pub focus_on_load: Option<bool>,
860}
861
862impl From<SlackBlockCheckboxesElement> for SlackSectionBlockElement {
863 fn from(element: SlackBlockCheckboxesElement) -> Self {
864 SlackSectionBlockElement::Checkboxes(element)
865 }
866}
867
868impl From<SlackBlockCheckboxesElement> for SlackInputBlockElement {
869 fn from(element: SlackBlockCheckboxesElement) -> Self {
870 SlackInputBlockElement::Checkboxes(element)
871 }
872}
873
874impl From<SlackBlockCheckboxesElement> for SlackActionBlockElement {
875 fn from(element: SlackBlockCheckboxesElement) -> Self {
876 SlackActionBlockElement::Checkboxes(element)
877 }
878}
879
880#[skip_serializing_none]
884#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
885pub struct SlackBlockPlainText {
886 pub text: String,
887 pub emoji: Option<bool>,
888}
889
890#[skip_serializing_none]
894#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
895pub struct SlackBlockMarkDownText {
896 pub text: String,
897 pub verbatim: Option<bool>,
898}
899
900#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
904#[serde(tag = "type")]
905pub enum SlackBlockText {
906 #[serde(rename = "plain_text")]
907 Plain(SlackBlockPlainText),
908 #[serde(rename = "mrkdwn")]
909 MarkDown(SlackBlockMarkDownText),
910}
911
912#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
913#[serde(tag = "type", rename = "plain_text")]
914pub struct SlackBlockPlainTextOnly {
915 #[serde(flatten)]
916 value: SlackBlockPlainText,
917}
918
919impl SlackBlockPlainText {
920 pub fn as_block_text(&self) -> SlackBlockText {
921 SlackBlockText::Plain(self.clone())
922 }
923}
924
925impl From<String> for SlackBlockPlainText {
926 fn from(value: String) -> Self {
927 SlackBlockPlainText::new(value)
928 }
929}
930
931impl From<&str> for SlackBlockPlainText {
932 fn from(value: &str) -> Self {
933 SlackBlockPlainText::new(String::from(value))
934 }
935}
936
937impl SlackBlockMarkDownText {
938 pub fn as_block_text(&self) -> SlackBlockText {
939 SlackBlockText::MarkDown(self.clone())
940 }
941}
942
943impl From<String> for SlackBlockMarkDownText {
944 fn from(value: String) -> Self {
945 SlackBlockMarkDownText::new(value)
946 }
947}
948
949impl From<&str> for SlackBlockMarkDownText {
950 fn from(value: &str) -> Self {
951 SlackBlockMarkDownText::new(String::from(value))
952 }
953}
954
955impl From<SlackBlockPlainText> for SlackBlockPlainTextOnly {
956 fn from(pt: SlackBlockPlainText) -> Self {
957 SlackBlockPlainTextOnly { value: pt }
958 }
959}
960
961impl From<SlackBlockPlainText> for SlackBlockText {
962 fn from(text: SlackBlockPlainText) -> Self {
963 SlackBlockText::Plain(text)
964 }
965}
966
967impl From<SlackBlockMarkDownText> for SlackBlockText {
968 fn from(text: SlackBlockMarkDownText) -> Self {
969 SlackBlockText::MarkDown(text)
970 }
971}
972
973impl From<SlackBlockPlainText> for SlackContextBlockElement {
974 fn from(text: SlackBlockPlainText) -> Self {
975 SlackContextBlockElement::Plain(text)
976 }
977}
978
979impl From<SlackBlockMarkDownText> for SlackContextBlockElement {
980 fn from(text: SlackBlockMarkDownText) -> Self {
981 SlackContextBlockElement::MarkDown(text)
982 }
983}
984
985impl From<SlackBlockPlainTextOnly> for SlackBlockText {
986 fn from(text: SlackBlockPlainTextOnly) -> Self {
987 SlackBlockText::Plain(text.value)
988 }
989}
990
991impl From<String> for SlackBlockPlainTextOnly {
992 fn from(value: String) -> Self {
993 SlackBlockPlainTextOnly {
994 value: value.into(),
995 }
996 }
997}
998
999impl From<&str> for SlackBlockPlainTextOnly {
1000 fn from(value: &str) -> Self {
1001 SlackBlockPlainTextOnly {
1002 value: value.into(),
1003 }
1004 }
1005}
1006
1007#[skip_serializing_none]
1011#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
1012pub struct SlackVideoBlock {
1013 pub alt_text: String,
1014 pub author_name: Option<String>,
1015 pub block_id: Option<SlackBlockId>,
1016 pub description: Option<SlackBlockPlainTextOnly>,
1017 pub provider_icon_url: Option<Url>,
1018 pub provider_name: Option<String>,
1019 pub title: SlackBlockPlainTextOnly,
1020 pub title_url: Option<Url>,
1021 pub thumbnail_url: Url,
1022 pub video_url: Url,
1023}
1024
1025impl From<SlackVideoBlock> for SlackBlock {
1026 fn from(block: SlackVideoBlock) -> Self {
1027 SlackBlock::Video(block)
1028 }
1029}
1030
1031#[skip_serializing_none]
1035#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
1036pub struct SlackMarkdownBlock {
1037 pub block_id: Option<SlackBlockId>,
1038 pub text: String,
1039}
1040
1041impl From<SlackMarkdownBlock> for SlackBlock {
1042 fn from(block: SlackMarkdownBlock) -> Self {
1043 SlackBlock::Markdown(block)
1044 }
1045}