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
use reqwest::Method;
use serde::{Deserialize, Serialize};

use crate::{
    core::{
        api_req::ApiRequest,
        api_resp::{ApiResponseTrait, BaseResponse, ResponseFormat},
        config::Config,
        constants::AccessTokenType,
        endpoints::hire::*,
        endpoints::EndpointBuilder,
        http::Transport,
        req_option::RequestOption,
        SDKResult,
    },
    service::hire::models::{CommonResponse, I18nText, PageResponse},
};

/// 面试设置服务
pub struct InterviewSettingsService {
    pub config: Config,
}

/// 面试设置信息
#[derive(Debug, Serialize, Deserialize)]
pub struct InterviewSettings {
    /// 设置ID
    pub id: String,
    /// 设置名称
    pub name: I18nText,
    /// 设置描述
    pub description: Option<I18nText>,
    /// 面试类型
    pub interview_type: String,
    /// 面试时长配置
    pub duration_config: InterviewDurationConfig,
    /// 面试官配置
    pub interviewer_config: InterviewerConfig,
    /// 评分配置
    pub evaluation_config: Option<EvaluationConfig>,
    /// 通知配置
    pub notification_config: Option<NotificationConfig>,
    /// 是否默认设置
    pub is_default: bool,
    /// 状态
    pub status: String,
    /// 创建时间
    pub created_time: Option<String>,
    /// 更新时间
    pub updated_time: Option<String>,
}

/// 面试时长配置
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct InterviewDurationConfig {
    // TODO: Add fields
}

/// 面试官配置
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct InterviewerConfig {
    // TODO: Add fields
}

/// 评分配置
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct EvaluationConfig {
    // TODO: Add fields
}

/// 评分项目
#[derive(Debug, Serialize, Deserialize)]
pub struct EvaluationItem {
    /// 项目ID
    pub id: String,
    /// 项目名称
    pub name: I18nText,
    /// 项目权重
    pub weight: Option<f32>,
    /// 是否必填
    pub is_required: bool,
}

/// 评分范围
#[derive(Debug, Serialize, Deserialize)]
pub struct ScoreRange {
    /// 最小分数
    pub min_score: f32,
    /// 最大分数
    pub max_score: f32,
    /// 分数步长
    pub step: Option<f32>,
}

/// 通知配置
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct NotificationConfig {
    // TODO: Add fields
}

/// 面试设置创建请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct InterviewSettingsCreateRequest {
    /// 设置名称
    pub name: I18nText,
    /// 设置描述
    pub description: Option<I18nText>,
    /// 面试类型
    pub interview_type: String,
    /// 面试时长配置
    pub duration_config: InterviewDurationConfig,
    /// 面试官配置
    pub interviewer_config: InterviewerConfig,
    /// 评分配置
    pub evaluation_config: Option<EvaluationConfig>,
    /// 通知配置
    pub notification_config: Option<NotificationConfig>,
    /// 是否默认设置
    pub is_default: Option<bool>,
}

/// 面试设置列表请求
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct InterviewSettingsListRequest {
    /// 分页大小
    pub page_size: Option<u32>,
    /// 分页标记
    pub page_token: Option<String>,
    /// 面试类型
    pub interview_type: Option<String>,
    /// 状态
    pub status: Option<String>,
}

/// 面试设置列表响应
#[derive(Debug, Serialize, Deserialize)]
pub struct InterviewSettingsListResponse {
    /// 面试设置列表
    #[serde(flatten)]
    pub settings: PageResponse<InterviewSettings>,
}

impl ApiResponseTrait for InterviewSettingsListResponse {
    fn data_format() -> ResponseFormat {
        ResponseFormat::Data
    }
}

/// 面试设置详情响应
#[derive(Debug, Serialize, Deserialize)]
pub struct InterviewSettingsDetailResponse {
    /// 面试设置信息
    pub settings: InterviewSettings,
}

impl ApiResponseTrait for InterviewSettingsDetailResponse {
    fn data_format() -> ResponseFormat {
        ResponseFormat::Data
    }
}

/// 面试设置操作响应
#[derive(Debug, Serialize, Deserialize)]
pub struct InterviewSettingsOperationResponse {
    /// 操作结果
    #[serde(flatten)]
    pub result: CommonResponse,
    /// 设置ID
    pub settings_id: Option<String>,
}

impl ApiResponseTrait for InterviewSettingsOperationResponse {
    fn data_format() -> ResponseFormat {
        ResponseFormat::Data
    }
}

impl InterviewSettingsService {
    pub fn new(config: Config) -> Self {
        Self { config }
    }

