slack_chat_api/
admin_teams.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct AdminTeams {
5    pub client: Client,
6}
7
8impl AdminTeams {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        AdminTeams { client }
12    }
13
14    /**
15     * This function performs a `POST` to the `/admin.teams.create` endpoint.
16     *
17     * Create an Enterprise team.
18     *
19     * FROM: <https://api.slack.com/methods/admin.teams.create>
20     *
21     * **Parameters:**
22     *
23     * * `token: &str` -- Authentication token. Requires scope: `admin.teams:write`.
24     */
25    pub async fn create(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
26        let url = self.client.url("/admin.teams.create", None);
27        self.client
28            .post(
29                &url,
30                crate::Message {
31                    body: None,
32                    content_type: Some("application/x-www-form-urlencoded".to_string()),
33                },
34            )
35            .await
36    }
37    /**
38     * This function performs a `GET` to the `/admin.teams.list` endpoint.
39     *
40     * List all teams on an Enterprise organization
41     *
42     * FROM: <https://api.slack.com/methods/admin.teams.list>
43     *
44     * **Parameters:**
45     *
46     * * `token: &str` -- Authentication token. Requires scope: `admin.teams:read`.
47     * * `limit: i64` -- The maximum number of items to return. Must be between 1 - 100 both inclusive.
48     * * `cursor: &str` -- Set `cursor` to `next_cursor` returned by the previous call to list items in the next page.
49     */
50    pub async fn list(
51        &self,
52        limit: i64,
53        cursor: &str,
54    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
55        let mut query_args: Vec<(String, String)> = Default::default();
56        if !cursor.is_empty() {
57            query_args.push(("cursor".to_string(), cursor.to_string()));
58        }
59        if limit > 0 {
60            query_args.push(("limit".to_string(), limit.to_string()));
61        }
62        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
63        let url = self
64            .client
65            .url(&format!("/admin.teams.list?{}", query_), None);
66        self.client
67            .get(
68                &url,
69                crate::Message {
70                    body: None,
71                    content_type: None,
72                },
73            )
74            .await
75    }
76}