1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// このファイルは codegen/generate.py が生成する。手で編集しない
#![allow(unused_imports)]
use crate::objects::*;
use crate::{
CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
};
use serde::{Deserialize, Serialize};
/// Arguments for the Slack Web API method [`dialog.open`](https://docs.slack.dev/reference/methods/dialog.open): Open a dialog with a user
///
/// Send it with [`SlackClient::dialog_open`].
#[doc(alias = "dialog.open")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct DialogOpenRequest {
/// The dialog definition. This must be a JSON-encoded string.
pub dialog: String,
/// Exchange a trigger to post to the user.
pub trigger_id: String,
}
impl DialogOpenRequest {
pub fn new(dialog: impl Into<String>, trigger_id: impl Into<String>) -> Self {
Self {
dialog: dialog.into(),
trigger_id: trigger_id.into(),
}
}
}
impl SlackApiMethod for DialogOpenRequest {
const METHOD: &'static str = "dialog.open";
type Response = DialogOpenResponse;
}
/// Successful response of the Slack Web API method [`dialog.open`](https://docs.slack.dev/reference/methods/dialog.open).
#[doc(alias = "dialog.open")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DialogOpenResponse {
/// Fields returned by Slack. This method has no documented response example.
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
#[serde(
default,
deserialize_with = "crate::de::opt_object",
skip_serializing_if = "Option::is_none"
)]
pub response_metadata: Option<ResponseMetadata>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub warning: Option<String>,
}
impl SlackClient {
/// Calls the Slack Web API method [`dialog.open`](https://docs.slack.dev/reference/methods/dialog.open): Open a dialog with a user
///
/// Rate limit: Tier 4 (<https://docs.slack.dev/apis/web-api/rate-limits>).
///
/// # Errors
///
/// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
#[doc(alias = "dialog.open")]
pub async fn dialog_open(
&self,
request: &DialogOpenRequest,
) -> Result<DialogOpenResponse, SlackError> {
self.call(request).await
}
}