use super::types::BatchItem;
use crate::{ZaiResult, client::http::HttpClient};
pub struct BatchesRetrieveRequest {
pub key: String,
url: String,
_body: (),
}
impl BatchesRetrieveRequest {
pub fn new(key: String, batch_id: impl AsRef<str>) -> Self {
let url = format!(
"https://open.bigmodel.cn/api/paas/v4/batches/{}",
batch_id.as_ref()
);
Self {
key,
url,
_body: (),
}
}
pub async fn send(&self) -> ZaiResult<BatchesRetrieveResponse> {
let resp: reqwest::Response = self.get().await?;
let parsed = resp.json::<BatchesRetrieveResponse>().await?;
Ok(parsed)
}
}
impl HttpClient for BatchesRetrieveRequest {
type Body = ();
type ApiUrl = String;
type ApiKey = String;
fn api_url(&self) -> &Self::ApiUrl {
&self.url
}
fn api_key(&self) -> &Self::ApiKey {
&self.key
}
fn body(&self) -> &Self::Body {
&self._body
}
}
pub type BatchesRetrieveResponse = BatchItem;