open_library_api_rs/api/
partner.rs1use crate::client::OpenLibraryClient;
3use crate::error::{Error, Result};
4use crate::models::common::VolumeIdType;
5use crate::models::partner::VolumesResponse;
6
7impl OpenLibraryClient {
8 pub async fn read_volume(
12 &self,
13 id_type: VolumeIdType,
14 id_value: &str,
15 ) -> Result<VolumesResponse> {
16 if id_value.is_empty() {
17 return Err(Error::InvalidInput("id_value must not be empty".into()));
18 }
19 let path = format!("api/volumes/brief/{}/{}.json", id_type.as_str(), id_value);
20 let url = self.base_url.join(&path)?;
21 self.get_json(url).await
22 }
23
24 pub async fn read_volumes_batch(
28 &self,
29 requests: &[String],
30 ) -> Result<VolumesResponse> {
31 if requests.is_empty() {
32 return Err(Error::InvalidInput("requests list must not be empty".into()));
33 }
34 let joined = requests.join("|");
35 let path = format!("api/volumes/brief/json/{}", joined);
36 let url = self.base_url.join(&path)?;
37 self.get_json(url).await
38 }
39}