zai_rs/batches/
retrieve.rs1use super::types::BatchItem;
2use crate::{ZaiResult, client::http::HttpClient};
3
4pub struct BatchesRetrieveRequest {
6 pub key: String,
8 url: String,
10 _body: (),
12}
13
14impl BatchesRetrieveRequest {
15 pub fn new(key: String, batch_id: impl AsRef<str>) -> Self {
17 let url = format!(
20 "https://open.bigmodel.cn/api/paas/v4/batches/{}",
21 batch_id.as_ref()
22 );
23 Self {
24 key,
25 url,
26 _body: (),
27 }
28 }
29
30 pub async fn send(&self) -> ZaiResult<BatchesRetrieveResponse> {
32 let resp: reqwest::Response = self.get().await?;
33 let parsed = resp.json::<BatchesRetrieveResponse>().await?;
34 Ok(parsed)
35 }
36}
37
38impl HttpClient for BatchesRetrieveRequest {
39 type Body = ();
40 type ApiUrl = String;
41 type ApiKey = String;
42
43 fn api_url(&self) -> &Self::ApiUrl {
44 &self.url
45 }
46 fn api_key(&self) -> &Self::ApiKey {
47 &self.key
48 }
49 fn body(&self) -> &Self::Body {
50 &self._body
51 }
52}
53
54pub type BatchesRetrieveResponse = BatchItem;