box-open-sdk 0.4.1

Box API client for Rust (open source, community, punk rock) — typed models, async managers, and a reqwest runtime with retry, backoff, and token refresh.
Documentation
// Code generated by box-gantry. DO NOT EDIT.

use crate::internal::path_escape;
use crate::runtime::{self, Error};

/// Operations for the "folder_locks" API area.
pub struct FolderLocksManager {
    session: std::sync::Arc<runtime::Client>,
}

impl FolderLocksManager {
    pub(crate) fn new(session: std::sync::Arc<runtime::Client>) -> Self {
        Self { session }
    }

    pub async fn list(
        &self,
        folder_id: String,
    ) -> Result<crate::models::schemas::FolderLocks, Error> {
        let mut url = self.session.base_url("api");
        url.push_str("/folder_locks");
        let mut req = self.session.new_request("GET", &url);
        req = runtime::with_query(req, "folder_id", &folder_id);
        let resp = self.session.fetch(req).await?;
        let data = runtime::response_bytes(&resp)?;
        Ok(serde_json::from_slice(&data)?)
    }

    pub async fn create(
        &self,
        body: crate::models::schemas::CreateFolderLockRequest,
    ) -> Result<crate::models::schemas::FolderLock, Error> {
        let mut url = self.session.base_url("api");
        url.push_str("/folder_locks");
        let mut req = self.session.new_request("POST", &url);
        let payload = serde_json::to_vec(&body)?;
        req = runtime::with_json_body(req, &payload);
        let resp = self.session.fetch(req).await?;
        let data = runtime::response_bytes(&resp)?;
        Ok(serde_json::from_slice(&data)?)
    }

    pub async fn delete(&self, folder_lock_id: String) -> Result<(), Error> {
        let mut url = self.session.base_url("api");
        url.push_str("/folder_locks");
        url.push('/');
        let seg = path_escape(&folder_lock_id);
        url.push_str(&seg);
        let req = self.session.new_request("DELETE", &url);
        let _ = self.session.fetch(req).await?;
        Ok(())
    }
}