    /// 创建面试设置
    ///
    /// 该接口用于创建新的面试设置模板,定义面试的
    /// 时长、面试官要求、评分标准、通知方式等配置。
    /// 创建的设置可应用于不同的面试场景。
    ///
    /// # 参数
    ///
    /// - `request`: 面试设置创建请求参数,包括:
    ///   - `name`: 设置名称(必填)
    ///   - `interview_type`: 面试类型(必填)
    ///   - `duration_config`: 时长配置(必填)
    ///   - `interviewer_config`: 面试官配置(必填)
    ///   - `description`: 设置描述
    ///   - `evaluation_config`: 评分配置
    ///   - `notification_config`: 通知配置
    ///   - `is_default`: 是否默认设置
    /// - `option`: 可选的请求配置
    ///
    /// # 返回值
    ///
    /// 返回面试设置创建操作结果,包括:
    /// - `success`: 创建是否成功
    /// - `settings_id`: 创建的设置ID
    /// - `message`: 操作结果消息
    ///
    /// # 示例
    ///
    /// ```ignore
    /// use open_lark::service::hire::recruitment_config::interview_settings::{
    ///     InterviewSettingsCreateRequest, InterviewDurationConfig, InterviewerConfig
    /// };
    /// use open_lark::service::hire::models::{I18nText, UserId};
    ///
    /// let request = InterviewSettingsCreateRequest {
    ///     name: I18nText {
    ///         zh_cn: Some("技术面试设置".to_string()),
    ///         en_us: Some("Technical Interview Settings".to_string()),
    ///         ja_jp: None,
    ///     },
    ///     interview_type: "technical".to_string(),
    ///     duration_config: InterviewDurationConfig::default(),
    ///     interviewer_config: InterviewerConfig::default(),
    ///     ..Default::default()
    /// };
    ///
    /// let response = client.hire.recruitment_config.interview_settings.create_settings(request, None).await?;
    /// ```
    pub async fn create_settings(
        &self,
        request: InterviewSettingsCreateRequest,
        option: Option<RequestOption>,
    ) -> SDKResult<BaseResponse<InterviewSettingsOperationResponse>> {
        let api_req = ApiRequest {
            http_method: Method::POST,
            api_path: HIRE_V1_INTERVIEW_SETTINGS.to_string(),
            supported_access_token_types: vec![AccessTokenType::Tenant],
            body: serde_json::to_vec(&request).unwrap_or_default(),
            ..Default::default()
        };

        Transport::request(api_req, &self.config, option).await
    }

    /// 获取面试设置详情
    ///
    /// 该接口用于获取指定面试设置的详细信息,包括
    /// 面试配置、评分标准、通知设置等完整数据。
    ///
    /// # 参数
    ///
    /// - `settings_id`: 面试设置ID
    /// - `option`: 可选的请求配置
    ///
    /// # 返回值
    ///
    /// 返回面试设置详细信息,包括:
    /// - 设置基本信息(名称、类型、状态等)
    /// - 面试时长配置
    /// - 面试官要求配置
    /// - 评分标准配置
    /// - 通知设置配置
    /// - 创建和更新时间
    ///
    /// # 示例
    ///
    /// ```ignore
    /// let settings_id = "settings_123456";
    /// let response = client.hire.recruitment_config.interview_settings.get_settings_detail(settings_id, None).await?;
    ///
    /// if let Some(data) = &response.data {
    ///     println!("设置名称: {:?}", data.settings.name.zh_cn);
    ///     println!("面试类型: {}", data.settings.interview_type);
    ///     println!("默认时长: {}分钟", data.settings.duration_config.default_duration);
    /// }
    /// ```
    pub async fn get_settings_detail(
        &self,
        settings_id: &str,
        option: Option<RequestOption>,
    ) -> SDKResult<BaseResponse<InterviewSettingsDetailResponse>> {
        let api_req = ApiRequest {
            http_method: Method::GET,
            api_path: EndpointBuilder::replace_param(
                HIRE_V1_INTERVIEW_SETTING_GET,
                "settings_id",
                settings_id,
            ),
            supported_access_token_types: vec![AccessTokenType::Tenant],
            body: vec![],
            ..Default::default()
        };

        Transport::request(api_req, &self.config, option).await
    }

