use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::client::parse_dailyco_response;
use crate::Client;
#[derive(Debug, Clone, Deserialize)]
pub struct RecordingObject {
pub id: Uuid,
pub room_name: String,
pub start_ts: i64,
pub status: RecordingStatus,
pub max_participants: u32,
pub duration: Option<u32>,
pub s3key: String,
#[serde(rename = "mtgSessionId")]
pub meeting_session_id: Uuid,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum RecordingStatus {
Finished,
InProgress,
Canceled,
}
#[derive(Copy, Clone, Debug, serde::Serialize, Default)]
pub struct GetRecordingAccessLink {
#[serde(skip_serializing_if = "Option::is_none")]
valid_for_secs: Option<u64>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct RecordingAccessLink {
pub download_link: String,
pub expires: i64,
}
impl GetRecordingAccessLink {
#[must_use]
pub fn new() -> Self {
Self::default()
}
pub fn valid_for_secs(&mut self, secs: u64) -> &mut Self {
self.valid_for_secs = Some(secs);
self
}
pub async fn send(&self, client: &Client, id: Uuid) -> crate::Result<RecordingAccessLink> {
let url = format!("{}/recordings/{id}/access-link", client.base_url);
let resp = client.client.get(url).query(self).send().await?;
parse_dailyco_response(resp).await
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct ListedRecordings {
pub total_count: u32,
pub data: Vec<RecordingObject>,
}
#[derive(Debug, Copy, Clone, Serialize, Default)]
pub struct ListRecordings<'a> {
limit: Option<u32>,
ending_before: Option<Uuid>,
starting_after: Option<Uuid>,
room_name: Option<&'a str>,
}
impl<'a> ListRecordings<'a> {
#[must_use]
pub fn new() -> Self {
Self::default()
}
pub fn limit(&mut self, limit: u32) -> &mut Self {
self.limit = Some(limit);
self
}
pub fn ending_before(&mut self, ending_before: Uuid) -> &mut Self {
self.ending_before = Some(ending_before);
self
}
pub fn starting_after(&mut self, starting_after: Uuid) -> &mut Self {
self.starting_after = Some(starting_after);
self
}
pub fn room_name(&mut self, room_name: &'a str) -> &mut Self {
self.room_name = Some(room_name);
self
}
pub async fn send(&self, client: &Client) -> crate::Result<ListedRecordings> {
let url = format!("{}/recordings", client.base_url);
let resp = client.client.get(url).query(self).send().await?;
parse_dailyco_response(resp).await
}
}