use reqwest::Method;
use super::types::{DynamicResponse, JoinMeetingRequest};
use crate::{enc, Error, HttpClient, QueryParam};
pub struct MascotsApi<'a> {
http: &'a HttpClient,
}
impl<'a> MascotsApi<'a> {
pub fn new(http: &'a HttpClient) -> Self {
Self { http }
}
pub async fn list_mascots(&self) -> Result<DynamicResponse, Error> {
self.http
.send_typed(Method::GET, "/mascots", &[], None, true)
.await
}
pub async fn get_demo(&self) -> Result<DynamicResponse, Error> {
self.http
.send_typed(Method::GET, "/mascots/demo", &[], None, true)
.await
}
pub async fn join_meeting(
&self,
request: &JoinMeetingRequest,
) -> Result<DynamicResponse, Error> {
let body = serde_json::to_value(request).expect("join meeting request is serializable");
self.http
.send_typed(
Method::POST,
"/mascots/join-meeting",
&[],
Some(&body),
true,
)
.await
}
pub async fn list_meetings(&self, query: &[QueryParam]) -> Result<DynamicResponse, Error> {
self.http
.send_typed(Method::GET, "/mascots/meetings", query, None, true)
.await
}
pub async fn get_mascot(&self, id: &str) -> Result<DynamicResponse, Error> {
let path = format!("/mascots/{}", enc(id));
self.http
.send_typed(Method::GET, &path, &[], None, true)
.await
}
pub async fn get_mascot_riv(&self, id: &str) -> Result<DynamicResponse, Error> {
let path = format!("/mascots/{}/riv", enc(id));
self.http
.send_typed(Method::GET, &path, &[], None, true)
.await
}
}