    /// 获取面试设置列表
    ///
    /// 该接口用于获取企业的面试设置列表,支持按类型、
    /// 状态等条件筛选。返回的列表包含设置基本信息,
    /// 可用于设置管理和选择。
    ///
    /// # 参数
    ///
    /// - `request`: 面试设置列表查询请求参数,包括:
    ///   - `page_size`: 分页大小,最大值100
    ///   - `page_token`: 分页标记
    ///   - `interview_type`: 面试类型筛选
    ///   - `status`: 设置状态筛选
    /// - `option`: 可选的请求配置
    ///
    /// # 返回值
    ///
    /// 返回分页的面试设置列表,包括:
    /// - 设置基本信息列表
    /// - 分页信息(是否有更多数据、下一页标记)
    ///
    /// # 示例
    ///
    /// ```ignore
    /// use open_lark::service::hire::recruitment_config::interview_settings::InterviewSettingsListRequest;
    ///
    /// let request = InterviewSettingsListRequest {
    ///     page_size: Some(50),
    ///     page_token: None,
    ///     interview_type: Some("technical".to_string()),
    ///     status: Some("active".to_string()),
    /// };
    ///
    /// let response = client.hire.recruitment_config.interview_settings.list_settings(request, None).await?;
    ///
    /// if let Some(data) = &response.data {
    ///     println!("设置总数: {}", data.settings.items.len());
    ///     for settings in &data.settings.items {
    ///         println!("设置: {:?} (类型: {})", settings.name.zh_cn, settings.interview_type);
    ///     }
    /// }
    /// ```
    pub async fn list_settings(
        &self,
        request: InterviewSettingsListRequest,
        option: Option<RequestOption>,
    ) -> SDKResult<BaseResponse<InterviewSettingsListResponse>> {
        let mut api_req = ApiRequest {
            http_method: Method::GET,
            api_path: HIRE_V1_INTERVIEW_SETTINGS.to_string(),
            supported_access_token_types: vec![AccessTokenType::Tenant],
            body: vec![],
            ..Default::default()
        };

        // 添加查询参数
        if let Some(page_size) = request.page_size {
            api_req
                .query_params
                .insert("page_size", page_size.to_string());
        }

        if let Some(page_token) = request.page_token {
            api_req.query_params.insert("page_token", page_token);
        }

        if let Some(interview_type) = request.interview_type {
            api_req
                .query_params
                .insert("interview_type", interview_type);
        }

        if let Some(status) = request.status {
            api_req.query_params.insert("status", status);
        }

        Transport::request(api_req, &self.config, option).await
    }

    /// 更新面试设置
    ///
    /// 该接口用于更新现有面试设置的配置,支持修改
    /// 时长要求、面试官配置、评分标准等信息。
    ///
    /// # 参数
    ///
    /// - `settings_id`: 面试设置ID
    /// - `request`: 面试设置更新请求参数
    /// - `option`: 可选的请求配置
    ///
    /// # 示例
    ///
    /// ```ignore
    /// use open_lark::service::hire::recruitment_config::interview_settings::{
    ///     InterviewSettingsCreateRequest, InterviewDurationConfig, InterviewerConfig
    /// };
    /// use open_lark::service::hire::models::I18nText;
    ///
    /// let settings_id = "settings_123456";
    /// let request = InterviewSettingsCreateRequest {
    ///     name: I18nText {
    ///         zh_cn: Some("高级技术面试设置".to_string()),
    ///         en_us: Some("Senior Technical Interview Settings".to_string()),
    ///         ja_jp: None,
    ///     },
    ///     interview_type: "senior_technical".to_string(),
    ///     duration_config: InterviewDurationConfig::default(),
    ///     interviewer_config: InterviewerConfig::default(),
    ///     ..Default::default()
    /// };
    ///
    /// let response = client.hire.recruitment_config.interview_settings.update_settings(settings_id, request, None).await?;
    /// ```
    pub async fn update_settings(
        &self,
        settings_id: &str,
        request: InterviewSettingsCreateRequest,
        option: Option<RequestOption>,
    ) -> SDKResult<BaseResponse<InterviewSettingsOperationResponse>> {
        let api_req = ApiRequest {
            http_method: Method::POST,
            api_path: EndpointBuilder::replace_param(
                HIRE_V1_INTERVIEW_SETTING_GET,
                "settings_id",
                settings_id,
            ),
            supported_access_token_types: vec![AccessTokenType::Tenant],
            body: serde_json::to_vec(&request).unwrap_or_default(),
            ..Default::default()
        };

        Transport::request(api_req, &self.config, option).await
    }

    /// 删除面试设置
    ///
    /// 该接口用于删除指定的面试设置。删除后的设置
    /// 将不再可用于面试安排。
    ///
    /// # 参数
    ///
    /// - `settings_id`: 面试设置ID
    /// - `option`: 可选的请求配置
    ///
    /// # 示例
    ///
    /// ```ignore
    /// let settings_id = "settings_123456";
    /// let response = client.hire.recruitment_config.interview_settings.delete_settings(settings_id, None).await?;
    /// ```
    pub async fn delete_settings(
        &self,
        settings_id: &str,
        option: Option<RequestOption>,
    ) -> SDKResult<BaseResponse<InterviewSettingsOperationResponse>> {
        let api_req = ApiRequest {
            http_method: Method::DELETE,
            api_path: EndpointBuilder::replace_param(
                HIRE_V1_INTERVIEW_SETTING_GET,
                "settings_id",
                settings_id,
            ),
            supported_access_token_types: vec![AccessTokenType::Tenant],
            body: vec![],
            ..Default::default()
        };

        Transport::request(api_req, &self.config, option).await
    }
}