openlark-workflow 0.17.0

OpenLark 工作流模块 - 提供飞书任务/审批/看板 API
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
//! 任务 v1 资源模块
//!
//! 提供任务 v1 版本的资源操作集合,覆盖任务生命周期、成员协作、评论与提醒等能力。
//!
//! ## 主要功能
//! - 任务基础操作:创建、查询、更新、删除、完成与取消完成
//! - 协作能力:关注者与协作者管理
//! - 扩展能力:评论与提醒管理

/// collaborator 模块。
pub mod collaborator;
/// 评论模块。
pub mod comment;
/// 完成任务接口。
pub mod complete;
/// 创建接口。
pub mod create;
/// 删除接口。
pub mod delete;
/// follower 模块。
pub mod follower;
/// 获取接口。
pub mod get;
/// 列表接口。
pub mod list;
/// 更新接口。
pub mod patch;
/// reminder 模块。
pub mod reminder;
/// 取消完成接口。
pub mod uncomplete;

// 显式导出 Request 类型,避免 ambiguous glob re-exports
pub use collaborator::{
    BatchDeleteTaskCollaboratorRequestV1, CreateTaskCollaboratorRequestV1,
    DeleteTaskCollaboratorRequestV1, ListTaskCollaboratorRequestV1,
};
pub use comment::{
    CreateTaskCommentRequestV1, DeleteTaskCommentRequestV1, GetTaskCommentRequestV1,
    ListTaskCommentRequestV1, UpdateTaskCommentRequestV1,
};
pub use complete::CompleteTaskRequestV1;
pub use create::CreateTaskRequestV1;
pub use delete::DeleteTaskRequestV1;
pub use follower::{
    BatchDeleteTaskFollowerRequestV1, CreateTaskFollowerRequestV1, DeleteTaskFollowerRequestV1,
    ListTaskFollowerRequestV1,
};
pub use get::GetTaskRequestV1;
pub use list::ListTaskRequestV1;
pub use patch::UpdateTaskRequestV1;
pub use reminder::{
    CreateTaskReminderRequestV1, DeleteTaskReminderRequestV1, ListTaskReminderRequestV1,
};
pub use uncomplete::UncompleteTaskRequestV1;

use openlark_core::config::Config;
use std::sync::Arc;

/// Task:任务资源(v1)
#[derive(Clone)]
pub struct Task {
    config: Arc<Config>,
}

impl Task {
    /// 创建新的实例。
    pub fn new(config: Arc<Config>) -> Self {
        Self { config }
    }

    /// 创建新建请求。
    pub fn create(&self) -> CreateTaskRequestV1 {
        CreateTaskRequestV1::new(self.config.clone())
    }

    /// 创建获取详情请求。
    pub fn get(&self, task_id: impl Into<String>) -> GetTaskRequestV1 {
        GetTaskRequestV1::new(self.config.clone(), task_id)
    }

    /// 创建更新请求。
    pub fn update(&self, task_id: impl Into<String>) -> UpdateTaskRequestV1 {
        UpdateTaskRequestV1::new(self.config.clone(), task_id)
    }

    /// 创建删除请求。
    pub fn delete(&self, task_id: impl Into<String>) -> DeleteTaskRequestV1 {
        DeleteTaskRequestV1::new(self.config.clone(), task_id)
    }

    /// 创建完成任务请求。
    pub fn complete(&self, task_id: impl Into<String>) -> CompleteTaskRequestV1 {
        CompleteTaskRequestV1::new(self.config.clone(), task_id)
    }

    /// 创建取消完成请求。
    pub fn uncomplete(&self, task_id: impl Into<String>) -> UncompleteTaskRequestV1 {
        UncompleteTaskRequestV1::new(self.config.clone(), task_id)
    }

    /// 创建列表请求。
    pub fn list(&self) -> ListTaskRequestV1 {
        ListTaskRequestV1::new(self.config.clone())
    }

    /// 关注者相关方法
    pub fn follower_create(&self, task_id: impl Into<String>) -> CreateTaskFollowerRequestV1 {
        CreateTaskFollowerRequestV1::new(self.config.clone(), task_id)
    }

    /// follower_delete。
    pub fn follower_delete(
        &self,
        task_id: impl Into<String>,
        follower_id: impl Into<String>,
    ) -> DeleteTaskFollowerRequestV1 {
        DeleteTaskFollowerRequestV1::new(self.config.clone(), task_id, follower_id)
    }

    /// follower_list。
    pub fn follower_list(&self, task_id: impl Into<String>) -> ListTaskFollowerRequestV1 {
        ListTaskFollowerRequestV1::new(self.config.clone(), task_id)
    }

    /// follower_batch_delete。
    pub fn follower_batch_delete(
        &self,
        task_id: impl Into<String>,
    ) -> BatchDeleteTaskFollowerRequestV1 {
        BatchDeleteTaskFollowerRequestV1::new(self.config.clone(), task_id)
    }

    /// 协作者相关方法
    pub fn collaborator_create(
        &self,
        task_id: impl Into<String>,
    ) -> CreateTaskCollaboratorRequestV1 {
        CreateTaskCollaboratorRequestV1::new(self.config.clone(), task_id)
    }

    /// collaborator_delete。
    pub fn collaborator_delete(
        &self,
        task_id: impl Into<String>,
        collaborator_id: impl Into<String>,
    ) -> DeleteTaskCollaboratorRequestV1 {
        DeleteTaskCollaboratorRequestV1::new(self.config.clone(), task_id, collaborator_id)
    }

