open-lark 0.14.0

Enterprise-grade Lark/Feishu Open API SDK with comprehensive Chinese documentation and advanced error handling
Documentation
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// 分页响应通用结构
#[derive(Debug, Serialize, Deserialize)]
pub struct PageResponse<T> {
    /// 数据列表
    pub items: Vec<T>,
    /// 是否还有更多数据
    pub has_more: bool,
    /// 下一页的分页标记
    pub page_token: Option<String>,
}

/// I18n 多语言文本
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct I18nText {
    /// 中文
    pub zh_cn: Option<String>,
    /// 英文
    pub en_us: Option<String>,
    /// 日文
    pub ja_jp: Option<String>,
}

/// 用户ID对象
#[derive(Debug, Serialize, Deserialize)]
pub struct UserId {
    /// 用户ID
    pub id: String,
    /// 用户ID类型
    pub id_type: String,
}

/// 部门ID对象
#[derive(Debug, Serialize, Deserialize)]
pub struct DepartmentId {
    /// 部门ID
    pub id: String,
    /// 部门ID类型
    pub id_type: String,
}

/// 附件信息
#[derive(Debug, Serialize, Deserialize)]
pub struct Attachment {
    /// 附件ID
    pub id: String,
    /// 附件名称
    pub name: String,
    /// 附件类型
    pub file_type: Option<String>,
    /// 附件大小
    pub size: Option<u64>,
    /// 创建时间
    pub created_time: Option<String>,
}

/// 地址信息
#[derive(Debug, Serialize, Deserialize)]
pub struct Location {
    /// 地址ID
    pub id: String,
    /// 地址名称
    pub name: I18nText,
    /// 地址类型
    pub location_type: String,
    /// 父级地址ID
    pub parent_id: Option<String>,
    /// 地址代码
    pub code: Option<String>,
    /// 活跃状态
    pub active_status: bool,
}

/// 地址查询请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct LocationQueryRequest {
    /// 地址类型
    pub location_type: Option<String>,
    /// 父级地址ID
    pub parent_id: Option<String>,
    /// 分页大小
    pub page_size: Option<u32>,
    /// 分页标记
    pub page_token: Option<String>,
}

/// 角色信息
#[derive(Debug, Serialize, Deserialize)]
pub struct Role {
    /// 角色ID
    pub id: String,
    /// 角色名称
    pub name: I18nText,
    /// 角色描述
    pub description: Option<I18nText>,
    /// 角色权限列表
    pub permissions: Vec<String>,
    /// 创建时间
    pub created_time: Option<String>,
    /// 更新时间
    pub updated_time: Option<String>,
}

/// 角色列表请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct RoleListRequest {
    /// 分页大小
    pub page_size: Option<u32>,
    /// 分页标记
    pub page_token: Option<String>,
}

/// 用户角色信息
#[derive(Debug, Serialize, Deserialize)]
pub struct UserRole {
    /// 用户ID
    pub user_id: String,
    /// 角色ID列表
    pub role_ids: Vec<String>,
    /// 角色详情列表
    pub roles: Option<Vec<Role>>,
}

/// 职位基本信息
#[derive(Debug, Serialize, Deserialize)]
pub struct Job {
    /// 职位ID
    pub id: String,
    /// 职位名称
    pub title: String,
    /// 职位描述
    pub description: Option<String>,
    /// 职位要求
    pub requirement: Option<String>,
    /// 职位状态
    pub status: String,
    /// 职位类型
    pub job_type: Option<String>,
    /// 职能分类ID
    pub job_function_id: Option<String>,
    /// 职位类别ID
    pub job_category_id: Option<String>,
    /// 工作地点
    pub locations: Vec<Location>,
    /// 部门ID
    pub department_id: Option<String>,
    /// 招聘人员
    pub recruiters: Vec<UserId>,
    /// 面试官
    pub interviewers: Vec<UserId>,
    /// 创建时间
    pub created_time: Option<String>,
    /// 更新时间
    pub updated_time: Option<String>,
    /// 自定义字段
    pub custom_fields: Option<HashMap<String, serde_json::Value>>,
}

/// 职位创建请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct JobCreateRequest {
    /// 职位名称
    pub title: String,
    /// 职位描述
    pub description: Option<String>,
    /// 职位要求
    pub requirement: Option<String>,
    /// 职位类型
    pub job_type: Option<String>,
    /// 职能分类ID
    pub job_function_id: Option<String>,
    /// 职位类别ID
    pub job_category_id: Option<String>,
    /// 工作地点ID列表
    pub location_ids: Vec<String>,
    /// 部门ID
    pub department_id: Option<String>,
    /// 招聘人员ID列表
    pub recruiter_ids: Vec<String>,
    /// 面试官ID列表
    pub interviewer_ids: Vec<String>,
    /// 自定义字段
    pub custom_fields: Option<HashMap<String, serde_json::Value>>,
}

