boomack 0.4.1

Client library for Boomack
Documentation
//! Structures and functions to create
//! [`ClientRequest`](../api/struct.ClientRequest.html) instances
//! for managing slots

use serde::Serialize;
use super::json::to_json_map;
use super::api::ClientRequest;

pub fn clear_slot_request(panel_id: Option<&str>, slot_id: &str) -> ClientRequest {
    ClientRequest::post(format!("panels/{}/slots/{}/clear",
        panel_id.unwrap_or("default"), slot_id))
}

/// Parameters for exporting an individual slot
/// as HTML file to the filesystem of the Boomack Server.
#[derive(Serialize)]
pub struct SlotExportParameters<'l> {
    /// A relative path to the target folder of the export.
    /// The path is always relative to the root export folder,
    /// configured in the Boomack Server.
    pub path: Option<&'l str>,
    /// The target filename without extensions
    pub name: Option<&'l str>,
    /// The theme to use during export
    pub theme: Option<&'l str>,
    /// A static CSS zoom factor for the export (1.0 = 100%)
    pub zoom: Option<f32>,
    // Controls visibility of tools in the slot's toolbar during export.
    pub tools: Option<bool>,
    // Control visibility of the slot's toolbar during export.
    pub toolbar: Option<bool>,
}

pub fn export_slot_request(panel_id: Option<&str>, slot_id: &str, p: SlotExportParameters) -> ClientRequest {
    let mut req = ClientRequest::post(format!("panels/{}/slots/{}/export",
        panel_id.unwrap_or("default"), slot_id));
    req.set_json_body(to_json_map(&p).unwrap());
    req
}