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 = "search.all")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct SearchAllRequest {
18 pub query: String,
20 #[serde(skip_serializing_if = "Option::is_none")]
21 pub count: Option<i64>,
22 #[serde(skip_serializing_if = "Option::is_none")]
24 pub highlight: Option<bool>,
25 #[serde(skip_serializing_if = "Option::is_none")]
26 pub page: Option<i64>,
27 #[serde(skip_serializing_if = "Option::is_none")]
29 pub sort: Option<String>,
30 #[serde(skip_serializing_if = "Option::is_none")]
32 pub sort_dir: Option<String>,
33 #[serde(skip_serializing_if = "Option::is_none")]
35 pub team_id: Option<String>,
36}
37
38impl SearchAllRequest {
39 pub fn new(query: impl Into<String>) -> Self {
40 Self {
41 query: query.into(),
42 count: None,
43 highlight: None,
44 page: None,
45 sort: None,
46 sort_dir: None,
47 team_id: None,
48 }
49 }
50
51 pub fn count(mut self, count: i64) -> Self {
52 self.count = Some(count);
53 self
54 }
55
56 pub fn highlight(mut self, highlight: bool) -> Self {
57 self.highlight = Some(highlight);
58 self
59 }
60
61 pub fn page(mut self, page: i64) -> Self {
62 self.page = Some(page);
63 self
64 }
65
66 pub fn sort(mut self, sort: impl Into<String>) -> Self {
67 self.sort = Some(sort.into());
68 self
69 }
70
71 pub fn sort_dir(mut self, sort_dir: impl Into<String>) -> Self {
72 self.sort_dir = Some(sort_dir.into());
73 self
74 }
75
76 pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
77 self.team_id = Some(team_id.into());
78 self
79 }
80}
81
82impl SlackApiMethod for SearchAllRequest {
83 const METHOD: &'static str = "search.all";
84 type Response = SearchAllResponse;
85}
86
87#[doc(alias = "search.all")]
89#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
90pub struct SearchAllResponse {
91 #[serde(
92 default,
93 deserialize_with = "crate::de::opt_object",
94 skip_serializing_if = "Option::is_none"
95 )]
96 pub files: Option<SearchAllResponseFiles>,
97 #[serde(
98 default,
99 deserialize_with = "crate::de::opt_object",
100 skip_serializing_if = "Option::is_none"
101 )]
102 pub messages: Option<SearchAllResponseMessages>,
103 #[serde(
104 default,
105 deserialize_with = "crate::de::opt_object",
106 skip_serializing_if = "Option::is_none"
107 )]
108 pub posts: Option<SearchAllResponsePosts>,
109 #[serde(
110 default,
111 deserialize_with = "crate::de::opt_string",
112 skip_serializing_if = "Option::is_none"
113 )]
114 pub query: Option<String>,
115 #[serde(
116 default,
117 deserialize_with = "crate::de::opt_object",
118 skip_serializing_if = "Option::is_none"
119 )]
120 pub response_metadata: Option<ResponseMetadata>,
121 #[serde(
122 default,
123 deserialize_with = "crate::de::opt_string",
124 skip_serializing_if = "Option::is_none"
125 )]
126 pub warning: Option<String>,
127}
128
129#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
130pub struct SearchAllResponseFiles {
131 #[serde(
132 default,
133 deserialize_with = "crate::de::vec",
134 skip_serializing_if = "Vec::is_empty"
135 )]
136 pub matches: Vec<SearchAllResponseFilesMatches>,
137 #[serde(
138 default,
139 deserialize_with = "crate::de::opt_object",
140 skip_serializing_if = "Option::is_none"
141 )]
142 pub pagination: Option<SearchAllResponseFilesPagination>,
143 #[serde(
144 default,
145 deserialize_with = "crate::de::opt_object",
146 skip_serializing_if = "Option::is_none"
147 )]
148 pub paging: Option<SearchAllResponseFilesPaging>,
149 #[serde(
150 default,
151 deserialize_with = "crate::de::opt_i64",
152 skip_serializing_if = "Option::is_none"
153 )]
154 pub total: Option<i64>,
155}
156
157#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
158pub struct SearchAllResponseFilesMatches {
159 #[serde(
160 default,
161 deserialize_with = "crate::de::vec",
162 skip_serializing_if = "Vec::is_empty"
163 )]
164 pub channels: Vec<serde_json::Value>,
165 #[serde(
166 default,
167 deserialize_with = "crate::de::opt_i64",
168 skip_serializing_if = "Option::is_none"
169 )]
170 pub comments_count: Option<i64>,
171 #[serde(
172 default,
173 deserialize_with = "crate::de::opt_i64",
174 skip_serializing_if = "Option::is_none"
175 )]
176 pub created: Option<i64>,
177 #[serde(
178 default,
179 deserialize_with = "crate::de::opt_bool",
180 skip_serializing_if = "Option::is_none"
181 )]
182 pub display_as_bot: Option<bool>,
183 #[serde(
184 default,
185 deserialize_with = "crate::de::opt_bool",
186 skip_serializing_if = "Option::is_none"
187 )]
188 pub editable: Option<bool>,
189 #[serde(
190 default,
191 deserialize_with = "crate::de::opt_string",
192 skip_serializing_if = "Option::is_none"
193 )]
194 pub external_type: Option<String>,
195 #[serde(
196 default,
197 deserialize_with = "crate::de::opt_string",
198 skip_serializing_if = "Option::is_none"
199 )]
200 pub filetype: Option<String>,
201 #[serde(
202 default,
203 deserialize_with = "crate::de::vec",
204 skip_serializing_if = "Vec::is_empty"
205 )]
206 pub groups: Vec<serde_json::Value>,
207 #[serde(
208 default,
209 deserialize_with = "crate::de::opt_string",
210 skip_serializing_if = "Option::is_none"
211 )]
212 pub id: Option<String>,
213 #[serde(
214 default,
215 deserialize_with = "crate::de::opt_i64",
216 skip_serializing_if = "Option::is_none"
217 )]
218 pub image_exif_rotation: Option<i64>,
219 #[serde(
220 default,
221 deserialize_with = "crate::de::vec",
222 skip_serializing_if = "Vec::is_empty"
223 )]
224 pub ims: Vec<serde_json::Value>,
225 #[serde(
226 default,
227 deserialize_with = "crate::de::opt_object",
228 skip_serializing_if = "Option::is_none"
229 )]
230 pub initial_comment: Option<SearchAllResponseFilesMatchesInitialComment>,
231 #[serde(
232 default,
233 deserialize_with = "crate::de::opt_bool",
234 skip_serializing_if = "Option::is_none"
235 )]
236 pub is_external: Option<bool>,
237 #[serde(
238 default,
239 deserialize_with = "crate::de::opt_bool",
240 skip_serializing_if = "Option::is_none"
241 )]
242 pub is_public: Option<bool>,
243 #[serde(
244 default,
245 deserialize_with = "crate::de::opt_string",
246 skip_serializing_if = "Option::is_none"
247 )]
248 pub mimetype: Option<String>,
249 #[serde(
250 default,
251 deserialize_with = "crate::de::opt_string",
252 skip_serializing_if = "Option::is_none"
253 )]
254 pub mode: Option<String>,
255 #[serde(
256 default,
257 deserialize_with = "crate::de::opt_string",
258 skip_serializing_if = "Option::is_none"
259 )]
260 pub name: Option<String>,
261 #[serde(
262 default,
263 deserialize_with = "crate::de::opt_i64",
264 skip_serializing_if = "Option::is_none"
265 )]
266 pub original_h: Option<i64>,
267 #[serde(
268 default,
269 deserialize_with = "crate::de::opt_i64",
270 skip_serializing_if = "Option::is_none"
271 )]
272 pub original_w: Option<i64>,
273 #[serde(
274 default,
275 deserialize_with = "crate::de::opt_string",
276 skip_serializing_if = "Option::is_none"
277 )]
278 pub permalink: Option<String>,
279 #[serde(
280 default,
281 deserialize_with = "crate::de::opt_string",
282 skip_serializing_if = "Option::is_none"
283 )]
284 pub permalink_public: Option<String>,
285 #[serde(
286 default,
287 deserialize_with = "crate::de::opt_string",
288 skip_serializing_if = "Option::is_none"
289 )]
290 pub pretty_type: Option<String>,
291 #[serde(default, skip_serializing_if = "Option::is_none")]
292 pub preview: Option<serde_json::Value>,
293 #[serde(
294 default,
295 deserialize_with = "crate::de::opt_bool",
296 skip_serializing_if = "Option::is_none"
297 )]
298 pub public_url_shared: Option<bool>,
299 #[serde(
300 default,
301 deserialize_with = "crate::de::opt_string",
302 skip_serializing_if = "Option::is_none"
303 )]
304 pub score: Option<String>,
305 #[serde(
306 default,
307 deserialize_with = "crate::de::opt_i64",
308 skip_serializing_if = "Option::is_none"
309 )]
310 pub size: Option<i64>,
311 #[serde(
312 default,
313 deserialize_with = "crate::de::opt_string",
314 skip_serializing_if = "Option::is_none"
315 )]
316 pub thumb_160: Option<String>,
317 #[serde(
318 default,
319 deserialize_with = "crate::de::opt_string",
320 skip_serializing_if = "Option::is_none"
321 )]
322 pub thumb_360: Option<String>,
323 #[serde(
324 default,
325 deserialize_with = "crate::de::opt_i64",
326 skip_serializing_if = "Option::is_none"
327 )]
328 pub thumb_360_h: Option<i64>,
329 #[serde(
330 default,
331 deserialize_with = "crate::de::opt_i64",
332 skip_serializing_if = "Option::is_none"
333 )]
334 pub thumb_360_w: Option<i64>,
335 #[serde(
336 default,
337 deserialize_with = "crate::de::opt_string",
338 skip_serializing_if = "Option::is_none"
339 )]
340 pub thumb_64: Option<String>,
341 #[serde(
342 default,
343 deserialize_with = "crate::de::opt_string",
344 skip_serializing_if = "Option::is_none"
345 )]
346 pub thumb_80: Option<String>,
347 #[serde(
348 default,
349 deserialize_with = "crate::de::opt_i64",
350 skip_serializing_if = "Option::is_none"
351 )]
352 pub timestamp: Option<i64>,
353 #[serde(
354 default,
355 deserialize_with = "crate::de::opt_string",
356 skip_serializing_if = "Option::is_none"
357 )]
358 pub title: Option<String>,
359 #[serde(
360 default,
361 deserialize_with = "crate::de::opt_bool",
362 skip_serializing_if = "Option::is_none"
363 )]
364 pub top_file: Option<bool>,
365 #[serde(
366 default,
367 deserialize_with = "crate::de::opt_string",
368 skip_serializing_if = "Option::is_none"
369 )]
370 pub url_private: Option<String>,
371 #[serde(
372 default,
373 deserialize_with = "crate::de::opt_string",
374 skip_serializing_if = "Option::is_none"
375 )]
376 pub url_private_download: Option<String>,
377 #[serde(
378 default,
379 deserialize_with = "crate::de::opt_string",
380 skip_serializing_if = "Option::is_none"
381 )]
382 pub user: Option<String>,
383 #[serde(
384 default,
385 deserialize_with = "crate::de::opt_string",
386 skip_serializing_if = "Option::is_none"
387 )]
388 pub username: Option<String>,
389}
390
391#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
392pub struct SearchAllResponseFilesMatchesInitialComment {
393 #[serde(
394 default,
395 deserialize_with = "crate::de::opt_string",
396 skip_serializing_if = "Option::is_none"
397 )]
398 pub comment: Option<String>,
399 #[serde(
400 default,
401 deserialize_with = "crate::de::opt_i64",
402 skip_serializing_if = "Option::is_none"
403 )]
404 pub created: Option<i64>,
405 #[serde(
406 default,
407 deserialize_with = "crate::de::opt_string",
408 skip_serializing_if = "Option::is_none"
409 )]
410 pub id: Option<String>,
411 #[serde(
412 default,
413 deserialize_with = "crate::de::opt_bool",
414 skip_serializing_if = "Option::is_none"
415 )]
416 pub is_intro: Option<bool>,
417 #[serde(
418 default,
419 deserialize_with = "crate::de::opt_i64",
420 skip_serializing_if = "Option::is_none"
421 )]
422 pub timestamp: Option<i64>,
423 #[serde(
424 default,
425 deserialize_with = "crate::de::opt_string",
426 skip_serializing_if = "Option::is_none"
427 )]
428 pub user: Option<String>,
429}
430
431#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
432pub struct SearchAllResponseFilesPagination {
433 #[serde(
434 default,
435 deserialize_with = "crate::de::opt_i64",
436 skip_serializing_if = "Option::is_none"
437 )]
438 pub first: Option<i64>,
439 #[serde(
440 default,
441 deserialize_with = "crate::de::opt_i64",
442 skip_serializing_if = "Option::is_none"
443 )]
444 pub last: Option<i64>,
445 #[serde(
446 default,
447 deserialize_with = "crate::de::opt_i64",
448 skip_serializing_if = "Option::is_none"
449 )]
450 pub page: Option<i64>,
451 #[serde(
452 default,
453 deserialize_with = "crate::de::opt_i64",
454 skip_serializing_if = "Option::is_none"
455 )]
456 pub page_count: Option<i64>,
457 #[serde(
458 default,
459 deserialize_with = "crate::de::opt_i64",
460 skip_serializing_if = "Option::is_none"
461 )]
462 pub per_page: Option<i64>,
463 #[serde(
464 default,
465 deserialize_with = "crate::de::opt_i64",
466 skip_serializing_if = "Option::is_none"
467 )]
468 pub total_count: Option<i64>,
469}
470
471#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
472pub struct SearchAllResponseFilesPaging {
473 #[serde(
474 default,
475 deserialize_with = "crate::de::opt_i64",
476 skip_serializing_if = "Option::is_none"
477 )]
478 pub count: Option<i64>,
479 #[serde(
480 default,
481 deserialize_with = "crate::de::opt_i64",
482 skip_serializing_if = "Option::is_none"
483 )]
484 pub page: Option<i64>,
485 #[serde(
486 default,
487 deserialize_with = "crate::de::opt_i64",
488 skip_serializing_if = "Option::is_none"
489 )]
490 pub pages: Option<i64>,
491 #[serde(
492 default,
493 deserialize_with = "crate::de::opt_i64",
494 skip_serializing_if = "Option::is_none"
495 )]
496 pub total: Option<i64>,
497}
498
499#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
500pub struct SearchAllResponseMessages {
501 #[serde(
502 default,
503 deserialize_with = "crate::de::vec",
504 skip_serializing_if = "Vec::is_empty"
505 )]
506 pub matches: Vec<SearchAllResponseMessagesMatches>,
507 #[serde(
508 default,
509 deserialize_with = "crate::de::opt_object",
510 skip_serializing_if = "Option::is_none"
511 )]
512 pub pagination: Option<SearchAllResponseMessagesPagination>,
513 #[serde(
514 default,
515 deserialize_with = "crate::de::opt_object",
516 skip_serializing_if = "Option::is_none"
517 )]
518 pub paging: Option<SearchAllResponseMessagesPaging>,
519 #[serde(
520 default,
521 deserialize_with = "crate::de::opt_i64",
522 skip_serializing_if = "Option::is_none"
523 )]
524 pub total: Option<i64>,
525}
526
527#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
528pub struct SearchAllResponseMessagesMatches {
529 #[serde(
530 default,
531 deserialize_with = "crate::de::opt_object",
532 skip_serializing_if = "Option::is_none"
533 )]
534 pub channel: Option<Conversation>,
535 #[serde(
536 default,
537 deserialize_with = "crate::de::opt_string",
538 skip_serializing_if = "Option::is_none"
539 )]
540 pub iid: Option<String>,
541 #[serde(
542 default,
543 deserialize_with = "crate::de::opt_object",
544 skip_serializing_if = "Option::is_none"
545 )]
546 pub next: Option<SearchAllResponseMessagesMatchesNext>,
547 #[serde(
548 default,
549 deserialize_with = "crate::de::opt_string",
550 skip_serializing_if = "Option::is_none"
551 )]
552 pub permalink: Option<String>,
553 #[serde(
554 default,
555 deserialize_with = "crate::de::opt_object",
556 skip_serializing_if = "Option::is_none"
557 )]
558 pub previous: Option<SearchAllResponseMessagesMatchesPrevious>,
559 #[serde(
560 default,
561 deserialize_with = "crate::de::opt_string",
562 skip_serializing_if = "Option::is_none"
563 )]
564 pub team: Option<String>,
565 #[serde(
566 default,
567 deserialize_with = "crate::de::opt_string",
568 skip_serializing_if = "Option::is_none"
569 )]
570 pub text: Option<String>,
571 #[serde(
572 default,
573 deserialize_with = "crate::de::opt_string",
574 skip_serializing_if = "Option::is_none"
575 )]
576 pub ts: Option<String>,
577 #[serde(
578 default,
579 deserialize_with = "crate::de::opt_string",
580 skip_serializing_if = "Option::is_none"
581 )]
582 pub r#type: Option<String>,
583 #[serde(
584 default,
585 deserialize_with = "crate::de::opt_string",
586 skip_serializing_if = "Option::is_none"
587 )]
588 pub user: Option<String>,
589 #[serde(
590 default,
591 deserialize_with = "crate::de::opt_string",
592 skip_serializing_if = "Option::is_none"
593 )]
594 pub username: Option<String>,
595}
596
597#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
598pub struct SearchAllResponseMessagesMatchesNext {
599 #[serde(
600 default,
601 deserialize_with = "crate::de::opt_string",
602 skip_serializing_if = "Option::is_none"
603 )]
604 pub iid: Option<String>,
605 #[serde(
606 default,
607 deserialize_with = "crate::de::opt_string",
608 skip_serializing_if = "Option::is_none"
609 )]
610 pub text: Option<String>,
611 #[serde(
612 default,
613 deserialize_with = "crate::de::opt_string",
614 skip_serializing_if = "Option::is_none"
615 )]
616 pub ts: Option<String>,
617 #[serde(
618 default,
619 deserialize_with = "crate::de::opt_string",
620 skip_serializing_if = "Option::is_none"
621 )]
622 pub r#type: Option<String>,
623 #[serde(
624 default,
625 deserialize_with = "crate::de::opt_string",
626 skip_serializing_if = "Option::is_none"
627 )]
628 pub user: Option<String>,
629 #[serde(
630 default,
631 deserialize_with = "crate::de::opt_string",
632 skip_serializing_if = "Option::is_none"
633 )]
634 pub username: Option<String>,
635}
636
637#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
638pub struct SearchAllResponseMessagesMatchesPrevious {
639 #[serde(
640 default,
641 deserialize_with = "crate::de::opt_string",
642 skip_serializing_if = "Option::is_none"
643 )]
644 pub iid: Option<String>,
645 #[serde(
646 default,
647 deserialize_with = "crate::de::opt_string",
648 skip_serializing_if = "Option::is_none"
649 )]
650 pub text: Option<String>,
651 #[serde(
652 default,
653 deserialize_with = "crate::de::opt_string",
654 skip_serializing_if = "Option::is_none"
655 )]
656 pub ts: Option<String>,
657 #[serde(
658 default,
659 deserialize_with = "crate::de::opt_string",
660 skip_serializing_if = "Option::is_none"
661 )]
662 pub r#type: Option<String>,
663 #[serde(
664 default,
665 deserialize_with = "crate::de::opt_string",
666 skip_serializing_if = "Option::is_none"
667 )]
668 pub user: Option<String>,
669 #[serde(
670 default,
671 deserialize_with = "crate::de::opt_string",
672 skip_serializing_if = "Option::is_none"
673 )]
674 pub username: Option<String>,
675}
676
677#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
678pub struct SearchAllResponseMessagesPagination {
679 #[serde(
680 default,
681 deserialize_with = "crate::de::opt_i64",
682 skip_serializing_if = "Option::is_none"
683 )]
684 pub first: Option<i64>,
685 #[serde(
686 default,
687 deserialize_with = "crate::de::opt_i64",
688 skip_serializing_if = "Option::is_none"
689 )]
690 pub last: Option<i64>,
691 #[serde(
692 default,
693 deserialize_with = "crate::de::opt_i64",
694 skip_serializing_if = "Option::is_none"
695 )]
696 pub page: Option<i64>,
697 #[serde(
698 default,
699 deserialize_with = "crate::de::opt_i64",
700 skip_serializing_if = "Option::is_none"
701 )]
702 pub page_count: Option<i64>,
703 #[serde(
704 default,
705 deserialize_with = "crate::de::opt_i64",
706 skip_serializing_if = "Option::is_none"
707 )]
708 pub per_page: Option<i64>,
709 #[serde(
710 default,
711 deserialize_with = "crate::de::opt_i64",
712 skip_serializing_if = "Option::is_none"
713 )]
714 pub total_count: Option<i64>,
715}
716
717#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
718pub struct SearchAllResponseMessagesPaging {
719 #[serde(
720 default,
721 deserialize_with = "crate::de::opt_i64",
722 skip_serializing_if = "Option::is_none"
723 )]
724 pub count: Option<i64>,
725 #[serde(
726 default,
727 deserialize_with = "crate::de::opt_i64",
728 skip_serializing_if = "Option::is_none"
729 )]
730 pub page: Option<i64>,
731 #[serde(
732 default,
733 deserialize_with = "crate::de::opt_i64",
734 skip_serializing_if = "Option::is_none"
735 )]
736 pub pages: Option<i64>,
737 #[serde(
738 default,
739 deserialize_with = "crate::de::opt_i64",
740 skip_serializing_if = "Option::is_none"
741 )]
742 pub total: Option<i64>,
743}
744
745#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
746pub struct SearchAllResponsePosts {
747 #[serde(
748 default,
749 deserialize_with = "crate::de::vec",
750 skip_serializing_if = "Vec::is_empty"
751 )]
752 pub matches: Vec<serde_json::Value>,
753 #[serde(
754 default,
755 deserialize_with = "crate::de::opt_i64",
756 skip_serializing_if = "Option::is_none"
757 )]
758 pub total: Option<i64>,
759}
760
761#[doc(alias = "search.files")]
765#[derive(Debug, Clone, PartialEq, Serialize)]
766#[non_exhaustive]
767pub struct SearchFilesRequest {
768 pub query: String,
770 #[serde(skip_serializing_if = "Option::is_none")]
771 pub count: Option<i64>,
772 #[serde(skip_serializing_if = "Option::is_none")]
774 pub highlight: Option<bool>,
775 #[serde(skip_serializing_if = "Option::is_none")]
776 pub page: Option<i64>,
777 #[serde(skip_serializing_if = "Option::is_none")]
779 pub sort: Option<String>,
780 #[serde(skip_serializing_if = "Option::is_none")]
782 pub sort_dir: Option<String>,
783 #[serde(skip_serializing_if = "Option::is_none")]
785 pub team_id: Option<String>,
786}
787
788impl SearchFilesRequest {
789 pub fn new(query: impl Into<String>) -> Self {
790 Self {
791 query: query.into(),
792 count: None,
793 highlight: None,
794 page: None,
795 sort: None,
796 sort_dir: None,
797 team_id: None,
798 }
799 }
800
801 pub fn count(mut self, count: i64) -> Self {
802 self.count = Some(count);
803 self
804 }
805
806 pub fn highlight(mut self, highlight: bool) -> Self {
807 self.highlight = Some(highlight);
808 self
809 }
810
811 pub fn page(mut self, page: i64) -> Self {
812 self.page = Some(page);
813 self
814 }
815
816 pub fn sort(mut self, sort: impl Into<String>) -> Self {
817 self.sort = Some(sort.into());
818 self
819 }
820
821 pub fn sort_dir(mut self, sort_dir: impl Into<String>) -> Self {
822 self.sort_dir = Some(sort_dir.into());
823 self
824 }
825
826 pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
827 self.team_id = Some(team_id.into());
828 self
829 }
830}
831
832impl SlackApiMethod for SearchFilesRequest {
833 const METHOD: &'static str = "search.files";
834 type Response = SearchFilesResponse;
835}
836
837#[doc(alias = "search.files")]
839#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
840pub struct SearchFilesResponse {
841 #[serde(
842 default,
843 deserialize_with = "crate::de::opt_object",
844 skip_serializing_if = "Option::is_none"
845 )]
846 pub files: Option<SearchFilesResponseFiles>,
847 #[serde(
848 default,
849 deserialize_with = "crate::de::opt_string",
850 skip_serializing_if = "Option::is_none"
851 )]
852 pub query: Option<String>,
853 #[serde(
854 default,
855 deserialize_with = "crate::de::opt_object",
856 skip_serializing_if = "Option::is_none"
857 )]
858 pub response_metadata: Option<ResponseMetadata>,
859 #[serde(
860 default,
861 deserialize_with = "crate::de::opt_string",
862 skip_serializing_if = "Option::is_none"
863 )]
864 pub warning: Option<String>,
865}
866
867#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
868pub struct SearchFilesResponseFiles {
869 #[serde(
870 default,
871 deserialize_with = "crate::de::vec",
872 skip_serializing_if = "Vec::is_empty"
873 )]
874 pub matches: Vec<SearchFilesResponseFilesMatches>,
875 #[serde(
876 default,
877 deserialize_with = "crate::de::opt_object",
878 skip_serializing_if = "Option::is_none"
879 )]
880 pub pagination: Option<SearchFilesResponseFilesPagination>,
881 #[serde(
882 default,
883 deserialize_with = "crate::de::opt_object",
884 skip_serializing_if = "Option::is_none"
885 )]
886 pub paging: Option<SearchFilesResponseFilesPaging>,
887 #[serde(
888 default,
889 deserialize_with = "crate::de::opt_i64",
890 skip_serializing_if = "Option::is_none"
891 )]
892 pub total: Option<i64>,
893}
894
895#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
896pub struct SearchFilesResponseFilesMatches {
897 #[serde(
898 default,
899 deserialize_with = "crate::de::vec",
900 skip_serializing_if = "Vec::is_empty"
901 )]
902 pub channels: Vec<serde_json::Value>,
903 #[serde(
904 default,
905 deserialize_with = "crate::de::opt_i64",
906 skip_serializing_if = "Option::is_none"
907 )]
908 pub comments_count: Option<i64>,
909 #[serde(
910 default,
911 deserialize_with = "crate::de::opt_i64",
912 skip_serializing_if = "Option::is_none"
913 )]
914 pub created: Option<i64>,
915 #[serde(
916 default,
917 deserialize_with = "crate::de::opt_string",
918 skip_serializing_if = "Option::is_none"
919 )]
920 pub deanimate_gif: Option<String>,
921 #[serde(
922 default,
923 deserialize_with = "crate::de::opt_bool",
924 skip_serializing_if = "Option::is_none"
925 )]
926 pub display_as_bot: Option<bool>,
927 #[serde(
928 default,
929 deserialize_with = "crate::de::opt_bool",
930 skip_serializing_if = "Option::is_none"
931 )]
932 pub editable: Option<bool>,
933 #[serde(
934 default,
935 deserialize_with = "crate::de::opt_string",
936 skip_serializing_if = "Option::is_none"
937 )]
938 pub external_type: Option<String>,
939 #[serde(
940 default,
941 deserialize_with = "crate::de::opt_string",
942 skip_serializing_if = "Option::is_none"
943 )]
944 pub filetype: Option<String>,
945 #[serde(
946 default,
947 deserialize_with = "crate::de::vec",
948 skip_serializing_if = "Vec::is_empty"
949 )]
950 pub groups: Vec<serde_json::Value>,
951 #[serde(
952 default,
953 deserialize_with = "crate::de::opt_string",
954 skip_serializing_if = "Option::is_none"
955 )]
956 pub id: Option<String>,
957 #[serde(
958 default,
959 deserialize_with = "crate::de::opt_i64",
960 skip_serializing_if = "Option::is_none"
961 )]
962 pub image_exif_rotation: Option<i64>,
963 #[serde(
964 default,
965 deserialize_with = "crate::de::vec",
966 skip_serializing_if = "Vec::is_empty"
967 )]
968 pub ims: Vec<serde_json::Value>,
969 #[serde(
970 default,
971 deserialize_with = "crate::de::opt_bool",
972 skip_serializing_if = "Option::is_none"
973 )]
974 pub is_external: Option<bool>,
975 #[serde(
976 default,
977 deserialize_with = "crate::de::opt_bool",
978 skip_serializing_if = "Option::is_none"
979 )]
980 pub is_public: Option<bool>,
981 #[serde(
982 default,
983 deserialize_with = "crate::de::opt_string",
984 skip_serializing_if = "Option::is_none"
985 )]
986 pub mimetype: Option<String>,
987 #[serde(
988 default,
989 deserialize_with = "crate::de::opt_string",
990 skip_serializing_if = "Option::is_none"
991 )]
992 pub mode: Option<String>,
993 #[serde(
994 default,
995 deserialize_with = "crate::de::opt_string",
996 skip_serializing_if = "Option::is_none"
997 )]
998 pub name: Option<String>,
999 #[serde(
1000 default,
1001 deserialize_with = "crate::de::opt_i64",
1002 skip_serializing_if = "Option::is_none"
1003 )]
1004 pub original_h: Option<i64>,
1005 #[serde(
1006 default,
1007 deserialize_with = "crate::de::opt_i64",
1008 skip_serializing_if = "Option::is_none"
1009 )]
1010 pub original_w: Option<i64>,
1011 #[serde(
1012 default,
1013 deserialize_with = "crate::de::opt_string",
1014 skip_serializing_if = "Option::is_none"
1015 )]
1016 pub permalink: Option<String>,
1017 #[serde(
1018 default,
1019 deserialize_with = "crate::de::opt_string",
1020 skip_serializing_if = "Option::is_none"
1021 )]
1022 pub permalink_public: Option<String>,
1023 #[serde(
1024 default,
1025 deserialize_with = "crate::de::opt_string",
1026 skip_serializing_if = "Option::is_none"
1027 )]
1028 pub pretty_type: Option<String>,
1029 #[serde(default, skip_serializing_if = "Option::is_none")]
1030 pub preview: Option<serde_json::Value>,
1031 #[serde(
1032 default,
1033 deserialize_with = "crate::de::opt_bool",
1034 skip_serializing_if = "Option::is_none"
1035 )]
1036 pub public_url_shared: Option<bool>,
1037 #[serde(
1038 default,
1039 deserialize_with = "crate::de::vec",
1040 skip_serializing_if = "Vec::is_empty"
1041 )]
1042 pub reactions: Vec<Reaction>,
1043 #[serde(
1044 default,
1045 deserialize_with = "crate::de::opt_string",
1046 skip_serializing_if = "Option::is_none"
1047 )]
1048 pub score: Option<String>,
1049 #[serde(
1050 default,
1051 deserialize_with = "crate::de::opt_i64",
1052 skip_serializing_if = "Option::is_none"
1053 )]
1054 pub size: Option<i64>,
1055 #[serde(
1056 default,
1057 deserialize_with = "crate::de::opt_string",
1058 skip_serializing_if = "Option::is_none"
1059 )]
1060 pub thumb_160: Option<String>,
1061 #[serde(
1062 default,
1063 deserialize_with = "crate::de::opt_string",
1064 skip_serializing_if = "Option::is_none"
1065 )]
1066 pub thumb_360: Option<String>,
1067 #[serde(
1068 default,
1069 deserialize_with = "crate::de::opt_string",
1070 skip_serializing_if = "Option::is_none"
1071 )]
1072 pub thumb_360_gif: Option<String>,
1073 #[serde(
1074 default,
1075 deserialize_with = "crate::de::opt_i64",
1076 skip_serializing_if = "Option::is_none"
1077 )]
1078 pub thumb_360_h: Option<i64>,
1079 #[serde(
1080 default,
1081 deserialize_with = "crate::de::opt_i64",
1082 skip_serializing_if = "Option::is_none"
1083 )]
1084 pub thumb_360_w: Option<i64>,
1085 #[serde(
1086 default,
1087 deserialize_with = "crate::de::opt_string",
1088 skip_serializing_if = "Option::is_none"
1089 )]
1090 pub thumb_480: Option<String>,
1091 #[serde(
1092 default,
1093 deserialize_with = "crate::de::opt_string",
1094 skip_serializing_if = "Option::is_none"
1095 )]
1096 pub thumb_480_gif: Option<String>,
1097 #[serde(
1098 default,
1099 deserialize_with = "crate::de::opt_i64",
1100 skip_serializing_if = "Option::is_none"
1101 )]
1102 pub thumb_480_h: Option<i64>,
1103 #[serde(
1104 default,
1105 deserialize_with = "crate::de::opt_i64",
1106 skip_serializing_if = "Option::is_none"
1107 )]
1108 pub thumb_480_w: Option<i64>,
1109 #[serde(
1110 default,
1111 deserialize_with = "crate::de::opt_string",
1112 skip_serializing_if = "Option::is_none"
1113 )]
1114 pub thumb_64: Option<String>,
1115 #[serde(
1116 default,
1117 deserialize_with = "crate::de::opt_string",
1118 skip_serializing_if = "Option::is_none"
1119 )]
1120 pub thumb_80: Option<String>,
1121 #[serde(
1122 default,
1123 deserialize_with = "crate::de::opt_i64",
1124 skip_serializing_if = "Option::is_none"
1125 )]
1126 pub timestamp: Option<i64>,
1127 #[serde(
1128 default,
1129 deserialize_with = "crate::de::opt_string",
1130 skip_serializing_if = "Option::is_none"
1131 )]
1132 pub title: Option<String>,
1133 #[serde(
1134 default,
1135 deserialize_with = "crate::de::opt_bool",
1136 skip_serializing_if = "Option::is_none"
1137 )]
1138 pub top_file: Option<bool>,
1139 #[serde(
1140 default,
1141 deserialize_with = "crate::de::opt_string",
1142 skip_serializing_if = "Option::is_none"
1143 )]
1144 pub url_private: Option<String>,
1145 #[serde(
1146 default,
1147 deserialize_with = "crate::de::opt_string",
1148 skip_serializing_if = "Option::is_none"
1149 )]
1150 pub url_private_download: Option<String>,
1151 #[serde(
1152 default,
1153 deserialize_with = "crate::de::opt_string",
1154 skip_serializing_if = "Option::is_none"
1155 )]
1156 pub user: Option<String>,
1157 #[serde(
1158 default,
1159 deserialize_with = "crate::de::opt_string",
1160 skip_serializing_if = "Option::is_none"
1161 )]
1162 pub username: Option<String>,
1163}
1164
1165#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
1166pub struct SearchFilesResponseFilesPagination {
1167 #[serde(
1168 default,
1169 deserialize_with = "crate::de::opt_i64",
1170 skip_serializing_if = "Option::is_none"
1171 )]
1172 pub first: Option<i64>,
1173 #[serde(
1174 default,
1175 deserialize_with = "crate::de::opt_i64",
1176 skip_serializing_if = "Option::is_none"
1177 )]
1178 pub last: Option<i64>,
1179 #[serde(
1180 default,
1181 deserialize_with = "crate::de::opt_i64",
1182 skip_serializing_if = "Option::is_none"
1183 )]
1184 pub page: Option<i64>,
1185 #[serde(
1186 default,
1187 deserialize_with = "crate::de::opt_i64",
1188 skip_serializing_if = "Option::is_none"
1189 )]
1190 pub page_count: Option<i64>,
1191 #[serde(
1192 default,
1193 deserialize_with = "crate::de::opt_i64",
1194 skip_serializing_if = "Option::is_none"
1195 )]
1196 pub per_page: Option<i64>,
1197 #[serde(
1198 default,
1199 deserialize_with = "crate::de::opt_i64",
1200 skip_serializing_if = "Option::is_none"
1201 )]
1202 pub total_count: Option<i64>,
1203}
1204
1205#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
1206pub struct SearchFilesResponseFilesPaging {
1207 #[serde(
1208 default,
1209 deserialize_with = "crate::de::opt_i64",
1210 skip_serializing_if = "Option::is_none"
1211 )]
1212 pub count: Option<i64>,
1213 #[serde(
1214 default,
1215 deserialize_with = "crate::de::opt_i64",
1216 skip_serializing_if = "Option::is_none"
1217 )]
1218 pub page: Option<i64>,
1219 #[serde(
1220 default,
1221 deserialize_with = "crate::de::opt_i64",
1222 skip_serializing_if = "Option::is_none"
1223 )]
1224 pub pages: Option<i64>,
1225 #[serde(
1226 default,
1227 deserialize_with = "crate::de::opt_i64",
1228 skip_serializing_if = "Option::is_none"
1229 )]
1230 pub total: Option<i64>,
1231}
1232
1233#[doc(alias = "search.messages")]
1237#[derive(Debug, Clone, PartialEq, Serialize)]
1238#[non_exhaustive]
1239pub struct SearchMessagesRequest {
1240 pub query: String,
1242 #[serde(skip_serializing_if = "Option::is_none")]
1244 pub count: Option<i64>,
1245 #[serde(skip_serializing_if = "Option::is_none")]
1247 pub highlight: Option<bool>,
1248 #[serde(skip_serializing_if = "Option::is_none")]
1249 pub page: Option<i64>,
1250 #[serde(skip_serializing_if = "Option::is_none")]
1252 pub cursor: Option<String>,
1253 #[serde(skip_serializing_if = "Option::is_none")]
1255 pub sort: Option<String>,
1256 #[serde(skip_serializing_if = "Option::is_none")]
1258 pub sort_dir: Option<String>,
1259 #[serde(skip_serializing_if = "Option::is_none")]
1261 pub team_id: Option<String>,
1262}
1263
1264impl SearchMessagesRequest {
1265 pub fn new(query: impl Into<String>) -> Self {
1266 Self {
1267 query: query.into(),
1268 count: None,
1269 highlight: None,
1270 page: None,
1271 cursor: None,
1272 sort: None,
1273 sort_dir: None,
1274 team_id: None,
1275 }
1276 }
1277
1278 pub fn count(mut self, count: i64) -> Self {
1279 self.count = Some(count);
1280 self
1281 }
1282
1283 pub fn highlight(mut self, highlight: bool) -> Self {
1284 self.highlight = Some(highlight);
1285 self
1286 }
1287
1288 pub fn page(mut self, page: i64) -> Self {
1289 self.page = Some(page);
1290 self
1291 }
1292
1293 pub fn cursor(mut self, cursor: impl Into<String>) -> Self {
1294 self.cursor = Some(cursor.into());
1295 self
1296 }
1297
1298 pub fn sort(mut self, sort: impl Into<String>) -> Self {
1299 self.sort = Some(sort.into());
1300 self
1301 }
1302
1303 pub fn sort_dir(mut self, sort_dir: impl Into<String>) -> Self {
1304 self.sort_dir = Some(sort_dir.into());
1305 self
1306 }
1307
1308 pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
1309 self.team_id = Some(team_id.into());
1310 self
1311 }
1312}
1313
1314impl SlackApiMethod for SearchMessagesRequest {
1315 const METHOD: &'static str = "search.messages";
1316 type Response = SearchMessagesResponse;
1317}
1318
1319impl CursorPaginated for SearchMessagesRequest {
1320 fn set_cursor(&mut self, cursor: String) {
1321 self.cursor = Some(cursor);
1322 }
1323}
1324
1325impl NextCursor for SearchMessagesResponse {
1326 fn next_cursor(&self) -> Option<&str> {
1327 self.response_metadata.as_ref()?.next_cursor.as_deref()
1328 }
1329}
1330
1331#[doc(alias = "search.messages")]
1333#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
1334pub struct SearchMessagesResponse {
1335 #[serde(
1336 default,
1337 deserialize_with = "crate::de::opt_object",
1338 skip_serializing_if = "Option::is_none"
1339 )]
1340 pub messages: Option<SearchMessagesResponseMessages>,
1341 #[serde(
1342 default,
1343 deserialize_with = "crate::de::opt_string",
1344 skip_serializing_if = "Option::is_none"
1345 )]
1346 pub query: Option<String>,
1347 #[serde(
1348 default,
1349 deserialize_with = "crate::de::opt_object",
1350 skip_serializing_if = "Option::is_none"
1351 )]
1352 pub response_metadata: Option<ResponseMetadata>,
1353 #[serde(
1354 default,
1355 deserialize_with = "crate::de::opt_string",
1356 skip_serializing_if = "Option::is_none"
1357 )]
1358 pub warning: Option<String>,
1359}
1360
1361#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
1362pub struct SearchMessagesResponseMessages {
1363 #[serde(
1364 default,
1365 deserialize_with = "crate::de::vec",
1366 skip_serializing_if = "Vec::is_empty"
1367 )]
1368 pub matches: Vec<SearchMessagesResponseMessagesMatches>,
1369 #[serde(
1370 default,
1371 deserialize_with = "crate::de::opt_object",
1372 skip_serializing_if = "Option::is_none"
1373 )]
1374 pub pagination: Option<SearchMessagesResponseMessagesPagination>,
1375 #[serde(
1376 default,
1377 deserialize_with = "crate::de::opt_object",
1378 skip_serializing_if = "Option::is_none"
1379 )]
1380 pub paging: Option<SearchMessagesResponseMessagesPaging>,
1381 #[serde(
1382 default,
1383 deserialize_with = "crate::de::opt_i64",
1384 skip_serializing_if = "Option::is_none"
1385 )]
1386 pub total: Option<i64>,
1387}
1388
1389#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
1390pub struct SearchMessagesResponseMessagesMatches {
1391 #[serde(
1392 default,
1393 deserialize_with = "crate::de::opt_object",
1394 skip_serializing_if = "Option::is_none"
1395 )]
1396 pub channel: Option<Conversation>,
1397 #[serde(
1398 default,
1399 deserialize_with = "crate::de::opt_string",
1400 skip_serializing_if = "Option::is_none"
1401 )]
1402 pub iid: Option<String>,
1403 #[serde(
1404 default,
1405 deserialize_with = "crate::de::opt_string",
1406 skip_serializing_if = "Option::is_none"
1407 )]
1408 pub permalink: Option<String>,
1409 #[serde(
1410 default,
1411 deserialize_with = "crate::de::opt_string",
1412 skip_serializing_if = "Option::is_none"
1413 )]
1414 pub team: Option<String>,
1415 #[serde(
1416 default,
1417 deserialize_with = "crate::de::opt_string",
1418 skip_serializing_if = "Option::is_none"
1419 )]
1420 pub text: Option<String>,
1421 #[serde(
1422 default,
1423 deserialize_with = "crate::de::opt_string",
1424 skip_serializing_if = "Option::is_none"
1425 )]
1426 pub ts: Option<String>,
1427 #[serde(
1428 default,
1429 deserialize_with = "crate::de::opt_string",
1430 skip_serializing_if = "Option::is_none"
1431 )]
1432 pub r#type: Option<String>,
1433 #[serde(
1434 default,
1435 deserialize_with = "crate::de::opt_string",
1436 skip_serializing_if = "Option::is_none"
1437 )]
1438 pub user: Option<String>,
1439 #[serde(
1440 default,
1441 deserialize_with = "crate::de::opt_string",
1442 skip_serializing_if = "Option::is_none"
1443 )]
1444 pub username: Option<String>,
1445}
1446
1447#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
1448pub struct SearchMessagesResponseMessagesPagination {
1449 #[serde(
1450 default,
1451 deserialize_with = "crate::de::opt_i64",
1452 skip_serializing_if = "Option::is_none"
1453 )]
1454 pub first: Option<i64>,
1455 #[serde(
1456 default,
1457 deserialize_with = "crate::de::opt_i64",
1458 skip_serializing_if = "Option::is_none"
1459 )]
1460 pub last: Option<i64>,
1461 #[serde(
1462 default,
1463 deserialize_with = "crate::de::opt_i64",
1464 skip_serializing_if = "Option::is_none"
1465 )]
1466 pub page: Option<i64>,
1467 #[serde(
1468 default,
1469 deserialize_with = "crate::de::opt_i64",
1470 skip_serializing_if = "Option::is_none"
1471 )]
1472 pub page_count: Option<i64>,
1473 #[serde(
1474 default,
1475 deserialize_with = "crate::de::opt_i64",
1476 skip_serializing_if = "Option::is_none"
1477 )]
1478 pub per_page: Option<i64>,
1479 #[serde(
1480 default,
1481 deserialize_with = "crate::de::opt_i64",
1482 skip_serializing_if = "Option::is_none"
1483 )]
1484 pub total_count: Option<i64>,
1485}
1486
1487#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
1488pub struct SearchMessagesResponseMessagesPaging {
1489 #[serde(
1490 default,
1491 deserialize_with = "crate::de::opt_i64",
1492 skip_serializing_if = "Option::is_none"
1493 )]
1494 pub count: Option<i64>,
1495 #[serde(
1496 default,
1497 deserialize_with = "crate::de::opt_i64",
1498 skip_serializing_if = "Option::is_none"
1499 )]
1500 pub page: Option<i64>,
1501 #[serde(
1502 default,
1503 deserialize_with = "crate::de::opt_i64",
1504 skip_serializing_if = "Option::is_none"
1505 )]
1506 pub pages: Option<i64>,
1507 #[serde(
1508 default,
1509 deserialize_with = "crate::de::opt_i64",
1510 skip_serializing_if = "Option::is_none"
1511 )]
1512 pub total: Option<i64>,
1513}
1514
1515impl SlackClient {
1516 #[doc(alias = "search.all")]
1528 pub async fn search_all(
1529 &self,
1530 request: &SearchAllRequest,
1531 ) -> Result<SearchAllResponse, SlackError> {
1532 self.call(request).await
1533 }
1534
1535 #[doc(alias = "search.files")]
1547 pub async fn search_files(
1548 &self,
1549 request: &SearchFilesRequest,
1550 ) -> Result<SearchFilesResponse, SlackError> {
1551 self.call(request).await
1552 }
1553
1554 #[doc(alias = "search.messages")]
1566 pub async fn search_messages(
1567 &self,
1568 request: &SearchMessagesRequest,
1569 ) -> Result<SearchMessagesResponse, SlackError> {
1570 self.call(request).await
1571 }
1572}