openlark_docs/common/
mod.rs1pub mod api_endpoints;
5pub mod api_utils;
6pub mod builders;
7pub mod chain;
8pub mod request_builder;
9
10pub use api_endpoints::{BaseApiV2, BitableApiV1, MinutesApiV1, SheetsApiV3};
12
13pub mod constants {
15 pub const DEFAULT_PAGE_SIZE: i32 = 20;
17 pub const MAX_PAGE_SIZE: i32 = 100;
19 pub const DEFAULT_TIMEOUT_SECS: u64 = 30;
21}
22
23pub mod types {
25 pub type AppToken = String;
27 pub type TableId = String;
28 pub type RecordId = String;
29 pub type FormId = String;
30 pub type ViewId = String;
31 pub type FieldId = String;
32 pub type RoleId = String;
33 pub type UserId = String;
34}
35
36pub mod batch {
38 use serde::{Deserialize, Serialize};
39
40 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
42 pub struct BatchCommonParams {
43 pub user_id_type: Option<String>,
45 pub client_token: Option<String>,
47 }
48
49 impl BatchCommonParams {
50 pub fn new() -> Self {
51 Self::default()
52 }
53
54 pub fn with_user_id_type(mut self, user_id_type: impl ToString) -> Self {
56 self.user_id_type = Some(user_id_type.to_string());
57 self
58 }
59
60 pub fn with_client_token(mut self, client_token: impl ToString) -> Self {
62 self.client_token = Some(client_token.to_string());
63 self
64 }
65 }
66
67 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
69 pub struct BatchCommonBody {
70 pub requests: Vec<serde_json::Value>,
72 }
73
74 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
76 pub struct BatchOperationResult {
77 pub success: bool,
79 pub results: Vec<BatchItemResult>,
81 pub error: Option<String>,
83 }
84
85 impl BatchOperationResult {
86 pub fn success() -> Self {
88 Self {
89 success: true,
90 results: Vec::new(),
91 error: None,
92 }
93 }
94
95 pub fn failure(error: impl ToString) -> Self {
97 Self {
98 success: false,
99 results: Vec::new(),
100 error: Some(error.to_string()),
101 }
102 }
103 }
104
105 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
107 pub struct BatchItemResult {
108 pub success: bool,
110 pub data: Option<serde_json::Value>,
112 pub error: Option<String>,
114 }
115}
116
117pub mod traits {
119 pub trait ApiRequest {
121 type Response;
122 fn validate(&self) -> openlark_core::SDKResult<()>;
123 fn build_path(&self) -> String;
124 }
125
126 pub trait PaginatedRequest {
128 fn page_token(self, token: impl Into<String>) -> Self;
129 fn page_size(self, size: i32) -> Self;
130 }
131
132 pub trait FilterableRequest {
134 fn add_filter(self, filter: serde_json::Value) -> Self;
135 }
136}