use crate::PlatformConfig;
use std::sync::Arc;
pub mod admin_dept_stat;
pub mod admin_user_stat;
pub mod audit;
pub mod audit_info;
pub mod badge;
pub mod badge_image;
pub mod password;
pub mod users;
#[derive(Debug, Clone)]
pub struct AdminV1 {
config: Arc<PlatformConfig>,
}
impl AdminV1 {
pub fn new(config: Arc<PlatformConfig>) -> Self {
Self { config }
}
pub fn badge(&self) -> badge::BadgeService {
badge::BadgeService::new(self.config.as_ref().clone())
}
pub fn badge_image(&self) -> badge_image::BadgeImageService {
badge_image::BadgeImageService::new(self.config.as_ref().clone())
}
pub fn password(&self) -> password::PasswordService {
password::PasswordService::new(self.config.as_ref().clone())
}
pub fn admin_dept_stat(&self) -> admin_dept_stat::AdminDeptStatService {
admin_dept_stat::AdminDeptStatService::new(self.config.as_ref().clone())
}
pub fn admin_user_stat(&self) -> admin_user_stat::AdminUserStatService {
admin_user_stat::AdminUserStatService::new(self.config.as_ref().clone())
}
pub fn audit_info(&self) -> audit_info::AuditInfoService {
audit_info::AuditInfoService::new(self.config.as_ref().clone())
}
pub fn audit(&self) -> audit::AuditApi {
audit::AuditApi::new(self.config.clone())
}
pub fn users(&self) -> users::UsersApi {
users::UsersApi::new(self.config.clone())
}
}
#[cfg(test)]
mod tests {
use super::AdminV1;
use crate::PlatformConfig;
#[test]
fn test_admin_v1_creation() {
let config = PlatformConfig::builder()
.app_id("test_app_id")
.app_secret("test_app_secret")
.build();
let api = AdminV1::new(std::sync::Arc::new(config));
assert_eq!(api.config.app_id(), "test_app_id");
}
#[test]
fn test_admin_v1_chain_access() {
let config = PlatformConfig::builder()
.app_id("test_app_id")
.app_secret("test_app_secret")
.build();
let api = AdminV1::new(std::sync::Arc::new(config));
let _ = api.badge().create();
let _ = api.badge().list();
let _ = api.badge_image().create();
let _ = api.password().reset();
let _ = api.admin_dept_stat().list();
let _ = api.admin_user_stat().list();
let _ = api.audit_info().list();
let _ = api.badge().grant().list();
let _ = api.audit();
let _ = api.users();
}
}