Skip to main content

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