mattermost_rust_client/apis/
integration_actions_api.rs

1/*
2 * Mattermost API Reference
3 *
4 * There is also a work-in-progress [Postman API reference](https://documenter.getpostman.com/view/4508214/RW8FERUn). 
5 *
6 * The version of the OpenAPI document: 4.0.0
7 * Contact: feedback@mattermost.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`open_interactive_dialog`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum OpenInteractiveDialogError {
22    Status400(crate::models::AppError),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`submit_interactive_dialog`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum SubmitInteractiveDialogError {
30    Status400(crate::models::AppError),
31    Status401(crate::models::AppError),
32    Status403(crate::models::AppError),
33    UnknownValue(serde_json::Value),
34}
35
36
37/// Open an interactive dialog using a trigger ID provided by a slash command, or some other action payload. See https://docs.mattermost.com/developer/interactive-dialogs.html for more information on interactive dialogs. __Minimum server version: 5.6__ 
38pub async fn open_interactive_dialog(configuration: &configuration::Configuration, open_interactive_dialog_request: crate::models::OpenInteractiveDialogRequest) -> Result<crate::models::StatusOk, Error<OpenInteractiveDialogError>> {
39    let local_var_configuration = configuration;
40
41    let local_var_client = &local_var_configuration.client;
42
43    let local_var_uri_str = format!("{}/actions/dialogs/open", local_var_configuration.base_path);
44    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
45
46    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
47        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
48    }
49    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
50        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
51    };
52    local_var_req_builder = local_var_req_builder.json(&open_interactive_dialog_request);
53
54    let local_var_req = local_var_req_builder.build()?;
55    let local_var_resp = local_var_client.execute(local_var_req).await?;
56
57    let local_var_status = local_var_resp.status();
58    let local_var_content = local_var_resp.text().await?;
59
60    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
61        serde_json::from_str(&local_var_content).map_err(Error::from)
62    } else {
63        let local_var_entity: Option<OpenInteractiveDialogError> = serde_json::from_str(&local_var_content).ok();
64        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
65        Err(Error::ResponseError(local_var_error))
66    }
67}
68
69/// Endpoint used by the Mattermost clients to submit a dialog. See https://docs.mattermost.com/developer/interactive-dialogs.html for more information on interactive dialogs. __Minimum server version: 5.6__ 
70pub async fn submit_interactive_dialog(configuration: &configuration::Configuration, submit_interactive_dialog_request: crate::models::SubmitInteractiveDialogRequest) -> Result<crate::models::StatusOk, Error<SubmitInteractiveDialogError>> {
71    let local_var_configuration = configuration;
72
73    let local_var_client = &local_var_configuration.client;
74
75    let local_var_uri_str = format!("{}/actions/dialogs/submit", local_var_configuration.base_path);
76    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
77
78    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
79        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
80    }
81    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
82        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
83    };
84    local_var_req_builder = local_var_req_builder.json(&submit_interactive_dialog_request);
85
86    let local_var_req = local_var_req_builder.build()?;
87    let local_var_resp = local_var_client.execute(local_var_req).await?;
88
89    let local_var_status = local_var_resp.status();
90    let local_var_content = local_var_resp.text().await?;
91
92    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
93        serde_json::from_str(&local_var_content).map_err(Error::from)
94    } else {
95        let local_var_entity: Option<SubmitInteractiveDialogError> = serde_json::from_str(&local_var_content).ok();
96        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
97        Err(Error::ResponseError(local_var_error))
98    }
99}
100