Skip to main content

slack_web_api/api/
entity.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 [`entity.acknowledgeCommentAction`](https://docs.slack.dev/reference/methods/entity.acknowledgeCommentAction): Acknowledge a comment post, edit, or delete on a Work Object. Apps call this method to confirm they have processed a comment action.
12///
13/// Send it with [`SlackClient::entity_acknowledge_comment_action`].
14#[doc(alias = "entity.acknowledgeCommentAction")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct EntityAcknowledgeCommentActionRequest {
18    /// A reference to the original user action that initiated the comment mutation
19    pub trigger_id: String,
20    /// The full comment data. Required for edit and post actions. See the [comment schema](https://docs.slack.dev/messaging/work-objects-comments.md#entity-present-comments-method) for the full list of properties.
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub comment: Option<serde_json::Value>,
23    /// Error message if the action failed in the app. When present, signals that the mutation could not be completed.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub error: Option<String>,
26}
27
28impl EntityAcknowledgeCommentActionRequest {
29    pub fn new(trigger_id: impl Into<String>) -> Self {
30        Self {
31            trigger_id: trigger_id.into(),
32            comment: None,
33            error: None,
34        }
35    }
36
37    pub fn comment(mut self, comment: serde_json::Value) -> Self {
38        self.comment = Some(comment);
39        self
40    }
41
42    pub fn error(mut self, error: impl Into<String>) -> Self {
43        self.error = Some(error.into());
44        self
45    }
46}
47
48impl SlackApiMethod for EntityAcknowledgeCommentActionRequest {
49    const METHOD: &'static str = "entity.acknowledgeCommentAction";
50    type Response = EntityAcknowledgeCommentActionResponse;
51}
52
53/// Successful response of the Slack Web API method [`entity.acknowledgeCommentAction`](https://docs.slack.dev/reference/methods/entity.acknowledgeCommentAction).
54#[doc(alias = "entity.acknowledgeCommentAction")]
55#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
56pub struct EntityAcknowledgeCommentActionResponse {
57    /// Fields returned by Slack. This method has no documented response example.
58    #[serde(flatten)]
59    pub extra: serde_json::Map<String, serde_json::Value>,
60    #[serde(
61        default,
62        deserialize_with = "crate::de::opt_object",
63        skip_serializing_if = "Option::is_none"
64    )]
65    pub response_metadata: Option<ResponseMetadata>,
66    #[serde(
67        default,
68        deserialize_with = "crate::de::opt_string",
69        skip_serializing_if = "Option::is_none"
70    )]
71    pub warning: Option<String>,
72}
73
74/// Arguments for the Slack Web API method [`entity.presentComments`](https://docs.slack.dev/reference/methods/entity.presentComments): Provide comments for Work Objects. Apps call this method to send per-user flexpane comment data to the client.
75///
76/// Send it with [`SlackClient::entity_present_comments`].
77#[doc(alias = "entity.presentComments")]
78#[derive(Debug, Clone, PartialEq, Serialize)]
79#[non_exhaustive]
80pub struct EntityPresentCommentsRequest {
81    /// Array of comments to present to the user. See the [comment schema](https://docs.slack.dev/messaging/work-objects-comments.md#entity-present-comments-method) for the full list of properties.
82    #[serde(serialize_with = "crate::form::as_json")]
83    pub comments: Vec<serde_json::Value>,
84    /// A reference to the original user action that initiated the request
85    pub trigger_id: String,
86    /// App supplied cursor used for pagination, will be sent in the next request for comments
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub cursor: Option<String>,
89    /// Indicates whether the user has permissions to post comments
90    #[serde(skip_serializing_if = "Option::is_none")]
91    pub can_post_comment: Option<bool>,
92    /// The block action id that will be sent when a delete request is initiated for a comment.
93    #[serde(skip_serializing_if = "Option::is_none")]
94    pub delete_action_id: Option<String>,
95    /// Set to true (or 1) to indicate that the user must authenticate to see the comments data.
96    #[serde(skip_serializing_if = "Option::is_none")]
97    pub user_auth_required: Option<bool>,
98    /// A custom URL to which users are directed for authentication if required.
99    #[serde(skip_serializing_if = "Option::is_none")]
100    pub user_auth_url: Option<String>,
101    #[serde(skip_serializing_if = "Option::is_none")]
102    pub error: Option<String>,
103}
104
105impl EntityPresentCommentsRequest {
106    pub fn new(comments: Vec<serde_json::Value>, trigger_id: impl Into<String>) -> Self {
107        Self {
108            comments,
109            trigger_id: trigger_id.into(),
110            cursor: None,
111            can_post_comment: None,
112            delete_action_id: None,
113            user_auth_required: None,
114            user_auth_url: None,
115            error: None,
116        }
117    }
118
119    pub fn cursor(mut self, cursor: impl Into<String>) -> Self {
120        self.cursor = Some(cursor.into());
121        self
122    }
123
124    pub fn can_post_comment(mut self, can_post_comment: bool) -> Self {
125        self.can_post_comment = Some(can_post_comment);
126        self
127    }
128
129    pub fn delete_action_id(mut self, delete_action_id: impl Into<String>) -> Self {
130        self.delete_action_id = Some(delete_action_id.into());
131        self
132    }
133
134    pub fn user_auth_required(mut self, user_auth_required: bool) -> Self {
135        self.user_auth_required = Some(user_auth_required);
136        self
137    }
138
139    pub fn user_auth_url(mut self, user_auth_url: impl Into<String>) -> Self {
140        self.user_auth_url = Some(user_auth_url.into());
141        self
142    }
143
144    pub fn error(mut self, error: impl Into<String>) -> Self {
145        self.error = Some(error.into());
146        self
147    }
148}
149
150impl SlackApiMethod for EntityPresentCommentsRequest {
151    const METHOD: &'static str = "entity.presentComments";
152    type Response = EntityPresentCommentsResponse;
153}
154
155impl CursorPaginated for EntityPresentCommentsRequest {
156    fn set_cursor(&mut self, cursor: String) {
157        self.cursor = Some(cursor);
158    }
159}
160
161impl NextCursor for EntityPresentCommentsResponse {
162    fn next_cursor(&self) -> Option<&str> {
163        self.response_metadata.as_ref()?.next_cursor.as_deref()
164    }
165}
166
167/// Successful response of the Slack Web API method [`entity.presentComments`](https://docs.slack.dev/reference/methods/entity.presentComments).
168#[doc(alias = "entity.presentComments")]
169#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
170pub struct EntityPresentCommentsResponse {
171    /// Fields returned by Slack. This method has no documented response example.
172    #[serde(flatten)]
173    pub extra: serde_json::Map<String, serde_json::Value>,
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/// Arguments for the Slack Web API method [`entity.presentDetails`](https://docs.slack.dev/reference/methods/entity.presentDetails): Provide custom flexpane behavior for Work Objects. Apps call this method to send per-user flexpane metadata to the client.
189///
190/// Send it with [`SlackClient::entity_present_details`].
191#[doc(alias = "entity.presentDetails")]
192#[derive(Debug, Clone, PartialEq, Serialize)]
193#[non_exhaustive]
194pub struct EntityPresentDetailsRequest {
195    /// A reference to the original user action that initiated the request.
196    pub trigger_id: String,
197    /// URL-encoded JSON object containing flexpane metadata from the app that will be conformed to a Work Object metadata schema, keyed by entity ID.
198    #[serde(skip_serializing_if = "Option::is_none")]
199    pub metadata: Option<serde_json::Value>,
200    /// Set to true (or 1) to indicate that the user must authenticate to view full flexpane data.
201    #[serde(skip_serializing_if = "Option::is_none")]
202    pub user_auth_required: Option<bool>,
203    /// A custom URL to which users are directed for authentication if required.
204    #[serde(skip_serializing_if = "Option::is_none")]
205    pub user_auth_url: Option<String>,
206    #[serde(skip_serializing_if = "Option::is_none")]
207    pub error: Option<String>,
208}
209
210impl EntityPresentDetailsRequest {
211    pub fn new(trigger_id: impl Into<String>) -> Self {
212        Self {
213            trigger_id: trigger_id.into(),
214            metadata: None,
215            user_auth_required: None,
216            user_auth_url: None,
217            error: None,
218        }
219    }
220
221    pub fn metadata(mut self, metadata: serde_json::Value) -> Self {
222        self.metadata = Some(metadata);
223        self
224    }
225
226    pub fn user_auth_required(mut self, user_auth_required: bool) -> Self {
227        self.user_auth_required = Some(user_auth_required);
228        self
229    }
230
231    pub fn user_auth_url(mut self, user_auth_url: impl Into<String>) -> Self {
232        self.user_auth_url = Some(user_auth_url.into());
233        self
234    }
235
236    pub fn error(mut self, error: impl Into<String>) -> Self {
237        self.error = Some(error.into());
238        self
239    }
240}
241
242impl SlackApiMethod for EntityPresentDetailsRequest {
243    const METHOD: &'static str = "entity.presentDetails";
244    type Response = EntityPresentDetailsResponse;
245}
246
247/// Successful response of the Slack Web API method [`entity.presentDetails`](https://docs.slack.dev/reference/methods/entity.presentDetails).
248#[doc(alias = "entity.presentDetails")]
249#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
250pub struct EntityPresentDetailsResponse {
251    /// Fields returned by Slack. This method has no documented response example.
252    #[serde(flatten)]
253    pub extra: serde_json::Map<String, serde_json::Value>,
254    #[serde(
255        default,
256        deserialize_with = "crate::de::opt_object",
257        skip_serializing_if = "Option::is_none"
258    )]
259    pub response_metadata: Option<ResponseMetadata>,
260    #[serde(
261        default,
262        deserialize_with = "crate::de::opt_string",
263        skip_serializing_if = "Option::is_none"
264    )]
265    pub warning: Option<String>,
266}
267
268impl SlackClient {
269    /// Calls the Slack Web API method [`entity.acknowledgeCommentAction`](https://docs.slack.dev/reference/methods/entity.acknowledgeCommentAction): Acknowledge a comment post, edit, or delete on a Work Object. Apps call this method to confirm they have processed a comment action.
270    ///
271    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
272    ///
273    /// # Errors
274    ///
275    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
276    #[doc(alias = "entity.acknowledgeCommentAction")]
277    pub async fn entity_acknowledge_comment_action(
278        &self,
279        request: &EntityAcknowledgeCommentActionRequest,
280    ) -> Result<EntityAcknowledgeCommentActionResponse, SlackError> {
281        self.call(request).await
282    }
283
284    /// Calls the Slack Web API method [`entity.presentComments`](https://docs.slack.dev/reference/methods/entity.presentComments): Provide comments for Work Objects. Apps call this method to send per-user flexpane comment data to the client.
285    ///
286    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
287    ///
288    /// # Errors
289    ///
290    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
291    #[doc(alias = "entity.presentComments")]
292    pub async fn entity_present_comments(
293        &self,
294        request: &EntityPresentCommentsRequest,
295    ) -> Result<EntityPresentCommentsResponse, SlackError> {
296        self.call(request).await
297    }
298
299    /// Calls the Slack Web API method [`entity.presentDetails`](https://docs.slack.dev/reference/methods/entity.presentDetails): Provide custom flexpane behavior for Work Objects. Apps call this method to send per-user flexpane metadata to the client.
300    ///
301    /// Rate limit: Tier 3 (<https://docs.slack.dev/apis/web-api/rate-limits>).
302    ///
303    /// # Errors
304    ///
305    /// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
306    #[doc(alias = "entity.presentDetails")]
307    pub async fn entity_present_details(
308        &self,
309        request: &EntityPresentDetailsRequest,
310    ) -> Result<EntityPresentDetailsResponse, SlackError> {
311        self.call(request).await
312    }
313}