asterisk_ari/apis/asterisk/variables/
mod.rs

1pub mod models;
2
3use crate::apis::client::Client;
4
5pub struct Variables<'c> {
6    client: &'c Client,
7}
8
9impl<'c> Variables<'c> {
10    pub fn new(client: &'c Client) -> Self {
11        Self { client }
12    }
13}
14
15impl Variables<'_> {
16    /// Get the value of a global variable.
17    pub async fn get(
18        &self,
19        variable: impl Into<String> + Send,
20    ) -> crate::errors::Result<models::Variable> {
21        self.client
22            .get_with_query("/asterisk/variable", &[("variable", variable.into())])
23            .await
24    }
25
26    /// Set the value of a global variable.
27    pub async fn set(
28        &self,
29        variable: impl Into<String> + Send,
30        value: Option<impl Into<String> + Send>,
31    ) -> crate::errors::Result<()> {
32        self.client
33            .post_with_query(
34                "/asterisk/variable",
35                vec![] as Vec<String>,
36                &[
37                    ("variable", variable.into()),
38                    ("value", value.map(|v| v.into()).unwrap_or_default()),
39                ],
40            )
41            .await
42    }
43}