use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct VideoResource {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "object")]
pub object: Object,
#[serde(rename = "model")]
pub model: Box<models::VideoModel>,
#[serde(rename = "status")]
pub status: models::VideoStatus,
#[serde(rename = "progress")]
pub progress: i32,
#[serde(rename = "created_at")]
pub created_at: i32,
#[serde(rename = "completed_at", deserialize_with = "Option::deserialize")]
pub completed_at: Option<i32>,
#[serde(rename = "expires_at", deserialize_with = "Option::deserialize")]
pub expires_at: Option<i32>,
#[serde(rename = "prompt", deserialize_with = "Option::deserialize")]
pub prompt: Option<String>,
#[serde(rename = "size")]
pub size: models::VideoSize,
#[serde(rename = "seconds")]
pub seconds: String,
#[serde(
rename = "remixed_from_video_id",
deserialize_with = "Option::deserialize"
)]
pub remixed_from_video_id: Option<String>,
#[serde(rename = "error", deserialize_with = "Option::deserialize")]
pub error: Option<Box<models::Error2>>,
}
impl VideoResource {
pub fn new(
id: String,
object: Object,
model: models::VideoModel,
status: models::VideoStatus,
progress: i32,
created_at: i32,
completed_at: Option<i32>,
expires_at: Option<i32>,
prompt: Option<String>,
size: models::VideoSize,
seconds: String,
remixed_from_video_id: Option<String>,
error: Option<models::Error2>,
) -> VideoResource {
VideoResource {
id,
object,
model: Box::new(model),
status,
progress,
created_at,
completed_at,
expires_at,
prompt,
size,
seconds,
remixed_from_video_id,
error: error.map(Box::new),
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
#[serde(rename = "video")]
Video,
}
impl Default for Object {
fn default() -> Object {
Self::Video
}
}
impl std::fmt::Display for VideoResource {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}