Skip to main content

slack_web_api/api/
emoji.rs

1// このファイルは codegen/generate.py が生成する。手で編集しない
2
3#![allow(unused_imports)]
4
5use crate::objects::*;
6use crate::{
7    CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
8};
9use serde::{Deserialize, Serialize};
10
11/// Arguments for the Slack Web API method [`emoji.list`](https://docs.slack.dev/reference/methods/emoji.list): Lists custom emoji for a team.
12///
13/// Send it with [`SlackClient::emoji_list`].
14#[doc(alias = "emoji.list")]
15#[derive(Debug, Clone, PartialEq, Serialize, Default)]
16#[non_exhaustive]
17pub struct EmojiListRequest {
18    /// Include a list of categories for Unicode emoji and the emoji in each category
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub include_categories: Option<bool>,
21}
22
23impl EmojiListRequest {
24    pub fn new() -> Self {
25        Self {
26            include_categories: None,
27        }
28    }
29
30    pub fn include_categories(mut self, include_categories: bool) -> Self {
31        self.include_categories = Some(include_categories);
32        self
33    }
34}
35
36impl SlackApiMethod for EmojiListRequest {
37    const METHOD: &'static str = "emoji.list";
38    type Response = EmojiListResponse;
39}
40
41/// Successful response of the Slack Web API method [`emoji.list`](https://docs.slack.dev/reference/methods/emoji.list).
42#[doc(alias = "emoji.list")]
43#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
44pub struct EmojiListResponse {
45    #[serde(
46        default,
47        deserialize_with = "crate::de::opt_object",
48        skip_serializing_if = "Option::is_none"
49    )]
50    pub emoji: Option<std::collections::HashMap<String, String>>,
51    #[serde(
52        default,
53        deserialize_with = "crate::de::opt_string",
54        skip_serializing_if = "Option::is_none"
55    )]
56    pub cache_ts: Option<String>,
57    #[serde(
58        default,
59        deserialize_with = "crate::de::opt_object",
60        skip_serializing_if = "Option::is_none"
61    )]
62    pub response_metadata: Option<ResponseMetadata>,
63    #[serde(
64        default,
65        deserialize_with = "crate::de::opt_string",
66        skip_serializing_if = "Option::is_none"
67    )]
68    pub warning: Option<String>,
69}
70
71impl SlackClient {
72    /// Calls the Slack Web API method [`emoji.list`](https://docs.slack.dev/reference/methods/emoji.list): Lists custom emoji for a team.
73    ///
74    /// Required scopes:
75    ///
76    /// - bot token: `emoji:read`
77    /// - user token: `emoji:read`
78    ///
79    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
80    ///
81    /// # Errors
82    ///
83    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
84    #[doc(alias = "emoji.list")]
85    pub async fn emoji_list(
86        &self,
87        request: &EmojiListRequest,
88    ) -> Result<EmojiListResponse, SlackError> {
89        self.call(request).await
90    }
91}