openlark_platform/directory/v1/
mod.rs1use crate::PlatformConfig;
6use std::sync::Arc;
7
8pub mod collaboration_rule;
10pub mod collaboration_share_entity;
12pub mod collaboration_tenant;
14pub mod department;
16pub mod departments;
18pub mod employee;
20pub mod sync;
22pub mod users;
24
25#[derive(Debug, Clone)]
27pub struct DirectoryV1 {
28 config: Arc<PlatformConfig>,
29}
30
31impl DirectoryV1 {
32 pub fn new(config: Arc<PlatformConfig>) -> Self {
34 Self { config }
35 }
36
37 pub fn department(&self) -> department::DepartmentService {
39 department::DepartmentService::new(self.config.as_ref().clone())
40 }
41
42 pub fn employee(&self) -> employee::EmployeeService {
44 employee::EmployeeService::new(self.config.as_ref().clone())
45 }
46
47 pub fn collaboration_rule(&self) -> collaboration_rule::CollaborationRuleService {
49 collaboration_rule::CollaborationRuleService::new(self.config.as_ref().clone())
50 }
51
52 pub fn collaboration_share_entity(
54 &self,
55 ) -> collaboration_share_entity::CollaborationShareEntityService {
56 collaboration_share_entity::CollaborationShareEntityService::new(
57 self.config.as_ref().clone(),
58 )
59 }
60
61 pub fn collaboration_tenant(&self) -> collaboration_tenant::CollaborationTenantService {
63 collaboration_tenant::CollaborationTenantService::new(self.config.as_ref().clone())
64 }
65}
66
67#[cfg(test)]
68mod tests {
69 use super::DirectoryV1;
70 use crate::PlatformConfig;
71
72 #[test]
73 fn test_directory_v1_creation() {
74 let config = PlatformConfig::builder()
75 .app_id("test_app_id")
76 .app_secret("test_app_secret")
77 .build();
78
79 let api = DirectoryV1::new(std::sync::Arc::new(config));
80 assert_eq!(api.config.app_id(), "test_app_id");
81 }
82
83 #[test]
84 fn test_directory_v1_chain_access() {
85 let config = PlatformConfig::builder()
86 .app_id("test_app_id")
87 .app_secret("test_app_secret")
88 .build();
89 let api = DirectoryV1::new(std::sync::Arc::new(config));
90 let _ = api.department().create("test_dept".to_string());
92 let _ = api.department().filter();
93 let _ = api.department().mget();
94 let _ = api.department().patch("dept_id".to_string());
95 let _ = api.department().delete("dept_id".to_string());
96 let _ = api.department().search("kw".to_string());
97 let _ = api.employee().create("n".to_string(), "m".to_string());
99 let _ = api.employee().filter();
100 let _ = api.employee().mget();
101 let _ = api.employee().patch("eid".to_string());
102 let _ = api.employee().delete("eid".to_string());
103 let _ = api.employee().regular("eid".to_string());
104 let _ = api.employee().resurrect("eid".to_string());
105 let _ = api.employee().search("kw".to_string());
106 let _ = api.employee().to_be_resigned("eid".to_string());
107 let _ = api.collaboration_rule().create("rule".to_string());
109 let _ = api.collaboration_rule().list();
110 let _ = api.collaboration_rule().update("rid".to_string());
111 let _ = api.collaboration_rule().delete("rid".to_string());
112 let _ = api.collaboration_share_entity().list();
114 let _ = api.collaboration_tenant().list();
115 }
116}