use crate::client::OpenAI;
use crate::error::OpenAIError;
pub struct Videos<'a> {
client: &'a OpenAI,
}
impl<'a> Videos<'a> {
pub(crate) fn new(client: &'a OpenAI) -> Self {
Self { client }
}
pub async fn create(
&self,
body: &impl serde::Serialize,
) -> Result<serde_json::Value, OpenAIError> {
self.client.post("/videos", body).await
}
pub async fn list(&self) -> Result<serde_json::Value, OpenAIError> {
self.client.get("/videos").await
}
pub async fn retrieve(&self, video_id: &str) -> Result<serde_json::Value, OpenAIError> {
self.client.get(&format!("/videos/{video_id}")).await
}
pub async fn delete(&self, video_id: &str) -> Result<serde_json::Value, OpenAIError> {
self.client.delete(&format!("/videos/{video_id}")).await
}
pub async fn content(&self, video_id: &str) -> Result<bytes::Bytes, OpenAIError> {
self.client
.get_raw(&format!("/videos/{video_id}/content"))
.await
}
pub async fn edit(
&self,
body: &impl serde::Serialize,
) -> Result<serde_json::Value, OpenAIError> {
self.client.post("/videos/edits", body).await
}
pub async fn extend(
&self,
body: &impl serde::Serialize,
) -> Result<serde_json::Value, OpenAIError> {
self.client.post("/videos/extensions", body).await
}
pub async fn remix(
&self,
video_id: &str,
body: &impl serde::Serialize,
) -> Result<serde_json::Value, OpenAIError> {
self.client
.post(&format!("/videos/{video_id}/remix"), body)
.await
}
pub async fn create_character(
&self,
body: &impl serde::Serialize,
) -> Result<serde_json::Value, OpenAIError> {
self.client.post("/videos/characters", body).await
}
pub async fn retrieve_character(
&self,
character_id: &str,
) -> Result<serde_json::Value, OpenAIError> {
self.client
.get(&format!("/videos/characters/{character_id}"))
.await
}
}