/// 职位更新请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct JobUpdateRequest {
    /// 职位ID
    pub job_id: String,
    /// 职位名称
    pub title: Option<String>,
    /// 职位描述
    pub description: Option<String>,
    /// 职位要求
    pub requirement: Option<String>,
    /// 职位类型
    pub job_type: Option<String>,
    /// 职能分类ID
    pub job_function_id: Option<String>,
    /// 职位类别ID
    pub job_category_id: Option<String>,
    /// 工作地点ID列表
    pub location_ids: Option<Vec<String>>,
    /// 部门ID
    pub department_id: Option<String>,
    /// 招聘人员ID列表
    pub recruiter_ids: Option<Vec<String>>,
    /// 面试官ID列表
    pub interviewer_ids: Option<Vec<String>>,
    /// 自定义字段
    pub custom_fields: Option<HashMap<String, serde_json::Value>>,
}

/// 职位列表请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct JobListRequest {
    /// 分页大小
    pub page_size: Option<u32>,
    /// 分页标记
    pub page_token: Option<String>,
    /// 职位状态
    pub status: Option<String>,
    /// 部门ID
    pub department_id: Option<String>,
    /// 职位类型
    pub job_type: Option<String>,
    /// 创建时间开始
    pub created_start_time: Option<String>,
    /// 创建时间结束
    pub created_end_time: Option<String>,
}

/// 招聘需求信息
#[derive(Debug, Serialize, Deserialize)]
pub struct JobRequirement {
    /// 需求ID
    pub id: String,
    /// 需求名称
    pub name: String,
    /// 需求描述
    pub description: Option<String>,
    /// 关联职位ID
    pub job_id: String,
    /// 需求人数
    pub headcount: u32,
    /// 需求状态
    pub status: String,
    /// 期望入职时间
    pub expected_entry_time: Option<String>,
    /// 创建人
    pub creator: Option<UserId>,
    /// 创建时间
    pub created_time: Option<String>,
    /// 更新时间
    pub updated_time: Option<String>,
}

/// 招聘需求创建请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct JobRequirementCreateRequest {
    /// 需求名称
    pub name: String,
    /// 需求描述
    pub description: Option<String>,
    /// 关联职位ID
    pub job_id: String,
    /// 需求人数
    pub headcount: u32,
    /// 期望入职时间
    pub expected_entry_time: Option<String>,
}

/// 人才基本信息
#[derive(Debug, Serialize, Deserialize)]
pub struct Talent {
    /// 人才ID
    pub id: String,
    /// 姓名
    pub name: String,
    /// 邮箱
    pub email: Option<String>,
    /// 电话
    pub phone: Option<String>,
    /// 性别
    pub gender: Option<String>,
    /// 生日
    pub birthday: Option<String>,
    /// 工作年限
    pub work_experience: Option<u32>,
    /// 学历
    pub education: Option<String>,
    /// 当前公司
    pub current_company: Option<String>,
    /// 当前职位
    pub current_position: Option<String>,
    /// 期望薪资
    pub expected_salary: Option<String>,
    /// 简历附件
    pub resume_attachments: Vec<Attachment>,
    /// 人才标签
    pub tags: Vec<String>,
    /// 创建时间
    pub created_time: Option<String>,
    /// 更新时间
    pub updated_time: Option<String>,
    /// 自定义字段
    pub custom_fields: Option<HashMap<String, serde_json::Value>>,
}

/// 人才创建请求
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct TalentCreateRequest {
    /// 姓名
    pub name: String,
    /// 邮箱
    pub email: Option<String>,
    /// 电话
    pub phone: Option<String>,
    /// 性别
    pub gender: Option<String>,
    /// 生日
    pub birthday: Option<String>,
    /// 工作年限
    pub work_experience: Option<u32>,
    /// 学历
    pub education: Option<String>,
    /// 当前公司
    pub current_company: Option<String>,
    /// 当前职位
    pub current_position: Option<String>,
    /// 期望薪资
    pub expected_salary: Option<String>,
    /// 简历附件ID列表
    pub resume_attachment_ids: Vec<String>,
    /// 人才标签
    pub tags: Vec<String>,
    /// 自定义字段
    pub custom_fields: Option<HashMap<String, serde_json::Value>>,
}

