//! Image block.
//!
//! <https://api.slack.com/reference/block-kit/blocks#image>

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

/// Image block.
///
/// <https://api.slack.com/reference/block-kit/blocks#image>
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "snake_case")]
pub struct ImageBlock {
    /// A plain-text summary of the image.
    pub alt_text: String,

    /// The URL for a publicly hosted image.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image_url: Option<url::Url>,

    // /// Slack file object.
    // ///
    // /// <https://api.slack.com/reference/block-kit/composition-objects#slack_file>
    // #[serde(skip_serializing_if = "Option::is_none")]
    // pub slack_file: Option<>,
    /// An optional title for the image in the form of a [text object](https://api.slack.com/reference/messaging/composition-objects#text) that can only be of `type: plain_text`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<TextObject>,

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