slack_chat_api/
apps_permissions_users.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct AppsPermissionsUsers {
5    pub client: Client,
6}
7
8impl AppsPermissionsUsers {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        AppsPermissionsUsers { client }
12    }
13
14    /**
15     * This function performs a `GET` to the `/apps.permissions.users.list` endpoint.
16     *
17     * Returns list of user grants and corresponding scopes this app has on a team.
18     *
19     * FROM: <https://api.slack.com/methods/apps.permissions.users.list>
20     *
21     * **Parameters:**
22     *
23     * * `token: &str` -- Authentication token. Requires scope: `none`.
24     * * `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.
25     * * `limit: i64` -- The maximum number of items to return.
26     */
27    pub async fn list(
28        &self,
29        cursor: &str,
30        limit: i64,
31    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
32        let mut query_args: Vec<(String, String)> = Default::default();
33        if !cursor.is_empty() {
34            query_args.push(("cursor".to_string(), cursor.to_string()));
35        }
36        if limit > 0 {
37            query_args.push(("limit".to_string(), limit.to_string()));
38        }
39        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
40        let url = self
41            .client
42            .url(&format!("/apps.permissions.users.list?{}", query_), None);
43        self.client
44            .get(
45                &url,
46                crate::Message {
47                    body: None,
48                    content_type: None,
49                },
50            )
51            .await
52    }
53    /**
54     * This function performs a `GET` to the `/apps.permissions.users.request` endpoint.
55     *
56     * Enables an app to trigger a permissions modal to grant an app access to a user access scope.
57     *
58     * FROM: <https://api.slack.com/methods/apps.permissions.users.request>
59     *
60     * **Parameters:**
61     *
62     * * `token: &str` -- Authentication token. Requires scope: `none`.
63     * * `scopes: &str` -- A comma separated list of user scopes to request for.
64     * * `trigger_id: &str` -- Token used to trigger the request.
65     * * `user: &str` -- The user this scope is being requested for.
66     */
67    pub async fn request(
68        &self,
69        scopes: &str,
70        trigger_id: &str,
71        user: &str,
72    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
73        let mut query_args: Vec<(String, String)> = Default::default();
74        if !scopes.is_empty() {
75            query_args.push(("scopes".to_string(), scopes.to_string()));
76        }
77        if !trigger_id.is_empty() {
78            query_args.push(("trigger_id".to_string(), trigger_id.to_string()));
79        }
80        if !user.is_empty() {
81            query_args.push(("user".to_string(), user.to_string()));
82        }
83        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
84        let url = self
85            .client
86            .url(&format!("/apps.permissions.users.request?{}", query_), None);
87        self.client
88            .get(
89                &url,
90                crate::Message {
91                    body: None,
92                    content_type: None,
93                },
94            )
95            .await
96    }
97}