pub mod api_endpoints;
pub mod api_utils;
pub mod builders;
pub mod chain;
pub mod request_builder;
pub use api_endpoints::{BaseApiV2, BitableApiV1, MinutesApiV1, SheetsApiV3};
pub mod constants {
pub const DEFAULT_PAGE_SIZE: i32 = 20;
pub const MAX_PAGE_SIZE: i32 = 100;
pub const DEFAULT_TIMEOUT_SECS: u64 = 30;
}
pub mod types {
pub type AppToken = String;
pub type TableId = String;
pub type RecordId = String;
pub type FormId = String;
pub type ViewId = String;
pub type FieldId = String;
pub type RoleId = String;
pub type UserId = String;
}
pub mod batch {
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct BatchCommonParams {
pub user_id_type: Option<String>,
pub client_token: Option<String>,
}
impl BatchCommonParams {
pub fn new() -> Self {
Self::default()
}
pub fn with_user_id_type(mut self, user_id_type: impl ToString) -> Self {
self.user_id_type = Some(user_id_type.to_string());
self
}
pub fn with_client_token(mut self, client_token: impl ToString) -> Self {
self.client_token = Some(client_token.to_string());
self
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct BatchCommonBody {
pub requests: Vec<serde_json::Value>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct BatchOperationResult {
pub success: bool,
pub results: Vec<BatchItemResult>,
pub error: Option<String>,
}
impl BatchOperationResult {
pub fn success() -> Self {
Self {
success: true,
results: Vec::new(),
error: None,
}
}
pub fn failure(error: impl ToString) -> Self {
Self {
success: false,
results: Vec::new(),
error: Some(error.to_string()),
}
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct BatchItemResult {
pub success: bool,
pub data: Option<serde_json::Value>,
pub error: Option<String>,
}
}
pub mod traits {
pub trait ApiRequest {
type Response;
fn validate(&self) -> openlark_core::SDKResult<()>;
fn build_path(&self) -> String;
}
pub trait PaginatedRequest {
fn page_token(self, token: impl Into<String>) -> Self;
fn page_size(self, size: i32) -> Self;
}
pub trait FilterableRequest {
fn add_filter(self, filter: serde_json::Value) -> Self;
}
}