1#[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 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 ChannelNotFound,
49 AlreadyArchived,
51 GroupContainsOthers,
53 RestrictedAction,
55 NotAuthed,
57 InvalidAuth,
59 AccountInactive,
61 UserIsBot,
63 UserIsUltraRestricted,
65 InvalidArgName,
67 InvalidArrayArg,
69 InvalidCharset,
71 InvalidFormData,
73 InvalidPostType,
75 MissingPostType,
77 TeamAddedToOrg,
79 RequestTimeout,
81 MalformedResponse(String, serde_json::error::Error),
83 Unknown(String),
85 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 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 ChannelNotFound,
178 NotAuthed,
180 InvalidAuth,
182 AccountInactive,
184 InvalidArgName,
186 InvalidArrayArg,
188 InvalidCharset,
190 InvalidFormData,
192 InvalidPostType,
194 MissingPostType,
196 TeamAddedToOrg,
198 RequestTimeout,
200 MalformedResponse(String, serde_json::error::Error),
202 Unknown(String),
204 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 pub name: &'a str,
265 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 NoChannel,
290 RestrictedAction,
292 NameTaken,
294 InvalidNameRequired,
296 InvalidNamePunctuation,
298 InvalidNameMaxlength,
300 InvalidNameSpecials,
302 InvalidName,
304 NotAuthed,
306 InvalidAuth,
308 AccountInactive,
310 UserIsBot,
312 UserIsUltraRestricted,
314 InvalidArgName,
316 InvalidArrayArg,
318 InvalidCharset,
320 InvalidFormData,
322 InvalidPostType,
324 MissingPostType,
326 TeamAddedToOrg,
328 RequestTimeout,
330 MalformedResponse(String, serde_json::error::Error),
332 Unknown(String),
334 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 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 ChannelNotFound,
436 AlreadyArchived,
438 RestrictedAction,
440 NotAuthed,
442 InvalidAuth,
444 AccountInactive,
446 UserIsBot,
448 UserIsUltraRestricted,
450 InvalidArgName,
452 InvalidArrayArg,
454 InvalidCharset,
456 InvalidFormData,
458 InvalidPostType,
460 MissingPostType,
462 TeamAddedToOrg,
464 RequestTimeout,
466 MalformedResponse(String, serde_json::error::Error),
468 Unknown(String),
470 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 pub channel: &'a str,
539 pub latest: Option<crate::Timestamp>,
541 pub oldest: Option<crate::Timestamp>,
543 pub inclusive: Option<bool>,
545 pub count: Option<u32>,
547 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 ChannelNotFound,
574 InvalidTsLatest,
576 InvalidTsOldest,
578 NotAuthed,
580 InvalidAuth,
582 AccountInactive,
584 InvalidArgName,
586 InvalidArrayArg,
588 InvalidCharset,
590 InvalidFormData,
592 InvalidPostType,
594 MissingPostType,
596 TeamAddedToOrg,
598 RequestTimeout,
600 MalformedResponse(String, serde_json::error::Error),
602 Unknown(String),
604 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 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 ChannelNotFound,
692 NotAuthed,
694 InvalidAuth,
696 AccountInactive,
698 InvalidArgName,
700 InvalidArrayArg,
702 InvalidCharset,
704 InvalidFormData,
706 InvalidPostType,
708 MissingPostType,
710 TeamAddedToOrg,
712 RequestTimeout,
714 MalformedResponse(String, serde_json::error::Error),
716 Unknown(String),
718 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 pub channel: &'a str,
779 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 ChannelNotFound,
804 UserNotFound,
806 CantInviteSelf,
808 IsArchived,
810 CantInvite,
812 UraMaxChannels,
814 NotAuthed,
816 InvalidAuth,
818 AccountInactive,
820 UserIsBot,
822 UserIsUltraRestricted,
824 InvalidArgName,
826 InvalidArrayArg,
828 InvalidCharset,
830 InvalidFormData,
832 InvalidPostType,
834 MissingPostType,
836 TeamAddedToOrg,
838 RequestTimeout,
840 MalformedResponse(String, serde_json::error::Error),
842 Unknown(String),
844 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 pub channel: &'a str,
919 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 ChannelNotFound,
943 UserNotFound,
945 CantKickSelf,
947 NotInGroup,
949 RestrictedAction,
951 NotAuthed,
953 InvalidAuth,
955 AccountInactive,
957 UserIsBot,
959 UserIsRestricted,
961 InvalidArgName,
963 InvalidArrayArg,
965 InvalidCharset,
967 InvalidFormData,
969 InvalidPostType,
971 MissingPostType,
973 TeamAddedToOrg,
975 RequestTimeout,
977 MalformedResponse(String, serde_json::error::Error),
979 Unknown(String),
981 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 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 ChannelNotFound,
1076 IsArchived,
1078 NotAuthed,
1080 InvalidAuth,
1082 AccountInactive,
1084 UserIsBot,
1086 UserIsUltraRestricted,
1088 InvalidArgName,
1090 InvalidArrayArg,
1092 InvalidCharset,
1094 InvalidFormData,
1096 InvalidPostType,
1098 MissingPostType,
1100 TeamAddedToOrg,
1102 RequestTimeout,
1104 MalformedResponse(String, serde_json::error::Error),
1106 Unknown(String),
1108 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 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 NotAuthed,
1198 InvalidAuth,
1200 AccountInactive,
1202 InvalidArgName,
1204 InvalidArrayArg,
1206 InvalidCharset,
1208 InvalidFormData,
1210 InvalidPostType,
1212 MissingPostType,
1214 TeamAddedToOrg,
1216 RequestTimeout,
1218 MalformedResponse(String, serde_json::error::Error),
1220 Unknown(String),
1222 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 pub channel: &'a str,
1281 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 ChannelNotFound,
1305 InvalidTimestamp,
1307 NotAuthed,
1309 InvalidAuth,
1311 AccountInactive,
1313 InvalidArgName,
1315 InvalidArrayArg,
1317 InvalidCharset,
1319 InvalidFormData,
1321 InvalidPostType,
1323 MissingPostType,
1325 TeamAddedToOrg,
1327 RequestTimeout,
1329 MalformedResponse(String, serde_json::error::Error),
1331 Unknown(String),
1333 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 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 ChannelNotFound,
1418 NotAuthed,
1420 InvalidAuth,
1422 AccountInactive,
1424 InvalidArgName,
1426 InvalidArrayArg,
1428 InvalidCharset,
1430 InvalidFormData,
1432 InvalidPostType,
1434 MissingPostType,
1436 TeamAddedToOrg,
1438 RequestTimeout,
1440 MalformedResponse(String, serde_json::error::Error),
1442 Unknown(String),
1444 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 pub channel: &'a str,
1505 pub name: &'a str,
1507 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 ChannelNotFound,
1540 InvalidName,
1542 NameTaken,
1544 InvalidNameRequired,
1546 InvalidNamePunctuation,
1548 InvalidNameMaxlength,
1550 InvalidNameSpecials,
1552 NotAuthed,
1554 InvalidAuth,
1556 AccountInactive,
1558 UserIsBot,
1560 UserIsRestricted,
1562 InvalidArgName,
1564 InvalidArrayArg,
1566 InvalidCharset,
1568 InvalidFormData,
1570 InvalidPostType,
1572 MissingPostType,
1574 TeamAddedToOrg,
1576 RequestTimeout,
1578 MalformedResponse(String, serde_json::error::Error),
1580 Unknown(String),
1582 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 pub channel: &'a str,
1659 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 ChannelNotFound,
1685 ThreadNotFound,
1687 NotAuthed,
1689 InvalidAuth,
1691 AccountInactive,
1693 UserIsBot,
1695 InvalidArgName,
1697 InvalidArrayArg,
1699 InvalidCharset,
1701 InvalidFormData,
1703 InvalidPostType,
1705 MissingPostType,
1707 TeamAddedToOrg,
1709 RequestTimeout,
1711 MalformedResponse(String, serde_json::error::Error),
1713 Unknown(String),
1715 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 pub channel: &'a str,
1780 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 ChannelNotFound,
1805 IsArchived,
1807 TooLong,
1809 UserIsRestricted,
1811 NotAuthed,
1813 InvalidAuth,
1815 AccountInactive,
1817 InvalidArgName,
1819 InvalidArrayArg,
1821 InvalidCharset,
1823 InvalidFormData,
1825 InvalidPostType,
1827 MissingPostType,
1829 TeamAddedToOrg,
1831 RequestTimeout,
1833 MalformedResponse(String, serde_json::error::Error),
1835 Unknown(String),
1837 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 pub channel: &'a str,
1904 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 ChannelNotFound,
1929 IsArchived,
1931 TooLong,
1933 UserIsRestricted,
1935 NotAuthed,
1937 InvalidAuth,
1939 AccountInactive,
1941 InvalidArgName,
1943 InvalidArrayArg,
1945 InvalidCharset,
1947 InvalidFormData,
1949 InvalidPostType,
1951 MissingPostType,
1953 TeamAddedToOrg,
1955 RequestTimeout,
1957 MalformedResponse(String, serde_json::error::Error),
1959 Unknown(String),
1961 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 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 ChannelNotFound,
2050 NotArchived,
2052 NotAuthed,
2054 InvalidAuth,
2056 AccountInactive,
2058 UserIsBot,
2060 UserIsRestricted,
2062 InvalidArgName,
2064 InvalidArrayArg,
2066 InvalidCharset,
2068 InvalidFormData,
2070 InvalidPostType,
2072 MissingPostType,
2074 TeamAddedToOrg,
2076 RequestTimeout,
2078 MalformedResponse(String, serde_json::error::Error),
2080 Unknown(String),
2082 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}