benchling/request/
get_feature.rs1use serde_json::json;
2use crate::model::*;
3use crate::BenchlingClient;
4pub struct GetFeatureRequest<'a> {
8 pub(crate) client: &'a BenchlingClient,
9 pub feature_id: String,
10}
11impl<'a> GetFeatureRequest<'a> {
12 pub async fn send(self) -> anyhow::Result<Feature> {
13 let mut r = self
14 .client
15 .client
16 .get(&format!("/features/{feature_id}", feature_id = self.feature_id));
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}