1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
use anyhow::Result;

use crate::Client;

pub struct Dnd {
    pub client: Client,
}

impl Dnd {
    #[doc(hidden)]
    pub fn new(client: Client) -> Self {
        Dnd { client }
    }

    /**
     * This function performs a `POST` to the `/dnd.endDnd` endpoint.
     *
     * Ends the current user's Do Not Disturb session immediately.
     *
     * FROM: <https://api.slack.com/methods/dnd.endDnd>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `dnd:write`.
     */
    pub async fn end(&self) -> Result<crate::types::DndEndSchema> {
        let url = self.client.url("/dnd.endDnd", None);
        self.client
            .post(
                &url,
                crate::Message {
                    body: None,
                    content_type: None,
                },
            )
            .await
    }
    /**
     * This function performs a `POST` to the `/dnd.endSnooze` endpoint.
     *
     * Ends the current user's snooze mode immediately.
     *
     * FROM: <https://api.slack.com/methods/dnd.endSnooze>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `dnd:write`.
     */
    pub async fn end_snooze(&self) -> Result<crate::types::DndEndSnoozeSchema> {
        let url = self.client.url("/dnd.endSnooze", None);
        self.client
            .post(
                &url,
                crate::Message {
                    body: None,
                    content_type: None,
                },
            )
            .await
    }
    /**
     * This function performs a `GET` to the `/dnd.info` endpoint.
     *
     * Retrieves a user's current Do Not Disturb status.
     *
     * FROM: <https://api.slack.com/methods/dnd.info>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `dnd:read`.
     * * `user: &str` -- User to fetch status for (defaults to current user).
     */
    pub async fn info(&self, user: &str) -> Result<crate::types::DndInfoSchema> {
        let mut query_args: Vec<(String, String)> = Default::default();
        if !user.is_empty() {
            query_args.push(("user".to_string(), user.to_string()));
        }
        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
        let url = self.client.url(&format!("/dnd.info?{}", query_), None);
        self.client
            .get(
                &url,
                crate::Message {
                    body: None,
                    content_type: None,
                },
            )
            .await
    }
    /**
     * This function performs a `POST` to the `/dnd.setSnooze` endpoint.
     *
     * Turns on Do Not Disturb mode for the current user, or changes its duration.
     *
     * FROM: <https://api.slack.com/methods/dnd.setSnooze>
     */
    pub async fn set_snooze(&self) -> Result<crate::types::DndSetSnoozeSchema> {
        let url = self.client.url("/dnd.setSnooze", None);
        self.client
            .post(
                &url,
                crate::Message {
                    body: None,
                    content_type: Some("application/x-www-form-urlencoded".to_string()),
                },
            )
            .await
    }
    /**
     * This function performs a `GET` to the `/dnd.teamInfo` endpoint.
     *
     * Retrieves the Do Not Disturb status for up to 50 users on a team.
     *
     * FROM: <https://api.slack.com/methods/dnd.teamInfo>
     *
     * **Parameters:**
     *
     * * `token: &str` -- Authentication token. Requires scope: `dnd:read`.
     * * `users: &str` -- Comma-separated list of users to fetch Do Not Disturb status for.
     */
    pub async fn team_info(&self, users: &str) -> Result<crate::types::DndEndSchema> {
        let mut query_args: Vec<(String, String)> = Default::default();
        if !users.is_empty() {
            query_args.push(("users".to_string(), users.to_string()));
        }
        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
        let url = self.client.url(&format!("/dnd.teamInfo?{}", query_), None);
        self.client
            .get(
                &url,
                crate::Message {
                    body: None,
                    content_type: None,
                },
            )
            .await
    }
}