openlark-docs 0.16.0

飞书开放平台云文档服务模块 - 文档、表格、知识库API (202 APIs, 100% 覆盖,不含旧版本)
Documentation
//! Sheets电子表格服务 v3
//!
//! 提供飞书电子表格 v3 版本的完整管理功能。

/// 范围类型。
pub type Range = String;

/// 电子表格令牌类型。
pub type SpreadsheetToken = String;

/// 工作表 ID 类型。
pub type SheetId = String;

use openlark_core::config::Config;

// pub mod charts; // Generated: Module file not found
// pub mod comments; // Generated: Module file not found
// pub mod conditional_format; // Generated: Module file not found
// pub mod data_filter; // Generated: Module file not found
// pub mod filter_views; // Generated: Module file not found
// pub mod find_replace; // 暂时注释
// pub mod float_images; // Generated: Module file not found
// pub mod macros; // Generated: Module file not found
/// Sheets v3 通用模型模块。
pub mod models;
// pub mod move_dimension; // 暂时注释
// pub mod pivot_tables; // Generated: Module file not found
// pub mod sheet; // Generated: Module file not found
// pub mod sheet_protection; // Generated: Module file not found
/// Sheets v3 电子表格模块。
pub mod spreadsheet;
// pub mod spreadsheet_create; // Generated: Module file not found
// pub mod spreadsheet_info; // Generated: Module file not found

/// 重新导出 Sheets v3 通用模型。
pub use models::{
    CellPosition, CellReference, FilterCondition, FilterInfo, FilterViewCondition, FilterViewId,
    FilterViewInfo, FloatImageId, FloatImageInfo, FloatImageToken, Locale, PagedResponse,
    ReplaceCellsRequest, ReplaceResult, SheetInfo, SheetProperty, SheetsResponse, TimeZone,
};
/// 重新导出电子表格相关类型。
pub use spreadsheet::{
    CreateFilterConditionRequest, CreateFilterConditionResponse, CreateFilterRequest,
    CreateFilterResponse, CreateFilterViewRequest, CreateFilterViewResponse,
    CreateFloatImageRequest, CreateFloatImageResponse, CreateSpreadsheetParams,
    CreateSpreadsheetResponse, CreatedSpreadsheet, DeleteFilterConditionResponse,
    DeleteFilterResponse, DeleteFilterViewResponse, DeleteFloatImageResponse, DimensionSource,
    FindCondition, FindParams, FindReplaceParams, FindReplaceResponse, FindResponse, FindResult,
    GetFilterConditionResponse, GetFilterResponse, GetFilterViewResponse, GetFloatImageResponse,
    GetSheetResponse, GetSpreadsheetResponse, GridProperties, MergeRange, MoveDimensionParams,
    MoveDimensionResponse, QueryFilterConditionsResponse, QueryFilterViewsResponse,
    QueryFloatImagesResponse, QuerySheetResponse, Sheet, SpreadsheetInfo,
    UpdateFilterConditionRequest, UpdateFilterConditionResponse, UpdateFilterRequest,
    UpdateFilterResponse, UpdateFilterViewRequest, UpdateFilterViewResponse,
    UpdateFloatImageRequest, UpdateFloatImageResponse, UpdateSpreadsheetParams,
    UpdateSpreadsheetResponse,
};

/// Sheets 服务主结构。
#[derive(Clone, Debug)]
pub struct SheetsService {
    /// 配置信息。
    config: Config,
}

impl SheetsService {
    /// 创建新的 Sheets 服务实例。
    pub fn new(config: Config) -> Self {
        Self { config }
    }

    /// 获取配置引用。
    pub fn config(&self) -> &Config {
        &self.config
    }
}

impl Default for SheetsService {
    fn default() -> Self {
        Self::new(Config::default())
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_sheets_service_creation() {
        let config = Config::default();
        let service = SheetsService::new(config);
        assert!(!service.config.base_url().is_empty());
    }

    #[test]
    fn test_type_aliases() {
        let range: Range = "A1:B10".to_string();
        let token: SpreadsheetToken = "sheet_token_123".to_string();
        let sheet_id: SheetId = "sheet_id_456".to_string();

        assert_eq!(range, "A1:B10");
        assert_eq!(token, "sheet_token_123");
        assert_eq!(sheet_id, "sheet_id_456");
    }

    #[test]
    fn test_sheets_service_default() {
        let service = SheetsService::default();
        assert!(!service.config.base_url().is_empty());
    }
}