zai_rs/batches/
retrieve.rs1use super::types::BatchItem;
2use crate::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!(
19 "https://open.bigmodel.cn/api/paas/v4/batches/{}",
20 batch_id.as_ref()
21 );
22 Self {
23 key,
24 url,
25 _body: (),
26 }
27 }
28
29 pub async fn send(&self) -> anyhow::Result<BatchesRetrieveResponse> {
31 let resp: reqwest::Response = self.get().await?;
32 let parsed = resp.json::<BatchesRetrieveResponse>().await?;
33 Ok(parsed)
34 }
35}
36
37impl HttpClient for BatchesRetrieveRequest {
38 type Body = ();
39 type ApiUrl = String;
40 type ApiKey = String;
41
42 fn api_url(&self) -> &Self::ApiUrl {
43 &self.url
44 }
45 fn api_key(&self) -> &Self::ApiKey {
46 &self.key
47 }
48 fn body(&self) -> &Self::Body {
49 &self._body
50 }
51}
52
53pub type BatchesRetrieveResponse = BatchItem;