files_sdk/admin/
styles.rs1use crate::{Result, client::FilesClient};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Serialize, Deserialize, Clone)]
5pub struct StyleEntity {
6 #[serde(flatten)]
7 pub data: serde_json::Map<String, serde_json::Value>,
8}
9
10pub struct StyleHandler {
11 client: FilesClient,
12}
13
14impl StyleHandler {
15 pub fn new(client: FilesClient) -> Self {
16 Self { client }
17 }
18
19 pub async fn get(&self, path: &str) -> Result<StyleEntity> {
20 let endpoint = format!("/styles/{}", path);
21 let response = self.client.get_raw(&endpoint).await?;
22 Ok(serde_json::from_value(response)?)
23 }
24
25 pub async fn update(&self, path: &str, params: serde_json::Value) -> Result<StyleEntity> {
26 let endpoint = format!("/styles/{}", path);
27 let response = self.client.patch_raw(&endpoint, params).await?;
28 Ok(serde_json::from_value(response)?)
29 }
30
31 pub async fn delete(&self, path: &str) -> Result<()> {
32 let endpoint = format!("/styles/{}", path);
33 self.client.delete_raw(&endpoint).await?;
34 Ok(())
35 }
36}