/// 投递信息
#[derive(Debug, Serialize, Deserialize)]
pub struct Application {
    /// 投递ID
    pub id: String,
    /// 人才ID
    pub talent_id: String,
    /// 职位ID
    pub job_id: String,
    /// 当前阶段ID
    pub stage_id: String,
    /// 投递状态
    pub status: String,
    /// 投递渠道
    pub source: Option<String>,
    /// 投递时间
    pub apply_time: Option<String>,
    /// 人才信息
    pub talent: Option<Talent>,
    /// 职位信息
    pub job: Option<Job>,
    /// 创建时间
    pub created_time: Option<String>,
    /// 更新时间
    pub updated_time: Option<String>,
}

/// 投递创建请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ApplicationCreateRequest {
    /// 人才ID
    pub talent_id: String,
    /// 职位ID
    pub job_id: String,
    /// 阶段ID
    pub stage_id: String,
    /// 投递渠道
    pub source: Option<String>,
    /// 投递时间
    pub apply_time: Option<String>,
}

/// 投递列表请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ApplicationListRequest {
    /// 分页大小
    pub page_size: Option<u32>,
    /// 分页标记
    pub page_token: Option<String>,
    /// 职位ID
    pub job_id: Option<String>,
    /// 投递状态
    pub status: Option<String>,
    /// 阶段ID
    pub stage_id: Option<String>,
    /// 投递渠道
    pub source: Option<String>,
    /// 创建时间开始
    pub created_start_time: Option<String>,
    /// 创建时间结束
    pub created_end_time: Option<String>,
}

/// 面试信息
#[derive(Debug, Serialize, Deserialize)]
pub struct Interview {
    /// 面试ID
    pub id: String,
    /// 投递ID
    pub application_id: String,
    /// 面试轮次
    pub round: u32,
    /// 面试类型
    pub interview_type: String,
    /// 面试状态
    pub status: String,
    /// 面试开始时间
    pub start_time: Option<String>,
    /// 面试结束时间
    pub end_time: Option<String>,
    /// 面试官列表
    pub interviewers: Vec<UserId>,
    /// 面试地点
    pub location: Option<String>,
    /// 面试备注
    pub remark: Option<String>,
    /// 面试结果
    pub result: Option<String>,
    /// 创建时间
    pub created_time: Option<String>,
    /// 更新时间
    pub updated_time: Option<String>,
}

/// Offer信息
#[derive(Debug, Serialize, Deserialize)]
pub struct Offer {
    /// Offer ID
    pub id: String,
    /// 投递ID
    pub application_id: String,
    /// Offer状态
    pub status: String,
    /// 职位级别
    pub job_level: Option<String>,
    /// 基本薪资
    pub basic_salary: Option<String>,
    /// 绩效奖金
    pub performance_bonus: Option<String>,
    /// 股票期权
    pub stock_option: Option<String>,
    /// 入职时间
    pub onboard_date: Option<String>,
    /// 过期时间
    pub expire_time: Option<String>,
    /// Offer备注
    pub remark: Option<String>,
    /// 创建时间
    pub created_time: Option<String>,
    /// 更新时间
    pub updated_time: Option<String>,
    /// 自定义字段
    pub custom_fields: Option<HashMap<String, serde_json::Value>>,
}

/// Offer创建请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct OfferCreateRequest {
    /// 投递ID
    pub application_id: String,
    /// 职位级别
    pub job_level: Option<String>,
    /// 基本薪资
    pub basic_salary: Option<String>,
    /// 绩效奖金
    pub performance_bonus: Option<String>,
    /// 股票期权
    pub stock_option: Option<String>,
    /// 入职时间
    pub onboard_date: Option<String>,
    /// 过期时间
    pub expire_time: Option<String>,
    /// Offer备注
    pub remark: Option<String>,
    /// 自定义字段
    pub custom_fields: Option<HashMap<String, serde_json::Value>>,
}

/// 内推账户信息
#[derive(Debug, Serialize, Deserialize)]
pub struct ReferralAccount {
    /// 账户ID
    pub id: String,
    /// 用户ID
    pub user_id: String,
    /// 账户状态
    pub status: String,
    /// 账户余额
    pub balance: String,
    /// 总收入
    pub total_income: String,
    /// 已提现金额
    pub withdrawn_amount: String,
    /// 创建时间
    pub created_time: Option<String>,
    /// 更新时间
    pub updated_time: Option<String>,
}

/// 内推账户注册请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ReferralAccountCreateRequest {
    /// 用户ID
    pub user_id: String,
    /// 身份证号
    pub id_card: Option<String>,
    /// 银行卡号
    pub bank_card: Option<String>,
    /// 开户行
    pub bank_name: Option<String>,
}

/// 附件创建请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct AttachmentCreateRequest {
    /// 文件名
    pub name: String,
    /// 文件内容(base64编码)
    pub content: String,
    /// 文件类型
    pub file_type: Option<String>,
}

