asterisk_ari/apis/playbacks/
mod.rs

1pub mod models;
2
3use crate::apis::client::Client;
4use serde::Serialize;
5
6pub struct Playbacks<'c> {
7    client: &'c Client,
8}
9
10impl<'c> Playbacks<'c> {
11    pub fn new(client: &'c Client) -> Self {
12        Self { client }
13    }
14}
15
16impl Playbacks<'_> {
17    pub async fn get(
18        &self,
19        playback_id: impl Into<String>,
20    ) -> crate::errors::Result<Vec<models::Playback>> {
21        self.client
22            .get(format!("/playback/{}", playback_id.into()).as_str())
23            .await
24    }
25
26    pub async fn control(
27        &self,
28        playback_id: impl Into<String>,
29        operation: Operation,
30    ) -> crate::errors::Result<()> {
31        self.client
32            .post_with_query(
33                format!("/playback/{}/control", playback_id.into()).as_str(),
34                vec![] as Vec<String>,
35                &[("operation", operation)],
36            )
37            .await
38    }
39
40    /// Stop a playback
41    pub async fn stop(&self, playback_id: impl Into<String>) -> crate::errors::Result<()> {
42        self.client
43            .delete(format!("/playback/{}", playback_id.into()).as_str())
44            .await
45    }
46}
47
48#[derive(Debug, Clone, Copy, Serialize)]
49pub enum Operation {
50    #[serde(rename = "restart")]
51    Restart,
52    #[serde(rename = "pause")]
53    Pause,
54    #[serde(rename = "unpause")]
55    Unpause,
56    #[serde(rename = "reverse")]
57    Reverse,
58    #[serde(rename = "forward")]
59    Forward,
60}