slack_chat_api/
calls.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct Calls {
5    pub client: Client,
6}
7
8impl Calls {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Calls { client }
12    }
13
14    /**
15     * This function performs a `POST` to the `/calls.add` endpoint.
16     *
17     * Registers a new Call.
18     *
19     * FROM: <https://api.slack.com/methods/calls.add>
20     *
21     * **Parameters:**
22     *
23     * * `token: &str` -- Authentication token. Requires scope: `calls:write`.
24     */
25    pub async fn add(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
26        let url = self.client.url("/calls.add", 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 `POST` to the `/calls.end` endpoint.
39     *
40     * Ends a Call.
41     *
42     * FROM: <https://api.slack.com/methods/calls.end>
43     *
44     * **Parameters:**
45     *
46     * * `token: &str` -- Authentication token. Requires scope: `calls:write`.
47     */
48    pub async fn end(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
49        let url = self.client.url("/calls.end", None);
50        self.client
51            .post(
52                &url,
53                crate::Message {
54                    body: None,
55                    content_type: Some("application/x-www-form-urlencoded".to_string()),
56                },
57            )
58            .await
59    }
60    /**
61     * This function performs a `GET` to the `/calls.info` endpoint.
62     *
63     * Returns information about a Call.
64     *
65     * FROM: <https://api.slack.com/methods/calls.info>
66     *
67     * **Parameters:**
68     *
69     * * `token: &str` -- Authentication token. Requires scope: `calls:read`.
70     * * `id: &str` -- `id` of the Call returned by the [`calls.add`](/methods/calls.add) method.
71     */
72    pub async fn info(
73        &self,
74        id: &str,
75    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
76        let mut query_args: Vec<(String, String)> = Default::default();
77        if !id.is_empty() {
78            query_args.push(("id".to_string(), id.to_string()));
79        }
80        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
81        let url = self.client.url(&format!("/calls.info?{}", query_), None);
82        self.client
83            .get(
84                &url,
85                crate::Message {
86                    body: None,
87                    content_type: None,
88                },
89            )
90            .await
91    }
92    /**
93     * This function performs a `POST` to the `/calls.update` endpoint.
94     *
95     * Updates information about a Call.
96     *
97     * FROM: <https://api.slack.com/methods/calls.update>
98     *
99     * **Parameters:**
100     *
101     * * `token: &str` -- Authentication token. Requires scope: `calls:write`.
102     */
103    pub async fn update(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
104        let url = self.client.url("/calls.update", None);
105        self.client
106            .post(
107                &url,
108                crate::Message {
109                    body: None,
110                    content_type: Some("application/x-www-form-urlencoded".to_string()),
111                },
112            )
113            .await
114    }
115}