Skip to main content

slack_web_api/api/
admin_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 [`admin.emoji.add`](https://docs.slack.dev/reference/methods/admin.emoji.add): Add an emoji.
12///
13/// Send it with [`SlackClient::admin_emoji_add`].
14#[doc(alias = "admin.emoji.add")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct AdminEmojiAddRequest {
18    /// The name of the emoji to be added (using lower-case letters only). Colons (`:myemoji:`) around the value are not required, although they may be included.
19    pub name: String,
20    /// The URL of a file to use as an image for the emoji. Square images under 128KB and with transparent backgrounds work best.
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub url: Option<String>,
23}
24
25impl AdminEmojiAddRequest {
26    pub fn new(name: impl Into<String>) -> Self {
27        Self {
28            name: name.into(),
29            url: None,
30        }
31    }
32
33    pub fn url(mut self, url: impl Into<String>) -> Self {
34        self.url = Some(url.into());
35        self
36    }
37}
38
39impl SlackApiMethod for AdminEmojiAddRequest {
40    const METHOD: &'static str = "admin.emoji.add";
41    type Response = AdminEmojiAddResponse;
42}
43
44/// Successful response of the Slack Web API method [`admin.emoji.add`](https://docs.slack.dev/reference/methods/admin.emoji.add).
45#[doc(alias = "admin.emoji.add")]
46#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
47pub struct AdminEmojiAddResponse {
48    /// Fields returned by Slack. This method has no documented response example.
49    #[serde(flatten)]
50    pub extra: serde_json::Map<String, serde_json::Value>,
51    #[serde(
52        default,
53        deserialize_with = "crate::de::opt_object",
54        skip_serializing_if = "Option::is_none"
55    )]
56    pub response_metadata: Option<ResponseMetadata>,
57    #[serde(
58        default,
59        deserialize_with = "crate::de::opt_string",
60        skip_serializing_if = "Option::is_none"
61    )]
62    pub warning: Option<String>,
63}
64
65/// Arguments for the Slack Web API method [`admin.emoji.addAlias`](https://docs.slack.dev/reference/methods/admin.emoji.addAlias): Add an emoji alias.
66///
67/// Send it with [`SlackClient::admin_emoji_add_alias`].
68#[doc(alias = "admin.emoji.addAlias")]
69#[derive(Debug, Clone, PartialEq, Serialize)]
70#[non_exhaustive]
71pub struct AdminEmojiAddAliasRequest {
72    /// The new alias for the specified emoji. Any wrapping whitespace or colons will be automatically trimmed.
73    pub name: String,
74    /// Name of the emoji for which the alias is being made. Any wrapping whitespace or colons will be automatically trimmed.
75    pub alias_for: String,
76}
77
78impl AdminEmojiAddAliasRequest {
79    pub fn new(name: impl Into<String>, alias_for: impl Into<String>) -> Self {
80        Self {
81            name: name.into(),
82            alias_for: alias_for.into(),
83        }
84    }
85}
86
87impl SlackApiMethod for AdminEmojiAddAliasRequest {
88    const METHOD: &'static str = "admin.emoji.addAlias";
89    type Response = AdminEmojiAddAliasResponse;
90}
91
92/// Successful response of the Slack Web API method [`admin.emoji.addAlias`](https://docs.slack.dev/reference/methods/admin.emoji.addAlias).
93#[doc(alias = "admin.emoji.addAlias")]
94#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
95pub struct AdminEmojiAddAliasResponse {
96    /// Fields returned by Slack. This method has no documented response example.
97    #[serde(flatten)]
98    pub extra: serde_json::Map<String, serde_json::Value>,
99    #[serde(
100        default,
101        deserialize_with = "crate::de::opt_object",
102        skip_serializing_if = "Option::is_none"
103    )]
104    pub response_metadata: Option<ResponseMetadata>,
105    #[serde(
106        default,
107        deserialize_with = "crate::de::opt_string",
108        skip_serializing_if = "Option::is_none"
109    )]
110    pub warning: Option<String>,
111}
112
113/// Arguments for the Slack Web API method [`admin.emoji.list`](https://docs.slack.dev/reference/methods/admin.emoji.list): List emoji for an Enterprise organization.
114///
115/// Send it with [`SlackClient::admin_emoji_list`].
116#[doc(alias = "admin.emoji.list")]
117#[derive(Debug, Clone, PartialEq, Serialize, Default)]
118#[non_exhaustive]
119pub struct AdminEmojiListRequest {
120    /// Set `cursor` to `next_cursor` returned by the previous call to list items in the next page
121    #[serde(skip_serializing_if = "Option::is_none")]
122    pub cursor: Option<String>,
123    /// The maximum number of items to return. Must be between 1 - 1000 both inclusive.
124    #[serde(skip_serializing_if = "Option::is_none")]
125    pub limit: Option<i64>,
126}
127
128impl AdminEmojiListRequest {
129    pub fn new() -> Self {
130        Self {
131            cursor: None,
132            limit: None,
133        }
134    }
135
136    pub fn cursor(mut self, cursor: impl Into<String>) -> Self {
137        self.cursor = Some(cursor.into());
138        self
139    }
140
141    pub fn limit(mut self, limit: i64) -> Self {
142        self.limit = Some(limit);
143        self
144    }
145}
146
147impl SlackApiMethod for AdminEmojiListRequest {
148    const METHOD: &'static str = "admin.emoji.list";
149    type Response = AdminEmojiListResponse;
150}
151
152impl CursorPaginated for AdminEmojiListRequest {
153    fn set_cursor(&mut self, cursor: String) {
154        self.cursor = Some(cursor);
155    }
156}
157
158impl NextCursor for AdminEmojiListResponse {
159    fn next_cursor(&self) -> Option<&str> {
160        self.response_metadata.as_ref()?.next_cursor.as_deref()
161    }
162}
163
164/// Successful response of the Slack Web API method [`admin.emoji.list`](https://docs.slack.dev/reference/methods/admin.emoji.list).
165#[doc(alias = "admin.emoji.list")]
166#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
167pub struct AdminEmojiListResponse {
168    #[serde(
169        default,
170        deserialize_with = "crate::de::opt_object",
171        skip_serializing_if = "Option::is_none"
172    )]
173    pub emoji: Option<std::collections::HashMap<String, AdminEmojiListResponseEmojiValue>>,
174    #[serde(
175        default,
176        deserialize_with = "crate::de::opt_object",
177        skip_serializing_if = "Option::is_none"
178    )]
179    pub response_metadata: Option<ResponseMetadata>,
180    #[serde(
181        default,
182        deserialize_with = "crate::de::opt_string",
183        skip_serializing_if = "Option::is_none"
184    )]
185    pub warning: Option<String>,
186}
187
188#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
189pub struct AdminEmojiListResponseEmojiValue {
190    #[serde(
191        default,
192        deserialize_with = "crate::de::opt_string",
193        skip_serializing_if = "Option::is_none"
194    )]
195    pub url: Option<String>,
196    #[serde(
197        default,
198        deserialize_with = "crate::de::opt_i64",
199        skip_serializing_if = "Option::is_none"
200    )]
201    pub date_created: Option<i64>,
202    #[serde(
203        default,
204        deserialize_with = "crate::de::opt_string",
205        skip_serializing_if = "Option::is_none"
206    )]
207    pub uploaded_by: Option<String>,
208}
209
210/// Arguments for the Slack Web API method [`admin.emoji.remove`](https://docs.slack.dev/reference/methods/admin.emoji.remove): Remove an emoji across an Enterprise organization
211///
212/// Send it with [`SlackClient::admin_emoji_remove`].
213#[doc(alias = "admin.emoji.remove")]
214#[derive(Debug, Clone, PartialEq, Serialize)]
215#[non_exhaustive]
216pub struct AdminEmojiRemoveRequest {
217    /// The name of the emoji to be removed. Colons (`:myemoji:`) around the value are not required, although they may be included.
218    pub name: String,
219}
220
221impl AdminEmojiRemoveRequest {
222    pub fn new(name: impl Into<String>) -> Self {
223        Self { name: name.into() }
224    }
225}
226
227impl SlackApiMethod for AdminEmojiRemoveRequest {
228    const METHOD: &'static str = "admin.emoji.remove";
229    type Response = AdminEmojiRemoveResponse;
230}
231
232/// Successful response of the Slack Web API method [`admin.emoji.remove`](https://docs.slack.dev/reference/methods/admin.emoji.remove).
233#[doc(alias = "admin.emoji.remove")]
234#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
235pub struct AdminEmojiRemoveResponse {
236    /// Fields returned by Slack. This method has no documented response example.
237    #[serde(flatten)]
238    pub extra: serde_json::Map<String, serde_json::Value>,
239    #[serde(
240        default,
241        deserialize_with = "crate::de::opt_object",
242        skip_serializing_if = "Option::is_none"
243    )]
244    pub response_metadata: Option<ResponseMetadata>,
245    #[serde(
246        default,
247        deserialize_with = "crate::de::opt_string",
248        skip_serializing_if = "Option::is_none"
249    )]
250    pub warning: Option<String>,
251}
252
253/// Arguments for the Slack Web API method [`admin.emoji.rename`](https://docs.slack.dev/reference/methods/admin.emoji.rename): Rename an emoji.
254///
255/// Send it with [`SlackClient::admin_emoji_rename`].
256#[doc(alias = "admin.emoji.rename")]
257#[derive(Debug, Clone, PartialEq, Serialize)]
258#[non_exhaustive]
259pub struct AdminEmojiRenameRequest {
260    /// The name of the emoji to be renamed. Colons (`:myemoji:`) around the value are not required, although they may be included.
261    pub name: String,
262    /// The new name of the emoji.
263    pub new_name: String,
264}
265
266impl AdminEmojiRenameRequest {
267    pub fn new(name: impl Into<String>, new_name: impl Into<String>) -> Self {
268        Self {
269            name: name.into(),
270            new_name: new_name.into(),
271        }
272    }
273}
274
275impl SlackApiMethod for AdminEmojiRenameRequest {
276    const METHOD: &'static str = "admin.emoji.rename";
277    type Response = AdminEmojiRenameResponse;
278}
279
280/// Successful response of the Slack Web API method [`admin.emoji.rename`](https://docs.slack.dev/reference/methods/admin.emoji.rename).
281#[doc(alias = "admin.emoji.rename")]
282#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
283pub struct AdminEmojiRenameResponse {
284    /// Fields returned by Slack. This method has no documented response example.
285    #[serde(flatten)]
286    pub extra: serde_json::Map<String, serde_json::Value>,
287    #[serde(
288        default,
289        deserialize_with = "crate::de::opt_object",
290        skip_serializing_if = "Option::is_none"
291    )]
292    pub response_metadata: Option<ResponseMetadata>,
293    #[serde(
294        default,
295        deserialize_with = "crate::de::opt_string",
296        skip_serializing_if = "Option::is_none"
297    )]
298    pub warning: Option<String>,
299}
300
301impl SlackClient {
302    /// Calls the Slack Web API method [`admin.emoji.add`](https://docs.slack.dev/reference/methods/admin.emoji.add): Add an emoji.
303    ///
304    /// Required scopes:
305    ///
306    /// - user token: `admin.teams:write`
307    ///
308    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
309    ///
310    /// # Errors
311    ///
312    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
313    #[doc(alias = "admin.emoji.add")]
314    pub async fn admin_emoji_add(
315        &self,
316        request: &AdminEmojiAddRequest,
317    ) -> Result<AdminEmojiAddResponse, SlackError> {
318        self.call(request).await
319    }
320
321    /// Calls the Slack Web API method [`admin.emoji.addAlias`](https://docs.slack.dev/reference/methods/admin.emoji.addAlias): Add an emoji alias.
322    ///
323    /// Required scopes:
324    ///
325    /// - user token: `admin.teams:write`
326    ///
327    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
328    ///
329    /// # Errors
330    ///
331    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
332    #[doc(alias = "admin.emoji.addAlias")]
333    pub async fn admin_emoji_add_alias(
334        &self,
335        request: &AdminEmojiAddAliasRequest,
336    ) -> Result<AdminEmojiAddAliasResponse, SlackError> {
337        self.call(request).await
338    }
339
340    /// Calls the Slack Web API method [`admin.emoji.list`](https://docs.slack.dev/reference/methods/admin.emoji.list): List emoji for an Enterprise organization.
341    ///
342    /// Required scopes:
343    ///
344    /// - user token: `admin.teams:read`
345    ///
346    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
347    ///
348    /// # Errors
349    ///
350    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
351    #[doc(alias = "admin.emoji.list")]
352    pub async fn admin_emoji_list(
353        &self,
354        request: &AdminEmojiListRequest,
355    ) -> Result<AdminEmojiListResponse, SlackError> {
356        self.call(request).await
357    }
358
359    /// Calls the Slack Web API method [`admin.emoji.remove`](https://docs.slack.dev/reference/methods/admin.emoji.remove): Remove an emoji across an Enterprise organization
360    ///
361    /// Required scopes:
362    ///
363    /// - user token: `admin.teams:write`
364    ///
365    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
366    ///
367    /// # Errors
368    ///
369    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
370    #[doc(alias = "admin.emoji.remove")]
371    pub async fn admin_emoji_remove(
372        &self,
373        request: &AdminEmojiRemoveRequest,
374    ) -> Result<AdminEmojiRemoveResponse, SlackError> {
375        self.call(request).await
376    }
377
378    /// Calls the Slack Web API method [`admin.emoji.rename`](https://docs.slack.dev/reference/methods/admin.emoji.rename): Rename an emoji.
379    ///
380    /// Required scopes:
381    ///
382    /// - user token: `admin.teams:write`
383    ///
384    /// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
385    ///
386    /// # Errors
387    ///
388    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
389    #[doc(alias = "admin.emoji.rename")]
390    pub async fn admin_emoji_rename(
391        &self,
392        request: &AdminEmojiRenameRequest,
393    ) -> Result<AdminEmojiRenameResponse, SlackError> {
394        self.call(request).await
395    }
396}