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 StoriesResource<'a> {
pub(crate) t: &'a Transport,
}
impl StoriesResource<'_> {
pub async fn create(self, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, "/stories", "", Some(body_or_empty(body))).await
}
pub async fn delete(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::DELETE, &format!("/stories/{}", encode_path(id)), "", None).await
}
pub async fn get(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/stories/{}", encode_path(id)), "", None).await
}
pub async fn list_my_posts(self, query: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, "/stories/my-posts", &build_query(query.as_ref(), &[]), None).await
}
pub async fn list_viewers(self, id: &str, query: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/stories/{}/viewers", encode_path(id)), &build_query(query.as_ref(), &[]), None).await
}
pub async fn mark_seen(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/stories/{}/view", encode_path(id)), "", None).await
}
pub async fn reply(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/stories/{}/reply", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn tray(self) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, "/stories/tray", "", None).await
}
}