Skip to main content

slack_web_api/api/
reminders.rs

1// このファイルは codegen/generate.py が生成する。手で編集しない
2
3#![allow(unused_imports)]
4
5use crate::objects::*;
6use crate::{
7    CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
8};
9use serde::{Deserialize, Serialize};
10
11/// Arguments for the Slack Web API method [`reminders.add`](https://docs.slack.dev/reference/methods/reminders.add): Creates a reminder.
12///
13/// Send it with [`SlackClient::reminders_add`].
14#[doc(alias = "reminders.add")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct RemindersAddRequest {
18    /// The content of the reminder
19    pub text: String,
20    /// Can also take a type of integer. When this reminder should happen: the Unix timestamp (up to five years from now), the number of seconds until the reminder (if within 24 hours), or a natural language description (Ex. "in 15 minutes," or "every Thursday")
21    pub time: String,
22    /// No longer supported - reminders cannot be set for other users. Previously, was the user who would receive the reminder.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub user: Option<String>,
25    /// Encoded team id, required if org token is used
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub team_id: Option<String>,
28    /// Specify the repeating behavior of a reminder. Available options: `daily`, `weekly`, `monthly`, or `yearly`. If `weekly`, may further specify the days of the week.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub recurrence: Option<serde_json::Value>,
31}
32
33impl RemindersAddRequest {
34    pub fn new(text: impl Into<String>, time: impl Into<String>) -> Self {
35        Self {
36            text: text.into(),
37            time: time.into(),
38            user: None,
39            team_id: None,
40            recurrence: None,
41        }
42    }
43
44    pub fn user(mut self, user: impl Into<String>) -> Self {
45        self.user = Some(user.into());
46        self
47    }
48
49    pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
50        self.team_id = Some(team_id.into());
51        self
52    }
53
54    pub fn recurrence(mut self, recurrence: serde_json::Value) -> Self {
55        self.recurrence = Some(recurrence);
56        self
57    }
58}
59
60impl SlackApiMethod for RemindersAddRequest {
61    const METHOD: &'static str = "reminders.add";
62    type Response = RemindersAddResponse;
63}
64
65/// Successful response of the Slack Web API method [`reminders.add`](https://docs.slack.dev/reference/methods/reminders.add).
66#[doc(alias = "reminders.add")]
67#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
68pub struct RemindersAddResponse {
69    #[serde(
70        default,
71        deserialize_with = "crate::de::opt_object",
72        skip_serializing_if = "Option::is_none"
73    )]
74    pub reminder: Option<Reminder>,
75    #[serde(
76        default,
77        deserialize_with = "crate::de::opt_object",
78        skip_serializing_if = "Option::is_none"
79    )]
80    pub response_metadata: Option<ResponseMetadata>,
81    #[serde(
82        default,
83        deserialize_with = "crate::de::opt_string",
84        skip_serializing_if = "Option::is_none"
85    )]
86    pub warning: Option<String>,
87}
88
89/// Arguments for the Slack Web API method [`reminders.complete`](https://docs.slack.dev/reference/methods/reminders.complete): Marks a reminder as complete.
90///
91/// Send it with [`SlackClient::reminders_complete`].
92#[doc(alias = "reminders.complete")]
93#[derive(Debug, Clone, PartialEq, Serialize)]
94#[non_exhaustive]
95pub struct RemindersCompleteRequest {
96    /// The ID of the reminder to be marked as complete
97    pub reminder: String,
98    /// Encoded team id, required if org token is used
99    #[serde(skip_serializing_if = "Option::is_none")]
100    pub team_id: Option<String>,
101}
102
103impl RemindersCompleteRequest {
104    pub fn new(reminder: impl Into<String>) -> Self {
105        Self {
106            reminder: reminder.into(),
107            team_id: None,
108        }
109    }
110
111    pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
112        self.team_id = Some(team_id.into());
113        self
114    }
115}
116
117impl SlackApiMethod for RemindersCompleteRequest {
118    const METHOD: &'static str = "reminders.complete";
119    type Response = RemindersCompleteResponse;
120}
121
122/// Successful response of the Slack Web API method [`reminders.complete`](https://docs.slack.dev/reference/methods/reminders.complete).
123#[doc(alias = "reminders.complete")]
124#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
125pub struct RemindersCompleteResponse {
126    /// Fields returned by Slack. This method has no documented response example.
127    #[serde(flatten)]
128    pub extra: serde_json::Map<String, serde_json::Value>,
129    #[serde(
130        default,
131        deserialize_with = "crate::de::opt_object",
132        skip_serializing_if = "Option::is_none"
133    )]
134    pub response_metadata: Option<ResponseMetadata>,
135    #[serde(
136        default,
137        deserialize_with = "crate::de::opt_string",
138        skip_serializing_if = "Option::is_none"
139    )]
140    pub warning: Option<String>,
141}
142
143/// Arguments for the Slack Web API method [`reminders.delete`](https://docs.slack.dev/reference/methods/reminders.delete): Deletes a reminder.
144///
145/// Send it with [`SlackClient::reminders_delete`].
146#[doc(alias = "reminders.delete")]
147#[derive(Debug, Clone, PartialEq, Serialize)]
148#[non_exhaustive]
149pub struct RemindersDeleteRequest {
150    /// The ID of the reminder
151    pub reminder: String,
152    /// Encoded team id, required if org token is used
153    #[serde(skip_serializing_if = "Option::is_none")]
154    pub team_id: Option<String>,
155}
156
157impl RemindersDeleteRequest {
158    pub fn new(reminder: impl Into<String>) -> Self {
159        Self {
160            reminder: reminder.into(),
161            team_id: None,
162        }
163    }
164
165    pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
166        self.team_id = Some(team_id.into());
167        self
168    }
169}
170
171impl SlackApiMethod for RemindersDeleteRequest {
172    const METHOD: &'static str = "reminders.delete";
173    type Response = RemindersDeleteResponse;
174}
175
176/// Successful response of the Slack Web API method [`reminders.delete`](https://docs.slack.dev/reference/methods/reminders.delete).
177#[doc(alias = "reminders.delete")]
178#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
179pub struct RemindersDeleteResponse {
180    /// Fields returned by Slack. This method has no documented response example.
181    #[serde(flatten)]
182    pub extra: serde_json::Map<String, serde_json::Value>,
183    #[serde(
184        default,
185        deserialize_with = "crate::de::opt_object",
186        skip_serializing_if = "Option::is_none"
187    )]
188    pub response_metadata: Option<ResponseMetadata>,
189    #[serde(
190        default,
191        deserialize_with = "crate::de::opt_string",
192        skip_serializing_if = "Option::is_none"
193    )]
194    pub warning: Option<String>,
195}
196
197/// Arguments for the Slack Web API method [`reminders.info`](https://docs.slack.dev/reference/methods/reminders.info): Gets information about a reminder.
198///
199/// Send it with [`SlackClient::reminders_info`].
200#[doc(alias = "reminders.info")]
201#[derive(Debug, Clone, PartialEq, Serialize)]
202#[non_exhaustive]
203pub struct RemindersInfoRequest {
204    /// The ID of the reminder
205    pub reminder: String,
206    /// Encoded team id, required if org token is passed
207    #[serde(skip_serializing_if = "Option::is_none")]
208    pub team_id: Option<String>,
209}
210
211impl RemindersInfoRequest {
212    pub fn new(reminder: impl Into<String>) -> Self {
213        Self {
214            reminder: reminder.into(),
215            team_id: None,
216        }
217    }
218
219    pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
220        self.team_id = Some(team_id.into());
221        self
222    }
223}
224
225impl SlackApiMethod for RemindersInfoRequest {
226    const METHOD: &'static str = "reminders.info";
227    type Response = RemindersInfoResponse;
228}
229
230/// Successful response of the Slack Web API method [`reminders.info`](https://docs.slack.dev/reference/methods/reminders.info).
231#[doc(alias = "reminders.info")]
232#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
233pub struct RemindersInfoResponse {
234    #[serde(
235        default,
236        deserialize_with = "crate::de::opt_object",
237        skip_serializing_if = "Option::is_none"
238    )]
239    pub reminder: Option<Reminder>,
240    #[serde(
241        default,
242        deserialize_with = "crate::de::opt_object",
243        skip_serializing_if = "Option::is_none"
244    )]
245    pub response_metadata: Option<ResponseMetadata>,
246    #[serde(
247        default,
248        deserialize_with = "crate::de::opt_string",
249        skip_serializing_if = "Option::is_none"
250    )]
251    pub warning: Option<String>,
252}
253
254/// Arguments for the Slack Web API method [`reminders.list`](https://docs.slack.dev/reference/methods/reminders.list): Lists all reminders created by or for a given user.
255///
256/// Send it with [`SlackClient::reminders_list`].
257#[doc(alias = "reminders.list")]
258#[derive(Debug, Clone, PartialEq, Serialize, Default)]
259#[non_exhaustive]
260pub struct RemindersListRequest {
261    /// Encoded team id, required if org token is passed
262    #[serde(skip_serializing_if = "Option::is_none")]
263    pub team_id: Option<String>,
264}
265
266impl RemindersListRequest {
267    pub fn new() -> Self {
268        Self { team_id: None }
269    }
270
271    pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
272        self.team_id = Some(team_id.into());
273        self
274    }
275}
276
277impl SlackApiMethod for RemindersListRequest {
278    const METHOD: &'static str = "reminders.list";
279    type Response = RemindersListResponse;
280}
281
282/// Successful response of the Slack Web API method [`reminders.list`](https://docs.slack.dev/reference/methods/reminders.list).
283#[doc(alias = "reminders.list")]
284#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
285pub struct RemindersListResponse {
286    #[serde(
287        default,
288        deserialize_with = "crate::de::vec",
289        skip_serializing_if = "Vec::is_empty"
290    )]
291    pub reminders: Vec<Reminder>,
292    #[serde(
293        default,
294        deserialize_with = "crate::de::opt_object",
295        skip_serializing_if = "Option::is_none"
296    )]
297    pub response_metadata: Option<ResponseMetadata>,
298    #[serde(
299        default,
300        deserialize_with = "crate::de::opt_string",
301        skip_serializing_if = "Option::is_none"
302    )]
303    pub warning: Option<String>,
304}
305
306impl SlackClient {
307    /// Calls the Slack Web API method [`reminders.add`](https://docs.slack.dev/reference/methods/reminders.add): Creates a reminder.
308    ///
309    /// Required scopes:
310    ///
311    /// - user token: `reminders:write`
312    ///
313    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
314    ///
315    /// # Errors
316    ///
317    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
318    #[doc(alias = "reminders.add")]
319    pub async fn reminders_add(
320        &self,
321        request: &RemindersAddRequest,
322    ) -> Result<RemindersAddResponse, SlackError> {
323        self.call(request).await
324    }
325
326    /// Calls the Slack Web API method [`reminders.complete`](https://docs.slack.dev/reference/methods/reminders.complete): Marks a reminder as complete.
327    ///
328    /// Required scopes:
329    ///
330    /// - user token: `reminders:write`
331    ///
332    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
333    ///
334    /// # Errors
335    ///
336    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
337    #[doc(alias = "reminders.complete")]
338    pub async fn reminders_complete(
339        &self,
340        request: &RemindersCompleteRequest,
341    ) -> Result<RemindersCompleteResponse, SlackError> {
342        self.call(request).await
343    }
344
345    /// Calls the Slack Web API method [`reminders.delete`](https://docs.slack.dev/reference/methods/reminders.delete): Deletes a reminder.
346    ///
347    /// Required scopes:
348    ///
349    /// - user token: `reminders:write`
350    ///
351    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
352    ///
353    /// # Errors
354    ///
355    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
356    #[doc(alias = "reminders.delete")]
357    pub async fn reminders_delete(
358        &self,
359        request: &RemindersDeleteRequest,
360    ) -> Result<RemindersDeleteResponse, SlackError> {
361        self.call(request).await
362    }
363
364    /// Calls the Slack Web API method [`reminders.info`](https://docs.slack.dev/reference/methods/reminders.info): Gets information about a reminder.
365    ///
366    /// Required scopes:
367    ///
368    /// - user token: `reminders:read`
369    ///
370    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
371    ///
372    /// # Errors
373    ///
374    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
375    #[doc(alias = "reminders.info")]
376    pub async fn reminders_info(
377        &self,
378        request: &RemindersInfoRequest,
379    ) -> Result<RemindersInfoResponse, SlackError> {
380        self.call(request).await
381    }
382
383    /// Calls the Slack Web API method [`reminders.list`](https://docs.slack.dev/reference/methods/reminders.list): Lists all reminders created by or for a given user.
384    ///
385    /// Required scopes:
386    ///
387    /// - user token: `reminders:read`
388    ///
389    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
390    ///
391    /// # Errors
392    ///
393    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
394    #[doc(alias = "reminders.list")]
395    pub async fn reminders_list(
396        &self,
397        request: &RemindersListRequest,
398    ) -> Result<RemindersListResponse, SlackError> {
399        self.call(request).await
400    }
401}