    /// collaborator_list。
    pub fn collaborator_list(&self, task_id: impl Into<String>) -> ListTaskCollaboratorRequestV1 {
        ListTaskCollaboratorRequestV1::new(self.config.clone(), task_id)
    }

    /// collaborator_batch_delete。
    pub fn collaborator_batch_delete(
        &self,
        task_id: impl Into<String>,
    ) -> BatchDeleteTaskCollaboratorRequestV1 {
        BatchDeleteTaskCollaboratorRequestV1::new(self.config.clone(), task_id)
    }

    /// 提醒相关方法
    pub fn reminder_create(&self, task_id: impl Into<String>) -> CreateTaskReminderRequestV1 {
        CreateTaskReminderRequestV1::new(self.config.clone(), task_id)
    }

    /// reminder_delete。
    pub fn reminder_delete(
        &self,
        task_id: impl Into<String>,
        reminder_id: impl Into<String>,
    ) -> DeleteTaskReminderRequestV1 {
        DeleteTaskReminderRequestV1::new(self.config.clone(), task_id, reminder_id)
    }

    /// reminder_list。
    pub fn reminder_list(&self, task_id: impl Into<String>) -> ListTaskReminderRequestV1 {
        ListTaskReminderRequestV1::new(self.config.clone(), task_id)
    }

    /// 评论相关方法
    pub fn comment_create(&self, task_id: impl Into<String>) -> CreateTaskCommentRequestV1 {
        CreateTaskCommentRequestV1::new(self.config.clone(), task_id)
    }

    /// comment_get。
    pub fn comment_get(
        &self,
        task_id: impl Into<String>,
        comment_id: impl Into<String>,
    ) -> GetTaskCommentRequestV1 {
        GetTaskCommentRequestV1::new(self.config.clone(), task_id, comment_id)
    }

    /// comment_update。
    pub fn comment_update(
        &self,
        task_id: impl Into<String>,
        comment_id: impl Into<String>,
    ) -> UpdateTaskCommentRequestV1 {
        UpdateTaskCommentRequestV1::new(self.config.clone(), task_id, comment_id)
    }

    /// comment_delete。
    pub fn comment_delete(
        &self,
        task_id: impl Into<String>,
        comment_id: impl Into<String>,
    ) -> DeleteTaskCommentRequestV1 {
        DeleteTaskCommentRequestV1::new(self.config.clone(), task_id, comment_id)
    }

    /// comment_list。
    pub fn comment_list(&self, task_id: impl Into<String>) -> ListTaskCommentRequestV1 {
        ListTaskCommentRequestV1::new(self.config.clone(), task_id)
    }
}

#[cfg(test)]
#[allow(unused_variables)]
#[allow(unused_imports)]
mod tests {
    use super::*;
    use std::sync::Arc;

    fn create_test_config() -> Arc<Config> {
        Arc::new(
            Config::builder()
                .app_id("test_app")
                .app_secret("test_secret")
                .build(),
        )
    }

    #[test]
    fn test_task_new() {
        let config = create_test_config();
        let _ = Task::new(config);
    }

    #[test]
    fn test_task_create() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.create();
    }

    #[test]
    fn test_task_get() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.get("task_123");
    }

    #[test]
    fn test_task_update() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.update("task_123");
    }

    #[test]
    fn test_task_delete() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.delete("task_123");
    }

    #[test]
    fn test_task_complete() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.complete("task_123");
    }

    #[test]
    fn test_task_uncomplete() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.uncomplete("task_123");
    }

    #[test]
    fn test_task_list() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.list();
    }

    // Follower tests
    #[test]
    fn test_task_follower_create() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.follower_create("task_123");
    }

    #[test]
    fn test_task_follower_delete() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.follower_delete("task_123", "follower_456");
    }

    #[test]
    fn test_task_follower_list() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.follower_list("task_123");
    }

    #[test]
    fn test_task_follower_batch_delete() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.follower_batch_delete("task_123");
    }

    // Collaborator tests
    #[test]
    fn test_task_collaborator_create() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.collaborator_create("task_123");
    }

    #[test]
    fn test_task_collaborator_delete() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.collaborator_delete("task_123", "collaborator_456");
    }

    #[test]
    fn test_task_collaborator_list() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.collaborator_list("task_123");
    }

    #[test]
    fn test_task_collaborator_batch_delete() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.collaborator_batch_delete("task_123");
    }

    // Reminder tests
    #[test]
    fn test_task_reminder_create() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.reminder_create("task_123");
    }

    #[test]
    fn test_task_reminder_delete() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.reminder_delete("task_123", "reminder_456");
    }

    #[test]
    fn test_task_reminder_list() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.reminder_list("task_123");
    }

    // Comment tests
    #[test]
    fn test_task_comment_create() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.comment_create("task_123");
    }

    #[test]
    fn test_task_comment_get() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.comment_get("task_123", "comment_456");
    }

    #[test]
    fn test_task_comment_update() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.comment_update("task_123", "comment_456");
    }

    #[test]
    fn test_task_comment_delete() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.comment_delete("task_123", "comment_456");
    }

    #[test]
    fn test_task_comment_list() {
        let config = create_test_config();
        let task = Task::new(config);
        let _ = task.comment_list("task_123");
    }
}