benchling/request/
bulk_update_workflow_tasks.rs

1use serde_json::json;
2use crate::model::*;
3use crate::BenchlingClient;
4/**Create this with the associated client method.
5
6That method takes required values as arguments. Set optional values using builder methods on this struct.*/
7pub struct BulkUpdateWorkflowTasksRequest<'a> {
8    pub(crate) client: &'a BenchlingClient,
9    pub workflow_tasks: Option<Vec<WorkflowTaskBulkUpdate>>,
10}
11impl<'a> BulkUpdateWorkflowTasksRequest<'a> {
12    pub async fn send(self) -> anyhow::Result<AsyncTaskLink> {
13        let mut r = self.client.client.post("/workflow-tasks:bulk-update");
14        if let Some(ref unwrapped) = self.workflow_tasks {
15            r = r.push_json(json!({ "workflowTasks" : unwrapped }));
16        }
17        r = self.client.authenticate(r);
18        let res = r.send().await.unwrap().error_for_status();
19        match res {
20            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
21            Err(res) => {
22                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
23                Err(anyhow::anyhow!("{:?}", text))
24            }
25        }
26    }
27    pub fn workflow_tasks(
28        mut self,
29        workflow_tasks: Vec<WorkflowTaskBulkUpdate>,
30    ) -> Self {
31        self.workflow_tasks = Some(workflow_tasks);
32        self
33    }
34}