use crate::PlatformConfig;
use std::sync::Arc;
pub mod collaboration_rule;
pub mod collaboration_share_entity;
pub mod collaboration_tenant;
pub mod department;
pub mod departments;
pub mod employee;
pub mod sync;
pub mod users;
#[derive(Debug, Clone)]
pub struct DirectoryV1 {
config: Arc<PlatformConfig>,
}
impl DirectoryV1 {
pub fn new(config: Arc<PlatformConfig>) -> Self {
Self { config }
}
pub fn department(&self) -> department::DepartmentService {
department::DepartmentService::new(self.config.as_ref().clone())
}
pub fn employee(&self) -> employee::EmployeeService {
employee::EmployeeService::new(self.config.as_ref().clone())
}
pub fn collaboration_rule(&self) -> collaboration_rule::CollaborationRuleService {
collaboration_rule::CollaborationRuleService::new(self.config.as_ref().clone())
}
pub fn collaboration_share_entity(
&self,
) -> collaboration_share_entity::CollaborationShareEntityService {
collaboration_share_entity::CollaborationShareEntityService::new(
self.config.as_ref().clone(),
)
}
pub fn collaboration_tenant(&self) -> collaboration_tenant::CollaborationTenantService {
collaboration_tenant::CollaborationTenantService::new(self.config.as_ref().clone())
}
}
#[cfg(test)]
mod tests {
use super::DirectoryV1;
use crate::PlatformConfig;
#[test]
fn test_directory_v1_creation() {
let config = PlatformConfig::builder()
.app_id("test_app_id")
.app_secret("test_app_secret")
.build();
let api = DirectoryV1::new(std::sync::Arc::new(config));
assert_eq!(api.config.app_id(), "test_app_id");
}
#[test]
fn test_directory_v1_chain_access() {
let config = PlatformConfig::builder()
.app_id("test_app_id")
.app_secret("test_app_secret")
.build();
let api = DirectoryV1::new(std::sync::Arc::new(config));
let _ = api.department().create("test_dept".to_string());
let _ = api.department().filter();
let _ = api.department().mget();
let _ = api.department().patch("dept_id".to_string());
let _ = api.department().delete("dept_id".to_string());
let _ = api.department().search("kw".to_string());
let _ = api.employee().create("n".to_string(), "m".to_string());
let _ = api.employee().filter();
let _ = api.employee().mget();
let _ = api.employee().patch("eid".to_string());
let _ = api.employee().delete("eid".to_string());
let _ = api.employee().regular("eid".to_string());
let _ = api.employee().resurrect("eid".to_string());
let _ = api.employee().search("kw".to_string());
let _ = api.employee().to_be_resigned("eid".to_string());
let _ = api.collaboration_rule().create("rule".to_string());
let _ = api.collaboration_rule().list();
let _ = api.collaboration_rule().update("rid".to_string());
let _ = api.collaboration_rule().delete("rid".to_string());
let _ = api.collaboration_share_entity().list();
let _ = api.collaboration_tenant().list();
}
}