1#![allow(unused_imports)]
4
5use crate::objects::*;
6use crate::{
7 CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
8};
9use serde::{Deserialize, Serialize};
10
11#[doc(alias = "dnd.endDnd")]
15#[derive(Debug, Clone, PartialEq, Serialize, Default)]
16#[non_exhaustive]
17pub struct DndEndDndRequest {}
18
19impl DndEndDndRequest {
20 pub fn new() -> Self {
21 Self {}
22 }
23}
24
25impl SlackApiMethod for DndEndDndRequest {
26 const METHOD: &'static str = "dnd.endDnd";
27 type Response = DndEndDndResponse;
28}
29
30#[doc(alias = "dnd.endDnd")]
32#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
33pub struct DndEndDndResponse {
34 #[serde(flatten)]
36 pub extra: serde_json::Map<String, serde_json::Value>,
37 #[serde(
38 default,
39 deserialize_with = "crate::de::opt_object",
40 skip_serializing_if = "Option::is_none"
41 )]
42 pub response_metadata: Option<ResponseMetadata>,
43 #[serde(
44 default,
45 deserialize_with = "crate::de::opt_string",
46 skip_serializing_if = "Option::is_none"
47 )]
48 pub warning: Option<String>,
49}
50
51#[doc(alias = "dnd.endSnooze")]
55#[derive(Debug, Clone, PartialEq, Serialize, Default)]
56#[non_exhaustive]
57pub struct DndEndSnoozeRequest {}
58
59impl DndEndSnoozeRequest {
60 pub fn new() -> Self {
61 Self {}
62 }
63}
64
65impl SlackApiMethod for DndEndSnoozeRequest {
66 const METHOD: &'static str = "dnd.endSnooze";
67 type Response = DndEndSnoozeResponse;
68}
69
70#[doc(alias = "dnd.endSnooze")]
72#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
73pub struct DndEndSnoozeResponse {
74 #[serde(
75 default,
76 deserialize_with = "crate::de::opt_bool",
77 skip_serializing_if = "Option::is_none"
78 )]
79 pub dnd_enabled: Option<bool>,
80 #[serde(
81 default,
82 deserialize_with = "crate::de::opt_i64",
83 skip_serializing_if = "Option::is_none"
84 )]
85 pub next_dnd_start_ts: Option<i64>,
86 #[serde(
87 default,
88 deserialize_with = "crate::de::opt_i64",
89 skip_serializing_if = "Option::is_none"
90 )]
91 pub next_dnd_end_ts: Option<i64>,
92 #[serde(
93 default,
94 deserialize_with = "crate::de::opt_bool",
95 skip_serializing_if = "Option::is_none"
96 )]
97 pub snooze_enabled: Option<bool>,
98 #[serde(
99 default,
100 deserialize_with = "crate::de::opt_object",
101 skip_serializing_if = "Option::is_none"
102 )]
103 pub response_metadata: Option<ResponseMetadata>,
104 #[serde(
105 default,
106 deserialize_with = "crate::de::opt_string",
107 skip_serializing_if = "Option::is_none"
108 )]
109 pub warning: Option<String>,
110}
111
112#[doc(alias = "dnd.info")]
116#[derive(Debug, Clone, PartialEq, Serialize, Default)]
117#[non_exhaustive]
118pub struct DndInfoRequest {
119 #[serde(skip_serializing_if = "Option::is_none")]
121 pub user: Option<String>,
122 #[serde(skip_serializing_if = "Option::is_none")]
124 pub team_id: Option<String>,
125}
126
127impl DndInfoRequest {
128 pub fn new() -> Self {
129 Self {
130 user: None,
131 team_id: None,
132 }
133 }
134
135 pub fn user(mut self, user: impl Into<String>) -> Self {
136 self.user = Some(user.into());
137 self
138 }
139
140 pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
141 self.team_id = Some(team_id.into());
142 self
143 }
144}
145
146impl SlackApiMethod for DndInfoRequest {
147 const METHOD: &'static str = "dnd.info";
148 type Response = DndInfoResponse;
149}
150
151#[doc(alias = "dnd.info")]
153#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
154pub struct DndInfoResponse {
155 #[serde(flatten)]
157 pub extra: serde_json::Map<String, serde_json::Value>,
158 #[serde(
159 default,
160 deserialize_with = "crate::de::opt_object",
161 skip_serializing_if = "Option::is_none"
162 )]
163 pub response_metadata: Option<ResponseMetadata>,
164 #[serde(
165 default,
166 deserialize_with = "crate::de::opt_string",
167 skip_serializing_if = "Option::is_none"
168 )]
169 pub warning: Option<String>,
170}
171
172#[doc(alias = "dnd.setSnooze")]
176#[derive(Debug, Clone, PartialEq, Serialize)]
177#[non_exhaustive]
178pub struct DndSetSnoozeRequest {
179 pub num_minutes: String,
181}
182
183impl DndSetSnoozeRequest {
184 pub fn new(num_minutes: impl Into<String>) -> Self {
185 Self {
186 num_minutes: num_minutes.into(),
187 }
188 }
189}
190
191impl SlackApiMethod for DndSetSnoozeRequest {
192 const METHOD: &'static str = "dnd.setSnooze";
193 type Response = DndSetSnoozeResponse;
194}
195
196#[doc(alias = "dnd.setSnooze")]
198#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
199pub struct DndSetSnoozeResponse {
200 #[serde(
201 default,
202 deserialize_with = "crate::de::opt_bool",
203 skip_serializing_if = "Option::is_none"
204 )]
205 pub snooze_enabled: Option<bool>,
206 #[serde(
207 default,
208 deserialize_with = "crate::de::opt_i64",
209 skip_serializing_if = "Option::is_none"
210 )]
211 pub snooze_endtime: Option<i64>,
212 #[serde(
213 default,
214 deserialize_with = "crate::de::opt_i64",
215 skip_serializing_if = "Option::is_none"
216 )]
217 pub snooze_remaining: Option<i64>,
218 #[serde(
219 default,
220 deserialize_with = "crate::de::opt_bool",
221 skip_serializing_if = "Option::is_none"
222 )]
223 pub snooze_is_indefinite: Option<bool>,
224 #[serde(
225 default,
226 deserialize_with = "crate::de::opt_object",
227 skip_serializing_if = "Option::is_none"
228 )]
229 pub response_metadata: Option<ResponseMetadata>,
230 #[serde(
231 default,
232 deserialize_with = "crate::de::opt_string",
233 skip_serializing_if = "Option::is_none"
234 )]
235 pub warning: Option<String>,
236}
237
238#[doc(alias = "dnd.teamInfo")]
242#[derive(Debug, Clone, PartialEq, Serialize)]
243#[non_exhaustive]
244pub struct DndTeamInfoRequest {
245 pub users: String,
247 #[serde(skip_serializing_if = "Option::is_none")]
249 pub team_id: Option<String>,
250}
251
252impl DndTeamInfoRequest {
253 pub fn new(users: impl Into<String>) -> Self {
254 Self {
255 users: users.into(),
256 team_id: None,
257 }
258 }
259
260 pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
261 self.team_id = Some(team_id.into());
262 self
263 }
264}
265
266impl SlackApiMethod for DndTeamInfoRequest {
267 const METHOD: &'static str = "dnd.teamInfo";
268 type Response = DndTeamInfoResponse;
269}
270
271#[doc(alias = "dnd.teamInfo")]
273#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
274pub struct DndTeamInfoResponse {
275 #[serde(
276 default,
277 deserialize_with = "crate::de::opt_object",
278 skip_serializing_if = "Option::is_none"
279 )]
280 pub users: Option<std::collections::HashMap<String, DndTeamInfoResponseUsersValue>>,
281 #[serde(
282 default,
283 deserialize_with = "crate::de::opt_object",
284 skip_serializing_if = "Option::is_none"
285 )]
286 pub response_metadata: Option<ResponseMetadata>,
287 #[serde(
288 default,
289 deserialize_with = "crate::de::opt_string",
290 skip_serializing_if = "Option::is_none"
291 )]
292 pub warning: Option<String>,
293}
294
295#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
296pub struct DndTeamInfoResponseUsersValue {
297 #[serde(
298 default,
299 deserialize_with = "crate::de::opt_bool",
300 skip_serializing_if = "Option::is_none"
301 )]
302 pub dnd_enabled: Option<bool>,
303 #[serde(
304 default,
305 deserialize_with = "crate::de::opt_i64",
306 skip_serializing_if = "Option::is_none"
307 )]
308 pub next_dnd_start_ts: Option<i64>,
309 #[serde(
310 default,
311 deserialize_with = "crate::de::opt_i64",
312 skip_serializing_if = "Option::is_none"
313 )]
314 pub next_dnd_end_ts: Option<i64>,
315}
316
317impl SlackClient {
318 #[doc(alias = "dnd.endDnd")]
330 pub async fn dnd_end_dnd(
331 &self,
332 request: &DndEndDndRequest,
333 ) -> Result<DndEndDndResponse, SlackError> {
334 self.call(request).await
335 }
336
337 #[doc(alias = "dnd.endSnooze")]
349 pub async fn dnd_end_snooze(
350 &self,
351 request: &DndEndSnoozeRequest,
352 ) -> Result<DndEndSnoozeResponse, SlackError> {
353 self.call(request).await
354 }
355
356 #[doc(alias = "dnd.info")]
369 pub async fn dnd_info(&self, request: &DndInfoRequest) -> Result<DndInfoResponse, SlackError> {
370 self.call(request).await
371 }
372
373 #[doc(alias = "dnd.setSnooze")]
385 pub async fn dnd_set_snooze(
386 &self,
387 request: &DndSetSnoozeRequest,
388 ) -> Result<DndSetSnoozeResponse, SlackError> {
389 self.call(request).await
390 }
391
392 #[doc(alias = "dnd.teamInfo")]
405 pub async fn dnd_team_info(
406 &self,
407 request: &DndTeamInfoRequest,
408 ) -> Result<DndTeamInfoResponse, SlackError> {
409 self.call(request).await
410 }
411}