slack_chat_api/
migration.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct Migration {
5    pub client: Client,
6}
7
8impl Migration {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Migration { client }
12    }
13
14    /**
15     * This function performs a `GET` to the `/migration.exchange` endpoint.
16     *
17     * For Enterprise Grid workspaces, map local user IDs to global user IDs
18     *
19     * FROM: <https://api.slack.com/methods/migration.exchange>
20     *
21     * **Parameters:**
22     *
23     * * `token: &str` -- Authentication token. Requires scope: `tokens.basic`.
24     * * `users: &str` -- A comma-separated list of user ids, up to 400 per request.
25     * * `team_id: &str` -- Specify team_id starts with `T` in case of Org Token.
26     * * `to_old: bool` -- Specify `true` to convert `W` global user IDs to workspace-specific `U` IDs. Defaults to `false`.
27     */
28    pub async fn exchange(
29        &self,
30        users: &str,
31        team_id: &str,
32        to_old: bool,
33    ) -> ClientResult<crate::Response<crate::types::MigrationExchangeSuccessSchema>> {
34        let mut query_args: Vec<(String, String)> = Default::default();
35        if !team_id.is_empty() {
36            query_args.push(("team_id".to_string(), team_id.to_string()));
37        }
38        if to_old {
39            query_args.push(("to_old".to_string(), to_old.to_string()));
40        }
41        if !users.is_empty() {
42            query_args.push(("users".to_string(), users.to_string()));
43        }
44        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
45        let url = self
46            .client
47            .url(&format!("/migration.exchange?{}", query_), None);
48        self.client
49            .get(
50                &url,
51                crate::Message {
52                    body: None,
53                    content_type: None,
54                },
55            )
56            .await
57    }
58}