/
user.rs
84 lines (68 loc) · 2.84 KB
/
user.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use anyhow::Result;
use dingtalk_rs::{Client, UserManager};
use dotenv::dotenv;
use tracing::info;
#[tokio::main]
async fn main() -> Result<()> {
dotenv().ok();
tracing_subscriber::fmt::init();
let c = Client::new_from_env()?;
// let resp = c.user_get_by_mobile("18612424366").await?;
// info!("user_get_by_mobile resp: {}", resp);
// let mut params_create =
// dingtalk_rs::client::ParamsCreateUser::new("陈亚东".to_string(), "".to_string(), vec![]);
// c.user_create(params_create).await?;
// let user_detail = c.user_get("03634229671222446", None).await?;
// info!("user_get resp: {}", serde_json::to_string(&user_detail)?);
// let params = dingtalk_rs::client::ParamsUserList {
// dept_id: 1,
// cursor: 0,
// size: 100,
// ..Default::default()
// };
// let user_sample_list = c.user_list_simple_by_dept(params).await?;
// info!(
// "user_sample_list: {}",
// serde_json::to_string(&user_sample_list)?
// );
// let user_ids = c.user_list_ids(1).await?;
// info!("user_ids: {}", serde_json::to_string(&user_ids)?);
// let params = dingtalk_rs::client::ParamsUserList {
// dept_id: 1,
// cursor: 0,
// size: 100,
// ..Default::default()
// };
// let user_list = c.user_list(params).await?;
// info!("user_ids: {}", serde_json::to_string(&user_list)?);
// let user_count = c.user_count(true).await?;
// info!("user_count: {}", user_count);
// let params = dingtalk_rs::client::ParamsUserInactiveGet {
// is_active: true,
// dept_ids: None,
// offset: 1,
// size: 100,
// query_date: String::from("20220706"),
// };
// let users = c.user_inactive_get(params).await?;
// info!("user_inactive_get: {}", serde_json::to_string(&users)?);
// let uid = c.user_get_by_unionid("sIXI7wdxNtbdYtsTCrzMtgiEiE").await?;
// info!("user_get_by_unionid: {}", serde_json::to_string(&uid)?);
// let admin = c.user_admin_list().await?;
// info!("user_admin_list: {}", serde_json::to_string(&admin)?);
// let admin_scope = c.user_admin_scope_get("224203514521476195").await?;
// info!("admin_scope: {}", serde_json::to_string(&admin_scope)?);
// 新版本服务器端API调用示例
// let params = dingtalk_rs::client::ParamsEmpLeaveRecordList {
// start_time: String::from("2021-07-10T00:00:00Z"),
// end_time: None,
// next_token: String::from("0"),
// max_results: 50,
// };
// let records = c.emp_leave_record_list(params).await?;
// info!("records: {}", serde_json::to_string(&records)?);
// let user = c.user_get("025618665127939390", None).await?;
let user = c.user_get("xueyu18237@ipalfish.com", None).await?;
info!("records: {}", serde_json::to_string(&user)?);
Ok(())
}