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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
use crate::Client;
use crate::ClientResult;

pub struct FilesRemote {
    pub client: Client,
}

impl FilesRemote {
    #[doc(hidden)]
    pub fn new(client: Client) -> Self {
        FilesRemote { client }
    }

    /**
     * This function performs a `POST` to the `/files.remote.add` endpoint.
     *
     * Adds a file from a remote service
     *
     * FROM: <https://api.slack.com/methods/files.remote.add>
     */
    pub async fn add(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
        let url = self.client.url("/files.remote.add", None);
        self.client
            .post(
                &url,
                crate::Message {
                    body: None,
                    content_type: Some("application/x-www-form-urlencoded".to_string()),
                },
            )
            .await
    }
    /**
     * This function performs a `GET` to the `/files.remote.info` endpoint.
     *
     * Retrieve information about a remote file added to Slack
     *
     * FROM: <https://api.slack.com/methods/files.remote.info>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `remote_files:read`.
     * * `file: &str` -- Specify a file by providing its ID.
     * * `external_id: &str` -- Creator defined GUID for the file.
     */
    pub async fn info(
        &self,
        file: &str,
        external_id: &str,
    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
        let mut query_args: Vec<(String, String)> = Default::default();
        if !external_id.is_empty() {
            query_args.push(("external_id".to_string(), external_id.to_string()));
        }
        if !file.is_empty() {
            query_args.push(("file".to_string(), file.to_string()));
        }
        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
        let url = self
            .client
            .url(&format!("/files.remote.info?{}", query_), None);
        self.client
            .get(
                &url,
                crate::Message {
                    body: None,
                    content_type: None,
                },
            )
            .await
    }
    /**
     * This function performs a `GET` to the `/files.remote.list` endpoint.
     *
     * Retrieve information about a remote file added to Slack
     *
     * FROM: <https://api.slack.com/methods/files.remote.list>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `remote_files:read`.
     * * `channel: &str` -- Filter files appearing in a specific channel, indicated by its ID.
     * * `ts_from: f64` -- Filter files created after this timestamp (inclusive).
     * * `ts_to: f64` -- Filter files created before this timestamp (inclusive).
     * * `limit: i64` -- The maximum number of items to return.
     * * `cursor: &str` -- Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](/docs/pagination) for more detail.
     */
    pub async fn list(
        &self,
        channel: &str,
        ts_from: f64,
        ts_to: f64,
        limit: i64,
        cursor: &str,
    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
        let mut query_args: Vec<(String, String)> = Default::default();
        if !channel.is_empty() {
            query_args.push(("channel".to_string(), channel.to_string()));
        }
        if !cursor.is_empty() {
            query_args.push(("cursor".to_string(), cursor.to_string()));
        }
        if limit > 0 {
            query_args.push(("limit".to_string(), limit.to_string()));
        }
        if !ts_from.to_string().is_empty() {
            query_args.push(("ts_from".to_string(), ts_from.to_string()));
        }
        if !ts_to.to_string().is_empty() {
            query_args.push(("ts_to".to_string(), ts_to.to_string()));
        }
        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
        let url = self
            .client
            .url(&format!("/files.remote.list?{}", query_), None);
        self.client
            .get(
                &url,
                crate::Message {
                    body: None,
                    content_type: None,
                },
            )
            .await
    }
    /**
     * This function performs a `POST` to the `/files.remote.remove` endpoint.
     *
     * Remove a remote file.
     *
     * FROM: <https://api.slack.com/methods/files.remote.remove>
     */
    pub async fn remove(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
        let url = self.client.url("/files.remote.remove", None);
        self.client
            .post(
                &url,
                crate::Message {
                    body: None,
                    content_type: Some("application/x-www-form-urlencoded".to_string()),
                },
            )
            .await
    }
    /**
     * This function performs a `GET` to the `/files.remote.share` endpoint.
     *
     * Share a remote file into a channel.
     *
     * FROM: <https://api.slack.com/methods/files.remote.share>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `remote_files:share`.
     * * `file: &str` -- Specify a file registered with Slack by providing its ID. Either this field or `external_id` or both are required.
     * * `external_id: &str` -- The globally unique identifier (GUID) for the file, as set by the app registering the file with Slack.  Either this field or `file` or both are required.
     * * `channels: &str` -- Comma-separated list of channel IDs where the file will be shared.
     */
    pub async fn share(
        &self,
        file: &str,
        external_id: &str,
        channels: &str,
    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
        let mut query_args: Vec<(String, String)> = Default::default();
        if !channels.is_empty() {
            query_args.push(("channels".to_string(), channels.to_string()));
        }
        if !external_id.is_empty() {
            query_args.push(("external_id".to_string(), external_id.to_string()));
        }
        if !file.is_empty() {
            query_args.push(("file".to_string(), file.to_string()));
        }
        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
        let url = self
            .client
            .url(&format!("/files.remote.share?{}", query_), None);
        self.client
            .get(
                &url,
                crate::Message {
                    body: None,
                    content_type: None,
                },
            )
            .await
    }
    /**
     * This function performs a `POST` to the `/files.remote.update` endpoint.
     *
     * Updates an existing remote file.
     *
     * FROM: <https://api.slack.com/methods/files.remote.update>
     */
    pub async fn update(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
        let url = self.client.url("/files.remote.update", None);
        self.client
            .post(
                &url,
                crate::Message {
                    body: None,
                    content_type: Some("application/x-www-form-urlencoded".to_string()),
                },
            )
            .await
    }
}