1#![allow(unused_imports)]
4
5use crate::objects::*;
6use crate::{
7 CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
8};
9use serde::{Deserialize, Serialize};
10
11#[doc(alias = "views.open")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct ViewsOpenRequest {
18 pub view: crate::blocks::View,
20 #[serde(skip_serializing_if = "Option::is_none")]
22 pub trigger_id: Option<String>,
23 #[serde(skip_serializing_if = "Option::is_none")]
25 pub interactivity_pointer: Option<String>,
26}
27
28impl ViewsOpenRequest {
29 pub fn new(view: crate::blocks::View) -> Self {
30 Self {
31 view,
32 trigger_id: None,
33 interactivity_pointer: None,
34 }
35 }
36
37 pub fn trigger_id(mut self, trigger_id: impl Into<String>) -> Self {
38 self.trigger_id = Some(trigger_id.into());
39 self
40 }
41
42 pub fn interactivity_pointer(mut self, interactivity_pointer: impl Into<String>) -> Self {
43 self.interactivity_pointer = Some(interactivity_pointer.into());
44 self
45 }
46}
47
48impl SlackApiMethod for ViewsOpenRequest {
49 const METHOD: &'static str = "views.open";
50 type Response = ViewsOpenResponse;
51}
52
53#[doc(alias = "views.open")]
55#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
56pub struct ViewsOpenResponse {
57 #[serde(
58 default,
59 deserialize_with = "crate::de::opt_object",
60 skip_serializing_if = "Option::is_none"
61 )]
62 pub view: Option<ViewInfo>,
63 #[serde(
64 default,
65 deserialize_with = "crate::de::opt_object",
66 skip_serializing_if = "Option::is_none"
67 )]
68 pub response_metadata: Option<ResponseMetadata>,
69 #[serde(
70 default,
71 deserialize_with = "crate::de::opt_string",
72 skip_serializing_if = "Option::is_none"
73 )]
74 pub warning: Option<String>,
75}
76
77#[doc(alias = "views.publish")]
81#[derive(Debug, Clone, PartialEq, Serialize)]
82#[non_exhaustive]
83pub struct ViewsPublishRequest {
84 pub user_id: String,
86 pub view: crate::blocks::View,
88 #[serde(skip_serializing_if = "Option::is_none")]
90 pub hash: Option<String>,
91 #[serde(skip_serializing_if = "Option::is_none")]
92 pub interactivity_pointer: Option<String>,
93}
94
95impl ViewsPublishRequest {
96 pub fn new(user_id: impl Into<String>, view: crate::blocks::View) -> Self {
97 Self {
98 user_id: user_id.into(),
99 view,
100 hash: None,
101 interactivity_pointer: None,
102 }
103 }
104
105 pub fn hash(mut self, hash: impl Into<String>) -> Self {
106 self.hash = Some(hash.into());
107 self
108 }
109
110 pub fn interactivity_pointer(mut self, interactivity_pointer: impl Into<String>) -> Self {
111 self.interactivity_pointer = Some(interactivity_pointer.into());
112 self
113 }
114}
115
116impl SlackApiMethod for ViewsPublishRequest {
117 const METHOD: &'static str = "views.publish";
118 type Response = ViewsPublishResponse;
119}
120
121#[doc(alias = "views.publish")]
123#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
124pub struct ViewsPublishResponse {
125 #[serde(
126 default,
127 deserialize_with = "crate::de::opt_object",
128 skip_serializing_if = "Option::is_none"
129 )]
130 pub view: Option<ViewInfo>,
131 #[serde(
132 default,
133 deserialize_with = "crate::de::opt_object",
134 skip_serializing_if = "Option::is_none"
135 )]
136 pub response_metadata: Option<ResponseMetadata>,
137 #[serde(
138 default,
139 deserialize_with = "crate::de::opt_string",
140 skip_serializing_if = "Option::is_none"
141 )]
142 pub warning: Option<String>,
143}
144
145#[doc(alias = "views.push")]
149#[derive(Debug, Clone, PartialEq, Serialize)]
150#[non_exhaustive]
151pub struct ViewsPushRequest {
152 pub view: crate::blocks::View,
154 #[serde(skip_serializing_if = "Option::is_none")]
156 pub trigger_id: Option<String>,
157 #[serde(skip_serializing_if = "Option::is_none")]
159 pub interactivity_pointer: Option<String>,
160}
161
162impl ViewsPushRequest {
163 pub fn new(view: crate::blocks::View) -> Self {
164 Self {
165 view,
166 trigger_id: None,
167 interactivity_pointer: None,
168 }
169 }
170
171 pub fn trigger_id(mut self, trigger_id: impl Into<String>) -> Self {
172 self.trigger_id = Some(trigger_id.into());
173 self
174 }
175
176 pub fn interactivity_pointer(mut self, interactivity_pointer: impl Into<String>) -> Self {
177 self.interactivity_pointer = Some(interactivity_pointer.into());
178 self
179 }
180}
181
182impl SlackApiMethod for ViewsPushRequest {
183 const METHOD: &'static str = "views.push";
184 type Response = ViewsPushResponse;
185}
186
187#[doc(alias = "views.push")]
189#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
190pub struct ViewsPushResponse {
191 #[serde(
192 default,
193 deserialize_with = "crate::de::opt_object",
194 skip_serializing_if = "Option::is_none"
195 )]
196 pub view: Option<ViewInfo>,
197 #[serde(
198 default,
199 deserialize_with = "crate::de::opt_object",
200 skip_serializing_if = "Option::is_none"
201 )]
202 pub response_metadata: Option<ResponseMetadata>,
203 #[serde(
204 default,
205 deserialize_with = "crate::de::opt_string",
206 skip_serializing_if = "Option::is_none"
207 )]
208 pub warning: Option<String>,
209}
210
211#[doc(alias = "views.update")]
215#[derive(Debug, Clone, PartialEq, Serialize)]
216#[non_exhaustive]
217pub struct ViewsUpdateRequest {
218 pub view: crate::blocks::View,
220 #[serde(skip_serializing_if = "Option::is_none")]
222 pub view_id: Option<String>,
223 #[serde(skip_serializing_if = "Option::is_none")]
225 pub external_id: Option<String>,
226 #[serde(skip_serializing_if = "Option::is_none")]
228 pub hash: Option<String>,
229}
230
231impl ViewsUpdateRequest {
232 pub fn new(view: crate::blocks::View) -> Self {
233 Self {
234 view,
235 view_id: None,
236 external_id: None,
237 hash: None,
238 }
239 }
240
241 pub fn view_id(mut self, view_id: impl Into<String>) -> Self {
242 self.view_id = Some(view_id.into());
243 self
244 }
245
246 pub fn external_id(mut self, external_id: impl Into<String>) -> Self {
247 self.external_id = Some(external_id.into());
248 self
249 }
250
251 pub fn hash(mut self, hash: impl Into<String>) -> Self {
252 self.hash = Some(hash.into());
253 self
254 }
255}
256
257impl SlackApiMethod for ViewsUpdateRequest {
258 const METHOD: &'static str = "views.update";
259 type Response = ViewsUpdateResponse;
260}
261
262#[doc(alias = "views.update")]
264#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
265pub struct ViewsUpdateResponse {
266 #[serde(
267 default,
268 deserialize_with = "crate::de::opt_object",
269 skip_serializing_if = "Option::is_none"
270 )]
271 pub view: Option<ViewInfo>,
272 #[serde(
273 default,
274 deserialize_with = "crate::de::opt_object",
275 skip_serializing_if = "Option::is_none"
276 )]
277 pub response_metadata: Option<ResponseMetadata>,
278 #[serde(
279 default,
280 deserialize_with = "crate::de::opt_string",
281 skip_serializing_if = "Option::is_none"
282 )]
283 pub warning: Option<String>,
284}
285
286impl SlackClient {
287 #[doc(alias = "views.open")]
295 pub async fn views_open(
296 &self,
297 request: &ViewsOpenRequest,
298 ) -> Result<ViewsOpenResponse, SlackError> {
299 self.call(request).await
300 }
301
302 #[doc(alias = "views.publish")]
310 pub async fn views_publish(
311 &self,
312 request: &ViewsPublishRequest,
313 ) -> Result<ViewsPublishResponse, SlackError> {
314 self.call(request).await
315 }
316
317 #[doc(alias = "views.push")]
325 pub async fn views_push(
326 &self,
327 request: &ViewsPushRequest,
328 ) -> Result<ViewsPushResponse, SlackError> {
329 self.call(request).await
330 }
331
332 #[doc(alias = "views.update")]
340 pub async fn views_update(
341 &self,
342 request: &ViewsUpdateRequest,
343 ) -> Result<ViewsUpdateResponse, SlackError> {
344 self.call(request).await
345 }
346}