slack_chat_api/
workflows.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct Workflows {
5    pub client: Client,
6}
7
8impl Workflows {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Workflows { client }
12    }
13
14    /**
15     * This function performs a `GET` to the `/workflows.stepCompleted` endpoint.
16     *
17     * Indicate that an app's step in a workflow completed execution.
18     *
19     * FROM: <https://api.slack.com/methods/workflows.stepCompleted>
20     *
21     * **Parameters:**
22     *
23     * * `token: &str` -- Authentication token. Requires scope: `workflow.steps:execute`.
24     * * `workflow_step_execute_id: &str` -- Context identifier that maps to the correct workflow step execution.
25     * * `outputs: &str` -- Key-value object of outputs from your step. Keys of this object reflect the configured `key` properties of your [`outputs`](/reference/workflows/workflow_step#output) array from your `workflow_step` object.
26     */
27    pub async fn step_completed(
28        &self,
29        workflow_step_execute_id: &str,
30        outputs: &str,
31    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
32        let mut query_args: Vec<(String, String)> = Default::default();
33        if !outputs.is_empty() {
34            query_args.push(("outputs".to_string(), outputs.to_string()));
35        }
36        if !workflow_step_execute_id.is_empty() {
37            query_args.push((
38                "workflow_step_execute_id".to_string(),
39                workflow_step_execute_id.to_string(),
40            ));
41        }
42        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
43        let url = self
44            .client
45            .url(&format!("/workflows.stepCompleted?{}", query_), None);
46        self.client
47            .get(
48                &url,
49                crate::Message {
50                    body: None,
51                    content_type: None,
52                },
53            )
54            .await
55    }
56    /**
57     * This function performs a `GET` to the `/workflows.stepFailed` endpoint.
58     *
59     * Indicate that an app's step in a workflow failed to execute.
60     *
61     * FROM: <https://api.slack.com/methods/workflows.stepFailed>
62     *
63     * **Parameters:**
64     *
65     * * `token: &str` -- Authentication token. Requires scope: `workflow.steps:execute`.
66     * * `workflow_step_execute_id: &str` -- Context identifier that maps to the correct workflow step execution.
67     * * `error: &str` -- A JSON-based object with a `message` property that should contain a human readable error message.
68     */
69    pub async fn step_failed(
70        &self,
71        workflow_step_execute_id: &str,
72        error: &str,
73    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
74        let mut query_args: Vec<(String, String)> = Default::default();
75        if !error.is_empty() {
76            query_args.push(("error".to_string(), error.to_string()));
77        }
78        if !workflow_step_execute_id.is_empty() {
79            query_args.push((
80                "workflow_step_execute_id".to_string(),
81                workflow_step_execute_id.to_string(),
82            ));
83        }
84        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
85        let url = self
86            .client
87            .url(&format!("/workflows.stepFailed?{}", query_), None);
88        self.client
89            .get(
90                &url,
91                crate::Message {
92                    body: None,
93                    content_type: None,
94                },
95            )
96            .await
97    }
98    /**
99     * This function performs a `GET` to the `/workflows.updateStep` endpoint.
100     *
101     * Update the configuration for a workflow extension step.
102     *
103     * FROM: <https://api.slack.com/methods/workflows.updateStep>
104     *
105     * **Parameters:**
106     *
107     * * `token: &str` -- Authentication token. Requires scope: `workflow.steps:execute`.
108     * * `workflow_step_edit_id: &str` -- A context identifier provided with `view_submission` payloads used to call back to `workflows.updateStep`.
109     * * `inputs: &str` -- A JSON key-value map of inputs required from a user during configuration. This is the data your app expects to receive when the workflow step starts. **Please note**: the embedded variable format is set and replaced by the workflow system. You cannot create custom variables that will be replaced at runtime. [Read more about variables in workflow steps here](/workflows/steps#variables).
110     * * `outputs: &str` -- An JSON array of output objects used during step execution. This is the data your app agrees to provide when your workflow step was executed.
111     * * `step_name: &str` -- An optional field that can be used to override the step name that is shown in the Workflow Builder.
112     * * `step_image_url: &str` -- An optional field that can be used to override app image that is shown in the Workflow Builder.
113     */
114    pub async fn update_step(
115        &self,
116        workflow_step_edit_id: &str,
117        inputs: &str,
118        outputs: &str,
119        step_name: &str,
120        step_image_url: &str,
121    ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
122        let mut query_args: Vec<(String, String)> = Default::default();
123        if !inputs.is_empty() {
124            query_args.push(("inputs".to_string(), inputs.to_string()));
125        }
126        if !outputs.is_empty() {
127            query_args.push(("outputs".to_string(), outputs.to_string()));
128        }
129        if !step_image_url.is_empty() {
130            query_args.push(("step_image_url".to_string(), step_image_url.to_string()));
131        }
132        if !step_name.is_empty() {
133            query_args.push(("step_name".to_string(), step_name.to_string()));
134        }
135        if !workflow_step_edit_id.is_empty() {
136            query_args.push((
137                "workflow_step_edit_id".to_string(),
138                workflow_step_edit_id.to_string(),
139            ));
140        }
141        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
142        let url = self
143            .client
144            .url(&format!("/workflows.updateStep?{}", query_), None);
145        self.client
146            .get(
147                &url,
148                crate::Message {
149                    body: None,
150                    content_type: None,
151                },
152            )
153            .await
154    }
155}