1use rsb_derive::Builder;
2use rvstruct::ValueStruct;
3use serde::{Deserialize, Serialize};
4use serde_with::skip_serializing_none;
5use url::Url;
6
7use crate::common::*;
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
33 #[serde(rename = "rich_text")]
35 RichText(serde_json::Value),
36}
37
38#[skip_serializing_none]
39#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
40pub struct SlackSectionBlock {
41 pub block_id: Option<SlackBlockId>,
42 pub text: Option<SlackBlockText>,
43 pub fields: Option<Vec<SlackBlockText>>,
44 pub accessory: Option<SlackSectionBlockElement>,
45}
46
47impl From<SlackSectionBlock> for SlackBlock {
48 fn from(block: SlackSectionBlock) -> Self {
49 SlackBlock::Section(block)
50 }
51}
52
53#[skip_serializing_none]
54#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
55pub struct SlackHeaderBlock {
56 pub block_id: Option<SlackBlockId>,
57 pub text: SlackBlockText,
58}
59
60impl From<SlackHeaderBlock> for SlackBlock {
61 fn from(block: SlackHeaderBlock) -> Self {
62 SlackBlock::Header(block)
63 }
64}
65
66#[skip_serializing_none]
67#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
68pub struct SlackDividerBlock {
69 pub block_id: Option<SlackBlockId>,
70}
71
72impl From<SlackDividerBlock> for SlackBlock {
73 fn from(block: SlackDividerBlock) -> Self {
74 SlackBlock::Divider(block)
75 }
76}
77
78#[skip_serializing_none]
79#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
80pub struct SlackImageBlock {
81 pub block_id: Option<SlackBlockId>,
82 pub image_url: Url,
83 pub alt_text: String,
84 pub title: Option<SlackBlockPlainTextOnly>,
85}
86
87impl From<SlackImageBlock> for SlackBlock {
88 fn from(block: SlackImageBlock) -> Self {
89 SlackBlock::Image(block)
90 }
91}
92
93#[skip_serializing_none]
94#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
95pub struct SlackActionsBlock {
96 pub block_id: Option<SlackBlockId>,
97 pub elements: Vec<SlackActionBlockElement>,
98}
99
100impl From<SlackActionsBlock> for SlackBlock {
101 fn from(block: SlackActionsBlock) -> Self {
102 SlackBlock::Actions(block)
103 }
104}
105
106#[skip_serializing_none]
107#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
108pub struct SlackContextBlock {
109 pub block_id: Option<SlackBlockId>,
110 pub elements: Vec<SlackContextBlockElement>,
111}
112
113impl From<SlackContextBlock> for SlackBlock {
114 fn from(block: SlackContextBlock) -> Self {
115 SlackBlock::Context(block)
116 }
117}
118
119#[skip_serializing_none]
120#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
121pub struct SlackInputBlock {
122 pub block_id: Option<SlackBlockId>,
123 pub label: SlackBlockPlainTextOnly,
124 pub element: SlackInputBlockElement,
125 pub hint: Option<SlackBlockPlainTextOnly>,
126 pub optional: Option<bool>,
127 pub dispatch_action: Option<bool>,
128}
129
130impl From<SlackInputBlock> for SlackBlock {
131 fn from(block: SlackInputBlock) -> Self {
132 SlackBlock::Input(block)
133 }
134}
135
136const SLACK_FILE_BLOCK_SOURCE_DEFAULT: &str = "remote";
137
138#[skip_serializing_none]
139#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
140pub struct SlackFileBlock {
141 pub block_id: Option<SlackBlockId>,
142 pub external_id: String,
143 #[default = "SLACK_FILE_BLOCK_SOURCE_DEFAULT.into()"]
144 pub source: String,
145}
146
147impl From<SlackFileBlock> for SlackBlock {
148 fn from(block: SlackFileBlock) -> Self {
149 SlackBlock::File(block)
150 }
151}
152
153#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
154#[serde(tag = "type")]
155pub enum SlackSectionBlockElement {
156 #[serde(rename = "image")]
157 Image(SlackBlockImageElement),
158 #[serde(rename = "button")]
159 Button(SlackBlockButtonElement),
160 #[serde(rename = "static_select")]
161 StaticSelect(SlackBlockStaticSelectElement),
162 #[serde(rename = "multi_static_select")]
163 MultiStaticSelect(SlackBlockMultiStaticSelectElement),
164 #[serde(rename = "external_select")]
165 ExternalSelect(SlackBlockExternalSelectElement),
166 #[serde(rename = "multi_external_select")]
167 MultiExternalSelect(SlackBlockMultiExternalSelectElement),
168 #[serde(rename = "users_select")]
169 UsersSelect(SlackBlockUsersSelectElement),
170 #[serde(rename = "multi_users_select")]
171 MultiUsersSelect(SlackBlockMultiUsersSelectElement),
172 #[serde(rename = "conversations_select")]
173 ConversationsSelect(SlackBlockConversationsSelectElement),
174 #[serde(rename = "multi_conversations_select")]
175 MultiConversationsSelect(SlackBlockMultiConversationsSelectElement),
176 #[serde(rename = "channels_select")]
177 ChannelsSelect(SlackBlockChannelsSelectElement),
178 #[serde(rename = "multi_channels_select")]
179 MultiChannelsSelect(SlackBlockMultiChannelsSelectElement),
180 #[serde(rename = "overflow")]
181 Overflow(SlackBlockOverflowElement),
182 #[serde(rename = "datepicker")]
183 DatePicker(SlackBlockDatePickerElement),
184 #[serde(rename = "plain_text_input")]
185 PlainTextInput(SlackBlockPlainTextInputElement),
186 #[serde(rename = "radio_buttons")]
187 RadioButtons(SlackBlockRadioButtonsElement),
188 #[serde(rename = "checkboxes")]
189 Checkboxes(SlackBlockCheckboxesElement),
190}
191
192#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
193#[serde(tag = "type")]
194pub enum SlackActionBlockElement {
195 #[serde(rename = "button")]
196 Button(SlackBlockButtonElement),
197 #[serde(rename = "overflow")]
198 Overflow(SlackBlockOverflowElement),
199 #[serde(rename = "datepicker")]
200 DatePicker(SlackBlockDatePickerElement),
201 #[serde(rename = "plain_text_input")]
202 PlainTextInput(SlackBlockPlainTextInputElement),
203 #[serde(rename = "radio_buttons")]
204 RadioButtons(SlackBlockRadioButtonsElement),
205 #[serde(rename = "checkboxes")]
206 Checkboxes(SlackBlockCheckboxesElement),
207}
208
209#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
210#[serde(tag = "type")]
211pub enum SlackContextBlockElement {
212 #[serde(rename = "image")]
213 Image(SlackBlockImageElement),
214 #[serde(rename = "plain_text")]
215 Plain(SlackBlockPlainText),
216 #[serde(rename = "mrkdwn")]
217 MarkDown(SlackBlockMarkDownText),
218}
219
220#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
221#[serde(tag = "type")]
222pub enum SlackInputBlockElement {
223 #[serde(rename = "static_select")]
224 StaticSelect(SlackBlockStaticSelectElement),
225 #[serde(rename = "multi_static_select")]
226 MultiStaticSelect(SlackBlockMultiStaticSelectElement),
227 #[serde(rename = "external_select")]
228 ExternalSelect(SlackBlockExternalSelectElement),
229 #[serde(rename = "multi_external_select")]
230 MultiExternalSelect(SlackBlockMultiExternalSelectElement),
231 #[serde(rename = "users_select")]
232 UsersSelect(SlackBlockUsersSelectElement),
233 #[serde(rename = "multi_users_select")]
234 MultiUsersSelect(SlackBlockMultiUsersSelectElement),
235 #[serde(rename = "conversations_select")]
236 ConversationsSelect(SlackBlockConversationsSelectElement),
237 #[serde(rename = "multi_conversations_select")]
238 MultiConversationsSelect(SlackBlockMultiConversationsSelectElement),
239 #[serde(rename = "channels_select")]
240 ChannelsSelect(SlackBlockChannelsSelectElement),
241 #[serde(rename = "multi_channels_select")]
242 MultiChannelsSelect(SlackBlockMultiChannelsSelectElement),
243 #[serde(rename = "datepicker")]
244 DatePicker(SlackBlockDatePickerElement),
245 #[serde(rename = "plain_text_input")]
246 PlainTextInput(SlackBlockPlainTextInputElement),
247 #[serde(rename = "radio_buttons")]
248 RadioButtons(SlackBlockRadioButtonsElement),
249 #[serde(rename = "checkboxes")]
250 Checkboxes(SlackBlockCheckboxesElement),
251}
252
253#[skip_serializing_none]
254#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
255pub struct SlackBlockImageElement {
256 pub image_url: String,
257 pub alt_text: String,
258}
259
260impl From<SlackBlockImageElement> for SlackSectionBlockElement {
261 fn from(element: SlackBlockImageElement) -> Self {
262 SlackSectionBlockElement::Image(element)
263 }
264}
265
266impl From<SlackBlockImageElement> for SlackContextBlockElement {
267 fn from(element: SlackBlockImageElement) -> Self {
268 SlackContextBlockElement::Image(element)
269 }
270}
271
272#[skip_serializing_none]
273#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
274pub struct SlackBlockButtonElement {
275 pub action_id: SlackActionId,
276 pub text: SlackBlockPlainTextOnly,
277 pub url: Option<Url>,
278 pub value: Option<String>,
279 pub style: Option<String>,
280 pub confirm: Option<SlackBlockConfirmItem>,
281}
282
283impl From<SlackBlockButtonElement> for SlackSectionBlockElement {
284 fn from(element: SlackBlockButtonElement) -> Self {
285 SlackSectionBlockElement::Button(element)
286 }
287}
288
289impl From<SlackBlockButtonElement> for SlackActionBlockElement {
290 fn from(element: SlackBlockButtonElement) -> Self {
291 SlackActionBlockElement::Button(element)
292 }
293}
294
295#[skip_serializing_none]
296#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
297pub struct SlackBlockConfirmItem {
298 pub title: SlackBlockPlainTextOnly,
299 pub text: SlackBlockText,
300 pub confirm: SlackBlockPlainTextOnly,
301 pub deny: SlackBlockPlainTextOnly,
302 pub style: Option<String>,
303}
304
305#[skip_serializing_none]
306#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
307pub struct SlackBlockChoiceItem<T: Into<SlackBlockText>> {
308 pub text: T,
309 pub value: String,
310 pub url: Option<Url>,
311}
312
313#[skip_serializing_none]
314#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
315pub struct SlackBlockOptionGroup<T: Into<SlackBlockText>> {
316 pub label: SlackBlockPlainTextOnly,
317 pub options: Vec<SlackBlockChoiceItem<T>>,
318}
319
320#[skip_serializing_none]
321#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
322pub struct SlackBlockStaticSelectElement {
323 pub action_id: SlackActionId,
324 pub placeholder: SlackBlockPlainTextOnly,
325 pub options: Option<Vec<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>>,
326 pub option_groups: Option<Vec<SlackBlockOptionGroup<SlackBlockPlainTextOnly>>>,
327 pub initial_option: Option<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>,
328 pub confirm: Option<SlackBlockConfirmItem>,
329}
330
331impl From<SlackBlockStaticSelectElement> for SlackSectionBlockElement {
332 fn from(element: SlackBlockStaticSelectElement) -> Self {
333 SlackSectionBlockElement::StaticSelect(element)
334 }
335}
336
337impl From<SlackBlockStaticSelectElement> for SlackInputBlockElement {
338 fn from(element: SlackBlockStaticSelectElement) -> Self {
339 SlackInputBlockElement::StaticSelect(element)
340 }
341}
342
343#[skip_serializing_none]
344#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
345pub struct SlackBlockMultiStaticSelectElement {
346 pub action_id: SlackActionId,
347 pub placeholder: SlackBlockPlainTextOnly,
348 pub options: Option<Vec<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>>,
349 pub option_groups: Option<Vec<SlackBlockOptionGroup<SlackBlockPlainTextOnly>>>,
350 pub initial_options: Option<Vec<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>>,
351 pub confirm: Option<SlackBlockConfirmItem>,
352 pub max_selected_items: Option<u64>,
353}
354
355impl From<SlackBlockMultiStaticSelectElement> for SlackSectionBlockElement {
356 fn from(element: SlackBlockMultiStaticSelectElement) -> Self {
357 SlackSectionBlockElement::MultiStaticSelect(element)
358 }
359}
360
361impl From<SlackBlockMultiStaticSelectElement> for SlackInputBlockElement {
362 fn from(element: SlackBlockMultiStaticSelectElement) -> Self {
363 SlackInputBlockElement::MultiStaticSelect(element)
364 }
365}
366
367#[skip_serializing_none]
368#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
369pub struct SlackBlockExternalSelectElement {
370 pub action_id: SlackActionId,
371 pub placeholder: SlackBlockPlainTextOnly,
372 pub initial_option: Option<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>,
373 pub confirm: Option<SlackBlockConfirmItem>,
374}
375
376impl From<SlackBlockExternalSelectElement> for SlackSectionBlockElement {
377 fn from(element: SlackBlockExternalSelectElement) -> Self {
378 SlackSectionBlockElement::ExternalSelect(element)
379 }
380}
381
382impl From<SlackBlockExternalSelectElement> for SlackInputBlockElement {
383 fn from(element: SlackBlockExternalSelectElement) -> Self {
384 SlackInputBlockElement::ExternalSelect(element)
385 }
386}
387
388#[skip_serializing_none]
389#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
390pub struct SlackBlockMultiExternalSelectElement {
391 pub action_id: SlackActionId,
392 pub placeholder: SlackBlockPlainTextOnly,
393 pub initial_options: Option<Vec<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>>,
394 pub confirm: Option<SlackBlockConfirmItem>,
395 pub max_selected_items: Option<u64>,
396}
397
398impl From<SlackBlockMultiExternalSelectElement> for SlackSectionBlockElement {
399 fn from(element: SlackBlockMultiExternalSelectElement) -> Self {
400 SlackSectionBlockElement::MultiExternalSelect(element)
401 }
402}
403
404impl From<SlackBlockMultiExternalSelectElement> for SlackInputBlockElement {
405 fn from(element: SlackBlockMultiExternalSelectElement) -> Self {
406 SlackInputBlockElement::MultiExternalSelect(element)
407 }
408}
409
410#[skip_serializing_none]
411#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
412pub struct SlackBlockUsersSelectElement {
413 pub action_id: SlackActionId,
414 pub placeholder: SlackBlockPlainTextOnly,
415 pub initial_user: Option<String>,
416 pub confirm: Option<SlackBlockConfirmItem>,
417}
418
419impl From<SlackBlockUsersSelectElement> for SlackSectionBlockElement {
420 fn from(element: SlackBlockUsersSelectElement) -> Self {
421 SlackSectionBlockElement::UsersSelect(element)
422 }
423}
424
425impl From<SlackBlockUsersSelectElement> for SlackInputBlockElement {
426 fn from(element: SlackBlockUsersSelectElement) -> Self {
427 SlackInputBlockElement::UsersSelect(element)
428 }
429}
430
431#[skip_serializing_none]
432#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
433pub struct SlackBlockMultiUsersSelectElement {
434 pub action_id: SlackActionId,
435 pub placeholder: SlackBlockPlainTextOnly,
436 pub initial_users: Option<Vec<String>>,
437 pub confirm: Option<SlackBlockConfirmItem>,
438 pub max_selected_items: Option<u64>,
439}
440
441impl From<SlackBlockMultiUsersSelectElement> for SlackSectionBlockElement {
442 fn from(element: SlackBlockMultiUsersSelectElement) -> Self {
443 SlackSectionBlockElement::MultiUsersSelect(element)
444 }
445}
446
447impl From<SlackBlockMultiUsersSelectElement> for SlackInputBlockElement {
448 fn from(element: SlackBlockMultiUsersSelectElement) -> Self {
449 SlackInputBlockElement::MultiUsersSelect(element)
450 }
451}
452
453#[skip_serializing_none]
454#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
455pub struct SlackBlockConversationsSelectElement {
456 pub action_id: SlackActionId,
457 pub placeholder: SlackBlockPlainTextOnly,
458 pub initial_conversation: Option<SlackConversationId>,
459 pub default_to_current_conversation: Option<bool>,
460 pub confirm: Option<SlackBlockConfirmItem>,
461 pub response_url_enabled: Option<bool>,
462}
463
464impl From<SlackBlockConversationsSelectElement> for SlackSectionBlockElement {
465 fn from(element: SlackBlockConversationsSelectElement) -> Self {
466 SlackSectionBlockElement::ConversationsSelect(element)
467 }
468}
469
470impl From<SlackBlockConversationsSelectElement> for SlackInputBlockElement {
471 fn from(element: SlackBlockConversationsSelectElement) -> Self {
472 SlackInputBlockElement::ConversationsSelect(element)
473 }
474}
475
476#[skip_serializing_none]
477#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
478pub struct SlackBlockMultiConversationsSelectElement {
479 pub action_id: SlackActionId,
480 pub placeholder: SlackBlockPlainTextOnly,
481 pub initial_conversations: Option<Vec<SlackConversationId>>,
482 pub default_to_current_conversation: Option<bool>,
483 pub confirm: Option<SlackBlockConfirmItem>,
484 pub max_selected_items: Option<u64>,
485}
486
487impl From<SlackBlockMultiConversationsSelectElement> for SlackSectionBlockElement {
488 fn from(element: SlackBlockMultiConversationsSelectElement) -> Self {
489 SlackSectionBlockElement::MultiConversationsSelect(element)
490 }
491}
492
493impl From<SlackBlockMultiConversationsSelectElement> for SlackInputBlockElement {
494 fn from(element: SlackBlockMultiConversationsSelectElement) -> Self {
495 SlackInputBlockElement::MultiConversationsSelect(element)
496 }
497}
498
499#[skip_serializing_none]
500#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
501pub struct SlackBlockChannelsSelectElement {
502 pub action_id: SlackActionId,
503 pub placeholder: SlackBlockPlainTextOnly,
504 pub initial_channel: Option<SlackChannelId>,
505 pub confirm: Option<SlackBlockConfirmItem>,
506 pub response_url_enabled: Option<bool>,
507}
508
509impl From<SlackBlockChannelsSelectElement> for SlackSectionBlockElement {
510 fn from(element: SlackBlockChannelsSelectElement) -> Self {
511 SlackSectionBlockElement::ChannelsSelect(element)
512 }
513}
514
515impl From<SlackBlockChannelsSelectElement> for SlackInputBlockElement {
516 fn from(element: SlackBlockChannelsSelectElement) -> Self {
517 SlackInputBlockElement::ChannelsSelect(element)
518 }
519}
520
521#[skip_serializing_none]
522#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
523pub struct SlackBlockMultiChannelsSelectElement {
524 pub action_id: SlackActionId,
525 pub placeholder: SlackBlockPlainTextOnly,
526 pub initial_channels: Option<Vec<SlackChannelId>>,
527 pub confirm: Option<SlackBlockConfirmItem>,
528 pub max_selected_items: Option<u64>,
529}
530
531impl From<SlackBlockMultiChannelsSelectElement> for SlackSectionBlockElement {
532 fn from(element: SlackBlockMultiChannelsSelectElement) -> Self {
533 SlackSectionBlockElement::MultiChannelsSelect(element)
534 }
535}
536
537impl From<SlackBlockMultiChannelsSelectElement> for SlackInputBlockElement {
538 fn from(element: SlackBlockMultiChannelsSelectElement) -> Self {
539 SlackInputBlockElement::MultiChannelsSelect(element)
540 }
541}
542
543#[skip_serializing_none]
544#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
545pub struct SlackBlockOverflowElement {
546 pub action_id: SlackActionId,
547 pub options: Vec<SlackBlockChoiceItem<SlackBlockPlainTextOnly>>,
548 pub confirm: Option<SlackBlockConfirmItem>,
549}
550
551impl From<SlackBlockOverflowElement> for SlackSectionBlockElement {
552 fn from(element: SlackBlockOverflowElement) -> Self {
553 SlackSectionBlockElement::Overflow(element)
554 }
555}
556
557impl From<SlackBlockOverflowElement> for SlackActionBlockElement {
558 fn from(element: SlackBlockOverflowElement) -> Self {
559 SlackActionBlockElement::Overflow(element)
560 }
561}
562
563#[skip_serializing_none]
564#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
565pub struct SlackBlockDatePickerElement {
566 pub action_id: SlackActionId,
567 pub placeholder: SlackBlockPlainTextOnly,
568 pub initial_date: Option<String>,
569 pub confirm: Option<SlackBlockConfirmItem>,
570}
571
572impl From<SlackBlockDatePickerElement> for SlackSectionBlockElement {
573 fn from(element: SlackBlockDatePickerElement) -> Self {
574 SlackSectionBlockElement::DatePicker(element)
575 }
576}
577
578impl From<SlackBlockDatePickerElement> for SlackInputBlockElement {
579 fn from(element: SlackBlockDatePickerElement) -> Self {
580 SlackInputBlockElement::DatePicker(element)
581 }
582}
583
584impl From<SlackBlockDatePickerElement> for SlackActionBlockElement {
585 fn from(element: SlackBlockDatePickerElement) -> Self {
586 SlackActionBlockElement::DatePicker(element)
587 }
588}
589
590#[skip_serializing_none]
591#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
592pub struct SlackBlockPlainTextInputElement {
593 pub action_id: SlackActionId,
594 pub placeholder: SlackBlockPlainTextOnly,
595 pub initial_value: Option<String>,
596 pub multiline: Option<bool>,
597 pub min_length: Option<u64>,
598 pub max_length: Option<u64>,
599}
600
601impl From<SlackBlockPlainTextInputElement> for SlackSectionBlockElement {
602 fn from(element: SlackBlockPlainTextInputElement) -> Self {
603 SlackSectionBlockElement::PlainTextInput(element)
604 }
605}
606
607impl From<SlackBlockPlainTextInputElement> for SlackInputBlockElement {
608 fn from(element: SlackBlockPlainTextInputElement) -> Self {
609 SlackInputBlockElement::PlainTextInput(element)
610 }
611}
612
613impl From<SlackBlockPlainTextInputElement> for SlackActionBlockElement {
614 fn from(element: SlackBlockPlainTextInputElement) -> Self {
615 SlackActionBlockElement::PlainTextInput(element)
616 }
617}
618
619#[skip_serializing_none]
620#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
621pub struct SlackBlockRadioButtonsElement {
622 pub action_id: SlackActionId,
623 pub options: Vec<SlackBlockChoiceItem<SlackBlockText>>,
624 pub initial_option: Option<SlackBlockChoiceItem<SlackBlockText>>,
625 pub confirm: Option<SlackBlockConfirmItem>,
626}
627
628impl From<SlackBlockRadioButtonsElement> for SlackSectionBlockElement {
629 fn from(element: SlackBlockRadioButtonsElement) -> Self {
630 SlackSectionBlockElement::RadioButtons(element)
631 }
632}
633
634impl From<SlackBlockRadioButtonsElement> for SlackInputBlockElement {
635 fn from(element: SlackBlockRadioButtonsElement) -> Self {
636 SlackInputBlockElement::RadioButtons(element)
637 }
638}
639
640impl From<SlackBlockRadioButtonsElement> for SlackActionBlockElement {
641 fn from(element: SlackBlockRadioButtonsElement) -> Self {
642 SlackActionBlockElement::RadioButtons(element)
643 }
644}
645
646#[skip_serializing_none]
647#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
648pub struct SlackBlockCheckboxesElement {
649 pub action_id: SlackActionId,
650 pub options: Vec<SlackBlockChoiceItem<SlackBlockText>>,
651 pub initial_options: Option<Vec<SlackBlockChoiceItem<SlackBlockText>>>,
652 pub confirm: Option<SlackBlockConfirmItem>,
653}
654
655impl From<SlackBlockCheckboxesElement> for SlackSectionBlockElement {
656 fn from(element: SlackBlockCheckboxesElement) -> Self {
657 SlackSectionBlockElement::Checkboxes(element)
658 }
659}
660
661impl From<SlackBlockCheckboxesElement> for SlackInputBlockElement {
662 fn from(element: SlackBlockCheckboxesElement) -> Self {
663 SlackInputBlockElement::Checkboxes(element)
664 }
665}
666
667impl From<SlackBlockCheckboxesElement> for SlackActionBlockElement {
668 fn from(element: SlackBlockCheckboxesElement) -> Self {
669 SlackActionBlockElement::Checkboxes(element)
670 }
671}
672
673#[skip_serializing_none]
677#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
678pub struct SlackBlockPlainText {
679 pub text: String,
680 pub emoji: Option<bool>,
681}
682
683#[skip_serializing_none]
687#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
688pub struct SlackBlockMarkDownText {
689 pub text: String,
690 pub verbatim: Option<bool>,
691}
692
693#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
697#[serde(tag = "type")]
698pub enum SlackBlockText {
699 #[serde(rename = "plain_text")]
700 Plain(SlackBlockPlainText),
701 #[serde(rename = "mrkdwn")]
702 MarkDown(SlackBlockMarkDownText),
703}
704
705#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
706#[serde(tag = "type", rename = "plain_text")]
707pub struct SlackBlockPlainTextOnly {
708 #[serde(flatten)]
709 value: SlackBlockPlainText,
710}
711
712impl SlackBlockPlainText {
713 pub fn as_block_text(&self) -> SlackBlockText {
714 SlackBlockText::Plain(self.clone())
715 }
716}
717
718impl From<String> for SlackBlockPlainText {
719 fn from(value: String) -> Self {
720 SlackBlockPlainText::new(value)
721 }
722}
723
724impl From<&str> for SlackBlockPlainText {
725 fn from(value: &str) -> Self {
726 SlackBlockPlainText::new(String::from(value))
727 }
728}
729
730impl SlackBlockMarkDownText {
731 pub fn as_block_text(&self) -> SlackBlockText {
732 SlackBlockText::MarkDown(self.clone())
733 }
734}
735
736impl From<String> for SlackBlockMarkDownText {
737 fn from(value: String) -> Self {
738 SlackBlockMarkDownText::new(value)
739 }
740}
741
742impl From<&str> for SlackBlockMarkDownText {
743 fn from(value: &str) -> Self {
744 SlackBlockMarkDownText::new(String::from(value))
745 }
746}
747
748impl From<SlackBlockPlainText> for SlackBlockPlainTextOnly {
749 fn from(pt: SlackBlockPlainText) -> Self {
750 SlackBlockPlainTextOnly { value: pt }
751 }
752}
753
754impl From<SlackBlockPlainText> for SlackBlockText {
755 fn from(text: SlackBlockPlainText) -> Self {
756 SlackBlockText::Plain(text)
757 }
758}
759
760impl From<SlackBlockMarkDownText> for SlackBlockText {
761 fn from(text: SlackBlockMarkDownText) -> Self {
762 SlackBlockText::MarkDown(text)
763 }
764}
765
766impl From<SlackBlockPlainText> for SlackContextBlockElement {
767 fn from(text: SlackBlockPlainText) -> Self {
768 SlackContextBlockElement::Plain(text)
769 }
770}
771
772impl From<SlackBlockMarkDownText> for SlackContextBlockElement {
773 fn from(text: SlackBlockMarkDownText) -> Self {
774 SlackContextBlockElement::MarkDown(text)
775 }
776}
777
778impl From<SlackBlockPlainTextOnly> for SlackBlockText {
779 fn from(text: SlackBlockPlainTextOnly) -> Self {
780 SlackBlockText::Plain(text.value)
781 }
782}
783
784impl From<String> for SlackBlockPlainTextOnly {
785 fn from(value: String) -> Self {
786 SlackBlockPlainTextOnly {
787 value: value.into(),
788 }
789 }
790}
791
792impl From<&str> for SlackBlockPlainTextOnly {
793 fn from(value: &str) -> Self {
794 SlackBlockPlainTextOnly {
795 value: value.into(),
796 }
797 }
798}