//! The type that represents a request of `files.upload`.
//!
//! <https://api.slack.com/methods/files.upload>

/// The type that represents a request of `files.upload`.
///
/// <https://api.slack.com/methods/files.upload>
#[derive(Clone, Debug)]
pub struct FilesUploadRequest {
    /// Comma-separated list of channel names or IDs where the file will be shared.
    ///
    /// <https://api.slack.com/methods/files.upload#arg_channels>
    pub channels: Vec<String>,

    /// File contents via a POST variable.
    ///
    /// <https://api.slack.com/methods/files.upload#arg_content>
    pub content: FilesUploadRequestContent,

    /// Filename of file.
    ///
    /// <https://api.slack.com/methods/files.upload#arg_filename>
    pub filename: Option<String>,

    /// A [file type](https://api.slack.com/types/file#file_types) identifier.
    ///
    /// <https://api.slack.com/methods/files.upload#arg_filetype>
    pub filetype: Option<String>,

    /// The message text introducing the file in specified `channels`.
    ///
    /// <https://api.slack.com/methods/files.upload#arg_initial_comment>
    pub initial_comment: Option<String>,

    /// Provide another message's `ts` value to upload this file as a reply.
    ///
    /// <https://api.slack.com/methods/files.upload#arg_thread_ts>
    pub thread_ts: Option<String>,

    /// Title of file.
    ///
    /// <https://api.slack.com/methods/files.upload#arg_title>
    pub title: Option<String>,
}

/// File contents via a POST variable.
#[derive(Clone, Debug)]
pub enum FilesUploadRequestContent {
    /// An editable text file.
    Content(String),

    /// File contents via `multipart/form-data`.
    /// `([local file path], [filename])`.
    File(String, String),

    /// File contents via `multipart/form-data` (same as [`Self::File`]).
    /// `([binary data], [filename])`.
    FileInMemory(Vec<u8>, String),
}
