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 TemplatesResource<'a> {
pub(crate) t: &'a Transport,
}
impl TemplatesResource<'_> {
pub async fn create(self, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, "/templates", "", Some(body_or_empty(body))).await
}
pub async fn delete(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::DELETE, &format!("/templates/{}", encode_path(id)), "", None).await
}
pub async fn get(self, id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, &format!("/templates/{}", encode_path(id)), "", None).await
}
pub async fn list(self, query: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, "/templates", &build_query(query.as_ref(), &[]), None).await
}
pub async fn remix(self, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, "/templates/remix", "", Some(body_or_empty(body))).await
}
pub async fn update(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PATCH, &format!("/templates/{}", encode_path(id)), "", Some(body_or_empty(body))).await
}
pub async fn use_(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, &format!("/templates/{}/use", encode_path(id)), "", Some(body_or_empty(body))).await
}
}