use crate::error::MisarDevError;
use crate::transport::Transport;
use crate::transport::body_or_empty;
use crate::transport::build_query;
use crate::transport::encode_path;
use reqwest::Method;
use serde_json::Value;
#[derive(Debug, Clone, Copy)]
pub struct NotificationsResource<'a> {
pub(crate) t: &'a Transport,
}
impl NotificationsResource<'_> {
pub async fn get_preferences(self) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, "/notifications/preferences", "", None).await
}
pub async fn list(self, query: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, "/notifications", &build_query(query.as_ref(), &[]), None).await
}
pub async fn mark_all_read(self, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PATCH, "/notifications", "", Some(body_or_empty(body))).await
}
pub async fn mark_read(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PATCH, &format!("/notifications/{}", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn update_preferences(self, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PATCH, "/notifications/preferences", "", Some(body_or_empty(body))).await
}
}