slack_chat_api/
apps_permissions.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct AppsPermissions {
5    pub client: Client,
6}
7
8impl AppsPermissions {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        AppsPermissions { client }
12    }
13
14    /**
15     * This function performs a `GET` to the `/apps.permissions.info` endpoint.
16     *
17     * Returns list of permissions this app has on a team.
18     *
19     * FROM: <https://api.slack.com/methods/apps.permissions.info>
20     *
21     * **Parameters:**
22     *
23     * * `token: &str` -- Authentication token. Requires scope: `none`.
24     */
25    pub async fn info(
26        &self,
27    ) -> ClientResult<crate::Response<crate::types::AppsPermissionsInfoSchema>> {
28        let url = self.client.url("/apps.permissions.info", None);
29        self.client
30            .get(
31                &url,
32                crate::Message {
33                    body: None,
34                    content_type: None,
35                },
36            )
37            .await
38    }
39    /**
40     * This function performs a `GET` to the `/apps.permissions.request` endpoint.
41     *
42     * Allows an app to request additional scopes
43     *
44     * FROM: <https://api.slack.com/methods/apps.permissions.request>
45     *
46     * **Parameters:**
47     *
48     * * `token: &str` -- Authentication token. Requires scope: `none`.
49     * * `scopes: &str` -- A comma separated list of scopes to request for.
50     * * `trigger_id: &str` -- Token used to trigger the permissions API.
51     */
52    pub async fn request(
53        &self,
54        scopes: &str,
55        trigger_id: &str,
56    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
57        let mut query_args: Vec<(String, String)> = Default::default();
58        if !scopes.is_empty() {
59            query_args.push(("scopes".to_string(), scopes.to_string()));
60        }
61        if !trigger_id.is_empty() {
62            query_args.push(("trigger_id".to_string(), trigger_id.to_string()));
63        }
64        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
65        let url = self
66            .client
67            .url(&format!("/apps.permissions.request?{}", query_), None);
68        self.client
69            .get(
70                &url,
71                crate::Message {
72                    body: None,
73                    content_type: None,
74                },
75            )
76            .await
77    }
78}