slack_chat_api/
dialog.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct Dialog {
5    pub client: Client,
6}
7
8impl Dialog {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Dialog { client }
12    }
13
14    /**
15     * This function performs a `GET` to the `/dialog.open` endpoint.
16     *
17     * Open a dialog with a user
18     *
19     * FROM: <https://api.slack.com/methods/dialog.open>
20     *
21     * **Parameters:**
22     *
23     * * `token: &str` -- Authentication token. Requires scope: `none`.
24     * * `dialog: &str` -- The dialog definition. This must be a JSON-encoded string.
25     * * `trigger_id: &str` -- Exchange a trigger to post to the user.
26     */
27    pub async fn open(
28        &self,
29        dialog: &str,
30        trigger_id: &str,
31    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
32        let mut query_args: Vec<(String, String)> = Default::default();
33        if !dialog.is_empty() {
34            query_args.push(("dialog".to_string(), dialog.to_string()));
35        }
36        if !trigger_id.is_empty() {
37            query_args.push(("trigger_id".to_string(), trigger_id.to_string()));
38        }
39        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
40        let url = self.client.url(&format!("/dialog.open?{}", query_), None);
41        self.client
42            .get(
43                &url,
44                crate::Message {
45                    body: None,
46                    content_type: None,
47                },
48            )
49            .await
50    }
51}