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 = "stars.add")]
15#[derive(Debug, Clone, PartialEq, Serialize, Default)]
16#[non_exhaustive]
17pub struct StarsAddRequest {
18 #[serde(skip_serializing_if = "Option::is_none")]
20 pub channel: Option<String>,
21 #[serde(skip_serializing_if = "Option::is_none")]
23 pub file: Option<String>,
24 #[serde(skip_serializing_if = "Option::is_none")]
26 pub file_comment: Option<String>,
27 #[serde(skip_serializing_if = "Option::is_none")]
29 pub timestamp: Option<String>,
30}
31
32impl StarsAddRequest {
33 pub fn new() -> Self {
34 Self {
35 channel: None,
36 file: None,
37 file_comment: None,
38 timestamp: None,
39 }
40 }
41
42 pub fn channel(mut self, channel: impl Into<String>) -> Self {
43 self.channel = Some(channel.into());
44 self
45 }
46
47 pub fn file(mut self, file: impl Into<String>) -> Self {
48 self.file = Some(file.into());
49 self
50 }
51
52 pub fn file_comment(mut self, file_comment: impl Into<String>) -> Self {
53 self.file_comment = Some(file_comment.into());
54 self
55 }
56
57 pub fn timestamp(mut self, timestamp: impl Into<String>) -> Self {
58 self.timestamp = Some(timestamp.into());
59 self
60 }
61}
62
63impl SlackApiMethod for StarsAddRequest {
64 const METHOD: &'static str = "stars.add";
65 type Response = StarsAddResponse;
66}
67
68#[doc(alias = "stars.add")]
70#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
71pub struct StarsAddResponse {
72 #[serde(flatten)]
74 pub extra: serde_json::Map<String, serde_json::Value>,
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#[doc(alias = "stars.list")]
93#[derive(Debug, Clone, PartialEq, Serialize, Default)]
94#[non_exhaustive]
95pub struct StarsListRequest {
96 #[serde(skip_serializing_if = "Option::is_none")]
97 pub count: Option<i64>,
98 #[serde(skip_serializing_if = "Option::is_none")]
100 pub cursor: Option<String>,
101 #[serde(skip_serializing_if = "Option::is_none")]
103 pub limit: Option<i64>,
104 #[serde(skip_serializing_if = "Option::is_none")]
105 pub page: Option<i64>,
106 #[serde(skip_serializing_if = "Option::is_none")]
108 pub team_id: Option<String>,
109}
110
111impl StarsListRequest {
112 pub fn new() -> Self {
113 Self {
114 count: None,
115 cursor: None,
116 limit: None,
117 page: None,
118 team_id: None,
119 }
120 }
121
122 pub fn count(mut self, count: i64) -> Self {
123 self.count = Some(count);
124 self
125 }
126
127 pub fn cursor(mut self, cursor: impl Into<String>) -> Self {
128 self.cursor = Some(cursor.into());
129 self
130 }
131
132 pub fn limit(mut self, limit: i64) -> Self {
133 self.limit = Some(limit);
134 self
135 }
136
137 pub fn page(mut self, page: i64) -> Self {
138 self.page = Some(page);
139 self
140 }
141
142 pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
143 self.team_id = Some(team_id.into());
144 self
145 }
146}
147
148impl SlackApiMethod for StarsListRequest {
149 const METHOD: &'static str = "stars.list";
150 type Response = StarsListResponse;
151}
152
153impl CursorPaginated for StarsListRequest {
154 fn set_cursor(&mut self, cursor: String) {
155 self.cursor = Some(cursor);
156 }
157}
158
159impl NextCursor for StarsListResponse {
160 fn next_cursor(&self) -> Option<&str> {
161 self.response_metadata.as_ref()?.next_cursor.as_deref()
162 }
163}
164
165#[doc(alias = "stars.list")]
167#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
168pub struct StarsListResponse {
169 #[serde(
170 default,
171 deserialize_with = "crate::de::vec",
172 skip_serializing_if = "Vec::is_empty"
173 )]
174 pub items: Vec<StarsListResponseItems>,
175 #[serde(
176 default,
177 deserialize_with = "crate::de::opt_object",
178 skip_serializing_if = "Option::is_none"
179 )]
180 pub paging: Option<StarsListResponsePaging>,
181 #[serde(
182 default,
183 deserialize_with = "crate::de::opt_object",
184 skip_serializing_if = "Option::is_none"
185 )]
186 pub response_metadata: Option<ResponseMetadata>,
187 #[serde(
188 default,
189 deserialize_with = "crate::de::opt_string",
190 skip_serializing_if = "Option::is_none"
191 )]
192 pub warning: Option<String>,
193}
194
195#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
196pub struct StarsListResponseItems {
197 #[serde(
198 default,
199 deserialize_with = "crate::de::opt_string",
200 skip_serializing_if = "Option::is_none"
201 )]
202 pub r#type: Option<String>,
203 #[serde(
204 default,
205 deserialize_with = "crate::de::opt_string",
206 skip_serializing_if = "Option::is_none"
207 )]
208 pub channel: Option<String>,
209 #[serde(
210 default,
211 deserialize_with = "crate::de::opt_object",
212 skip_serializing_if = "Option::is_none"
213 )]
214 pub message: Option<Message>,
215 #[serde(
216 default,
217 deserialize_with = "crate::de::opt_i64",
218 skip_serializing_if = "Option::is_none"
219 )]
220 pub date_create: Option<i64>,
221}
222
223#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
224pub struct StarsListResponsePaging {
225 #[serde(
226 default,
227 deserialize_with = "crate::de::opt_i64",
228 skip_serializing_if = "Option::is_none"
229 )]
230 pub per_page: Option<i64>,
231 #[serde(
232 default,
233 deserialize_with = "crate::de::opt_i64",
234 skip_serializing_if = "Option::is_none"
235 )]
236 pub spill: Option<i64>,
237 #[serde(
238 default,
239 deserialize_with = "crate::de::opt_i64",
240 skip_serializing_if = "Option::is_none"
241 )]
242 pub page: Option<i64>,
243 #[serde(
244 default,
245 deserialize_with = "crate::de::opt_i64",
246 skip_serializing_if = "Option::is_none"
247 )]
248 pub total: Option<i64>,
249 #[serde(
250 default,
251 deserialize_with = "crate::de::opt_i64",
252 skip_serializing_if = "Option::is_none"
253 )]
254 pub pages: Option<i64>,
255}
256
257#[doc(alias = "stars.remove")]
261#[derive(Debug, Clone, PartialEq, Serialize, Default)]
262#[non_exhaustive]
263pub struct StarsRemoveRequest {
264 #[serde(skip_serializing_if = "Option::is_none")]
266 pub channel: Option<String>,
267 #[serde(skip_serializing_if = "Option::is_none")]
269 pub file: Option<String>,
270 #[serde(skip_serializing_if = "Option::is_none")]
272 pub file_comment: Option<String>,
273 #[serde(skip_serializing_if = "Option::is_none")]
275 pub timestamp: Option<String>,
276}
277
278impl StarsRemoveRequest {
279 pub fn new() -> Self {
280 Self {
281 channel: None,
282 file: None,
283 file_comment: None,
284 timestamp: None,
285 }
286 }
287
288 pub fn channel(mut self, channel: impl Into<String>) -> Self {
289 self.channel = Some(channel.into());
290 self
291 }
292
293 pub fn file(mut self, file: impl Into<String>) -> Self {
294 self.file = Some(file.into());
295 self
296 }
297
298 pub fn file_comment(mut self, file_comment: impl Into<String>) -> Self {
299 self.file_comment = Some(file_comment.into());
300 self
301 }
302
303 pub fn timestamp(mut self, timestamp: impl Into<String>) -> Self {
304 self.timestamp = Some(timestamp.into());
305 self
306 }
307}
308
309impl SlackApiMethod for StarsRemoveRequest {
310 const METHOD: &'static str = "stars.remove";
311 type Response = StarsRemoveResponse;
312}
313
314#[doc(alias = "stars.remove")]
316#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
317pub struct StarsRemoveResponse {
318 #[serde(flatten)]
320 pub extra: serde_json::Map<String, serde_json::Value>,
321 #[serde(
322 default,
323 deserialize_with = "crate::de::opt_object",
324 skip_serializing_if = "Option::is_none"
325 )]
326 pub response_metadata: Option<ResponseMetadata>,
327 #[serde(
328 default,
329 deserialize_with = "crate::de::opt_string",
330 skip_serializing_if = "Option::is_none"
331 )]
332 pub warning: Option<String>,
333}
334
335impl SlackClient {
336 #[doc(alias = "stars.add")]
348 pub async fn stars_add(
349 &self,
350 request: &StarsAddRequest,
351 ) -> Result<StarsAddResponse, SlackError> {
352 self.call(request).await
353 }
354
355 #[doc(alias = "stars.list")]
367 pub async fn stars_list(
368 &self,
369 request: &StarsListRequest,
370 ) -> Result<StarsListResponse, SlackError> {
371 self.call(request).await
372 }
373
374 #[doc(alias = "stars.remove")]
386 pub async fn stars_remove(
387 &self,
388 request: &StarsRemoveRequest,
389 ) -> Result<StarsRemoveResponse, SlackError> {
390 self.call(request).await
391 }
392}