slack_api/mod_types/
groups_types.rs

1//=============================================================================
2//
3//                    WARNING: This file is AUTO-GENERATED
4//
5// Do not make changes directly to this file.
6//
7// If you would like to make a change to the library, please update the schema
8// definitions at https://github.com/slack-rs/slack-api-schemas
9//
10// If you would like to make a change how the library was generated,
11// please edit https://github.com/slack-rs/slack-rs-api/tree/master/codegen
12//
13//=============================================================================
14
15//! Get info on your team's private channels.
16
17#[allow(unused_imports)]
18use std::collections::HashMap;
19use std::convert::From;
20use std::error::Error;
21use std::fmt;
22
23#[derive(Clone, Default, Debug)]
24pub struct ArchiveRequest<'a> {
25    /// Private channel to archive
26    pub channel: &'a str,
27}
28
29#[derive(Clone, Debug, Deserialize)]
30pub struct ArchiveResponse {
31    error: Option<String>,
32    #[serde(default)]
33    ok: bool,
34}
35
36impl<E: Error> Into<Result<ArchiveResponse, ArchiveError<E>>> for ArchiveResponse {
37    fn into(self) -> Result<ArchiveResponse, ArchiveError<E>> {
38        if self.ok {
39            Ok(self)
40        } else {
41            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
42        }
43    }
44}
45#[derive(Debug)]
46pub enum ArchiveError<E: Error> {
47    /// Value passed for channel was invalid.
48    ChannelNotFound,
49    /// Group has already been archived.
50    AlreadyArchived,
51    /// Multi-channel guests cannot archive groups containing others.
52    GroupContainsOthers,
53    /// A team preference prevents the authenticated user from archiving.
54    RestrictedAction,
55    /// No authentication token provided.
56    NotAuthed,
57    /// Invalid authentication token.
58    InvalidAuth,
59    /// Authentication token is for a deleted user or team.
60    AccountInactive,
61    /// This method cannot be called by a bot user.
62    UserIsBot,
63    /// This method cannot be called by a single channel guest.
64    UserIsUltraRestricted,
65    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
66    InvalidArgName,
67    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
68    InvalidArrayArg,
69    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
70    InvalidCharset,
71    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
72    InvalidFormData,
73    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
74    InvalidPostType,
75    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
76    MissingPostType,
77    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
78    TeamAddedToOrg,
79    /// The method was called via a POST request, but the POST data was either missing or truncated.
80    RequestTimeout,
81    /// The response was not parseable as the expected object
82    MalformedResponse(String, serde_json::error::Error),
83    /// The response returned an error that was unknown to the library
84    Unknown(String),
85    /// The client had an error sending the request to Slack
86    Client(E),
87}
88
89impl<'a, E: Error> From<&'a str> for ArchiveError<E> {
90    fn from(s: &'a str) -> Self {
91        match s {
92            "channel_not_found" => ArchiveError::ChannelNotFound,
93            "already_archived" => ArchiveError::AlreadyArchived,
94            "group_contains_others" => ArchiveError::GroupContainsOthers,
95            "restricted_action" => ArchiveError::RestrictedAction,
96            "not_authed" => ArchiveError::NotAuthed,
97            "invalid_auth" => ArchiveError::InvalidAuth,
98            "account_inactive" => ArchiveError::AccountInactive,
99            "user_is_bot" => ArchiveError::UserIsBot,
100            "user_is_ultra_restricted" => ArchiveError::UserIsUltraRestricted,
101            "invalid_arg_name" => ArchiveError::InvalidArgName,
102            "invalid_array_arg" => ArchiveError::InvalidArrayArg,
103            "invalid_charset" => ArchiveError::InvalidCharset,
104            "invalid_form_data" => ArchiveError::InvalidFormData,
105            "invalid_post_type" => ArchiveError::InvalidPostType,
106            "missing_post_type" => ArchiveError::MissingPostType,
107            "team_added_to_org" => ArchiveError::TeamAddedToOrg,
108            "request_timeout" => ArchiveError::RequestTimeout,
109            _ => ArchiveError::Unknown(s.to_owned()),
110        }
111    }
112}
113
114impl<E: Error> fmt::Display for ArchiveError<E> {
115    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
116        let d = match *self {
117                        ArchiveError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
118ArchiveError::AlreadyArchived => "already_archived: Group has already been archived.",
119ArchiveError::GroupContainsOthers => "group_contains_others: Multi-channel guests cannot archive groups containing others.",
120ArchiveError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from archiving.",
121ArchiveError::NotAuthed => "not_authed: No authentication token provided.",
122ArchiveError::InvalidAuth => "invalid_auth: Invalid authentication token.",
123ArchiveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
124ArchiveError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
125ArchiveError::UserIsUltraRestricted => "user_is_ultra_restricted: This method cannot be called by a single channel guest.",
126ArchiveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
127ArchiveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
128ArchiveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
129ArchiveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
130ArchiveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
131ArchiveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
132ArchiveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
133ArchiveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
134                        ArchiveError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
135                        ArchiveError::Unknown(ref s) => return write!(f, "{}", s),
136                        ArchiveError::Client(ref inner) => return write!(f, "{}", inner),
137                    };
138        write!(f, "{}", d)
139    }
140}
141
142impl<E: Error + 'static> Error for ArchiveError<E> {
143    fn source(&self) -> Option<&(dyn Error + 'static)> {
144        match *self {
145            ArchiveError::MalformedResponse(_, ref e) => Some(e),
146            ArchiveError::Client(ref inner) => Some(inner),
147            _ => None,
148        }
149    }
150}
151
152#[derive(Clone, Default, Debug)]
153pub struct CloseRequest<'a> {
154    /// Private channel to close.
155    pub channel: &'a str,
156}
157
158#[derive(Clone, Debug, Deserialize)]
159pub struct CloseResponse {
160    error: Option<String>,
161    #[serde(default)]
162    ok: bool,
163}
164
165impl<E: Error> Into<Result<CloseResponse, CloseError<E>>> for CloseResponse {
166    fn into(self) -> Result<CloseResponse, CloseError<E>> {
167        if self.ok {
168            Ok(self)
169        } else {
170            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
171        }
172    }
173}
174#[derive(Debug)]
175pub enum CloseError<E: Error> {
176    /// Value passed for channel was invalid.
177    ChannelNotFound,
178    /// No authentication token provided.
179    NotAuthed,
180    /// Invalid authentication token.
181    InvalidAuth,
182    /// Authentication token is for a deleted user or team.
183    AccountInactive,
184    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
185    InvalidArgName,
186    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
187    InvalidArrayArg,
188    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
189    InvalidCharset,
190    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
191    InvalidFormData,
192    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
193    InvalidPostType,
194    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
195    MissingPostType,
196    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
197    TeamAddedToOrg,
198    /// The method was called via a POST request, but the POST data was either missing or truncated.
199    RequestTimeout,
200    /// The response was not parseable as the expected object
201    MalformedResponse(String, serde_json::error::Error),
202    /// The response returned an error that was unknown to the library
203    Unknown(String),
204    /// The client had an error sending the request to Slack
205    Client(E),
206}
207
208impl<'a, E: Error> From<&'a str> for CloseError<E> {
209    fn from(s: &'a str) -> Self {
210        match s {
211            "channel_not_found" => CloseError::ChannelNotFound,
212            "not_authed" => CloseError::NotAuthed,
213            "invalid_auth" => CloseError::InvalidAuth,
214            "account_inactive" => CloseError::AccountInactive,
215            "invalid_arg_name" => CloseError::InvalidArgName,
216            "invalid_array_arg" => CloseError::InvalidArrayArg,
217            "invalid_charset" => CloseError::InvalidCharset,
218            "invalid_form_data" => CloseError::InvalidFormData,
219            "invalid_post_type" => CloseError::InvalidPostType,
220            "missing_post_type" => CloseError::MissingPostType,
221            "team_added_to_org" => CloseError::TeamAddedToOrg,
222            "request_timeout" => CloseError::RequestTimeout,
223            _ => CloseError::Unknown(s.to_owned()),
224        }
225    }
226}
227
228impl<E: Error> fmt::Display for CloseError<E> {
229    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
230        let d = match *self {
231                        CloseError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
232CloseError::NotAuthed => "not_authed: No authentication token provided.",
233CloseError::InvalidAuth => "invalid_auth: Invalid authentication token.",
234CloseError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
235CloseError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
236CloseError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
237CloseError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
238CloseError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
239CloseError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
240CloseError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
241CloseError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
242CloseError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
243                        CloseError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
244                        CloseError::Unknown(ref s) => return write!(f, "{}", s),
245                        CloseError::Client(ref inner) => return write!(f, "{}", inner),
246                    };
247        write!(f, "{}", d)
248    }
249}
250
251impl<E: Error + 'static> Error for CloseError<E> {
252    fn source(&self) -> Option<&(dyn Error + 'static)> {
253        match *self {
254            CloseError::MalformedResponse(_, ref e) => Some(e),
255            CloseError::Client(ref inner) => Some(inner),
256            _ => None,
257        }
258    }
259}
260
261#[derive(Clone, Default, Debug)]
262pub struct CreateRequest<'a> {
263    /// Name of private channel to create
264    pub name: &'a str,
265    /// Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.
266    pub validate: Option<bool>,
267}
268
269#[derive(Clone, Debug, Deserialize)]
270pub struct CreateResponse {
271    error: Option<String>,
272    pub group: Option<crate::Group>,
273    #[serde(default)]
274    ok: bool,
275}
276
277impl<E: Error> Into<Result<CreateResponse, CreateError<E>>> for CreateResponse {
278    fn into(self) -> Result<CreateResponse, CreateError<E>> {
279        if self.ok {
280            Ok(self)
281        } else {
282            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
283        }
284    }
285}
286#[derive(Debug)]
287pub enum CreateError<E: Error> {
288    /// No group name was passed.
289    NoChannel,
290    /// A team preference prevents the authenticated user from creating groups.
291    RestrictedAction,
292    /// A group cannot be created with the given name.
293    NameTaken,
294    /// Value passed for name was empty.
295    InvalidNameRequired,
296    /// Value passed for name contained only punctuation.
297    InvalidNamePunctuation,
298    /// Value passed for name exceeded max length.
299    InvalidNameMaxlength,
300    /// Value passed for name contained unallowed special characters or upper case characters.
301    InvalidNameSpecials,
302    /// Value passed for name was invalid.
303    InvalidName,
304    /// No authentication token provided.
305    NotAuthed,
306    /// Invalid authentication token.
307    InvalidAuth,
308    /// Authentication token is for a deleted user or team.
309    AccountInactive,
310    /// This method cannot be called by a bot user.
311    UserIsBot,
312    /// This method cannot be called by a single channel guest.
313    UserIsUltraRestricted,
314    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
315    InvalidArgName,
316    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
317    InvalidArrayArg,
318    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
319    InvalidCharset,
320    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
321    InvalidFormData,
322    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
323    InvalidPostType,
324    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
325    MissingPostType,
326    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
327    TeamAddedToOrg,
328    /// The method was called via a POST request, but the POST data was either missing or truncated.
329    RequestTimeout,
330    /// The response was not parseable as the expected object
331    MalformedResponse(String, serde_json::error::Error),
332    /// The response returned an error that was unknown to the library
333    Unknown(String),
334    /// The client had an error sending the request to Slack
335    Client(E),
336}
337
338impl<'a, E: Error> From<&'a str> for CreateError<E> {
339    fn from(s: &'a str) -> Self {
340        match s {
341            "no_channel" => CreateError::NoChannel,
342            "restricted_action" => CreateError::RestrictedAction,
343            "name_taken" => CreateError::NameTaken,
344            "invalid_name_required" => CreateError::InvalidNameRequired,
345            "invalid_name_punctuation" => CreateError::InvalidNamePunctuation,
346            "invalid_name_maxlength" => CreateError::InvalidNameMaxlength,
347            "invalid_name_specials" => CreateError::InvalidNameSpecials,
348            "invalid_name" => CreateError::InvalidName,
349            "not_authed" => CreateError::NotAuthed,
350            "invalid_auth" => CreateError::InvalidAuth,
351            "account_inactive" => CreateError::AccountInactive,
352            "user_is_bot" => CreateError::UserIsBot,
353            "user_is_ultra_restricted" => CreateError::UserIsUltraRestricted,
354            "invalid_arg_name" => CreateError::InvalidArgName,
355            "invalid_array_arg" => CreateError::InvalidArrayArg,
356            "invalid_charset" => CreateError::InvalidCharset,
357            "invalid_form_data" => CreateError::InvalidFormData,
358            "invalid_post_type" => CreateError::InvalidPostType,
359            "missing_post_type" => CreateError::MissingPostType,
360            "team_added_to_org" => CreateError::TeamAddedToOrg,
361            "request_timeout" => CreateError::RequestTimeout,
362            _ => CreateError::Unknown(s.to_owned()),
363        }
364    }
365}
366
367impl<E: Error> fmt::Display for CreateError<E> {
368    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
369        let d = match *self {
370                        CreateError::NoChannel => "no_channel: No group name was passed.",
371CreateError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from creating groups.",
372CreateError::NameTaken => "name_taken: A group cannot be created with the given name.",
373CreateError::InvalidNameRequired => "invalid_name_required: Value passed for name was empty.",
374CreateError::InvalidNamePunctuation => "invalid_name_punctuation: Value passed for name contained only punctuation.",
375CreateError::InvalidNameMaxlength => "invalid_name_maxlength: Value passed for name exceeded max length.",
376CreateError::InvalidNameSpecials => "invalid_name_specials: Value passed for name contained unallowed special characters or upper case characters.",
377CreateError::InvalidName => "invalid_name: Value passed for name was invalid.",
378CreateError::NotAuthed => "not_authed: No authentication token provided.",
379CreateError::InvalidAuth => "invalid_auth: Invalid authentication token.",
380CreateError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
381CreateError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
382CreateError::UserIsUltraRestricted => "user_is_ultra_restricted: This method cannot be called by a single channel guest.",
383CreateError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
384CreateError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
385CreateError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
386CreateError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
387CreateError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
388CreateError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
389CreateError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
390CreateError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
391                        CreateError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
392                        CreateError::Unknown(ref s) => return write!(f, "{}", s),
393                        CreateError::Client(ref inner) => return write!(f, "{}", inner),
394                    };
395        write!(f, "{}", d)
396    }
397}
398
399impl<E: Error + 'static> Error for CreateError<E> {
400    fn source(&self) -> Option<&(dyn Error + 'static)> {
401        match *self {
402            CreateError::MalformedResponse(_, ref e) => Some(e),
403            CreateError::Client(ref inner) => Some(inner),
404            _ => None,
405        }
406    }
407}
408
409#[derive(Clone, Default, Debug)]
410pub struct CreateChildRequest<'a> {
411    /// Private channel to clone and archive.
412    pub channel: &'a str,
413}
414
415#[derive(Clone, Debug, Deserialize)]
416pub struct CreateChildResponse {
417    error: Option<String>,
418    pub group: Option<crate::Group>,
419    #[serde(default)]
420    ok: bool,
421}
422
423impl<E: Error> Into<Result<CreateChildResponse, CreateChildError<E>>> for CreateChildResponse {
424    fn into(self) -> Result<CreateChildResponse, CreateChildError<E>> {
425        if self.ok {
426            Ok(self)
427        } else {
428            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
429        }
430    }
431}
432#[derive(Debug)]
433pub enum CreateChildError<E: Error> {
434    /// Value passed for channel was invalid.
435    ChannelNotFound,
436    /// An archived group cannot be cloned
437    AlreadyArchived,
438    /// A team preference prevents the authenticated user from creating groups.
439    RestrictedAction,
440    /// No authentication token provided.
441    NotAuthed,
442    /// Invalid authentication token.
443    InvalidAuth,
444    /// Authentication token is for a deleted user or team.
445    AccountInactive,
446    /// This method cannot be called by a bot user.
447    UserIsBot,
448    /// This method cannot be called by a single channel guest.
449    UserIsUltraRestricted,
450    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
451    InvalidArgName,
452    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
453    InvalidArrayArg,
454    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
455    InvalidCharset,
456    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
457    InvalidFormData,
458    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
459    InvalidPostType,
460    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
461    MissingPostType,
462    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
463    TeamAddedToOrg,
464    /// The method was called via a POST request, but the POST data was either missing or truncated.
465    RequestTimeout,
466    /// The response was not parseable as the expected object
467    MalformedResponse(String, serde_json::error::Error),
468    /// The response returned an error that was unknown to the library
469    Unknown(String),
470    /// The client had an error sending the request to Slack
471    Client(E),
472}
473
474impl<'a, E: Error> From<&'a str> for CreateChildError<E> {
475    fn from(s: &'a str) -> Self {
476        match s {
477            "channel_not_found" => CreateChildError::ChannelNotFound,
478            "already_archived" => CreateChildError::AlreadyArchived,
479            "restricted_action" => CreateChildError::RestrictedAction,
480            "not_authed" => CreateChildError::NotAuthed,
481            "invalid_auth" => CreateChildError::InvalidAuth,
482            "account_inactive" => CreateChildError::AccountInactive,
483            "user_is_bot" => CreateChildError::UserIsBot,
484            "user_is_ultra_restricted" => CreateChildError::UserIsUltraRestricted,
485            "invalid_arg_name" => CreateChildError::InvalidArgName,
486            "invalid_array_arg" => CreateChildError::InvalidArrayArg,
487            "invalid_charset" => CreateChildError::InvalidCharset,
488            "invalid_form_data" => CreateChildError::InvalidFormData,
489            "invalid_post_type" => CreateChildError::InvalidPostType,
490            "missing_post_type" => CreateChildError::MissingPostType,
491            "team_added_to_org" => CreateChildError::TeamAddedToOrg,
492            "request_timeout" => CreateChildError::RequestTimeout,
493            _ => CreateChildError::Unknown(s.to_owned()),
494        }
495    }
496}
497
498impl<E: Error> fmt::Display for CreateChildError<E> {
499    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
500        let d = match *self {
501                        CreateChildError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
502CreateChildError::AlreadyArchived => "already_archived: An archived group cannot be cloned",
503CreateChildError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from creating groups.",
504CreateChildError::NotAuthed => "not_authed: No authentication token provided.",
505CreateChildError::InvalidAuth => "invalid_auth: Invalid authentication token.",
506CreateChildError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
507CreateChildError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
508CreateChildError::UserIsUltraRestricted => "user_is_ultra_restricted: This method cannot be called by a single channel guest.",
509CreateChildError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
510CreateChildError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
511CreateChildError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
512CreateChildError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
513CreateChildError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
514CreateChildError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
515CreateChildError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
516CreateChildError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
517                        CreateChildError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
518                        CreateChildError::Unknown(ref s) => return write!(f, "{}", s),
519                        CreateChildError::Client(ref inner) => return write!(f, "{}", inner),
520                    };
521        write!(f, "{}", d)
522    }
523}
524
525impl<E: Error + 'static> Error for CreateChildError<E> {
526    fn source(&self) -> Option<&(dyn Error + 'static)> {
527        match *self {
528            CreateChildError::MalformedResponse(_, ref e) => Some(e),
529            CreateChildError::Client(ref inner) => Some(inner),
530            _ => None,
531        }
532    }
533}
534
535#[derive(Clone, Default, Debug)]
536pub struct HistoryRequest<'a> {
537    /// Private channel to fetch history for.
538    pub channel: &'a str,
539    /// End of time range of messages to include in results.
540    pub latest: Option<crate::Timestamp>,
541    /// Start of time range of messages to include in results.
542    pub oldest: Option<crate::Timestamp>,
543    /// Include messages with latest or oldest timestamp in results.
544    pub inclusive: Option<bool>,
545    /// Number of messages to return, between 1 and 1000.
546    pub count: Option<u32>,
547    /// Include unread_count_display in the output?
548    pub unreads: Option<bool>,
549}
550
551#[derive(Clone, Debug, Deserialize)]
552pub struct HistoryResponse {
553    error: Option<String>,
554    pub has_more: Option<bool>,
555    pub latest: Option<String>,
556    pub messages: Option<Vec<crate::Message>>,
557    #[serde(default)]
558    ok: bool,
559}
560
561impl<E: Error> Into<Result<HistoryResponse, HistoryError<E>>> for HistoryResponse {
562    fn into(self) -> Result<HistoryResponse, HistoryError<E>> {
563        if self.ok {
564            Ok(self)
565        } else {
566            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
567        }
568    }
569}
570#[derive(Debug)]
571pub enum HistoryError<E: Error> {
572    /// Value passed for channel was invalid.
573    ChannelNotFound,
574    /// Value passed for latest was invalid
575    InvalidTsLatest,
576    /// Value passed for oldest was invalid
577    InvalidTsOldest,
578    /// No authentication token provided.
579    NotAuthed,
580    /// Invalid authentication token.
581    InvalidAuth,
582    /// Authentication token is for a deleted user or team.
583    AccountInactive,
584    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
585    InvalidArgName,
586    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
587    InvalidArrayArg,
588    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
589    InvalidCharset,
590    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
591    InvalidFormData,
592    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
593    InvalidPostType,
594    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
595    MissingPostType,
596    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
597    TeamAddedToOrg,
598    /// The method was called via a POST request, but the POST data was either missing or truncated.
599    RequestTimeout,
600    /// The response was not parseable as the expected object
601    MalformedResponse(String, serde_json::error::Error),
602    /// The response returned an error that was unknown to the library
603    Unknown(String),
604    /// The client had an error sending the request to Slack
605    Client(E),
606}
607
608impl<'a, E: Error> From<&'a str> for HistoryError<E> {
609    fn from(s: &'a str) -> Self {
610        match s {
611            "channel_not_found" => HistoryError::ChannelNotFound,
612            "invalid_ts_latest" => HistoryError::InvalidTsLatest,
613            "invalid_ts_oldest" => HistoryError::InvalidTsOldest,
614            "not_authed" => HistoryError::NotAuthed,
615            "invalid_auth" => HistoryError::InvalidAuth,
616            "account_inactive" => HistoryError::AccountInactive,
617            "invalid_arg_name" => HistoryError::InvalidArgName,
618            "invalid_array_arg" => HistoryError::InvalidArrayArg,
619            "invalid_charset" => HistoryError::InvalidCharset,
620            "invalid_form_data" => HistoryError::InvalidFormData,
621            "invalid_post_type" => HistoryError::InvalidPostType,
622            "missing_post_type" => HistoryError::MissingPostType,
623            "team_added_to_org" => HistoryError::TeamAddedToOrg,
624            "request_timeout" => HistoryError::RequestTimeout,
625            _ => HistoryError::Unknown(s.to_owned()),
626        }
627    }
628}
629
630impl<E: Error> fmt::Display for HistoryError<E> {
631    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
632        let d = match *self {
633                        HistoryError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
634HistoryError::InvalidTsLatest => "invalid_ts_latest: Value passed for latest was invalid",
635HistoryError::InvalidTsOldest => "invalid_ts_oldest: Value passed for oldest was invalid",
636HistoryError::NotAuthed => "not_authed: No authentication token provided.",
637HistoryError::InvalidAuth => "invalid_auth: Invalid authentication token.",
638HistoryError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
639HistoryError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
640HistoryError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
641HistoryError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
642HistoryError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
643HistoryError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
644HistoryError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
645HistoryError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
646HistoryError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
647                        HistoryError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
648                        HistoryError::Unknown(ref s) => return write!(f, "{}", s),
649                        HistoryError::Client(ref inner) => return write!(f, "{}", inner),
650                    };
651        write!(f, "{}", d)
652    }
653}
654
655impl<E: Error + 'static> Error for HistoryError<E> {
656    fn source(&self) -> Option<&(dyn Error + 'static)> {
657        match *self {
658            HistoryError::MalformedResponse(_, ref e) => Some(e),
659            HistoryError::Client(ref inner) => Some(inner),
660            _ => None,
661        }
662    }
663}
664
665#[derive(Clone, Default, Debug)]
666pub struct InfoRequest<'a> {
667    /// Private channel to get info on
668    pub channel: &'a str,
669}
670
671#[derive(Clone, Debug, Deserialize)]
672pub struct InfoResponse {
673    error: Option<String>,
674    pub group: Option<crate::Group>,
675    #[serde(default)]
676    ok: bool,
677}
678
679impl<E: Error> Into<Result<InfoResponse, InfoError<E>>> for InfoResponse {
680    fn into(self) -> Result<InfoResponse, InfoError<E>> {
681        if self.ok {
682            Ok(self)
683        } else {
684            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
685        }
686    }
687}
688#[derive(Debug)]
689pub enum InfoError<E: Error> {
690    /// Value passed for channel was invalid.
691    ChannelNotFound,
692    /// No authentication token provided.
693    NotAuthed,
694    /// Invalid authentication token.
695    InvalidAuth,
696    /// Authentication token is for a deleted user or team.
697    AccountInactive,
698    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
699    InvalidArgName,
700    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
701    InvalidArrayArg,
702    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
703    InvalidCharset,
704    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
705    InvalidFormData,
706    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
707    InvalidPostType,
708    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
709    MissingPostType,
710    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
711    TeamAddedToOrg,
712    /// The method was called via a POST request, but the POST data was either missing or truncated.
713    RequestTimeout,
714    /// The response was not parseable as the expected object
715    MalformedResponse(String, serde_json::error::Error),
716    /// The response returned an error that was unknown to the library
717    Unknown(String),
718    /// The client had an error sending the request to Slack
719    Client(E),
720}
721
722impl<'a, E: Error> From<&'a str> for InfoError<E> {
723    fn from(s: &'a str) -> Self {
724        match s {
725            "channel_not_found" => InfoError::ChannelNotFound,
726            "not_authed" => InfoError::NotAuthed,
727            "invalid_auth" => InfoError::InvalidAuth,
728            "account_inactive" => InfoError::AccountInactive,
729            "invalid_arg_name" => InfoError::InvalidArgName,
730            "invalid_array_arg" => InfoError::InvalidArrayArg,
731            "invalid_charset" => InfoError::InvalidCharset,
732            "invalid_form_data" => InfoError::InvalidFormData,
733            "invalid_post_type" => InfoError::InvalidPostType,
734            "missing_post_type" => InfoError::MissingPostType,
735            "team_added_to_org" => InfoError::TeamAddedToOrg,
736            "request_timeout" => InfoError::RequestTimeout,
737            _ => InfoError::Unknown(s.to_owned()),
738        }
739    }
740}
741
742impl<E: Error> fmt::Display for InfoError<E> {
743    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
744        let d = match *self {
745                        InfoError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
746InfoError::NotAuthed => "not_authed: No authentication token provided.",
747InfoError::InvalidAuth => "invalid_auth: Invalid authentication token.",
748InfoError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
749InfoError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
750InfoError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
751InfoError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
752InfoError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
753InfoError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
754InfoError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
755InfoError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
756InfoError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
757                        InfoError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
758                        InfoError::Unknown(ref s) => return write!(f, "{}", s),
759                        InfoError::Client(ref inner) => return write!(f, "{}", inner),
760                    };
761        write!(f, "{}", d)
762    }
763}
764
765impl<E: Error + 'static> Error for InfoError<E> {
766    fn source(&self) -> Option<&(dyn Error + 'static)> {
767        match *self {
768            InfoError::MalformedResponse(_, ref e) => Some(e),
769            InfoError::Client(ref inner) => Some(inner),
770            _ => None,
771        }
772    }
773}
774
775#[derive(Clone, Default, Debug)]
776pub struct InviteRequest<'a> {
777    /// Private channel to invite user to.
778    pub channel: &'a str,
779    /// User to invite.
780    pub user: &'a str,
781}
782
783#[derive(Clone, Debug, Deserialize)]
784pub struct InviteResponse {
785    error: Option<String>,
786    pub group: Option<crate::Group>,
787    #[serde(default)]
788    ok: bool,
789}
790
791impl<E: Error> Into<Result<InviteResponse, InviteError<E>>> for InviteResponse {
792    fn into(self) -> Result<InviteResponse, InviteError<E>> {
793        if self.ok {
794            Ok(self)
795        } else {
796            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
797        }
798    }
799}
800#[derive(Debug)]
801pub enum InviteError<E: Error> {
802    /// Value passed for channel was invalid.
803    ChannelNotFound,
804    /// Value passed for user was invalid.
805    UserNotFound,
806    /// Authenticated user cannot invite themselves to a group.
807    CantInviteSelf,
808    /// Group has been archived.
809    IsArchived,
810    /// User cannot be invited to this group.
811    CantInvite,
812    /// URA is already in the maximum number of channels.
813    UraMaxChannels,
814    /// No authentication token provided.
815    NotAuthed,
816    /// Invalid authentication token.
817    InvalidAuth,
818    /// Authentication token is for a deleted user or team.
819    AccountInactive,
820    /// This method cannot be called by a bot user.
821    UserIsBot,
822    /// This method cannot be called by a single channel guest.
823    UserIsUltraRestricted,
824    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
825    InvalidArgName,
826    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
827    InvalidArrayArg,
828    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
829    InvalidCharset,
830    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
831    InvalidFormData,
832    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
833    InvalidPostType,
834    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
835    MissingPostType,
836    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
837    TeamAddedToOrg,
838    /// The method was called via a POST request, but the POST data was either missing or truncated.
839    RequestTimeout,
840    /// The response was not parseable as the expected object
841    MalformedResponse(String, serde_json::error::Error),
842    /// The response returned an error that was unknown to the library
843    Unknown(String),
844    /// The client had an error sending the request to Slack
845    Client(E),
846}
847
848impl<'a, E: Error> From<&'a str> for InviteError<E> {
849    fn from(s: &'a str) -> Self {
850        match s {
851            "channel_not_found" => InviteError::ChannelNotFound,
852            "user_not_found" => InviteError::UserNotFound,
853            "cant_invite_self" => InviteError::CantInviteSelf,
854            "is_archived" => InviteError::IsArchived,
855            "cant_invite" => InviteError::CantInvite,
856            "ura_max_channels" => InviteError::UraMaxChannels,
857            "not_authed" => InviteError::NotAuthed,
858            "invalid_auth" => InviteError::InvalidAuth,
859            "account_inactive" => InviteError::AccountInactive,
860            "user_is_bot" => InviteError::UserIsBot,
861            "user_is_ultra_restricted" => InviteError::UserIsUltraRestricted,
862            "invalid_arg_name" => InviteError::InvalidArgName,
863            "invalid_array_arg" => InviteError::InvalidArrayArg,
864            "invalid_charset" => InviteError::InvalidCharset,
865            "invalid_form_data" => InviteError::InvalidFormData,
866            "invalid_post_type" => InviteError::InvalidPostType,
867            "missing_post_type" => InviteError::MissingPostType,
868            "team_added_to_org" => InviteError::TeamAddedToOrg,
869            "request_timeout" => InviteError::RequestTimeout,
870            _ => InviteError::Unknown(s.to_owned()),
871        }
872    }
873}
874
875impl<E: Error> fmt::Display for InviteError<E> {
876    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
877        let d = match *self {
878                        InviteError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
879InviteError::UserNotFound => "user_not_found: Value passed for user was invalid.",
880InviteError::CantInviteSelf => "cant_invite_self: Authenticated user cannot invite themselves to a group.",
881InviteError::IsArchived => "is_archived: Group has been archived.",
882InviteError::CantInvite => "cant_invite: User cannot be invited to this group.",
883InviteError::UraMaxChannels => "ura_max_channels: URA is already in the maximum number of channels.",
884InviteError::NotAuthed => "not_authed: No authentication token provided.",
885InviteError::InvalidAuth => "invalid_auth: Invalid authentication token.",
886InviteError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
887InviteError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
888InviteError::UserIsUltraRestricted => "user_is_ultra_restricted: This method cannot be called by a single channel guest.",
889InviteError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
890InviteError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
891InviteError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
892InviteError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
893InviteError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
894InviteError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
895InviteError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
896InviteError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
897                        InviteError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
898                        InviteError::Unknown(ref s) => return write!(f, "{}", s),
899                        InviteError::Client(ref inner) => return write!(f, "{}", inner),
900                    };
901        write!(f, "{}", d)
902    }
903}
904
905impl<E: Error + 'static> Error for InviteError<E> {
906    fn source(&self) -> Option<&(dyn Error + 'static)> {
907        match *self {
908            InviteError::MalformedResponse(_, ref e) => Some(e),
909            InviteError::Client(ref inner) => Some(inner),
910            _ => None,
911        }
912    }
913}
914
915#[derive(Clone, Default, Debug)]
916pub struct KickRequest<'a> {
917    /// Private channel to remove user from.
918    pub channel: &'a str,
919    /// User to remove from private channel.
920    pub user: &'a str,
921}
922
923#[derive(Clone, Debug, Deserialize)]
924pub struct KickResponse {
925    error: Option<String>,
926    #[serde(default)]
927    ok: bool,
928}
929
930impl<E: Error> Into<Result<KickResponse, KickError<E>>> for KickResponse {
931    fn into(self) -> Result<KickResponse, KickError<E>> {
932        if self.ok {
933            Ok(self)
934        } else {
935            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
936        }
937    }
938}
939#[derive(Debug)]
940pub enum KickError<E: Error> {
941    /// Value passed for channel was invalid.
942    ChannelNotFound,
943    /// Value passed for user was invalid.
944    UserNotFound,
945    /// You can't remove yourself from a group
946    CantKickSelf,
947    /// User or caller were are not in the group
948    NotInGroup,
949    /// A team preference prevents the authenticated user from kicking.
950    RestrictedAction,
951    /// No authentication token provided.
952    NotAuthed,
953    /// Invalid authentication token.
954    InvalidAuth,
955    /// Authentication token is for a deleted user or team.
956    AccountInactive,
957    /// This method cannot be called by a bot user.
958    UserIsBot,
959    /// This method cannot be called by a restricted user or single channel guest.
960    UserIsRestricted,
961    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
962    InvalidArgName,
963    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
964    InvalidArrayArg,
965    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
966    InvalidCharset,
967    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
968    InvalidFormData,
969    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
970    InvalidPostType,
971    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
972    MissingPostType,
973    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
974    TeamAddedToOrg,
975    /// The method was called via a POST request, but the POST data was either missing or truncated.
976    RequestTimeout,
977    /// The response was not parseable as the expected object
978    MalformedResponse(String, serde_json::error::Error),
979    /// The response returned an error that was unknown to the library
980    Unknown(String),
981    /// The client had an error sending the request to Slack
982    Client(E),
983}
984
985impl<'a, E: Error> From<&'a str> for KickError<E> {
986    fn from(s: &'a str) -> Self {
987        match s {
988            "channel_not_found" => KickError::ChannelNotFound,
989            "user_not_found" => KickError::UserNotFound,
990            "cant_kick_self" => KickError::CantKickSelf,
991            "not_in_group" => KickError::NotInGroup,
992            "restricted_action" => KickError::RestrictedAction,
993            "not_authed" => KickError::NotAuthed,
994            "invalid_auth" => KickError::InvalidAuth,
995            "account_inactive" => KickError::AccountInactive,
996            "user_is_bot" => KickError::UserIsBot,
997            "user_is_restricted" => KickError::UserIsRestricted,
998            "invalid_arg_name" => KickError::InvalidArgName,
999            "invalid_array_arg" => KickError::InvalidArrayArg,
1000            "invalid_charset" => KickError::InvalidCharset,
1001            "invalid_form_data" => KickError::InvalidFormData,
1002            "invalid_post_type" => KickError::InvalidPostType,
1003            "missing_post_type" => KickError::MissingPostType,
1004            "team_added_to_org" => KickError::TeamAddedToOrg,
1005            "request_timeout" => KickError::RequestTimeout,
1006            _ => KickError::Unknown(s.to_owned()),
1007        }
1008    }
1009}
1010
1011impl<E: Error> fmt::Display for KickError<E> {
1012    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1013        let d = match *self {
1014                        KickError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
1015KickError::UserNotFound => "user_not_found: Value passed for user was invalid.",
1016KickError::CantKickSelf => "cant_kick_self: You can't remove yourself from a group",
1017KickError::NotInGroup => "not_in_group: User or caller were are not in the group",
1018KickError::RestrictedAction => "restricted_action: A team preference prevents the authenticated user from kicking.",
1019KickError::NotAuthed => "not_authed: No authentication token provided.",
1020KickError::InvalidAuth => "invalid_auth: Invalid authentication token.",
1021KickError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
1022KickError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
1023KickError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.",
1024KickError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
1025KickError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
1026KickError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
1027KickError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
1028KickError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
1029KickError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
1030KickError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
1031KickError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
1032                        KickError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
1033                        KickError::Unknown(ref s) => return write!(f, "{}", s),
1034                        KickError::Client(ref inner) => return write!(f, "{}", inner),
1035                    };
1036        write!(f, "{}", d)
1037    }
1038}
1039
1040impl<E: Error + 'static> Error for KickError<E> {
1041    fn source(&self) -> Option<&(dyn Error + 'static)> {
1042        match *self {
1043            KickError::MalformedResponse(_, ref e) => Some(e),
1044            KickError::Client(ref inner) => Some(inner),
1045            _ => None,
1046        }
1047    }
1048}
1049
1050#[derive(Clone, Default, Debug)]
1051pub struct LeaveRequest<'a> {
1052    /// Private channel to leave
1053    pub channel: &'a str,
1054}
1055
1056#[derive(Clone, Debug, Deserialize)]
1057pub struct LeaveResponse {
1058    error: Option<String>,
1059    #[serde(default)]
1060    ok: bool,
1061}
1062
1063impl<E: Error> Into<Result<LeaveResponse, LeaveError<E>>> for LeaveResponse {
1064    fn into(self) -> Result<LeaveResponse, LeaveError<E>> {
1065        if self.ok {
1066            Ok(self)
1067        } else {
1068            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
1069        }
1070    }
1071}
1072#[derive(Debug)]
1073pub enum LeaveError<E: Error> {
1074    /// Value passed for channel was invalid.
1075    ChannelNotFound,
1076    /// Group has been archived.
1077    IsArchived,
1078    /// No authentication token provided.
1079    NotAuthed,
1080    /// Invalid authentication token.
1081    InvalidAuth,
1082    /// Authentication token is for a deleted user or team.
1083    AccountInactive,
1084    /// This method cannot be called by a bot user.
1085    UserIsBot,
1086    /// This method cannot be called by a single channel guest.
1087    UserIsUltraRestricted,
1088    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
1089    InvalidArgName,
1090    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
1091    InvalidArrayArg,
1092    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
1093    InvalidCharset,
1094    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
1095    InvalidFormData,
1096    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
1097    InvalidPostType,
1098    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
1099    MissingPostType,
1100    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
1101    TeamAddedToOrg,
1102    /// The method was called via a POST request, but the POST data was either missing or truncated.
1103    RequestTimeout,
1104    /// The response was not parseable as the expected object
1105    MalformedResponse(String, serde_json::error::Error),
1106    /// The response returned an error that was unknown to the library
1107    Unknown(String),
1108    /// The client had an error sending the request to Slack
1109    Client(E),
1110}
1111
1112impl<'a, E: Error> From<&'a str> for LeaveError<E> {
1113    fn from(s: &'a str) -> Self {
1114        match s {
1115            "channel_not_found" => LeaveError::ChannelNotFound,
1116            "is_archived" => LeaveError::IsArchived,
1117            "not_authed" => LeaveError::NotAuthed,
1118            "invalid_auth" => LeaveError::InvalidAuth,
1119            "account_inactive" => LeaveError::AccountInactive,
1120            "user_is_bot" => LeaveError::UserIsBot,
1121            "user_is_ultra_restricted" => LeaveError::UserIsUltraRestricted,
1122            "invalid_arg_name" => LeaveError::InvalidArgName,
1123            "invalid_array_arg" => LeaveError::InvalidArrayArg,
1124            "invalid_charset" => LeaveError::InvalidCharset,
1125            "invalid_form_data" => LeaveError::InvalidFormData,
1126            "invalid_post_type" => LeaveError::InvalidPostType,
1127            "missing_post_type" => LeaveError::MissingPostType,
1128            "team_added_to_org" => LeaveError::TeamAddedToOrg,
1129            "request_timeout" => LeaveError::RequestTimeout,
1130            _ => LeaveError::Unknown(s.to_owned()),
1131        }
1132    }
1133}
1134
1135impl<E: Error> fmt::Display for LeaveError<E> {
1136    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1137        let d = match *self {
1138                        LeaveError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
1139LeaveError::IsArchived => "is_archived: Group has been archived.",
1140LeaveError::NotAuthed => "not_authed: No authentication token provided.",
1141LeaveError::InvalidAuth => "invalid_auth: Invalid authentication token.",
1142LeaveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
1143LeaveError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
1144LeaveError::UserIsUltraRestricted => "user_is_ultra_restricted: This method cannot be called by a single channel guest.",
1145LeaveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
1146LeaveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
1147LeaveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
1148LeaveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
1149LeaveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
1150LeaveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
1151LeaveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
1152LeaveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
1153                        LeaveError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
1154                        LeaveError::Unknown(ref s) => return write!(f, "{}", s),
1155                        LeaveError::Client(ref inner) => return write!(f, "{}", inner),
1156                    };
1157        write!(f, "{}", d)
1158    }
1159}
1160
1161impl<E: Error + 'static> Error for LeaveError<E> {
1162    fn source(&self) -> Option<&(dyn Error + 'static)> {
1163        match *self {
1164            LeaveError::MalformedResponse(_, ref e) => Some(e),
1165            LeaveError::Client(ref inner) => Some(inner),
1166            _ => None,
1167        }
1168    }
1169}
1170
1171#[derive(Clone, Default, Debug)]
1172pub struct ListRequest {
1173    /// Don't return archived private channels.
1174    pub exclude_archived: Option<bool>,
1175}
1176
1177#[derive(Clone, Debug, Deserialize)]
1178pub struct ListResponse {
1179    error: Option<String>,
1180    pub groups: Option<Vec<crate::Group>>,
1181    #[serde(default)]
1182    ok: bool,
1183}
1184
1185impl<E: Error> Into<Result<ListResponse, ListError<E>>> for ListResponse {
1186    fn into(self) -> Result<ListResponse, ListError<E>> {
1187        if self.ok {
1188            Ok(self)
1189        } else {
1190            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
1191        }
1192    }
1193}
1194#[derive(Debug)]
1195pub enum ListError<E: Error> {
1196    /// No authentication token provided.
1197    NotAuthed,
1198    /// Invalid authentication token.
1199    InvalidAuth,
1200    /// Authentication token is for a deleted user or team.
1201    AccountInactive,
1202    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
1203    InvalidArgName,
1204    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
1205    InvalidArrayArg,
1206    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
1207    InvalidCharset,
1208    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
1209    InvalidFormData,
1210    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
1211    InvalidPostType,
1212    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
1213    MissingPostType,
1214    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
1215    TeamAddedToOrg,
1216    /// The method was called via a POST request, but the POST data was either missing or truncated.
1217    RequestTimeout,
1218    /// The response was not parseable as the expected object
1219    MalformedResponse(String, serde_json::error::Error),
1220    /// The response returned an error that was unknown to the library
1221    Unknown(String),
1222    /// The client had an error sending the request to Slack
1223    Client(E),
1224}
1225
1226impl<'a, E: Error> From<&'a str> for ListError<E> {
1227    fn from(s: &'a str) -> Self {
1228        match s {
1229            "not_authed" => ListError::NotAuthed,
1230            "invalid_auth" => ListError::InvalidAuth,
1231            "account_inactive" => ListError::AccountInactive,
1232            "invalid_arg_name" => ListError::InvalidArgName,
1233            "invalid_array_arg" => ListError::InvalidArrayArg,
1234            "invalid_charset" => ListError::InvalidCharset,
1235            "invalid_form_data" => ListError::InvalidFormData,
1236            "invalid_post_type" => ListError::InvalidPostType,
1237            "missing_post_type" => ListError::MissingPostType,
1238            "team_added_to_org" => ListError::TeamAddedToOrg,
1239            "request_timeout" => ListError::RequestTimeout,
1240            _ => ListError::Unknown(s.to_owned()),
1241        }
1242    }
1243}
1244
1245impl<E: Error> fmt::Display for ListError<E> {
1246    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1247        let d = match *self {
1248                        ListError::NotAuthed => "not_authed: No authentication token provided.",
1249ListError::InvalidAuth => "invalid_auth: Invalid authentication token.",
1250ListError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
1251ListError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
1252ListError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
1253ListError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
1254ListError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
1255ListError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
1256ListError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
1257ListError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
1258ListError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
1259                        ListError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
1260                        ListError::Unknown(ref s) => return write!(f, "{}", s),
1261                        ListError::Client(ref inner) => return write!(f, "{}", inner),
1262                    };
1263        write!(f, "{}", d)
1264    }
1265}
1266
1267impl<E: Error + 'static> Error for ListError<E> {
1268    fn source(&self) -> Option<&(dyn Error + 'static)> {
1269        match *self {
1270            ListError::MalformedResponse(_, ref e) => Some(e),
1271            ListError::Client(ref inner) => Some(inner),
1272            _ => None,
1273        }
1274    }
1275}
1276
1277#[derive(Clone, Default, Debug)]
1278pub struct MarkRequest<'a> {
1279    /// Private channel to set reading cursor in.
1280    pub channel: &'a str,
1281    /// Timestamp of the most recently seen message.
1282    pub ts: crate::Timestamp,
1283}
1284
1285#[derive(Clone, Debug, Deserialize)]
1286pub struct MarkResponse {
1287    error: Option<String>,
1288    #[serde(default)]
1289    ok: bool,
1290}
1291
1292impl<E: Error> Into<Result<MarkResponse, MarkError<E>>> for MarkResponse {
1293    fn into(self) -> Result<MarkResponse, MarkError<E>> {
1294        if self.ok {
1295            Ok(self)
1296        } else {
1297            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
1298        }
1299    }
1300}
1301#[derive(Debug)]
1302pub enum MarkError<E: Error> {
1303    /// Value passed for channel was invalid.
1304    ChannelNotFound,
1305    /// Value passed for timestamp was invalid.
1306    InvalidTimestamp,
1307    /// No authentication token provided.
1308    NotAuthed,
1309    /// Invalid authentication token.
1310    InvalidAuth,
1311    /// Authentication token is for a deleted user or team.
1312    AccountInactive,
1313    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
1314    InvalidArgName,
1315    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
1316    InvalidArrayArg,
1317    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
1318    InvalidCharset,
1319    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
1320    InvalidFormData,
1321    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
1322    InvalidPostType,
1323    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
1324    MissingPostType,
1325    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
1326    TeamAddedToOrg,
1327    /// The method was called via a POST request, but the POST data was either missing or truncated.
1328    RequestTimeout,
1329    /// The response was not parseable as the expected object
1330    MalformedResponse(String, serde_json::error::Error),
1331    /// The response returned an error that was unknown to the library
1332    Unknown(String),
1333    /// The client had an error sending the request to Slack
1334    Client(E),
1335}
1336
1337impl<'a, E: Error> From<&'a str> for MarkError<E> {
1338    fn from(s: &'a str) -> Self {
1339        match s {
1340            "channel_not_found" => MarkError::ChannelNotFound,
1341            "invalid_timestamp" => MarkError::InvalidTimestamp,
1342            "not_authed" => MarkError::NotAuthed,
1343            "invalid_auth" => MarkError::InvalidAuth,
1344            "account_inactive" => MarkError::AccountInactive,
1345            "invalid_arg_name" => MarkError::InvalidArgName,
1346            "invalid_array_arg" => MarkError::InvalidArrayArg,
1347            "invalid_charset" => MarkError::InvalidCharset,
1348            "invalid_form_data" => MarkError::InvalidFormData,
1349            "invalid_post_type" => MarkError::InvalidPostType,
1350            "missing_post_type" => MarkError::MissingPostType,
1351            "team_added_to_org" => MarkError::TeamAddedToOrg,
1352            "request_timeout" => MarkError::RequestTimeout,
1353            _ => MarkError::Unknown(s.to_owned()),
1354        }
1355    }
1356}
1357
1358impl<E: Error> fmt::Display for MarkError<E> {
1359    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1360        let d = match *self {
1361                        MarkError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
1362MarkError::InvalidTimestamp => "invalid_timestamp: Value passed for timestamp was invalid.",
1363MarkError::NotAuthed => "not_authed: No authentication token provided.",
1364MarkError::InvalidAuth => "invalid_auth: Invalid authentication token.",
1365MarkError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
1366MarkError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
1367MarkError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
1368MarkError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
1369MarkError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
1370MarkError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
1371MarkError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
1372MarkError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
1373MarkError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
1374                        MarkError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
1375                        MarkError::Unknown(ref s) => return write!(f, "{}", s),
1376                        MarkError::Client(ref inner) => return write!(f, "{}", inner),
1377                    };
1378        write!(f, "{}", d)
1379    }
1380}
1381
1382impl<E: Error + 'static> Error for MarkError<E> {
1383    fn source(&self) -> Option<&(dyn Error + 'static)> {
1384        match *self {
1385            MarkError::MalformedResponse(_, ref e) => Some(e),
1386            MarkError::Client(ref inner) => Some(inner),
1387            _ => None,
1388        }
1389    }
1390}
1391
1392#[derive(Clone, Default, Debug)]
1393pub struct OpenRequest<'a> {
1394    /// Private channel to open.
1395    pub channel: &'a str,
1396}
1397
1398#[derive(Clone, Debug, Deserialize)]
1399pub struct OpenResponse {
1400    error: Option<String>,
1401    #[serde(default)]
1402    ok: bool,
1403}
1404
1405impl<E: Error> Into<Result<OpenResponse, OpenError<E>>> for OpenResponse {
1406    fn into(self) -> Result<OpenResponse, OpenError<E>> {
1407        if self.ok {
1408            Ok(self)
1409        } else {
1410            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
1411        }
1412    }
1413}
1414#[derive(Debug)]
1415pub enum OpenError<E: Error> {
1416    /// Value passed for channel was invalid.
1417    ChannelNotFound,
1418    /// No authentication token provided.
1419    NotAuthed,
1420    /// Invalid authentication token.
1421    InvalidAuth,
1422    /// Authentication token is for a deleted user or team.
1423    AccountInactive,
1424    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
1425    InvalidArgName,
1426    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
1427    InvalidArrayArg,
1428    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
1429    InvalidCharset,
1430    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
1431    InvalidFormData,
1432    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
1433    InvalidPostType,
1434    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
1435    MissingPostType,
1436    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
1437    TeamAddedToOrg,
1438    /// The method was called via a POST request, but the POST data was either missing or truncated.
1439    RequestTimeout,
1440    /// The response was not parseable as the expected object
1441    MalformedResponse(String, serde_json::error::Error),
1442    /// The response returned an error that was unknown to the library
1443    Unknown(String),
1444    /// The client had an error sending the request to Slack
1445    Client(E),
1446}
1447
1448impl<'a, E: Error> From<&'a str> for OpenError<E> {
1449    fn from(s: &'a str) -> Self {
1450        match s {
1451            "channel_not_found" => OpenError::ChannelNotFound,
1452            "not_authed" => OpenError::NotAuthed,
1453            "invalid_auth" => OpenError::InvalidAuth,
1454            "account_inactive" => OpenError::AccountInactive,
1455            "invalid_arg_name" => OpenError::InvalidArgName,
1456            "invalid_array_arg" => OpenError::InvalidArrayArg,
1457            "invalid_charset" => OpenError::InvalidCharset,
1458            "invalid_form_data" => OpenError::InvalidFormData,
1459            "invalid_post_type" => OpenError::InvalidPostType,
1460            "missing_post_type" => OpenError::MissingPostType,
1461            "team_added_to_org" => OpenError::TeamAddedToOrg,
1462            "request_timeout" => OpenError::RequestTimeout,
1463            _ => OpenError::Unknown(s.to_owned()),
1464        }
1465    }
1466}
1467
1468impl<E: Error> fmt::Display for OpenError<E> {
1469    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1470        let d = match *self {
1471                        OpenError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
1472OpenError::NotAuthed => "not_authed: No authentication token provided.",
1473OpenError::InvalidAuth => "invalid_auth: Invalid authentication token.",
1474OpenError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
1475OpenError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
1476OpenError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
1477OpenError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
1478OpenError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
1479OpenError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
1480OpenError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
1481OpenError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
1482OpenError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
1483                        OpenError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
1484                        OpenError::Unknown(ref s) => return write!(f, "{}", s),
1485                        OpenError::Client(ref inner) => return write!(f, "{}", inner),
1486                    };
1487        write!(f, "{}", d)
1488    }
1489}
1490
1491impl<E: Error + 'static> Error for OpenError<E> {
1492    fn source(&self) -> Option<&(dyn Error + 'static)> {
1493        match *self {
1494            OpenError::MalformedResponse(_, ref e) => Some(e),
1495            OpenError::Client(ref inner) => Some(inner),
1496            _ => None,
1497        }
1498    }
1499}
1500
1501#[derive(Clone, Default, Debug)]
1502pub struct RenameRequest<'a> {
1503    /// Private channel to rename
1504    pub channel: &'a str,
1505    /// New name for private channel.
1506    pub name: &'a str,
1507    /// Whether to return errors on invalid channel name instead of modifying it to meet the specified criteria.
1508    pub validate: Option<bool>,
1509}
1510
1511#[derive(Clone, Debug, Deserialize)]
1512pub struct RenameResponse {
1513    pub channel: Option<RenameResponseChannel>,
1514    error: Option<String>,
1515    #[serde(default)]
1516    ok: bool,
1517}
1518
1519#[derive(Clone, Debug, Deserialize)]
1520pub struct RenameResponseChannel {
1521    pub created: Option<f32>,
1522    pub id: Option<String>,
1523    pub is_group: Option<bool>,
1524    pub name: Option<String>,
1525}
1526
1527impl<E: Error> Into<Result<RenameResponse, RenameError<E>>> for RenameResponse {
1528    fn into(self) -> Result<RenameResponse, RenameError<E>> {
1529        if self.ok {
1530            Ok(self)
1531        } else {
1532            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
1533        }
1534    }
1535}
1536#[derive(Debug)]
1537pub enum RenameError<E: Error> {
1538    /// Value passed for channel was invalid.
1539    ChannelNotFound,
1540    /// Value passed for name was invalid.
1541    InvalidName,
1542    /// New channel name is taken
1543    NameTaken,
1544    /// Value passed for name was empty.
1545    InvalidNameRequired,
1546    /// Value passed for name contained only punctuation.
1547    InvalidNamePunctuation,
1548    /// Value passed for name exceeded max length.
1549    InvalidNameMaxlength,
1550    /// Value passed for name contained unallowed special characters or upper case characters.
1551    InvalidNameSpecials,
1552    /// No authentication token provided.
1553    NotAuthed,
1554    /// Invalid authentication token.
1555    InvalidAuth,
1556    /// Authentication token is for a deleted user or team.
1557    AccountInactive,
1558    /// This method cannot be called by a bot user.
1559    UserIsBot,
1560    /// This method cannot be called by a restricted user or single channel guest.
1561    UserIsRestricted,
1562    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
1563    InvalidArgName,
1564    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
1565    InvalidArrayArg,
1566    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
1567    InvalidCharset,
1568    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
1569    InvalidFormData,
1570    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
1571    InvalidPostType,
1572    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
1573    MissingPostType,
1574    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
1575    TeamAddedToOrg,
1576    /// The method was called via a POST request, but the POST data was either missing or truncated.
1577    RequestTimeout,
1578    /// The response was not parseable as the expected object
1579    MalformedResponse(String, serde_json::error::Error),
1580    /// The response returned an error that was unknown to the library
1581    Unknown(String),
1582    /// The client had an error sending the request to Slack
1583    Client(E),
1584}
1585
1586impl<'a, E: Error> From<&'a str> for RenameError<E> {
1587    fn from(s: &'a str) -> Self {
1588        match s {
1589            "channel_not_found" => RenameError::ChannelNotFound,
1590            "invalid_name" => RenameError::InvalidName,
1591            "name_taken" => RenameError::NameTaken,
1592            "invalid_name_required" => RenameError::InvalidNameRequired,
1593            "invalid_name_punctuation" => RenameError::InvalidNamePunctuation,
1594            "invalid_name_maxlength" => RenameError::InvalidNameMaxlength,
1595            "invalid_name_specials" => RenameError::InvalidNameSpecials,
1596            "not_authed" => RenameError::NotAuthed,
1597            "invalid_auth" => RenameError::InvalidAuth,
1598            "account_inactive" => RenameError::AccountInactive,
1599            "user_is_bot" => RenameError::UserIsBot,
1600            "user_is_restricted" => RenameError::UserIsRestricted,
1601            "invalid_arg_name" => RenameError::InvalidArgName,
1602            "invalid_array_arg" => RenameError::InvalidArrayArg,
1603            "invalid_charset" => RenameError::InvalidCharset,
1604            "invalid_form_data" => RenameError::InvalidFormData,
1605            "invalid_post_type" => RenameError::InvalidPostType,
1606            "missing_post_type" => RenameError::MissingPostType,
1607            "team_added_to_org" => RenameError::TeamAddedToOrg,
1608            "request_timeout" => RenameError::RequestTimeout,
1609            _ => RenameError::Unknown(s.to_owned()),
1610        }
1611    }
1612}
1613
1614impl<E: Error> fmt::Display for RenameError<E> {
1615    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1616        let d = match *self {
1617                        RenameError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
1618RenameError::InvalidName => "invalid_name: Value passed for name was invalid.",
1619RenameError::NameTaken => "name_taken: New channel name is taken",
1620RenameError::InvalidNameRequired => "invalid_name_required: Value passed for name was empty.",
1621RenameError::InvalidNamePunctuation => "invalid_name_punctuation: Value passed for name contained only punctuation.",
1622RenameError::InvalidNameMaxlength => "invalid_name_maxlength: Value passed for name exceeded max length.",
1623RenameError::InvalidNameSpecials => "invalid_name_specials: Value passed for name contained unallowed special characters or upper case characters.",
1624RenameError::NotAuthed => "not_authed: No authentication token provided.",
1625RenameError::InvalidAuth => "invalid_auth: Invalid authentication token.",
1626RenameError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
1627RenameError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
1628RenameError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.",
1629RenameError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
1630RenameError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
1631RenameError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
1632RenameError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
1633RenameError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
1634RenameError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
1635RenameError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
1636RenameError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
1637                        RenameError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
1638                        RenameError::Unknown(ref s) => return write!(f, "{}", s),
1639                        RenameError::Client(ref inner) => return write!(f, "{}", inner),
1640                    };
1641        write!(f, "{}", d)
1642    }
1643}
1644
1645impl<E: Error + 'static> Error for RenameError<E> {
1646    fn source(&self) -> Option<&(dyn Error + 'static)> {
1647        match *self {
1648            RenameError::MalformedResponse(_, ref e) => Some(e),
1649            RenameError::Client(ref inner) => Some(inner),
1650            _ => None,
1651        }
1652    }
1653}
1654
1655#[derive(Clone, Default, Debug)]
1656pub struct RepliesRequest<'a> {
1657    /// Private channel to fetch thread from
1658    pub channel: &'a str,
1659    /// Unique identifier of a thread's parent message
1660    pub thread_ts: crate::Timestamp,
1661}
1662
1663#[derive(Clone, Debug, Deserialize)]
1664pub struct RepliesResponse {
1665    error: Option<String>,
1666    pub messages: Option<Vec<crate::Message>>,
1667    #[serde(default)]
1668    ok: bool,
1669    pub thread_info: Option<crate::ThreadInfo>,
1670}
1671
1672impl<E: Error> Into<Result<RepliesResponse, RepliesError<E>>> for RepliesResponse {
1673    fn into(self) -> Result<RepliesResponse, RepliesError<E>> {
1674        if self.ok {
1675            Ok(self)
1676        } else {
1677            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
1678        }
1679    }
1680}
1681#[derive(Debug)]
1682pub enum RepliesError<E: Error> {
1683    /// Value for channel was missing or invalid.
1684    ChannelNotFound,
1685    /// Value for thread_ts was missing or invalid.
1686    ThreadNotFound,
1687    /// No authentication token provided.
1688    NotAuthed,
1689    /// Invalid authentication token.
1690    InvalidAuth,
1691    /// Authentication token is for a deleted user or team.
1692    AccountInactive,
1693    /// This method cannot be called by a bot user.
1694    UserIsBot,
1695    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
1696    InvalidArgName,
1697    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
1698    InvalidArrayArg,
1699    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
1700    InvalidCharset,
1701    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
1702    InvalidFormData,
1703    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
1704    InvalidPostType,
1705    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
1706    MissingPostType,
1707    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
1708    TeamAddedToOrg,
1709    /// The method was called via a POST request, but the POST data was either missing or truncated.
1710    RequestTimeout,
1711    /// The response was not parseable as the expected object
1712    MalformedResponse(String, serde_json::error::Error),
1713    /// The response returned an error that was unknown to the library
1714    Unknown(String),
1715    /// The client had an error sending the request to Slack
1716    Client(E),
1717}
1718
1719impl<'a, E: Error> From<&'a str> for RepliesError<E> {
1720    fn from(s: &'a str) -> Self {
1721        match s {
1722            "channel_not_found" => RepliesError::ChannelNotFound,
1723            "thread_not_found" => RepliesError::ThreadNotFound,
1724            "not_authed" => RepliesError::NotAuthed,
1725            "invalid_auth" => RepliesError::InvalidAuth,
1726            "account_inactive" => RepliesError::AccountInactive,
1727            "user_is_bot" => RepliesError::UserIsBot,
1728            "invalid_arg_name" => RepliesError::InvalidArgName,
1729            "invalid_array_arg" => RepliesError::InvalidArrayArg,
1730            "invalid_charset" => RepliesError::InvalidCharset,
1731            "invalid_form_data" => RepliesError::InvalidFormData,
1732            "invalid_post_type" => RepliesError::InvalidPostType,
1733            "missing_post_type" => RepliesError::MissingPostType,
1734            "team_added_to_org" => RepliesError::TeamAddedToOrg,
1735            "request_timeout" => RepliesError::RequestTimeout,
1736            _ => RepliesError::Unknown(s.to_owned()),
1737        }
1738    }
1739}
1740
1741impl<E: Error> fmt::Display for RepliesError<E> {
1742    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1743        let d = match *self {
1744                        RepliesError::ChannelNotFound => "channel_not_found: Value for channel was missing or invalid.",
1745RepliesError::ThreadNotFound => "thread_not_found: Value for thread_ts was missing or invalid.",
1746RepliesError::NotAuthed => "not_authed: No authentication token provided.",
1747RepliesError::InvalidAuth => "invalid_auth: Invalid authentication token.",
1748RepliesError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
1749RepliesError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
1750RepliesError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
1751RepliesError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
1752RepliesError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
1753RepliesError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
1754RepliesError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
1755RepliesError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
1756RepliesError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
1757RepliesError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
1758                        RepliesError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
1759                        RepliesError::Unknown(ref s) => return write!(f, "{}", s),
1760                        RepliesError::Client(ref inner) => return write!(f, "{}", inner),
1761                    };
1762        write!(f, "{}", d)
1763    }
1764}
1765
1766impl<E: Error + 'static> Error for RepliesError<E> {
1767    fn source(&self) -> Option<&(dyn Error + 'static)> {
1768        match *self {
1769            RepliesError::MalformedResponse(_, ref e) => Some(e),
1770            RepliesError::Client(ref inner) => Some(inner),
1771            _ => None,
1772        }
1773    }
1774}
1775
1776#[derive(Clone, Default, Debug)]
1777pub struct SetPurposeRequest<'a> {
1778    /// Private channel to set the purpose of
1779    pub channel: &'a str,
1780    /// The new purpose
1781    pub purpose: &'a str,
1782}
1783
1784#[derive(Clone, Debug, Deserialize)]
1785pub struct SetPurposeResponse {
1786    error: Option<String>,
1787    #[serde(default)]
1788    ok: bool,
1789    pub purpose: Option<String>,
1790}
1791
1792impl<E: Error> Into<Result<SetPurposeResponse, SetPurposeError<E>>> for SetPurposeResponse {
1793    fn into(self) -> Result<SetPurposeResponse, SetPurposeError<E>> {
1794        if self.ok {
1795            Ok(self)
1796        } else {
1797            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
1798        }
1799    }
1800}
1801#[derive(Debug)]
1802pub enum SetPurposeError<E: Error> {
1803    /// Value passed for channel was invalid.
1804    ChannelNotFound,
1805    /// Private group has been archived
1806    IsArchived,
1807    /// Purpose was longer than 250 characters.
1808    TooLong,
1809    /// This method cannot be called by a restricted user or single channel guest.
1810    UserIsRestricted,
1811    /// No authentication token provided.
1812    NotAuthed,
1813    /// Invalid authentication token.
1814    InvalidAuth,
1815    /// Authentication token is for a deleted user or team.
1816    AccountInactive,
1817    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
1818    InvalidArgName,
1819    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
1820    InvalidArrayArg,
1821    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
1822    InvalidCharset,
1823    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
1824    InvalidFormData,
1825    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
1826    InvalidPostType,
1827    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
1828    MissingPostType,
1829    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
1830    TeamAddedToOrg,
1831    /// The method was called via a POST request, but the POST data was either missing or truncated.
1832    RequestTimeout,
1833    /// The response was not parseable as the expected object
1834    MalformedResponse(String, serde_json::error::Error),
1835    /// The response returned an error that was unknown to the library
1836    Unknown(String),
1837    /// The client had an error sending the request to Slack
1838    Client(E),
1839}
1840
1841impl<'a, E: Error> From<&'a str> for SetPurposeError<E> {
1842    fn from(s: &'a str) -> Self {
1843        match s {
1844            "channel_not_found" => SetPurposeError::ChannelNotFound,
1845            "is_archived" => SetPurposeError::IsArchived,
1846            "too_long" => SetPurposeError::TooLong,
1847            "user_is_restricted" => SetPurposeError::UserIsRestricted,
1848            "not_authed" => SetPurposeError::NotAuthed,
1849            "invalid_auth" => SetPurposeError::InvalidAuth,
1850            "account_inactive" => SetPurposeError::AccountInactive,
1851            "invalid_arg_name" => SetPurposeError::InvalidArgName,
1852            "invalid_array_arg" => SetPurposeError::InvalidArrayArg,
1853            "invalid_charset" => SetPurposeError::InvalidCharset,
1854            "invalid_form_data" => SetPurposeError::InvalidFormData,
1855            "invalid_post_type" => SetPurposeError::InvalidPostType,
1856            "missing_post_type" => SetPurposeError::MissingPostType,
1857            "team_added_to_org" => SetPurposeError::TeamAddedToOrg,
1858            "request_timeout" => SetPurposeError::RequestTimeout,
1859            _ => SetPurposeError::Unknown(s.to_owned()),
1860        }
1861    }
1862}
1863
1864impl<E: Error> fmt::Display for SetPurposeError<E> {
1865    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1866        let d = match *self {
1867                        SetPurposeError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
1868SetPurposeError::IsArchived => "is_archived: Private group has been archived",
1869SetPurposeError::TooLong => "too_long: Purpose was longer than 250 characters.",
1870SetPurposeError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.",
1871SetPurposeError::NotAuthed => "not_authed: No authentication token provided.",
1872SetPurposeError::InvalidAuth => "invalid_auth: Invalid authentication token.",
1873SetPurposeError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
1874SetPurposeError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
1875SetPurposeError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
1876SetPurposeError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
1877SetPurposeError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
1878SetPurposeError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
1879SetPurposeError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
1880SetPurposeError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
1881SetPurposeError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
1882                        SetPurposeError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
1883                        SetPurposeError::Unknown(ref s) => return write!(f, "{}", s),
1884                        SetPurposeError::Client(ref inner) => return write!(f, "{}", inner),
1885                    };
1886        write!(f, "{}", d)
1887    }
1888}
1889
1890impl<E: Error + 'static> Error for SetPurposeError<E> {
1891    fn source(&self) -> Option<&(dyn Error + 'static)> {
1892        match *self {
1893            SetPurposeError::MalformedResponse(_, ref e) => Some(e),
1894            SetPurposeError::Client(ref inner) => Some(inner),
1895            _ => None,
1896        }
1897    }
1898}
1899
1900#[derive(Clone, Default, Debug)]
1901pub struct SetTopicRequest<'a> {
1902    /// Private channel to set the topic of
1903    pub channel: &'a str,
1904    /// The new topic
1905    pub topic: &'a str,
1906}
1907
1908#[derive(Clone, Debug, Deserialize)]
1909pub struct SetTopicResponse {
1910    error: Option<String>,
1911    #[serde(default)]
1912    ok: bool,
1913    pub topic: Option<String>,
1914}
1915
1916impl<E: Error> Into<Result<SetTopicResponse, SetTopicError<E>>> for SetTopicResponse {
1917    fn into(self) -> Result<SetTopicResponse, SetTopicError<E>> {
1918        if self.ok {
1919            Ok(self)
1920        } else {
1921            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
1922        }
1923    }
1924}
1925#[derive(Debug)]
1926pub enum SetTopicError<E: Error> {
1927    /// Value passed for channel was invalid.
1928    ChannelNotFound,
1929    /// Private group has been archived
1930    IsArchived,
1931    /// Topic was longer than 250 characters.
1932    TooLong,
1933    /// This method cannot be called by a restricted user or single channel guest.
1934    UserIsRestricted,
1935    /// No authentication token provided.
1936    NotAuthed,
1937    /// Invalid authentication token.
1938    InvalidAuth,
1939    /// Authentication token is for a deleted user or team.
1940    AccountInactive,
1941    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
1942    InvalidArgName,
1943    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
1944    InvalidArrayArg,
1945    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
1946    InvalidCharset,
1947    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
1948    InvalidFormData,
1949    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
1950    InvalidPostType,
1951    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
1952    MissingPostType,
1953    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
1954    TeamAddedToOrg,
1955    /// The method was called via a POST request, but the POST data was either missing or truncated.
1956    RequestTimeout,
1957    /// The response was not parseable as the expected object
1958    MalformedResponse(String, serde_json::error::Error),
1959    /// The response returned an error that was unknown to the library
1960    Unknown(String),
1961    /// The client had an error sending the request to Slack
1962    Client(E),
1963}
1964
1965impl<'a, E: Error> From<&'a str> for SetTopicError<E> {
1966    fn from(s: &'a str) -> Self {
1967        match s {
1968            "channel_not_found" => SetTopicError::ChannelNotFound,
1969            "is_archived" => SetTopicError::IsArchived,
1970            "too_long" => SetTopicError::TooLong,
1971            "user_is_restricted" => SetTopicError::UserIsRestricted,
1972            "not_authed" => SetTopicError::NotAuthed,
1973            "invalid_auth" => SetTopicError::InvalidAuth,
1974            "account_inactive" => SetTopicError::AccountInactive,
1975            "invalid_arg_name" => SetTopicError::InvalidArgName,
1976            "invalid_array_arg" => SetTopicError::InvalidArrayArg,
1977            "invalid_charset" => SetTopicError::InvalidCharset,
1978            "invalid_form_data" => SetTopicError::InvalidFormData,
1979            "invalid_post_type" => SetTopicError::InvalidPostType,
1980            "missing_post_type" => SetTopicError::MissingPostType,
1981            "team_added_to_org" => SetTopicError::TeamAddedToOrg,
1982            "request_timeout" => SetTopicError::RequestTimeout,
1983            _ => SetTopicError::Unknown(s.to_owned()),
1984        }
1985    }
1986}
1987
1988impl<E: Error> fmt::Display for SetTopicError<E> {
1989    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1990        let d = match *self {
1991                        SetTopicError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
1992SetTopicError::IsArchived => "is_archived: Private group has been archived",
1993SetTopicError::TooLong => "too_long: Topic was longer than 250 characters.",
1994SetTopicError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.",
1995SetTopicError::NotAuthed => "not_authed: No authentication token provided.",
1996SetTopicError::InvalidAuth => "invalid_auth: Invalid authentication token.",
1997SetTopicError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
1998SetTopicError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
1999SetTopicError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
2000SetTopicError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
2001SetTopicError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
2002SetTopicError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
2003SetTopicError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
2004SetTopicError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
2005SetTopicError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
2006                        SetTopicError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
2007                        SetTopicError::Unknown(ref s) => return write!(f, "{}", s),
2008                        SetTopicError::Client(ref inner) => return write!(f, "{}", inner),
2009                    };
2010        write!(f, "{}", d)
2011    }
2012}
2013
2014impl<E: Error + 'static> Error for SetTopicError<E> {
2015    fn source(&self) -> Option<&(dyn Error + 'static)> {
2016        match *self {
2017            SetTopicError::MalformedResponse(_, ref e) => Some(e),
2018            SetTopicError::Client(ref inner) => Some(inner),
2019            _ => None,
2020        }
2021    }
2022}
2023
2024#[derive(Clone, Default, Debug)]
2025pub struct UnarchiveRequest<'a> {
2026    /// Private channel to unarchive
2027    pub channel: &'a str,
2028}
2029
2030#[derive(Clone, Debug, Deserialize)]
2031pub struct UnarchiveResponse {
2032    error: Option<String>,
2033    #[serde(default)]
2034    ok: bool,
2035}
2036
2037impl<E: Error> Into<Result<UnarchiveResponse, UnarchiveError<E>>> for UnarchiveResponse {
2038    fn into(self) -> Result<UnarchiveResponse, UnarchiveError<E>> {
2039        if self.ok {
2040            Ok(self)
2041        } else {
2042            Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into())
2043        }
2044    }
2045}
2046#[derive(Debug)]
2047pub enum UnarchiveError<E: Error> {
2048    /// Value passed for channel was invalid.
2049    ChannelNotFound,
2050    /// Group is not archived.
2051    NotArchived,
2052    /// No authentication token provided.
2053    NotAuthed,
2054    /// Invalid authentication token.
2055    InvalidAuth,
2056    /// Authentication token is for a deleted user or team.
2057    AccountInactive,
2058    /// This method cannot be called by a bot user.
2059    UserIsBot,
2060    /// This method cannot be called by a restricted user or single channel guest.
2061    UserIsRestricted,
2062    /// The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
2063    InvalidArgName,
2064    /// The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.
2065    InvalidArrayArg,
2066    /// The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
2067    InvalidCharset,
2068    /// The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
2069    InvalidFormData,
2070    /// The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.
2071    InvalidPostType,
2072    /// The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
2073    MissingPostType,
2074    /// The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
2075    TeamAddedToOrg,
2076    /// The method was called via a POST request, but the POST data was either missing or truncated.
2077    RequestTimeout,
2078    /// The response was not parseable as the expected object
2079    MalformedResponse(String, serde_json::error::Error),
2080    /// The response returned an error that was unknown to the library
2081    Unknown(String),
2082    /// The client had an error sending the request to Slack
2083    Client(E),
2084}
2085
2086impl<'a, E: Error> From<&'a str> for UnarchiveError<E> {
2087    fn from(s: &'a str) -> Self {
2088        match s {
2089            "channel_not_found" => UnarchiveError::ChannelNotFound,
2090            "not_archived" => UnarchiveError::NotArchived,
2091            "not_authed" => UnarchiveError::NotAuthed,
2092            "invalid_auth" => UnarchiveError::InvalidAuth,
2093            "account_inactive" => UnarchiveError::AccountInactive,
2094            "user_is_bot" => UnarchiveError::UserIsBot,
2095            "user_is_restricted" => UnarchiveError::UserIsRestricted,
2096            "invalid_arg_name" => UnarchiveError::InvalidArgName,
2097            "invalid_array_arg" => UnarchiveError::InvalidArrayArg,
2098            "invalid_charset" => UnarchiveError::InvalidCharset,
2099            "invalid_form_data" => UnarchiveError::InvalidFormData,
2100            "invalid_post_type" => UnarchiveError::InvalidPostType,
2101            "missing_post_type" => UnarchiveError::MissingPostType,
2102            "team_added_to_org" => UnarchiveError::TeamAddedToOrg,
2103            "request_timeout" => UnarchiveError::RequestTimeout,
2104            _ => UnarchiveError::Unknown(s.to_owned()),
2105        }
2106    }
2107}
2108
2109impl<E: Error> fmt::Display for UnarchiveError<E> {
2110    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2111        let d = match *self {
2112                        UnarchiveError::ChannelNotFound => "channel_not_found: Value passed for channel was invalid.",
2113UnarchiveError::NotArchived => "not_archived: Group is not archived.",
2114UnarchiveError::NotAuthed => "not_authed: No authentication token provided.",
2115UnarchiveError::InvalidAuth => "invalid_auth: Invalid authentication token.",
2116UnarchiveError::AccountInactive => "account_inactive: Authentication token is for a deleted user or team.",
2117UnarchiveError::UserIsBot => "user_is_bot: This method cannot be called by a bot user.",
2118UnarchiveError::UserIsRestricted => "user_is_restricted: This method cannot be called by a restricted user or single channel guest.",
2119UnarchiveError::InvalidArgName => "invalid_arg_name: The method was passed an argument whose name falls outside the bounds of common decency. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.",
2120UnarchiveError::InvalidArrayArg => "invalid_array_arg: The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.",
2121UnarchiveError::InvalidCharset => "invalid_charset: The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.",
2122UnarchiveError::InvalidFormData => "invalid_form_data: The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.",
2123UnarchiveError::InvalidPostType => "invalid_post_type: The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.",
2124UnarchiveError::MissingPostType => "missing_post_type: The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.",
2125UnarchiveError::TeamAddedToOrg => "team_added_to_org: The team associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.",
2126UnarchiveError::RequestTimeout => "request_timeout: The method was called via a POST request, but the POST data was either missing or truncated.",
2127                        UnarchiveError::MalformedResponse(_, ref e) => return write!(f, "{}", e),
2128                        UnarchiveError::Unknown(ref s) => return write!(f, "{}", s),
2129                        UnarchiveError::Client(ref inner) => return write!(f, "{}", inner),
2130                    };
2131        write!(f, "{}", d)
2132    }
2133}
2134
2135impl<E: Error + 'static> Error for UnarchiveError<E> {
2136    fn source(&self) -> Option<&(dyn Error + 'static)> {
2137        match *self {
2138            UnarchiveError::MalformedResponse(_, ref e) => Some(e),
2139            UnarchiveError::Client(ref inner) => Some(inner),
2140            _ => None,
2141        }
2142    }
2143}