zai_rs/model/voice_delete/
data.rs1use super::request::VoiceDeleteBody;
2use crate::client::http::HttpClient;
3use validator::Validate;
4
5pub struct VoiceDeleteRequest {
7 pub key: String,
8 body: VoiceDeleteBody,
9}
10
11impl VoiceDeleteRequest {
12 pub fn new(key: String, voice: impl Into<String>) -> Self {
13 let body = VoiceDeleteBody::new(voice);
14 Self { key, body }
15 }
16
17 pub fn with_request_id(mut self, request_id: impl Into<String>) -> Self {
18 self.body = self.body.with_request_id(request_id);
19 self
20 }
21
22 pub fn validate(&self) -> anyhow::Result<()> {
23 self.body.validate().map_err(|e| anyhow::anyhow!(e))?;
24 Ok(())
25 }
26
27 pub async fn send(&self) -> anyhow::Result<super::response::VoiceDeleteResponse> {
28 self.validate()?;
29 let resp = self.post().await?;
30 let parsed = resp.json::<super::response::VoiceDeleteResponse>().await?;
31 Ok(parsed)
32 }
33}
34
35impl HttpClient for VoiceDeleteRequest {
36 type Body = VoiceDeleteBody;
37 type ApiUrl = &'static str;
38 type ApiKey = String;
39
40 fn api_url(&self) -> &Self::ApiUrl {
41 &"https://open.bigmodel.cn/api/paas/v4/voice/delete"
42 }
43 fn api_key(&self) -> &Self::ApiKey {
44 &self.key
45 }
46 fn body(&self) -> &Self::Body {
47 &self.body
48 }
49}