benchling/request/
create_assay_runs.rs1use serde_json::json;
2use crate::model::*;
3use crate::BenchlingClient;
4pub struct CreateAssayRunsRequest<'a> {
8 pub(crate) client: &'a BenchlingClient,
9 pub assay_runs: Vec<AssayRunCreate>,
10}
11impl<'a> CreateAssayRunsRequest<'a> {
12 pub async fn send(self) -> anyhow::Result<AssayRunsBulkCreateResponse> {
13 let mut r = self.client.client.post("/assay-runs");
14 r = r.push_json(json!({ "assayRuns" : self.assay_runs }));
15 r = self.client.authenticate(r);
16 let res = r.send().await.unwrap().error_for_status();
17 match res {
18 Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
19 Err(res) => {
20 let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
21 Err(anyhow::anyhow!("{:?}", text))
22 }
23 }
24 }
25}