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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
use anyhow::Result;

use crate::Client;

pub struct Conversations {
    pub client: Client,
}

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

    /**
     * This function performs a `POST` to the `/conversations.archive` endpoint.
     *
     * Archives a conversation.
     *
     * FROM: <https://api.slack.com/methods/conversations.archive>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn archive(&self) -> Result<crate::types::DndEndSchema> {
        let url = "/conversations.archive".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.close` endpoint.
     *
     * Closes a direct message or multi-person direct message.
     *
     * FROM: <https://api.slack.com/methods/conversations.close>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn close(&self) -> Result<crate::types::ConversationsCloseSuccessSchema> {
        let url = "/conversations.close".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.create` endpoint.
     *
     * Initiates a public or private channel-based conversation
     *
     * FROM: <https://api.slack.com/methods/conversations.create>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn create(&self) -> Result<crate::types::ConversationsInfoSuccessSchema> {
        let url = "/conversations.create".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `GET` to the `/conversations.history` endpoint.
     *
     * Fetches a conversation's history of messages and events.
     *
     * FROM: <https://api.slack.com/methods/conversations.history>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:history`.
     * * `channel: &str` -- Conversation ID to fetch history for.
     * * `latest: f64` -- End of time range of messages to include in results.
     * * `oldest: f64` -- Start of time range of messages to include in results.
     * * `inclusive: bool` -- Include messages with latest or oldest timestamp in results only when either timestamp is specified.
     * * `limit: i64` -- The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached.
     * * `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 history(
        &self,
        channel: &str,
        latest: f64,
        oldest: f64,
        inclusive: bool,
        limit: i64,
        cursor: &str,
    ) -> Result<crate::types::ConversationsHistorySuccessSchema> {
        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 inclusive {
            query_args.push(("inclusive".to_string(), inclusive.to_string()));
        }
        if !latest.to_string().is_empty() {
            query_args.push(("latest".to_string(), latest.to_string()));
        }
        if limit > 0 {
            query_args.push(("limit".to_string(), limit.to_string()));
        }
        if !oldest.to_string().is_empty() {
            query_args.push(("oldest".to_string(), oldest.to_string()));
        }
        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
        let url = format!("/conversations.history?{}", query_);

        self.client.get(&url, None).await
    }

    /**
     * This function performs a `GET` to the `/conversations.info` endpoint.
     *
     * Retrieve information about a conversation.
     *
     * FROM: <https://api.slack.com/methods/conversations.info>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:read`.
     * * `channel: &str` -- Conversation ID to learn more about.
     * * `include_locale: bool` -- Set this to `true` to receive the locale for this conversation. Defaults to `false`.
     * * `include_num_members: bool` -- Set to `true` to include the member count for the specified conversation. Defaults to `false`.
     */
    pub async fn info(
        &self,
        channel: &str,
        include_locale: bool,
        include_num_members: bool,
    ) -> Result<crate::types::ConversationsInfoSuccessSchema> {
        let mut query_args: Vec<(String, String)> = Default::default();
        if !channel.is_empty() {
            query_args.push(("channel".to_string(), channel.to_string()));
        }
        if include_locale {
            query_args.push(("include_locale".to_string(), include_locale.to_string()));
        }
        if include_num_members {
            query_args.push((
                "include_num_members".to_string(),
                include_num_members.to_string(),
            ));
        }
        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
        let url = format!("/conversations.info?{}", query_);

        self.client.get(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.invite` endpoint.
     *
     * Invites users to a channel.
     *
     * FROM: <https://api.slack.com/methods/conversations.invite>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn invite(&self) -> Result<crate::types::ConversationsInfoSuccessSchema> {
        let url = "/conversations.invite".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.join` endpoint.
     *
     * Joins an existing conversation.
     *
     * FROM: <https://api.slack.com/methods/conversations.join>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `channels:write`.
     */
    pub async fn join(&self) -> Result<crate::types::ConversationsJoinSuccessSchema> {
        let url = "/conversations.join".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.kick` endpoint.
     *
     * Removes a user from a conversation.
     *
     * FROM: <https://api.slack.com/methods/conversations.kick>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn kick(&self) -> Result<crate::types::DndEndSchema> {
        let url = "/conversations.kick".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.leave` endpoint.
     *
     * Leaves a conversation.
     *
     * FROM: <https://api.slack.com/methods/conversations.leave>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn leave(&self) -> Result<crate::types::ConversationsLeaveSuccessSchema> {
        let url = "/conversations.leave".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `GET` to the `/conversations.list` endpoint.
     *
     * Lists all channels in a Slack team.
     *
     * FROM: <https://api.slack.com/methods/conversations.list>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:read`.
     * * `exclude_archived: bool` -- Set to `true` to exclude archived channels from the list.
     * * `types: &str` -- Mix and match channel types by providing a comma-separated list of any combination of `public_channel`, `private_channel`, `mpim`, `im`.
     * * `limit: i64` -- The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. Must be an integer no larger than 1000.
     * * `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,
        exclude_archived: bool,
        types: &str,
        limit: i64,
        cursor: &str,
    ) -> Result<crate::types::ConversationsListSuccessSchema> {
        let mut query_args: Vec<(String, String)> = Default::default();
        if !cursor.is_empty() {
            query_args.push(("cursor".to_string(), cursor.to_string()));
        }
        if exclude_archived {
            query_args.push(("exclude_archived".to_string(), exclude_archived.to_string()));
        }
        if limit > 0 {
            query_args.push(("limit".to_string(), limit.to_string()));
        }
        if !types.is_empty() {
            query_args.push(("types".to_string(), types.to_string()));
        }
        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
        let url = format!("/conversations.list?{}", query_);

        self.client.get(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.mark` endpoint.
     *
     * Sets the read cursor in a channel.
     *
     * FROM: <https://api.slack.com/methods/conversations.mark>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn mark(&self) -> Result<crate::types::DndEndSchema> {
        let url = "/conversations.mark".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `GET` to the `/conversations.members` endpoint.
     *
     * Retrieve members of a conversation.
     *
     * FROM: <https://api.slack.com/methods/conversations.members>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:read`.
     * * `channel: &str` -- ID of the conversation to retrieve members for.
     * * `limit: i64` -- The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached.
     * * `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 member(
        &self,
        channel: &str,
        limit: i64,
        cursor: &str,
    ) -> Result<crate::types::ConversationsMembersSuccessSchema> {
        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()));
        }
        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
        let url = format!("/conversations.members?{}", query_);

        self.client.get(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.open` endpoint.
     *
     * Opens or resumes a direct message or multi-person direct message.
     *
     * FROM: <https://api.slack.com/methods/conversations.open>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn open(&self) -> Result<crate::types::ConversationsOpenSuccessSchema> {
        let url = "/conversations.open".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.rename` endpoint.
     *
     * Renames a conversation.
     *
     * FROM: <https://api.slack.com/methods/conversations.rename>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn rename(&self) -> Result<crate::types::ConversationsInfoSuccessSchema> {
        let url = "/conversations.rename".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `GET` to the `/conversations.replies` endpoint.
     *
     * Retrieve a thread of messages posted to a conversation
     *
     * FROM: <https://api.slack.com/methods/conversations.replies>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:history`.
     * * `channel: &str` -- Conversation ID to fetch thread from.
     * * `ts: f64` -- Unique identifier of a thread's parent message. `ts` must be the timestamp of an existing message with 0 or more replies. If there are no replies then just the single message referenced by `ts` will return - it is just an ordinary, unthreaded message.
     * * `latest: f64` -- End of time range of messages to include in results.
     * * `oldest: f64` -- Start of time range of messages to include in results.
     * * `inclusive: bool` -- Include messages with latest or oldest timestamp in results only when either timestamp is specified.
     * * `limit: i64` -- The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached.
     * * `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 replie(
        &self,
        channel: &str,
        ts: f64,
        latest: f64,
        oldest: f64,
        inclusive: bool,
        limit: i64,
        cursor: &str,
    ) -> Result<crate::types::ConversationsRepliesSuccessSchema> {
        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 inclusive {
            query_args.push(("inclusive".to_string(), inclusive.to_string()));
        }
        if !latest.to_string().is_empty() {
            query_args.push(("latest".to_string(), latest.to_string()));
        }
        if limit > 0 {
            query_args.push(("limit".to_string(), limit.to_string()));
        }
        if !oldest.to_string().is_empty() {
            query_args.push(("oldest".to_string(), oldest.to_string()));
        }
        if !ts.to_string().is_empty() {
            query_args.push(("ts".to_string(), ts.to_string()));
        }
        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
        let url = format!("/conversations.replies?{}", query_);

        self.client.get(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.setPurpose` endpoint.
     *
     * Sets the purpose for a conversation.
     *
     * FROM: <https://api.slack.com/methods/conversations.setPurpose>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn set_purpose(&self) -> Result<crate::types::ConversationsInfoSuccessSchema> {
        let url = "/conversations.setPurpose".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.setTopic` endpoint.
     *
     * Sets the topic for a conversation.
     *
     * FROM: <https://api.slack.com/methods/conversations.setTopic>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn set_topic(&self) -> Result<crate::types::ConversationsInfoSuccessSchema> {
        let url = "/conversations.setTopic".to_string();
        self.client.post(&url, None).await
    }

    /**
     * This function performs a `POST` to the `/conversations.unarchive` endpoint.
     *
     * Reverses conversation archival.
     *
     * FROM: <https://api.slack.com/methods/conversations.unarchive>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `conversations:write`.
     */
    pub async fn unarchive(&self) -> Result<crate::types::DndEndSchema> {
        let url = "/conversations.unarchive".to_string();
        self.client.post(&url, None).await
    }
}