sfr_slack_api/builder/
files_complete_upload_external.rs

1//! The builder for [`FilesCompleteUploadExternal`].
2
3use sfr_types as st;
4
5use crate::api::files_complete_upload_external::FilesCompleteUploadExternal;
6
7/// The builder for [`FilesCompleteUploadExternal`].
8#[derive(Debug, Default)]
9pub struct FilesCompleteUploadExternalBuilder {
10    /// The [`files`][`st::FilesCompleteUploadExternalRequest::files`].
11    files: Vec<st::FilesCompleteUploadExternalRequestFile>,
12
13    /// The [`channel_id`][`st::FilesCompleteUploadExternalRequest::channel_id`].
14    channel_id: Option<String>,
15
16    /// The [`initial_comment`][`st::FilesCompleteUploadExternalRequest::initial_comment`].
17    initial_comment: Option<String>,
18
19    /// The [`thread_ts`][`st::FilesCompleteUploadExternalRequest::thread_ts`].
20    thread_ts: Option<String>,
21}
22
23impl FilesCompleteUploadExternalBuilder {
24    /// The constructor.
25    pub fn new() -> Self {
26        Self::default()
27    }
28
29    /// Builds [`FilesCompleteUploadExternal`].
30    pub fn build(self) -> FilesCompleteUploadExternal {
31        let result = st::FilesCompleteUploadExternalRequest {
32            files: self.files,
33            channel_id: self.channel_id,
34            initial_comment: self.initial_comment,
35            thread_ts: self.thread_ts,
36        };
37
38        result.into()
39    }
40
41    /// Adds [`st::FilesCompleteUploadExternalRequestFile`] element to [`files`][`st::FilesCompleteUploadExternalRequest::files`].
42    pub fn add_file(mut self, id: String, title: Option<String>) -> Self {
43        self.files
44            .push(st::FilesCompleteUploadExternalRequestFile { id, title });
45        self
46    }
47
48    /// Sets [`channel_id`][`st::FilesCompleteUploadExternalRequest::channel_id`].
49    pub fn channel_id(mut self, channel_id: Option<String>) -> Self {
50        self.channel_id = channel_id;
51        self
52    }
53
54    /// Sets [`initial_comment`][`st::FilesCompleteUploadExternalRequest::initial_comment`].
55    pub fn initial_comment(mut self, initial_comment: Option<String>) -> Self {
56        self.initial_comment = initial_comment;
57        self
58    }
59
60    /// Sets [`thread_ts`][`st::FilesCompleteUploadExternalRequest::thread_ts`].
61    pub fn thread_ts(mut self, thread_ts: Option<String>) -> Self {
62        self.thread_ts = thread_ts;
63        self
64    }
65}