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 = "bookmarks.add")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct BookmarksAddRequest {
18 pub title: String,
20 pub r#type: String,
22 #[serde(skip_serializing_if = "Option::is_none")]
24 pub channel_id: Option<String>,
25 #[serde(skip_serializing_if = "Option::is_none")]
27 pub link: Option<String>,
28 #[serde(skip_serializing_if = "Option::is_none")]
30 pub emoji: Option<String>,
31 #[serde(skip_serializing_if = "Option::is_none")]
33 pub entity_id: Option<String>,
34 #[serde(skip_serializing_if = "Option::is_none")]
36 pub access_level: Option<String>,
37 #[serde(skip_serializing_if = "Option::is_none")]
39 pub parent_id: Option<String>,
40}
41
42impl BookmarksAddRequest {
43 pub fn new(title: impl Into<String>, r#type: impl Into<String>) -> Self {
44 Self {
45 title: title.into(),
46 r#type: r#type.into(),
47 channel_id: None,
48 link: None,
49 emoji: None,
50 entity_id: None,
51 access_level: None,
52 parent_id: None,
53 }
54 }
55
56 pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
57 self.channel_id = Some(channel_id.into());
58 self
59 }
60
61 pub fn link(mut self, link: impl Into<String>) -> Self {
62 self.link = Some(link.into());
63 self
64 }
65
66 pub fn emoji(mut self, emoji: impl Into<String>) -> Self {
67 self.emoji = Some(emoji.into());
68 self
69 }
70
71 pub fn entity_id(mut self, entity_id: impl Into<String>) -> Self {
72 self.entity_id = Some(entity_id.into());
73 self
74 }
75
76 pub fn access_level(mut self, access_level: impl Into<String>) -> Self {
77 self.access_level = Some(access_level.into());
78 self
79 }
80
81 pub fn parent_id(mut self, parent_id: impl Into<String>) -> Self {
82 self.parent_id = Some(parent_id.into());
83 self
84 }
85}
86
87impl SlackApiMethod for BookmarksAddRequest {
88 const METHOD: &'static str = "bookmarks.add";
89 type Response = BookmarksAddResponse;
90}
91
92#[doc(alias = "bookmarks.add")]
94#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
95pub struct BookmarksAddResponse {
96 #[serde(
97 default,
98 deserialize_with = "crate::de::opt_object",
99 skip_serializing_if = "Option::is_none"
100 )]
101 pub bookmark: Option<Bookmark>,
102 #[serde(
103 default,
104 deserialize_with = "crate::de::opt_object",
105 skip_serializing_if = "Option::is_none"
106 )]
107 pub response_metadata: Option<ResponseMetadata>,
108 #[serde(
109 default,
110 deserialize_with = "crate::de::opt_string",
111 skip_serializing_if = "Option::is_none"
112 )]
113 pub warning: Option<String>,
114}
115
116#[doc(alias = "bookmarks.edit")]
120#[derive(Debug, Clone, PartialEq, Serialize, Default)]
121#[non_exhaustive]
122pub struct BookmarksEditRequest {
123 #[serde(skip_serializing_if = "Option::is_none")]
125 pub channel_id: Option<String>,
126 #[serde(skip_serializing_if = "Option::is_none")]
128 pub bookmark_id: Option<String>,
129 #[serde(skip_serializing_if = "Option::is_none")]
131 pub title: Option<String>,
132 #[serde(skip_serializing_if = "Option::is_none")]
134 pub link: Option<String>,
135 #[serde(skip_serializing_if = "Option::is_none")]
137 pub emoji: Option<String>,
138}
139
140impl BookmarksEditRequest {
141 pub fn new() -> Self {
142 Self {
143 channel_id: None,
144 bookmark_id: None,
145 title: None,
146 link: None,
147 emoji: None,
148 }
149 }
150
151 pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
152 self.channel_id = Some(channel_id.into());
153 self
154 }
155
156 pub fn bookmark_id(mut self, bookmark_id: impl Into<String>) -> Self {
157 self.bookmark_id = Some(bookmark_id.into());
158 self
159 }
160
161 pub fn title(mut self, title: impl Into<String>) -> Self {
162 self.title = Some(title.into());
163 self
164 }
165
166 pub fn link(mut self, link: impl Into<String>) -> Self {
167 self.link = Some(link.into());
168 self
169 }
170
171 pub fn emoji(mut self, emoji: impl Into<String>) -> Self {
172 self.emoji = Some(emoji.into());
173 self
174 }
175}
176
177impl SlackApiMethod for BookmarksEditRequest {
178 const METHOD: &'static str = "bookmarks.edit";
179 type Response = BookmarksEditResponse;
180}
181
182#[doc(alias = "bookmarks.edit")]
184#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
185pub struct BookmarksEditResponse {
186 #[serde(
187 default,
188 deserialize_with = "crate::de::opt_object",
189 skip_serializing_if = "Option::is_none"
190 )]
191 pub bookmark: Option<Bookmark>,
192 #[serde(
193 default,
194 deserialize_with = "crate::de::opt_object",
195 skip_serializing_if = "Option::is_none"
196 )]
197 pub response_metadata: Option<ResponseMetadata>,
198 #[serde(
199 default,
200 deserialize_with = "crate::de::opt_string",
201 skip_serializing_if = "Option::is_none"
202 )]
203 pub warning: Option<String>,
204}
205
206#[doc(alias = "bookmarks.list")]
210#[derive(Debug, Clone, PartialEq, Serialize, Default)]
211#[non_exhaustive]
212pub struct BookmarksListRequest {
213 #[serde(skip_serializing_if = "Option::is_none")]
215 pub channel_id: Option<String>,
216}
217
218impl BookmarksListRequest {
219 pub fn new() -> Self {
220 Self { channel_id: None }
221 }
222
223 pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
224 self.channel_id = Some(channel_id.into());
225 self
226 }
227}
228
229impl SlackApiMethod for BookmarksListRequest {
230 const METHOD: &'static str = "bookmarks.list";
231 type Response = BookmarksListResponse;
232}
233
234#[doc(alias = "bookmarks.list")]
236#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
237pub struct BookmarksListResponse {
238 #[serde(
239 default,
240 deserialize_with = "crate::de::vec",
241 skip_serializing_if = "Vec::is_empty"
242 )]
243 pub bookmarks: Vec<Bookmark>,
244 #[serde(
245 default,
246 deserialize_with = "crate::de::opt_object",
247 skip_serializing_if = "Option::is_none"
248 )]
249 pub response_metadata: Option<ResponseMetadata>,
250 #[serde(
251 default,
252 deserialize_with = "crate::de::opt_string",
253 skip_serializing_if = "Option::is_none"
254 )]
255 pub warning: Option<String>,
256}
257
258#[doc(alias = "bookmarks.remove")]
262#[derive(Debug, Clone, PartialEq, Serialize, Default)]
263#[non_exhaustive]
264pub struct BookmarksRemoveRequest {
265 #[serde(skip_serializing_if = "Option::is_none")]
267 pub channel_id: Option<String>,
268 #[serde(skip_serializing_if = "Option::is_none")]
270 pub bookmark_id: Option<String>,
271 #[serde(skip_serializing_if = "Option::is_none")]
273 pub quip_section_id: Option<String>,
274}
275
276impl BookmarksRemoveRequest {
277 pub fn new() -> Self {
278 Self {
279 channel_id: None,
280 bookmark_id: None,
281 quip_section_id: None,
282 }
283 }
284
285 pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
286 self.channel_id = Some(channel_id.into());
287 self
288 }
289
290 pub fn bookmark_id(mut self, bookmark_id: impl Into<String>) -> Self {
291 self.bookmark_id = Some(bookmark_id.into());
292 self
293 }
294
295 pub fn quip_section_id(mut self, quip_section_id: impl Into<String>) -> Self {
296 self.quip_section_id = Some(quip_section_id.into());
297 self
298 }
299}
300
301impl SlackApiMethod for BookmarksRemoveRequest {
302 const METHOD: &'static str = "bookmarks.remove";
303 type Response = BookmarksRemoveResponse;
304}
305
306#[doc(alias = "bookmarks.remove")]
308#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
309pub struct BookmarksRemoveResponse {
310 #[serde(flatten)]
312 pub extra: serde_json::Map<String, serde_json::Value>,
313 #[serde(
314 default,
315 deserialize_with = "crate::de::opt_object",
316 skip_serializing_if = "Option::is_none"
317 )]
318 pub response_metadata: Option<ResponseMetadata>,
319 #[serde(
320 default,
321 deserialize_with = "crate::de::opt_string",
322 skip_serializing_if = "Option::is_none"
323 )]
324 pub warning: Option<String>,
325}
326
327impl SlackClient {
328 #[doc(alias = "bookmarks.add")]
341 pub async fn bookmarks_add(
342 &self,
343 request: &BookmarksAddRequest,
344 ) -> Result<BookmarksAddResponse, SlackError> {
345 self.call(request).await
346 }
347
348 #[doc(alias = "bookmarks.edit")]
361 pub async fn bookmarks_edit(
362 &self,
363 request: &BookmarksEditRequest,
364 ) -> Result<BookmarksEditResponse, SlackError> {
365 self.call(request).await
366 }
367
368 #[doc(alias = "bookmarks.list")]
381 pub async fn bookmarks_list(
382 &self,
383 request: &BookmarksListRequest,
384 ) -> Result<BookmarksListResponse, SlackError> {
385 self.call(request).await
386 }
387
388 #[doc(alias = "bookmarks.remove")]
401 pub async fn bookmarks_remove(
402 &self,
403 request: &BookmarksRemoveRequest,
404 ) -> Result<BookmarksRemoveResponse, SlackError> {
405 self.call(request).await
406 }
407}