#[allow(dead_code)]
use super::*;
const SAMPLES_PATH: &str = "/samples";
const AUDIO_PATH: &str = "/audio";
#[derive(Clone, Debug)]
pub struct DeleteSample(SamplePathParams);
impl DeleteSample {
pub fn new<T: Into<String>>(voice_id: T, sample_id: &str) -> Self {
Self {
0: SamplePathParams::new(voice_id, sample_id),
}
}
}
impl Endpoint for DeleteSample {
type ResponseBody = StatusResponseBody;
fn method(&self) -> Method {
Method::DELETE
}
async fn response_body(self, resp: Response) -> Result<Self::ResponseBody> {
Ok(resp.json().await?)
}
fn url(&self) -> Url {
let mut url = BASE_URL.parse::<Url>().unwrap();
url.set_path(&format!(
"{}/{}{}/{}",
VOICES_PATH, self.0.voice_id.0, SAMPLES_PATH, self.0.sample_id
));
url
}
}
#[derive(Clone, Debug)]
pub struct SamplePathParams {
voice_id: VoiceID,
sample_id: String,
}
impl SamplePathParams {
pub fn new<T: Into<String>>(voice_id: T, sample_id: &str) -> Self {
Self {
voice_id: VoiceID::from(voice_id.into()),
sample_id: sample_id.to_string(),
}
}
}
#[derive(Clone, Debug)]
pub struct GetAudioFromSample(SamplePathParams);
impl GetAudioFromSample {
pub fn new<T: Into<String>>(voice_id: T, sample_id: &str) -> Self {
Self {
0: SamplePathParams::new(voice_id, sample_id),
}
}
}
impl Endpoint for GetAudioFromSample {
type ResponseBody = Bytes;
fn method(&self) -> Method {
Method::GET
}
async fn response_body(self, resp: Response) -> Result<Self::ResponseBody> {
Ok(resp.bytes().await?)
}
fn url(&self) -> Url {
let mut url = BASE_URL.parse::<Url>().unwrap();
url.set_path(&format!(
"{}/{}{}/{}{}",
VOICES_PATH, self.0.voice_id.0, SAMPLES_PATH, self.0.sample_id, AUDIO_PATH
));
url
}
}