1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//! Section block.
//!
//! <https://api.slack.com/reference/block-kit/blocks#section>

use crate::BlockId;
use crate::Element;
use crate::TextObject;
use serde::Serialize;

/// Section block.
///
/// <https://api.slack.com/reference/block-kit/blocks#section>
#[derive(Serialize, Debug, Clone, Default)]
#[serde(rename_all = "snake_case")]
pub struct SectionBlock {
    /// The text for the block, in the form of a [text object](https://api.slack.com/reference/messaging/composition-objects#text).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub text: Option<TextObject>,

    /// A unique identifier for a block.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub block_id: Option<BlockId>,

    /// Required if no `text` is provided.
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub fields: Vec<TextObject>,

    /// One of the compatible [element objects](https://api.slack.com/reference/block-kit/blocks#section) noted above.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub accessory: Option<Element>,
}