slack_chat_api/auth.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct Auth {
5 pub client: Client,
6}
7
8impl Auth {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 Auth { client }
12 }
13
14 /**
15 * This function performs a `GET` to the `/auth.revoke` endpoint.
16 *
17 * Revokes a token.
18 *
19 * FROM: <https://api.slack.com/methods/auth.revoke>
20 *
21 * **Parameters:**
22 *
23 * * `token: &str` -- Authentication token. Requires scope: `none`.
24 * * `test: bool` -- Setting this parameter to `1` triggers a _testing mode_ where the specified token will not actually be revoked.
25 */
26 pub async fn revoke(
27 &self,
28 test: bool,
29 ) -> ClientResult<crate::Response<crate::types::AuthRevokeSchema>> {
30 let mut query_args: Vec<(String, String)> = Default::default();
31 if test {
32 query_args.push(("test".to_string(), test.to_string()));
33 }
34 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
35 let url = self.client.url(&format!("/auth.revoke?{}", query_), None);
36 self.client
37 .get(
38 &url,
39 crate::Message {
40 body: None,
41 content_type: None,
42 },
43 )
44 .await
45 }
46 /**
47 * This function performs a `GET` to the `/auth.test` endpoint.
48 *
49 * Checks authentication & identity.
50 *
51 * FROM: <https://api.slack.com/methods/auth.test>
52 *
53 * **Parameters:**
54 *
55 * * `token: &str` -- Authentication token. Requires scope: `none`.
56 */
57 pub async fn test(&self) -> ClientResult<crate::Response<crate::types::AuthTestSuccessSchema>> {
58 let url = self.client.url("/auth.test", None);
59 self.client
60 .get(
61 &url,
62 crate::Message {
63 body: None,
64 content_type: None,
65 },
66 )
67 .await
68 }
69}