Skip to main content

slack_web_api/api/
users.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 [`users.conversations`](https://docs.slack.dev/reference/methods/users.conversations): List conversations the calling user is a member of.
12///
13/// Send it with [`SlackClient::users_conversations`].
14#[doc(alias = "users.conversations")]
15#[derive(Debug, Clone, PartialEq, Serialize, Default)]
16#[non_exhaustive]
17pub struct UsersConversationsRequest {
18    /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](https://docs.slack.dev/apis/web-api/pagination.md) for more detail.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub cursor: Option<String>,
21    /// Set to `true` to exclude archived channels from the list
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub exclude_archived: Option<bool>,
24    /// Set to `true` to exclude muted channels from the list
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub exclude_muted: Option<bool>,
27    /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. Must be an integer with a max value of 999.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub limit: Option<i64>,
30    /// encoded team id to list conversations in, required if org token is used
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub team_id: Option<String>,
33    /// Mix and match channel types by providing a comma-separated list of any combination of `public_channel`, `private_channel`, `mpim`, `im`
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub types: Option<String>,
36    /// Browse conversations by a specific user ID's membership. Non-public channels are restricted to those where the calling user shares membership.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub user: Option<String>,
39}
40
41impl UsersConversationsRequest {
42    pub fn new() -> Self {
43        Self {
44            cursor: None,
45            exclude_archived: None,
46            exclude_muted: None,
47            limit: None,
48            team_id: None,
49            types: None,
50            user: None,
51        }
52    }
53
54    pub fn cursor(mut self, cursor: impl Into<String>) -> Self {
55        self.cursor = Some(cursor.into());
56        self
57    }
58
59    pub fn exclude_archived(mut self, exclude_archived: bool) -> Self {
60        self.exclude_archived = Some(exclude_archived);
61        self
62    }
63
64    pub fn exclude_muted(mut self, exclude_muted: bool) -> Self {
65        self.exclude_muted = Some(exclude_muted);
66        self
67    }
68
69    pub fn limit(mut self, limit: i64) -> Self {
70        self.limit = Some(limit);
71        self
72    }
73
74    pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
75        self.team_id = Some(team_id.into());
76        self
77    }
78
79    pub fn types(mut self, types: impl Into<String>) -> Self {
80        self.types = Some(types.into());
81        self
82    }
83
84    pub fn user(mut self, user: impl Into<String>) -> Self {
85        self.user = Some(user.into());
86        self
87    }
88}
89
90impl SlackApiMethod for UsersConversationsRequest {
91    const METHOD: &'static str = "users.conversations";
92    type Response = UsersConversationsResponse;
93}
94
95impl CursorPaginated for UsersConversationsRequest {
96    fn set_cursor(&mut self, cursor: String) {
97        self.cursor = Some(cursor);
98    }
99}
100
101impl NextCursor for UsersConversationsResponse {
102    fn next_cursor(&self) -> Option<&str> {
103        self.response_metadata.as_ref()?.next_cursor.as_deref()
104    }
105}
106
107/// Successful response of the Slack Web API method [`users.conversations`](https://docs.slack.dev/reference/methods/users.conversations).
108#[doc(alias = "users.conversations")]
109#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
110pub struct UsersConversationsResponse {
111    #[serde(
112        default,
113        deserialize_with = "crate::de::vec",
114        skip_serializing_if = "Vec::is_empty"
115    )]
116    pub channels: Vec<Conversation>,
117    #[serde(
118        default,
119        deserialize_with = "crate::de::opt_object",
120        skip_serializing_if = "Option::is_none"
121    )]
122    pub response_metadata: Option<ResponseMetadata>,
123    #[serde(
124        default,
125        deserialize_with = "crate::de::opt_string",
126        skip_serializing_if = "Option::is_none"
127    )]
128    pub warning: Option<String>,
129}
130
131/// Arguments for the Slack Web API method [`users.deletePhoto`](https://docs.slack.dev/reference/methods/users.deletePhoto): Delete the user profile photo
132///
133/// Send it with [`SlackClient::users_delete_photo`].
134#[doc(alias = "users.deletePhoto")]
135#[derive(Debug, Clone, PartialEq, Serialize, Default)]
136#[non_exhaustive]
137pub struct UsersDeletePhotoRequest {}
138
139impl UsersDeletePhotoRequest {
140    pub fn new() -> Self {
141        Self {}
142    }
143}
144
145impl SlackApiMethod for UsersDeletePhotoRequest {
146    const METHOD: &'static str = "users.deletePhoto";
147    type Response = UsersDeletePhotoResponse;
148}
149
150/// Successful response of the Slack Web API method [`users.deletePhoto`](https://docs.slack.dev/reference/methods/users.deletePhoto).
151#[doc(alias = "users.deletePhoto")]
152#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
153pub struct UsersDeletePhotoResponse {
154    /// Fields returned by Slack. This method has no documented response example.
155    #[serde(flatten)]
156    pub extra: serde_json::Map<String, serde_json::Value>,
157    #[serde(
158        default,
159        deserialize_with = "crate::de::opt_object",
160        skip_serializing_if = "Option::is_none"
161    )]
162    pub response_metadata: Option<ResponseMetadata>,
163    #[serde(
164        default,
165        deserialize_with = "crate::de::opt_string",
166        skip_serializing_if = "Option::is_none"
167    )]
168    pub warning: Option<String>,
169}
170
171/// Arguments for the Slack Web API method [`users.discoverableContacts.lookup`](https://docs.slack.dev/reference/methods/users.discoverableContacts.lookup): Look up an email address to see if someone is discoverable on Slack
172///
173/// Send it with [`SlackClient::users_discoverable_contacts_lookup`].
174#[doc(alias = "users.discoverableContacts.lookup")]
175#[derive(Debug, Clone, PartialEq, Serialize)]
176#[non_exhaustive]
177pub struct UsersDiscoverableContactsLookupRequest {
178    pub email: String,
179}
180
181impl UsersDiscoverableContactsLookupRequest {
182    pub fn new(email: impl Into<String>) -> Self {
183        Self {
184            email: email.into(),
185        }
186    }
187}
188
189impl SlackApiMethod for UsersDiscoverableContactsLookupRequest {
190    const METHOD: &'static str = "users.discoverableContacts.lookup";
191    type Response = UsersDiscoverableContactsLookupResponse;
192}
193
194/// Successful response of the Slack Web API method [`users.discoverableContacts.lookup`](https://docs.slack.dev/reference/methods/users.discoverableContacts.lookup).
195#[doc(alias = "users.discoverableContacts.lookup")]
196#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
197pub struct UsersDiscoverableContactsLookupResponse {
198    #[serde(
199        default,
200        deserialize_with = "crate::de::opt_bool",
201        skip_serializing_if = "Option::is_none"
202    )]
203    pub is_discoverable: Option<bool>,
204    #[serde(
205        default,
206        deserialize_with = "crate::de::opt_object",
207        skip_serializing_if = "Option::is_none"
208    )]
209    pub response_metadata: Option<ResponseMetadata>,
210    #[serde(
211        default,
212        deserialize_with = "crate::de::opt_string",
213        skip_serializing_if = "Option::is_none"
214    )]
215    pub warning: Option<String>,
216}
217
218/// Arguments for the Slack Web API method [`users.getPresence`](https://docs.slack.dev/reference/methods/users.getPresence): Gets user presence information.
219///
220/// Send it with [`SlackClient::users_get_presence`].
221#[doc(alias = "users.getPresence")]
222#[derive(Debug, Clone, PartialEq, Serialize, Default)]
223#[non_exhaustive]
224pub struct UsersGetPresenceRequest {
225    /// User to get presence info on. Defaults to the authed user.
226    #[serde(skip_serializing_if = "Option::is_none")]
227    pub user: Option<String>,
228}
229
230impl UsersGetPresenceRequest {
231    pub fn new() -> Self {
232        Self { user: None }
233    }
234
235    pub fn user(mut self, user: impl Into<String>) -> Self {
236        self.user = Some(user.into());
237        self
238    }
239}
240
241impl SlackApiMethod for UsersGetPresenceRequest {
242    const METHOD: &'static str = "users.getPresence";
243    type Response = UsersGetPresenceResponse;
244}
245
246/// Successful response of the Slack Web API method [`users.getPresence`](https://docs.slack.dev/reference/methods/users.getPresence).
247#[doc(alias = "users.getPresence")]
248#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
249pub struct UsersGetPresenceResponse {
250    #[serde(
251        default,
252        deserialize_with = "crate::de::opt_string",
253        skip_serializing_if = "Option::is_none"
254    )]
255    pub presence: Option<String>,
256    #[serde(
257        default,
258        deserialize_with = "crate::de::opt_bool",
259        skip_serializing_if = "Option::is_none"
260    )]
261    pub online: Option<bool>,
262    #[serde(
263        default,
264        deserialize_with = "crate::de::opt_bool",
265        skip_serializing_if = "Option::is_none"
266    )]
267    pub auto_away: Option<bool>,
268    #[serde(
269        default,
270        deserialize_with = "crate::de::opt_bool",
271        skip_serializing_if = "Option::is_none"
272    )]
273    pub manual_away: Option<bool>,
274    #[serde(
275        default,
276        deserialize_with = "crate::de::opt_i64",
277        skip_serializing_if = "Option::is_none"
278    )]
279    pub connection_count: Option<i64>,
280    #[serde(
281        default,
282        deserialize_with = "crate::de::opt_i64",
283        skip_serializing_if = "Option::is_none"
284    )]
285    pub last_activity: Option<i64>,
286    #[serde(
287        default,
288        deserialize_with = "crate::de::opt_object",
289        skip_serializing_if = "Option::is_none"
290    )]
291    pub response_metadata: Option<ResponseMetadata>,
292    #[serde(
293        default,
294        deserialize_with = "crate::de::opt_string",
295        skip_serializing_if = "Option::is_none"
296    )]
297    pub warning: Option<String>,
298}
299
300/// Arguments for the Slack Web API method [`users.identity`](https://docs.slack.dev/reference/methods/users.identity): Get a user's identity.
301///
302/// Send it with [`SlackClient::users_identity`].
303#[doc(alias = "users.identity")]
304#[derive(Debug, Clone, PartialEq, Serialize, Default)]
305#[non_exhaustive]
306pub struct UsersIdentityRequest {}
307
308impl UsersIdentityRequest {
309    pub fn new() -> Self {
310        Self {}
311    }
312}
313
314impl SlackApiMethod for UsersIdentityRequest {
315    const METHOD: &'static str = "users.identity";
316    type Response = UsersIdentityResponse;
317}
318
319/// Successful response of the Slack Web API method [`users.identity`](https://docs.slack.dev/reference/methods/users.identity).
320#[doc(alias = "users.identity")]
321#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
322pub struct UsersIdentityResponse {
323    #[serde(
324        default,
325        deserialize_with = "crate::de::opt_object",
326        skip_serializing_if = "Option::is_none"
327    )]
328    pub user: Option<UsersIdentityResponseUser>,
329    #[serde(
330        default,
331        deserialize_with = "crate::de::opt_object",
332        skip_serializing_if = "Option::is_none"
333    )]
334    pub team: Option<UsersIdentityResponseTeam>,
335    #[serde(
336        default,
337        deserialize_with = "crate::de::opt_object",
338        skip_serializing_if = "Option::is_none"
339    )]
340    pub response_metadata: Option<ResponseMetadata>,
341    #[serde(
342        default,
343        deserialize_with = "crate::de::opt_string",
344        skip_serializing_if = "Option::is_none"
345    )]
346    pub warning: Option<String>,
347}
348
349#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
350pub struct UsersIdentityResponseUser {
351    #[serde(
352        default,
353        deserialize_with = "crate::de::opt_string",
354        skip_serializing_if = "Option::is_none"
355    )]
356    pub name: Option<String>,
357    #[serde(
358        default,
359        deserialize_with = "crate::de::opt_string",
360        skip_serializing_if = "Option::is_none"
361    )]
362    pub id: Option<String>,
363    #[serde(
364        default,
365        deserialize_with = "crate::de::opt_string",
366        skip_serializing_if = "Option::is_none"
367    )]
368    pub email: Option<String>,
369    #[serde(
370        default,
371        deserialize_with = "crate::de::opt_string",
372        skip_serializing_if = "Option::is_none"
373    )]
374    pub image_24: Option<String>,
375    #[serde(
376        default,
377        deserialize_with = "crate::de::opt_string",
378        skip_serializing_if = "Option::is_none"
379    )]
380    pub image_32: Option<String>,
381    #[serde(
382        default,
383        deserialize_with = "crate::de::opt_string",
384        skip_serializing_if = "Option::is_none"
385    )]
386    pub image_48: Option<String>,
387    #[serde(
388        default,
389        deserialize_with = "crate::de::opt_string",
390        skip_serializing_if = "Option::is_none"
391    )]
392    pub image_72: Option<String>,
393    #[serde(
394        default,
395        deserialize_with = "crate::de::opt_string",
396        skip_serializing_if = "Option::is_none"
397    )]
398    pub image_192: Option<String>,
399}
400
401#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
402pub struct UsersIdentityResponseTeam {
403    #[serde(
404        default,
405        deserialize_with = "crate::de::opt_string",
406        skip_serializing_if = "Option::is_none"
407    )]
408    pub id: Option<String>,
409    #[serde(
410        default,
411        deserialize_with = "crate::de::opt_string",
412        skip_serializing_if = "Option::is_none"
413    )]
414    pub name: Option<String>,
415}
416
417/// Arguments for the Slack Web API method [`users.info`](https://docs.slack.dev/reference/methods/users.info): Gets information about a user.
418///
419/// Send it with [`SlackClient::users_info`].
420#[doc(alias = "users.info")]
421#[derive(Debug, Clone, PartialEq, Serialize, Default)]
422#[non_exhaustive]
423pub struct UsersInfoRequest {
424    /// Set this to `true` to receive the locale for this user. Defaults to `false`
425    #[serde(skip_serializing_if = "Option::is_none")]
426    pub include_locale: Option<bool>,
427    /// User to get info on
428    #[serde(skip_serializing_if = "Option::is_none")]
429    pub user: Option<String>,
430}
431
432impl UsersInfoRequest {
433    pub fn new() -> Self {
434        Self {
435            include_locale: None,
436            user: None,
437        }
438    }
439
440    pub fn include_locale(mut self, include_locale: bool) -> Self {
441        self.include_locale = Some(include_locale);
442        self
443    }
444
445    pub fn user(mut self, user: impl Into<String>) -> Self {
446        self.user = Some(user.into());
447        self
448    }
449}
450
451impl SlackApiMethod for UsersInfoRequest {
452    const METHOD: &'static str = "users.info";
453    type Response = UsersInfoResponse;
454}
455
456/// Successful response of the Slack Web API method [`users.info`](https://docs.slack.dev/reference/methods/users.info).
457#[doc(alias = "users.info")]
458#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
459pub struct UsersInfoResponse {
460    #[serde(
461        default,
462        deserialize_with = "crate::de::opt_object",
463        skip_serializing_if = "Option::is_none"
464    )]
465    pub user: Option<User>,
466    #[serde(
467        default,
468        deserialize_with = "crate::de::opt_object",
469        skip_serializing_if = "Option::is_none"
470    )]
471    pub response_metadata: Option<ResponseMetadata>,
472    #[serde(
473        default,
474        deserialize_with = "crate::de::opt_string",
475        skip_serializing_if = "Option::is_none"
476    )]
477    pub warning: Option<String>,
478}
479
480/// Arguments for the Slack Web API method [`users.list`](https://docs.slack.dev/reference/methods/users.list): Lists all users in a Slack team.
481///
482/// Send it with [`SlackClient::users_list`].
483#[doc(alias = "users.list")]
484#[derive(Debug, Clone, PartialEq, Serialize, Default)]
485#[non_exhaustive]
486pub struct UsersListRequest {
487    /// Paginate through collections of data by setting the `cursor` parameter to a `next_cursor` attribute returned by a previous request's `response_metadata`. Default value fetches the first "page" of the collection. See [pagination](https://docs.slack.dev/apis/web-api/pagination.md) for more detail.
488    #[serde(skip_serializing_if = "Option::is_none")]
489    pub cursor: Option<String>,
490    /// Set this to `true` to receive the locale for users. Defaults to `false`
491    #[serde(skip_serializing_if = "Option::is_none")]
492    pub include_locale: Option<bool>,
493    /// The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached. Providing no `limit` value will result in Slack attempting to deliver you the entire result set. If the collection is too large you may experience `limit_required` or HTTP 500 errors.
494    #[serde(skip_serializing_if = "Option::is_none")]
495    pub limit: Option<i64>,
496    /// encoded team id to list users in, required if org token is used
497    #[serde(skip_serializing_if = "Option::is_none")]
498    pub team_id: Option<String>,
499}
500
501impl UsersListRequest {
502    pub fn new() -> Self {
503        Self {
504            cursor: None,
505            include_locale: None,
506            limit: None,
507            team_id: None,
508        }
509    }
510
511    pub fn cursor(mut self, cursor: impl Into<String>) -> Self {
512        self.cursor = Some(cursor.into());
513        self
514    }
515
516    pub fn include_locale(mut self, include_locale: bool) -> Self {
517        self.include_locale = Some(include_locale);
518        self
519    }
520
521    pub fn limit(mut self, limit: i64) -> Self {
522        self.limit = Some(limit);
523        self
524    }
525
526    pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
527        self.team_id = Some(team_id.into());
528        self
529    }
530}
531
532impl SlackApiMethod for UsersListRequest {
533    const METHOD: &'static str = "users.list";
534    type Response = UsersListResponse;
535}
536
537impl CursorPaginated for UsersListRequest {
538    fn set_cursor(&mut self, cursor: String) {
539        self.cursor = Some(cursor);
540    }
541}
542
543impl NextCursor for UsersListResponse {
544    fn next_cursor(&self) -> Option<&str> {
545        self.response_metadata.as_ref()?.next_cursor.as_deref()
546    }
547}
548
549/// Successful response of the Slack Web API method [`users.list`](https://docs.slack.dev/reference/methods/users.list).
550#[doc(alias = "users.list")]
551#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
552pub struct UsersListResponse {
553    #[serde(
554        default,
555        deserialize_with = "crate::de::vec",
556        skip_serializing_if = "Vec::is_empty"
557    )]
558    pub members: Vec<User>,
559    #[serde(
560        default,
561        deserialize_with = "crate::de::opt_i64",
562        skip_serializing_if = "Option::is_none"
563    )]
564    pub cache_ts: Option<i64>,
565    #[serde(
566        default,
567        deserialize_with = "crate::de::opt_object",
568        skip_serializing_if = "Option::is_none"
569    )]
570    pub response_metadata: Option<ResponseMetadata>,
571    #[serde(
572        default,
573        deserialize_with = "crate::de::opt_string",
574        skip_serializing_if = "Option::is_none"
575    )]
576    pub warning: Option<String>,
577}
578
579/// Arguments for the Slack Web API method [`users.lookupByEmail`](https://docs.slack.dev/reference/methods/users.lookupByEmail): Find a user with an email address.
580///
581/// Send it with [`SlackClient::users_lookup_by_email`].
582#[doc(alias = "users.lookupByEmail")]
583#[derive(Debug, Clone, PartialEq, Serialize)]
584#[non_exhaustive]
585pub struct UsersLookupByEmailRequest {
586    /// An email address belonging to a user in the workspace
587    pub email: String,
588}
589
590impl UsersLookupByEmailRequest {
591    pub fn new(email: impl Into<String>) -> Self {
592        Self {
593            email: email.into(),
594        }
595    }
596}
597
598impl SlackApiMethod for UsersLookupByEmailRequest {
599    const METHOD: &'static str = "users.lookupByEmail";
600    type Response = UsersLookupByEmailResponse;
601}
602
603/// Successful response of the Slack Web API method [`users.lookupByEmail`](https://docs.slack.dev/reference/methods/users.lookupByEmail).
604#[doc(alias = "users.lookupByEmail")]
605#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
606pub struct UsersLookupByEmailResponse {
607    #[serde(
608        default,
609        deserialize_with = "crate::de::opt_object",
610        skip_serializing_if = "Option::is_none"
611    )]
612    pub user: Option<User>,
613    #[serde(
614        default,
615        deserialize_with = "crate::de::opt_object",
616        skip_serializing_if = "Option::is_none"
617    )]
618    pub response_metadata: Option<ResponseMetadata>,
619    #[serde(
620        default,
621        deserialize_with = "crate::de::opt_string",
622        skip_serializing_if = "Option::is_none"
623    )]
624    pub warning: Option<String>,
625}
626
627/// Arguments for the Slack Web API method [`users.profile.get`](https://docs.slack.dev/reference/methods/users.profile.get): Retrieve a user's profile information, including their custom status.
628///
629/// Send it with [`SlackClient::users_profile_get`].
630#[doc(alias = "users.profile.get")]
631#[derive(Debug, Clone, PartialEq, Serialize, Default)]
632#[non_exhaustive]
633pub struct UsersProfileGetRequest {
634    /// Include labels for each ID in custom profile fields. Using this parameter will heavily rate-limit your requests and is not recommended.
635    #[serde(skip_serializing_if = "Option::is_none")]
636    pub include_labels: Option<bool>,
637    /// User to retrieve profile info for
638    #[serde(skip_serializing_if = "Option::is_none")]
639    pub user: Option<String>,
640}
641
642impl UsersProfileGetRequest {
643    pub fn new() -> Self {
644        Self {
645            include_labels: None,
646            user: None,
647        }
648    }
649
650    pub fn include_labels(mut self, include_labels: bool) -> Self {
651        self.include_labels = Some(include_labels);
652        self
653    }
654
655    pub fn user(mut self, user: impl Into<String>) -> Self {
656        self.user = Some(user.into());
657        self
658    }
659}
660
661impl SlackApiMethod for UsersProfileGetRequest {
662    const METHOD: &'static str = "users.profile.get";
663    type Response = UsersProfileGetResponse;
664}
665
666/// Successful response of the Slack Web API method [`users.profile.get`](https://docs.slack.dev/reference/methods/users.profile.get).
667#[doc(alias = "users.profile.get")]
668#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
669pub struct UsersProfileGetResponse {
670    #[serde(
671        default,
672        deserialize_with = "crate::de::opt_object",
673        skip_serializing_if = "Option::is_none"
674    )]
675    pub profile: Option<UserProfile>,
676    #[serde(
677        default,
678        deserialize_with = "crate::de::opt_object",
679        skip_serializing_if = "Option::is_none"
680    )]
681    pub response_metadata: Option<ResponseMetadata>,
682    #[serde(
683        default,
684        deserialize_with = "crate::de::opt_string",
685        skip_serializing_if = "Option::is_none"
686    )]
687    pub warning: Option<String>,
688}
689
690/// Arguments for the Slack Web API method [`users.profile.set`](https://docs.slack.dev/reference/methods/users.profile.set): Set a user's profile information, including custom status.
691///
692/// Send it with [`SlackClient::users_profile_set`].
693#[doc(alias = "users.profile.set")]
694#[derive(Debug, Clone, PartialEq, Serialize, Default)]
695#[non_exhaustive]
696pub struct UsersProfileSetRequest {
697    /// Name of a single key to set. Usable only if `profile` is not passed.
698    #[serde(skip_serializing_if = "Option::is_none")]
699    pub name: Option<String>,
700    /// Collection of key:value pairs presented as a URL-encoded JSON hash. At most 50 fields may be set. Each field name is limited to 255 characters.
701    #[serde(skip_serializing_if = "Option::is_none")]
702    pub profile: Option<String>,
703    /// ID of user to change. This argument may only be specified by admins on paid teams.
704    #[serde(skip_serializing_if = "Option::is_none")]
705    pub user: Option<String>,
706    /// Value to set a single key to. Usable only if `profile` is not passed.
707    #[serde(skip_serializing_if = "Option::is_none")]
708    pub value: Option<String>,
709}
710
711impl UsersProfileSetRequest {
712    pub fn new() -> Self {
713        Self {
714            name: None,
715            profile: None,
716            user: None,
717            value: None,
718        }
719    }
720
721    pub fn name(mut self, name: impl Into<String>) -> Self {
722        self.name = Some(name.into());
723        self
724    }
725
726    pub fn profile(mut self, profile: impl Into<String>) -> Self {
727        self.profile = Some(profile.into());
728        self
729    }
730
731    pub fn user(mut self, user: impl Into<String>) -> Self {
732        self.user = Some(user.into());
733        self
734    }
735
736    pub fn value(mut self, value: impl Into<String>) -> Self {
737        self.value = Some(value.into());
738        self
739    }
740}
741
742impl SlackApiMethod for UsersProfileSetRequest {
743    const METHOD: &'static str = "users.profile.set";
744    type Response = UsersProfileSetResponse;
745}
746
747/// Successful response of the Slack Web API method [`users.profile.set`](https://docs.slack.dev/reference/methods/users.profile.set).
748#[doc(alias = "users.profile.set")]
749#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
750pub struct UsersProfileSetResponse {
751    #[serde(
752        default,
753        deserialize_with = "crate::de::opt_object",
754        skip_serializing_if = "Option::is_none"
755    )]
756    pub profile: Option<UserProfile>,
757    #[serde(
758        default,
759        deserialize_with = "crate::de::opt_object",
760        skip_serializing_if = "Option::is_none"
761    )]
762    pub response_metadata: Option<ResponseMetadata>,
763    #[serde(
764        default,
765        deserialize_with = "crate::de::opt_string",
766        skip_serializing_if = "Option::is_none"
767    )]
768    pub warning: Option<String>,
769}
770
771/// Arguments for the Slack Web API method [`users.setActive`](https://docs.slack.dev/reference/methods/users.setActive): Marked a user as active. Deprecated and non-functional.
772///
773/// Send it with [`SlackClient::users_set_active`].
774#[doc(alias = "users.setActive")]
775#[derive(Debug, Clone, PartialEq, Serialize, Default)]
776#[non_exhaustive]
777pub struct UsersSetActiveRequest {}
778
779impl UsersSetActiveRequest {
780    pub fn new() -> Self {
781        Self {}
782    }
783}
784
785impl SlackApiMethod for UsersSetActiveRequest {
786    const METHOD: &'static str = "users.setActive";
787    type Response = UsersSetActiveResponse;
788}
789
790/// Successful response of the Slack Web API method [`users.setActive`](https://docs.slack.dev/reference/methods/users.setActive).
791#[doc(alias = "users.setActive")]
792#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
793pub struct UsersSetActiveResponse {
794    /// Fields returned by Slack. This method has no documented response example.
795    #[serde(flatten)]
796    pub extra: serde_json::Map<String, serde_json::Value>,
797    #[serde(
798        default,
799        deserialize_with = "crate::de::opt_object",
800        skip_serializing_if = "Option::is_none"
801    )]
802    pub response_metadata: Option<ResponseMetadata>,
803    #[serde(
804        default,
805        deserialize_with = "crate::de::opt_string",
806        skip_serializing_if = "Option::is_none"
807    )]
808    pub warning: Option<String>,
809}
810
811/// Arguments for the Slack Web API method [`users.setPhoto`](https://docs.slack.dev/reference/methods/users.setPhoto): Set the user profile photo
812///
813/// Send it with [`SlackClient::users_set_photo`].
814#[doc(alias = "users.setPhoto")]
815#[derive(Debug, Clone, PartialEq, Serialize, Default)]
816#[non_exhaustive]
817pub struct UsersSetPhotoRequest {
818    /// Width/height of crop box (always square)
819    #[serde(skip_serializing_if = "Option::is_none")]
820    pub crop_w: Option<String>,
821    /// X coordinate of top-left corner of crop box
822    #[serde(skip_serializing_if = "Option::is_none")]
823    pub crop_x: Option<String>,
824    /// Y coordinate of top-left corner of crop box
825    #[serde(skip_serializing_if = "Option::is_none")]
826    pub crop_y: Option<String>,
827    /// File contents via `multipart/form-data`.
828    #[serde(skip_serializing_if = "Option::is_none")]
829    pub image: Option<String>,
830}
831
832impl UsersSetPhotoRequest {
833    pub fn new() -> Self {
834        Self {
835            crop_w: None,
836            crop_x: None,
837            crop_y: None,
838            image: None,
839        }
840    }
841
842    pub fn crop_w(mut self, crop_w: impl Into<String>) -> Self {
843        self.crop_w = Some(crop_w.into());
844        self
845    }
846
847    pub fn crop_x(mut self, crop_x: impl Into<String>) -> Self {
848        self.crop_x = Some(crop_x.into());
849        self
850    }
851
852    pub fn crop_y(mut self, crop_y: impl Into<String>) -> Self {
853        self.crop_y = Some(crop_y.into());
854        self
855    }
856
857    pub fn image(mut self, image: impl Into<String>) -> Self {
858        self.image = Some(image.into());
859        self
860    }
861}
862
863impl SlackApiMethod for UsersSetPhotoRequest {
864    const METHOD: &'static str = "users.setPhoto";
865    type Response = UsersSetPhotoResponse;
866}
867
868/// Successful response of the Slack Web API method [`users.setPhoto`](https://docs.slack.dev/reference/methods/users.setPhoto).
869#[doc(alias = "users.setPhoto")]
870#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
871pub struct UsersSetPhotoResponse {
872    /// Fields returned by Slack. This method has no documented response example.
873    #[serde(flatten)]
874    pub extra: serde_json::Map<String, serde_json::Value>,
875    #[serde(
876        default,
877        deserialize_with = "crate::de::opt_object",
878        skip_serializing_if = "Option::is_none"
879    )]
880    pub response_metadata: Option<ResponseMetadata>,
881    #[serde(
882        default,
883        deserialize_with = "crate::de::opt_string",
884        skip_serializing_if = "Option::is_none"
885    )]
886    pub warning: Option<String>,
887}
888
889/// Arguments for the Slack Web API method [`users.setPresence`](https://docs.slack.dev/reference/methods/users.setPresence): Manually sets user presence.
890///
891/// Send it with [`SlackClient::users_set_presence`].
892#[doc(alias = "users.setPresence")]
893#[derive(Debug, Clone, PartialEq, Serialize)]
894#[non_exhaustive]
895pub struct UsersSetPresenceRequest {
896    /// Either `auto` or `away`
897    pub presence: String,
898}
899
900impl UsersSetPresenceRequest {
901    pub fn new(presence: impl Into<String>) -> Self {
902        Self {
903            presence: presence.into(),
904        }
905    }
906}
907
908impl SlackApiMethod for UsersSetPresenceRequest {
909    const METHOD: &'static str = "users.setPresence";
910    type Response = UsersSetPresenceResponse;
911}
912
913/// Successful response of the Slack Web API method [`users.setPresence`](https://docs.slack.dev/reference/methods/users.setPresence).
914#[doc(alias = "users.setPresence")]
915#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
916pub struct UsersSetPresenceResponse {
917    /// Fields returned by Slack. This method has no documented response example.
918    #[serde(flatten)]
919    pub extra: serde_json::Map<String, serde_json::Value>,
920    #[serde(
921        default,
922        deserialize_with = "crate::de::opt_object",
923        skip_serializing_if = "Option::is_none"
924    )]
925    pub response_metadata: Option<ResponseMetadata>,
926    #[serde(
927        default,
928        deserialize_with = "crate::de::opt_string",
929        skip_serializing_if = "Option::is_none"
930    )]
931    pub warning: Option<String>,
932}
933
934impl SlackClient {
935    /// Calls the Slack Web API method [`users.conversations`](https://docs.slack.dev/reference/methods/users.conversations): List conversations the calling user is a member of.
936    ///
937    /// Required scopes:
938    ///
939    /// - bot token: `groups:read`, `im:read`, `mpim:read`, `channels:read`
940    /// - user token: `groups:read`, `im:read`, `mpim:read`, `channels:read`
941    ///
942    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
943    ///
944    /// # Errors
945    ///
946    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
947    #[doc(alias = "users.conversations")]
948    pub async fn users_conversations(
949        &self,
950        request: &UsersConversationsRequest,
951    ) -> Result<UsersConversationsResponse, SlackError> {
952        self.call(request).await
953    }
954
955    /// Calls the Slack Web API method [`users.deletePhoto`](https://docs.slack.dev/reference/methods/users.deletePhoto): Delete the user profile photo
956    ///
957    /// Required scopes:
958    ///
959    /// - user token: `users.profile:write`
960    ///
961    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
962    ///
963    /// # Errors
964    ///
965    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
966    #[doc(alias = "users.deletePhoto")]
967    pub async fn users_delete_photo(
968        &self,
969        request: &UsersDeletePhotoRequest,
970    ) -> Result<UsersDeletePhotoResponse, SlackError> {
971        self.call(request).await
972    }
973
974    /// Calls the Slack Web API method [`users.discoverableContacts.lookup`](https://docs.slack.dev/reference/methods/users.discoverableContacts.lookup): Look up an email address to see if someone is discoverable on Slack
975    ///
976    /// Required scopes:
977    ///
978    /// - bot token: `conversations.connect:manage`, `team:read`
979    ///
980    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
981    ///
982    /// # Errors
983    ///
984    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
985    #[doc(alias = "users.discoverableContacts.lookup")]
986    pub async fn users_discoverable_contacts_lookup(
987        &self,
988        request: &UsersDiscoverableContactsLookupRequest,
989    ) -> Result<UsersDiscoverableContactsLookupResponse, SlackError> {
990        self.call(request).await
991    }
992
993    /// Calls the Slack Web API method [`users.getPresence`](https://docs.slack.dev/reference/methods/users.getPresence): Gets user presence information.
994    ///
995    /// Required scopes:
996    ///
997    /// - bot token: `users:read`
998    /// - user token: `users:read`
999    ///
1000    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
1001    ///
1002    /// # Errors
1003    ///
1004    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
1005    #[doc(alias = "users.getPresence")]
1006    pub async fn users_get_presence(
1007        &self,
1008        request: &UsersGetPresenceRequest,
1009    ) -> Result<UsersGetPresenceResponse, SlackError> {
1010        self.call(request).await
1011    }
1012
1013    /// Calls the Slack Web API method [`users.identity`](https://docs.slack.dev/reference/methods/users.identity): Get a user's identity.
1014    ///
1015    /// Required scopes:
1016    ///
1017    /// - user token: `identity:read`
1018    ///
1019    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
1020    ///
1021    /// # Errors
1022    ///
1023    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
1024    #[doc(alias = "users.identity")]
1025    pub async fn users_identity(
1026        &self,
1027        request: &UsersIdentityRequest,
1028    ) -> Result<UsersIdentityResponse, SlackError> {
1029        self.call(request).await
1030    }
1031
1032    /// Calls the Slack Web API method [`users.info`](https://docs.slack.dev/reference/methods/users.info): Gets information about a user.
1033    ///
1034    /// Required scopes:
1035    ///
1036    /// - bot token: `users:read`
1037    /// - user token: `users:read`
1038    ///
1039    /// Rate limit: Tier 4 (<https://docs.slack.dev/apis/web-api/rate-limits>).
1040    ///
1041    /// # Errors
1042    ///
1043    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
1044    #[doc(alias = "users.info")]
1045    pub async fn users_info(
1046        &self,
1047        request: &UsersInfoRequest,
1048    ) -> Result<UsersInfoResponse, SlackError> {
1049        self.call(request).await
1050    }
1051
1052    /// Calls the Slack Web API method [`users.list`](https://docs.slack.dev/reference/methods/users.list): Lists all users in a Slack team.
1053    ///
1054    /// Required scopes:
1055    ///
1056    /// - bot token: `users:read`
1057    /// - user token: `users:read`
1058    ///
1059    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
1060    ///
1061    /// # Errors
1062    ///
1063    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
1064    #[doc(alias = "users.list")]
1065    pub async fn users_list(
1066        &self,
1067        request: &UsersListRequest,
1068    ) -> Result<UsersListResponse, SlackError> {
1069        self.call(request).await
1070    }
1071
1072    /// Calls the Slack Web API method [`users.lookupByEmail`](https://docs.slack.dev/reference/methods/users.lookupByEmail): Find a user with an email address.
1073    ///
1074    /// Required scopes:
1075    ///
1076    /// - bot token: `users:read.email`
1077    /// - user token: `users:read.email`
1078    ///
1079    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
1080    ///
1081    /// # Errors
1082    ///
1083    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
1084    #[doc(alias = "users.lookupByEmail")]
1085    pub async fn users_lookup_by_email(
1086        &self,
1087        request: &UsersLookupByEmailRequest,
1088    ) -> Result<UsersLookupByEmailResponse, SlackError> {
1089        self.call(request).await
1090    }
1091
1092    /// Calls the Slack Web API method [`users.profile.get`](https://docs.slack.dev/reference/methods/users.profile.get): Retrieve a user's profile information, including their custom status.
1093    ///
1094    /// Required scopes:
1095    ///
1096    /// - bot token: `users.profile:read`
1097    /// - user token: `users.profile:read`
1098    ///
1099    /// Rate limit: Tier 4 (<https://docs.slack.dev/apis/web-api/rate-limits>).
1100    ///
1101    /// # Errors
1102    ///
1103    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
1104    #[doc(alias = "users.profile.get")]
1105    pub async fn users_profile_get(
1106        &self,
1107        request: &UsersProfileGetRequest,
1108    ) -> Result<UsersProfileGetResponse, SlackError> {
1109        self.call(request).await
1110    }
1111
1112    /// Calls the Slack Web API method [`users.profile.set`](https://docs.slack.dev/reference/methods/users.profile.set): Set a user's profile information, including custom status.
1113    ///
1114    /// Required scopes:
1115    ///
1116    /// - user token: `users.profile:write`
1117    ///
1118    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
1119    ///
1120    /// # Errors
1121    ///
1122    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
1123    #[doc(alias = "users.profile.set")]
1124    pub async fn users_profile_set(
1125        &self,
1126        request: &UsersProfileSetRequest,
1127    ) -> Result<UsersProfileSetResponse, SlackError> {
1128        self.call(request).await
1129    }
1130
1131    /// Calls the Slack Web API method [`users.setActive`](https://docs.slack.dev/reference/methods/users.setActive): Marked a user as active. Deprecated and non-functional.
1132    ///
1133    /// Required scopes:
1134    ///
1135    /// - bot token: `users:write`
1136    /// - user token: `users:write`
1137    ///
1138    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
1139    ///
1140    /// # Errors
1141    ///
1142    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
1143    #[doc(alias = "users.setActive")]
1144    pub async fn users_set_active(
1145        &self,
1146        request: &UsersSetActiveRequest,
1147    ) -> Result<UsersSetActiveResponse, SlackError> {
1148        self.call(request).await
1149    }
1150
1151    /// Calls the Slack Web API method [`users.setPhoto`](https://docs.slack.dev/reference/methods/users.setPhoto): Set the user profile photo
1152    ///
1153    /// Required scopes:
1154    ///
1155    /// - user token: `users.profile:write`
1156    ///
1157    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
1158    ///
1159    /// # Errors
1160    ///
1161    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
1162    #[doc(alias = "users.setPhoto")]
1163    pub async fn users_set_photo(
1164        &self,
1165        request: &UsersSetPhotoRequest,
1166    ) -> Result<UsersSetPhotoResponse, SlackError> {
1167        self.call(request).await
1168    }
1169
1170    /// Calls the Slack Web API method [`users.setPresence`](https://docs.slack.dev/reference/methods/users.setPresence): Manually sets user presence.
1171    ///
1172    /// Required scopes:
1173    ///
1174    /// - bot token: `users:write`
1175    /// - user token: `users:write`
1176    ///
1177    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
1178    ///
1179    /// # Errors
1180    ///
1181    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
1182    #[doc(alias = "users.setPresence")]
1183    pub async fn users_set_presence(
1184        &self,
1185        request: &UsersSetPresenceRequest,
1186    ) -> Result<UsersSetPresenceResponse, SlackError> {
1187        self.call(request).await
1188    }
1189}