openlark_docs/common/
mod.rs1pub mod api_endpoints;
3pub mod api_utils;
5pub mod builders;
7pub mod chain;
9pub mod request_builder;
11#[cfg(all(
12 test,
13 any(
14 feature = "baike",
15 feature = "lingo",
16 feature = "ccm-core",
17 feature = "minutes"
18 )
19))]
20pub(crate) mod test_utils;
21
22pub use api_endpoints::{BaseApiV2, BitableApiV1, MinutesApiV1, SheetsApiV3};
24
25pub mod constants {
27 pub const DEFAULT_PAGE_SIZE: i32 = 20;
29 pub const MAX_PAGE_SIZE: i32 = 100;
31 pub const DEFAULT_TIMEOUT_SECS: u64 = 30;
33}
34
35pub mod types {
37 pub type AppToken = String;
39 pub type TableId = String;
41 pub type RecordId = String;
43 pub type FormId = String;
45 pub type ViewId = String;
47 pub type FieldId = String;
49 pub type RoleId = String;
51 pub type UserId = String;
53}
54
55pub mod batch {
57 use serde::{Deserialize, Serialize};
58
59 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
61 pub struct BatchCommonParams {
62 pub user_id_type: Option<String>,
64 pub client_token: Option<String>,
66 }
67
68 impl BatchCommonParams {
69 pub fn new() -> Self {
71 Self::default()
72 }
73
74 pub fn with_user_id_type(mut self, user_id_type: impl ToString) -> Self {
76 self.user_id_type = Some(user_id_type.to_string());
77 self
78 }
79
80 pub fn with_client_token(mut self, client_token: impl ToString) -> Self {
82 self.client_token = Some(client_token.to_string());
83 self
84 }
85 }
86
87 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
89 pub struct BatchCommonBody {
90 pub requests: Vec<serde_json::Value>,
92 }
93
94 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
96 pub struct BatchOperationResult {
97 pub success: bool,
99 pub results: Vec<BatchItemResult>,
101 pub error: Option<String>,
103 }
104
105 impl BatchOperationResult {
106 pub fn success() -> Self {
108 Self {
109 success: true,
110 results: Vec::new(),
111 error: None,
112 }
113 }
114
115 pub fn failure(error: impl ToString) -> Self {
117 Self {
118 success: false,
119 results: Vec::new(),
120 error: Some(error.to_string()),
121 }
122 }
123 }
124
125 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
127 pub struct BatchItemResult {
128 pub success: bool,
130 pub data: Option<serde_json::Value>,
132 pub error: Option<String>,
134 }
135}
136
137pub mod traits {
139 pub trait ApiRequest {
141 type Response;
143
144 fn validate(&self) -> openlark_core::SDKResult<()>;
146 fn build_path(&self) -> String;
148 }
149
150 pub trait PaginatedRequest {
152 fn page_token(self, token: impl Into<String>) -> Self;
154 fn page_size(self, size: i32) -> Self;
156 }
157
158 pub trait FilterableRequest {
160 fn add_filter(self, filter: serde_json::Value) -> Self;
162 }
163}