mod call;
pub use call::Call;
use std::sync::Arc;
use reqwest::Method;
use crate::client::Client;
use crate::error::Result;
use crate::models::{
CallTypeCrudResponse, CreateCallTypeRequest, GetEdgesResponse, ListCallTypeResponse,
QueryCallsRequest, QueryCallsResponse, Response, UpdateCallTypeRequest,
};
#[derive(Clone)]
pub struct VideoClient {
client: Arc<Client>,
}
impl VideoClient {
pub(crate) fn new(client: Arc<Client>) -> Self {
Self { client }
}
pub fn call(&self, call_type: impl Into<String>, call_id: impl Into<String>) -> Call {
Call::new(self.client.clone(), call_type.into(), call_id.into())
}
pub async fn query_calls(&self, request: QueryCallsRequest) -> Result<QueryCallsResponse> {
self.client
.request(Method::POST, "/api/v2/video/calls", &[], Some(&request))
.await
}
pub async fn get_edges(&self) -> Result<GetEdgesResponse> {
self.client
.request::<(), _>(Method::GET, "/api/v2/video/edges", &[], None)
.await
}
pub async fn list_call_types(&self) -> Result<ListCallTypeResponse> {
self.client
.request::<(), _>(Method::GET, "/api/v2/video/calltypes", &[], None)
.await
}
pub async fn create_call_type(
&self,
request: CreateCallTypeRequest,
) -> Result<CallTypeCrudResponse> {
self.client
.request(Method::POST, "/api/v2/video/calltypes", &[], Some(&request))
.await
}
pub async fn get_call_type(&self, name: &str) -> Result<CallTypeCrudResponse> {
let path = Client::build_path("/api/v2/video/calltypes/{name}", &[("name", name)]);
self.client
.request::<(), _>(Method::GET, &path, &[], None)
.await
}
pub async fn update_call_type(
&self,
name: &str,
request: UpdateCallTypeRequest,
) -> Result<CallTypeCrudResponse> {
let path = Client::build_path("/api/v2/video/calltypes/{name}", &[("name", name)]);
self.client
.request(Method::PUT, &path, &[], Some(&request))
.await
}
pub async fn delete_call_type(&self, name: &str) -> Result<Response> {
let path = Client::build_path("/api/v2/video/calltypes/{name}", &[("name", name)]);
self.client
.request::<(), _>(Method::DELETE, &path, &[], None)
.await
}
}