use reqwest::Method;
use crate::client::Client;
use crate::error::Result;
use crate::models::Group;
const PATH: &str = "api/v1/groups";
#[derive(Debug)]
pub struct GroupsApi<'a> {
client: &'a Client,
}
impl<'a> GroupsApi<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
pub async fn list(&self) -> Result<Vec<Group>> {
let req = self.client.request(Method::GET, PATH);
self.client.send_json(req).await
}
pub async fn get(&self, id: u64) -> Result<Group> {
let req = self.client.request(Method::GET, &format!("{PATH}/{id}"));
self.client.send_json(req).await
}
}