openlark_workflow/v1/task/reminder/
list.rs1use openlark_core::{
6 SDKResult,
7 api::{ApiRequest, ApiResponseTrait, ResponseFormat},
8 config::Config,
9};
10use serde::Deserialize;
11use std::sync::Arc;
12
13#[derive(Debug, Clone, Deserialize)]
15pub struct TaskReminderItemV1 {
17 pub reminder_id: String,
19 pub trigger_time: i64,
21 pub type_: Option<String>,
23}
24
25#[derive(Debug, Clone, Deserialize)]
27pub struct ListTaskReminderResponseV1 {
29 pub items: Vec<TaskReminderItemV1>,
31}
32
33#[derive(Debug, Clone)]
35pub struct ListTaskReminderRequestV1 {
37 config: Arc<Config>,
38 task_id: String,
39}
40
41impl ListTaskReminderRequestV1 {
42 pub fn new(config: Arc<Config>, task_id: impl Into<String>) -> Self {
44 Self {
45 config,
46 task_id: task_id.into(),
47 }
48 }
49
50 pub async fn execute(self) -> SDKResult<ListTaskReminderResponseV1> {
52 self.execute_with_options(openlark_core::req_option::RequestOption::default())
53 .await
54 }
55
56 pub async fn execute_with_options(
58 self,
59 option: openlark_core::req_option::RequestOption,
60 ) -> SDKResult<ListTaskReminderResponseV1> {
61 let api_endpoint =
62 crate::common::api_endpoints::TaskApiV1::TaskReminderList(self.task_id.clone());
63 let request = ApiRequest::<ListTaskReminderResponseV1>::get(api_endpoint.to_url());
64
65 let response =
66 openlark_core::http::Transport::request(request, &self.config, Some(option)).await?;
67 response.data.ok_or_else(|| {
68 openlark_core::error::validation_error("响应数据为空", "服务器没有返回有效的数据")
69 })
70 }
71}
72
73impl ApiResponseTrait for ListTaskReminderResponseV1 {
74 fn data_format() -> ResponseFormat {
75 ResponseFormat::Data
76 }
77}
78
79#[cfg(test)]
80#[allow(unused_imports)]
81mod tests {
82
83 #[test]
84 fn test_list_task_reminder_v1_url() {
85 let endpoint =
86 crate::common::api_endpoints::TaskApiV1::TaskReminderList("task_123".to_string());
87 assert_eq!(
88 endpoint.to_url(),
89 "/open-apis/task/v1/tasks/task_123/reminders"
90 );
91 }
92}