openlark_docs/common/
mod.rs1pub mod api_endpoints;
3pub mod api_utils;
5pub mod builders;
7pub mod chain;
9pub mod request_builder;
11
12pub use api_endpoints::{BaseApiV2, BitableApiV1, MinutesApiV1, SheetsApiV3};
14
15pub mod constants {
17 pub const DEFAULT_PAGE_SIZE: i32 = 20;
19 pub const MAX_PAGE_SIZE: i32 = 100;
21 pub const DEFAULT_TIMEOUT_SECS: u64 = 30;
23}
24
25pub mod types {
27 pub type AppToken = String;
29 pub type TableId = String;
31 pub type RecordId = String;
33 pub type FormId = String;
35 pub type ViewId = String;
37 pub type FieldId = String;
39 pub type RoleId = String;
41 pub type UserId = String;
43}
44
45pub mod batch {
47 use serde::{Deserialize, Serialize};
48
49 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
51 pub struct BatchCommonParams {
52 pub user_id_type: Option<String>,
54 pub client_token: Option<String>,
56 }
57
58 impl BatchCommonParams {
59 pub fn new() -> Self {
61 Self::default()
62 }
63
64 pub fn with_user_id_type(mut self, user_id_type: impl ToString) -> Self {
66 self.user_id_type = Some(user_id_type.to_string());
67 self
68 }
69
70 pub fn with_client_token(mut self, client_token: impl ToString) -> Self {
72 self.client_token = Some(client_token.to_string());
73 self
74 }
75 }
76
77 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
79 pub struct BatchCommonBody {
80 pub requests: Vec<serde_json::Value>,
82 }
83
84 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
86 pub struct BatchOperationResult {
87 pub success: bool,
89 pub results: Vec<BatchItemResult>,
91 pub error: Option<String>,
93 }
94
95 impl BatchOperationResult {
96 pub fn success() -> Self {
98 Self {
99 success: true,
100 results: Vec::new(),
101 error: None,
102 }
103 }
104
105 pub fn failure(error: impl ToString) -> Self {
107 Self {
108 success: false,
109 results: Vec::new(),
110 error: Some(error.to_string()),
111 }
112 }
113 }
114
115 #[derive(Debug, Clone, Default, Serialize, Deserialize)]
117 pub struct BatchItemResult {
118 pub success: bool,
120 pub data: Option<serde_json::Value>,
122 pub error: Option<String>,
124 }
125}
126
127pub mod traits {
129 pub trait ApiRequest {
131 type Response;
133
134 fn validate(&self) -> openlark_core::SDKResult<()>;
136 fn build_path(&self) -> String;
138 }
139
140 pub trait PaginatedRequest {
142 fn page_token(self, token: impl Into<String>) -> Self;
144 fn page_size(self, size: i32) -> Self;
146 }
147
148 pub trait FilterableRequest {
150 fn add_filter(self, filter: serde_json::Value) -> Self;
152 }
153}