use crate::error::MisarDevError;
use crate::transport::Transport;
use crate::transport::body_or_empty;
use crate::transport::encode_path;
use reqwest::Method;
use serde_json::Value;
#[derive(Debug, Clone, Copy)]
pub struct AccountResource<'a> {
pub(crate) t: &'a Transport,
}
impl AccountResource<'_> {
pub async fn create_key(self, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::POST, "/account/api-keys", "", Some(body_or_empty(body))).await
}
pub async fn delete_key(self, key_id: &str) -> Result<Value, MisarDevError> {
self.t.request(Method::DELETE, &format!("/account/api-keys/{}", encode_path(key_id)), "", None).await
}
pub async fn export(self) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, "/account/export", "", None).await
}
pub async fn list_keys(self) -> Result<Value, MisarDevError> {
self.t.request(Method::GET, "/account/api-keys", "", None).await
}
pub async fn update_key(self, key_id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
self.t.request(Method::PATCH, &format!("/account/api-keys/{}", encode_path(key_id)), "", Some(body_or_empty(body))).await
}
}