Skip to main content

openlark_docs/common/api_endpoints/
docs.rs

1//! Docs API 端点目录。
2
3use super::CatalogEndpoint;
4use openlark_core::api::{ApiRequest, HttpMethod};
5
6/// Docs API V1 端点枚举
7#[derive(Debug, Clone, PartialEq)]
8#[cfg_attr(test, derive(strum_macros::EnumIter))]
9pub enum DocsApiV1 {
10    /// 获取云文档内容
11    ContentGet,
12}
13
14impl DocsApiV1 {
15    /// 生成对应的 URL
16    pub fn to_url(&self) -> String {
17        match self {
18            DocsApiV1::ContentGet => "/open-apis/docs/v1/content".to_string(),
19        }
20    }
21
22    /// 返回配置了稳定请求语义的请求。
23    pub fn to_request<R>(&self) -> ApiRequest<R> {
24        <Self as CatalogEndpoint>::to_request(self)
25    }
26}
27
28impl CatalogEndpoint for DocsApiV1 {
29    fn to_url(&self) -> String {
30        DocsApiV1::to_url(self)
31    }
32
33    fn method(&self) -> HttpMethod {
34        HttpMethod::Get
35    }
36
37    // supported_access_token_types 使用 trait 默认实现(User + Tenant)
38}
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43    use crate::common::api_endpoints::test_support::catalog_semantics_snapshot;
44
45    #[test]
46    fn docs_catalog_semantics_snapshot() {
47        insta::assert_snapshot!(catalog_semantics_snapshot::<DocsApiV1>());
48    }
49}