openlark-docs 0.15.0-rc.2

飞书开放平台云文档服务模块 - 文档、表格、知识库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
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
pub mod spreadsheet;
// pub mod spreadsheet_create; // Generated: Module file not found
// pub mod spreadsheet_info; // Generated: Module file not found

// 重新导出所有服务类型
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,
};
// 重新导出 models 中的类型(排除已在 spreadsheet 中导出的类型,以及模块顶部定义的类型别名)
pub use models::{
    CellPosition, CellReference, FilterCondition, FilterInfo, FilterViewCondition, FilterViewId,
    FilterViewInfo, FloatImageId, FloatImageInfo, FloatImageToken, Locale, PagedResponse,
    ReplaceCellsRequest, ReplaceResult, SheetInfo, SheetProperty, SheetsResponse, TimeZone,
};

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

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

    /// 获取配置引用(避免 `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());
    }
}