use serde_json::json;
use crate::model::*;
use crate::PostmanClient;
pub struct PublishMockRequest<'a> {
pub(crate) http_client: &'a PostmanClient,
pub mock_uid: String,
}
impl<'a> PublishMockRequest<'a> {
pub async fn send(self) -> anyhow::Result<serde_json::Value> {
let mut r = self
.http_client
.client
.post(&format!("/mocks/{mock_uid}/publish", mock_uid = self.mock_uid));
r = self.http_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))
}
}
}
}