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

use crate::{BlockId, ExternalId};
use derive_new::new;
use serde::Serialize;

/// File block.
///
/// <https://api.slack.com/reference/block-kit/blocks#file>
#[derive(Serialize, Debug, Clone, new)]
#[serde(rename_all = "snake_case")]
pub struct FileBlock {
    /// The external unique ID for this file.
    pub external_id: ExternalId,

    /// At the moment, `source` will always be `remote` for a remote file.
    #[new(default)]
    pub source: FileBlockSource,

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

/// A `source` field in File block.
///
/// <https://api.slack.com/reference/block-kit/blocks#file_fields>
#[derive(Serialize, Debug, Clone, Default)]
#[serde(rename_all = "snake_case")]
pub enum FileBlockSource {
    /// The `source` will always be `remote`.
    #[default]
    Remote,
}