/// 通用响应结构
#[derive(Debug, Serialize, Deserialize)]
pub struct CommonResponse {
    /// 操作是否成功
    pub success: bool,
    /// 操作消息
    pub message: Option<String>,
    /// 操作时间
    pub timestamp: Option<String>,
}

#[cfg(test)]
#[allow(unused_variables, unused_unsafe)]
mod tests {
    use super::*;
    use serde_json;

    #[test]
    fn test_page_response_serialization() {
        let response = PageResponse {
            items: vec!["item1".to_string(), "item2".to_string()],
            has_more: true,
            page_token: Some("token123".to_string()),
        };
        let json = serde_json::to_string(&response).unwrap();
        assert!(json.contains("item1"));
        assert!(json.contains("has_more"));
        assert!(json.contains("token123"));
    }

    #[test]
    fn test_i18n_text_complete() {
        let text = I18nText {
            zh_cn: Some("中文".to_string()),
            en_us: Some("English".to_string()),
            ja_jp: Some("日本語".to_string()),
        };
        let json = serde_json::to_string(&text).unwrap();
        let deserialized: I18nText = serde_json::from_str(&json).unwrap();
        assert_eq!(deserialized.zh_cn, Some("中文".to_string()));
        assert_eq!(deserialized.en_us, Some("English".to_string()));
        assert_eq!(deserialized.ja_jp, Some("日本語".to_string()));
    }

    #[test]
    fn test_i18n_text_default() {
        let text = I18nText::default();
        assert_eq!(text.zh_cn, None);
        assert_eq!(text.en_us, None);
        assert_eq!(text.ja_jp, None);
    }

    #[test]
    fn test_user_id_serialization() {
        let user_id = UserId {
            id: "user123".to_string(),
            id_type: "open_id".to_string(),
        };
        let json = serde_json::to_string(&user_id).unwrap();
        assert!(json.contains("user123"));
        assert!(json.contains("open_id"));
    }

    #[test]
    fn test_department_id_serialization() {
        let dept_id = DepartmentId {
            id: "dept456".to_string(),
            id_type: "department_id".to_string(),
        };
        let json = serde_json::to_string(&dept_id).unwrap();
        assert!(json.contains("dept456"));
        assert!(json.contains("department_id"));
    }

    #[test]
    fn test_attachment_complete() {
        let attachment = Attachment {
            id: "att789".to_string(),
            name: "resume.pdf".to_string(),
            file_type: Some("application/pdf".to_string()),
            size: Some(1024000),
            created_time: Some("2024-01-01T00:00:00Z".to_string()),
        };
        let json = serde_json::to_string(&attachment).unwrap();
        assert!(json.contains("att789"));
        assert!(json.contains("resume.pdf"));
        assert!(json.contains("application/pdf"));
    }

    #[test]
    fn test_location_active() {
        let location = Location {
            id: "loc001".to_string(),
            name: I18nText {
                zh_cn: Some("北京".to_string()),
                en_us: Some("Beijing".to_string()),
                ja_jp: None,
            },
            location_type: "city".to_string(),
            parent_id: Some("china".to_string()),
            code: Some("BJ".to_string()),
            active_status: true,
        };
        let json = serde_json::to_string(&location).unwrap();
        assert!(json.contains("loc001"));
        assert!(json.contains("北京"));
        assert!(json.contains("Beijing"));
        assert!(json.contains("true"));
    }

    #[test]
    fn test_location_query_request_default() {
        let request = LocationQueryRequest::default();
        assert_eq!(request.location_type, None);
        assert_eq!(request.parent_id, None);
        assert_eq!(request.page_size, None);
        assert_eq!(request.page_token, None);
    }

    #[test]
    fn test_common_response_success() {
        let response = CommonResponse {
            success: true,
            message: Some("Operation completed".to_string()),
            timestamp: Some("2024-01-01T00:00:00Z".to_string()),
        };
        let json = serde_json::to_string(&response).unwrap();
        assert!(json.contains("true"));
        assert!(json.contains("Operation completed"));
    }

    #[test]
    fn test_common_response_error() {
        let response = CommonResponse {
            success: false,
            message: Some("Operation failed".to_string()),
            timestamp: None,
        };
        let json = serde_json::to_string(&response).unwrap();
        assert!(json.contains("false"));
        assert!(json.contains("Operation failed"));
    }

    #[test]
    fn test_attachment_create_request() {
        let request = AttachmentCreateRequest {
            name: "document.pdf".to_string(),
            content: "base64encodedcontent".to_string(),
            file_type: Some("application/pdf".to_string()),
        };
        let json = serde_json::to_string(&request).unwrap();
        assert!(json.contains("document.pdf"));
        assert!(json.contains("base64encodedcontent"));
        assert!(json.contains("application/pdf"));
    }
}