use serde_json::json;
use crate::model::*;
use crate::BenchlingClient;
pub struct GetRequestResponseRequest<'a> {
pub(crate) client: &'a BenchlingClient,
pub request_id: String,
}
impl<'a> GetRequestResponseRequest<'a> {
pub async fn send(self) -> anyhow::Result<RequestResponse> {
let mut r = self
.client
.client
.get(
&format!("/requests/{request_id}/response", request_id = self.request_id),
);
r = self.client.authenticate(r);
let res = r.send().await.unwrap().error_for_status();
match res {
Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
Err(res) => {
let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
Err(anyhow::anyhow!("{:?}", text))
}
}
}
}