use serde::Serialize;
use url::Url;
use crate::{
errors::OapiError,
realtime::RealtimeSession,
rest::post::{Post, PostNoStream},
};
#[derive(Debug, Clone, Serialize)]
pub struct CreateTranscriptionSessionRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub session: Option<serde_json::Value>,
#[serde(flatten, skip_serializing_if = "Option::is_none")]
pub extra_body: Option<serde_json::Map<String, serde_json::Value>>,
}
impl Post for CreateTranscriptionSessionRequest {
fn is_streaming(&self) -> bool {
false
}
fn build_url(&self, base_url: &str) -> Result<String, OapiError> {
let mut url = Url::parse(base_url.trim_end_matches('/')).map_err(OapiError::UrlError)?;
url.path_segments_mut()
.map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
.push("realtime")
.push("transcription_sessions");
Ok(url.to_string())
}
}
impl PostNoStream for CreateTranscriptionSessionRequest {
type Response = RealtimeSession;
}