slack_chat_api/
admin_invite_requests.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct AdminInviteRequests {
5    pub client: Client,
6}
7
8impl AdminInviteRequests {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        AdminInviteRequests { client }
12    }
13
14    /**
15     * This function performs a `POST` to the `/admin.inviteRequests.approve` endpoint.
16     *
17     * Approve a workspace invite request.
18     *
19     * FROM: <https://api.slack.com/methods/admin.inviteRequests.approve>
20     *
21     * **Parameters:**
22     *
23     * * `token: &str` -- Authentication token. Requires scope: `admin.invites:write`.
24     */
25    pub async fn approve(
26        &self,
27        body: &crate::types::AdminInviteRequestsApproveRequest,
28    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
29        let url = self.client.url("/admin.inviteRequests.approve", None);
30        self.client
31            .post(
32                &url,
33                crate::Message {
34                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
35                    content_type: None,
36                },
37            )
38            .await
39    }
40    /**
41     * This function performs a `POST` to the `/admin.inviteRequests.deny` endpoint.
42     *
43     * Deny a workspace invite request.
44     *
45     * FROM: <https://api.slack.com/methods/admin.inviteRequests.deny>
46     *
47     * **Parameters:**
48     *
49     * * `token: &str` -- Authentication token. Requires scope: `admin.invites:write`.
50     */
51    pub async fn deny(
52        &self,
53        body: &crate::types::AdminInviteRequestsApproveRequest,
54    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
55        let url = self.client.url("/admin.inviteRequests.deny", None);
56        self.client
57            .post(
58                &url,
59                crate::Message {
60                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
61                    content_type: None,
62                },
63            )
64            .await
65    }
66    /**
67     * This function performs a `GET` to the `/admin.inviteRequests.list` endpoint.
68     *
69     * List all pending workspace invite requests.
70     *
71     * FROM: <https://api.slack.com/methods/admin.inviteRequests.list>
72     *
73     * **Parameters:**
74     *
75     * * `token: &str` -- Authentication token. Requires scope: `admin.invites:read`.
76     * * `team_id: &str` -- ID for the workspace where the invite requests were made.
77     * * `cursor: &str` -- Value of the `next_cursor` field sent as part of the previous API response.
78     * * `limit: i64` -- The number of results that will be returned by the API on each invocation. Must be between 1 - 1000, both inclusive.
79     */
80    pub async fn list(
81        &self,
82        team_id: &str,
83        cursor: &str,
84        limit: i64,
85    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
86        let mut query_args: Vec<(String, String)> = Default::default();
87        if !cursor.is_empty() {
88            query_args.push(("cursor".to_string(), cursor.to_string()));
89        }
90        if limit > 0 {
91            query_args.push(("limit".to_string(), limit.to_string()));
92        }
93        if !team_id.is_empty() {
94            query_args.push(("team_id".to_string(), team_id.to_string()));
95        }
96        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
97        let url = self
98            .client
99            .url(&format!("/admin.inviteRequests.list?{}", query_), None);
100        self.client
101            .get(
102                &url,
103                crate::Message {
104                    body: None,
105                    content_type: None,
106                },
107            )
108            .await
109    }
110}