### Quick Start Example Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/im/mod.rs Demonstrates how to initialize the LarkClient and send a text message using the IM service's v1 API. ```Rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // 发送文本消息 let message = CreateMessageRequestBody::builder() .receive_id("ou_xxx") .msg_type("text") .content("{\"text\":\"Hello!\"}") .build(); let request = CreateMessageRequest::builder() .receive_id_type("open_id") .request_body(message) .build(); // let result = client.im.v1.message.create(request, None).await?; ``` -------------------------------- ### Quick Start: Initialize LarkClient and Send Message Source: https://docs.rs/open-lark/0.13.0/open_lark/client/struct.LarkClient Provides a quick start example for initializing the `LarkClient` using its builder pattern for self-built applications. It demonstrates setting up the client with app credentials and then constructing and sending a text message via the IM service. ```Rust use open_lark::prelude::*; // 创建自建应用客户端 let client = LarkClient::builder("your_app_id", "your_app_secret") .with_app_type(AppType::SelfBuild) .with_enable_token_cache(true) .build(); // 发送文本消息 let message = CreateMessageRequestBody::builder() .receive_id("ou_xxx") .msg_type("text") .content("{\"text\":\"Hello from Rust!\"}") .build(); let request = CreateMessageRequest::builder() .receive_id_type("open_id") .request_body(message) .build(); // let result = client.im.message.create(request, None).await?; ``` -------------------------------- ### Rust Example: LarkClient Usage for Authentication Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/authentication/mod.rs Demonstrates initializing the LarkClient and provides commented-out examples for obtaining App Access Tokens and User Access Tokens using the authentication service. ```rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // 认证服务通过核心配置处理,无需直接访问 // 获取App Access Token // let app_token_request = GetAppAccessTokenRequest::builder() // .app_id("app_id") // .app_secret("app_secret") // .build(); // let token = auth.v1.app_access_token.get(app_token_request, None).await?; // 获取用户访问令牌 // let user_token_request = GetUserAccessTokenRequest::builder() // .grant_type("authorization_code") // .code("authorization_code") // .build(); // let user_token = auth.v1.user_access_token.get(user_token_request, None).await?; ``` -------------------------------- ### Example Usage: Sheets API v2 Client Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/cloud_docs/sheets/v2/mod.rs Demonstrates how to initialize the LarkClient and access the v2 version of the Sheets API services. This example shows the basic setup for using the Sheets API. ```Rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // 使用v2版本API let sheets_v2 = &client.sheets.v2; // 基础工作表操作 // let sheet_ops = &sheets_v2.spreadsheet_sheet; ``` -------------------------------- ### Sheets v3 API Usage Example Source: https://docs.rs/open-lark/0.13.0/open_lark/service/cloud_docs/sheets/v3/struct.V3 Demonstrates how to initialize the LarkClient and access the v3 services to perform operations like creating a spreadsheet. This example shows the typical workflow for interacting with the v3 Sheets API, including client setup and service access. ```Rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // 使用v3版本API let sheets_v3 = &client.sheets.v3; // 创建电子表格 // let create_req = CreateSpreadsheetRequest::builder() // .title("数据统计表") // .build(); // let response = sheets_v3.spreadsheet.create(create_req, None).await?; ``` -------------------------------- ### Rust SDK: Batch Get Departments Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/contact/v3/department.rs Example of retrieving information for multiple departments simultaneously using a BatchGetDepartmentsRequest. ```rust use crate::service::contact::models::BatchGetDepartmentsRequest; // Assuming 'department_service' is an initialized DepartmentService instance let batch_req = BatchGetDepartmentsRequest { department_ids: Some(vec!["67890".to_string(), "11223".to_string()]), // ... other fields like "fetch_child" if applicable }; match department_service.batch(&batch_req).await { Ok(response) => { println!("Departments retrieved successfully: {:?}", response); } Err(e) => { eprintln!("Failed to retrieve departments: {}", e); } } ``` -------------------------------- ### Open Lark Cloud Docs Usage Example Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/cloud_docs/mod.rs Demonstrates how to initialize the Lark client and access the `cloud_docs` service. It includes commented-out examples for various cloud document operations like creating files, knowledge bases, documents, spreadsheets, and multi-dimensional tables. ```rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // Get the Cloud Docs service let cloud_docs = &client.cloud_docs; // Cloud Space Operations // let file_request = CreateFileRequest::builder() // .name("Project Plan.docx") // .parent_token("folder_123") // .file_type("docx") // .build(); // let file = cloud_docs.drive.v1.file.create(file_request, None).await?; // Create Knowledge Base // let wiki_request = CreateWikiRequest::builder() // .name("Product Knowledge Base") // .description("Documents and materials related to the product") // .build(); // let wiki = cloud_docs.wiki.v2.space.create(wiki_request, None).await?; // Operate on Documents // let docx_request = CreateDocumentRequest::builder() // .title("Meeting Minutes") // .folder_token("folder_456") // .build(); // let document = cloud_docs.docx.v1.document.create(docx_request, None).await?; // Operate on Spreadsheets // let sheets_request = CreateSpreadsheetRequest::builder() // .title("Sales Data") // .folder_token("folder_789") // .build(); // let spreadsheet = cloud_docs.sheets.v3.spreadsheet.create(sheets_request, None).await?; // Operate on Multi-dimensional Tables // let bitable_request = CreateBitableRequest::builder() // .name("Project Management Table") // .folder_token("folder_abc") // .build(); // let bitable = cloud_docs.bitable.v1.app.create(bitable_request, None).await?; ``` -------------------------------- ### FeishuCard Example Usage Source: https://docs.rs/open-lark/0.13.0/src/open_lark/card.rs Demonstrates how to create a simple Feishu card with a header and elements. This example shows chaining methods like `new`, `config`, `header`, and `elements`. ```rust use open_lark::card::{FeishuCard, FeishuCardConfig}; use open_lark::card::components::content_components::title::FeishuCardTitle; use open_lark::card::components::content_components::title::Title; use open_lark::card::components::CardElement; // 创建简单卡片 let card = FeishuCard::new() .config( FeishuCardConfig::new() .enable_forward(true) .update_multi(false) )? .header("zh_cn", FeishuCardTitle::new() .title(Title::new("欢迎使用飞书卡片")) )? .elements("zh_cn", vec![ /* 添加卡片元素 */ ])?; # Ok::<(), open_lark::core::error::LarkAPIError>(()) ``` -------------------------------- ### Contact Service Usage Example (Rust) Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/contact/mod.rs Demonstrates how to initialize the LarkClient and access the Contact Service. It shows setting up the client with application credentials and then obtaining a reference to the contact service to interact with its functionalities, including commented-out examples for fetching users and departments. ```rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // 获取通讯录服务 let contact = &client.contact; // 使用v3版本API // let users = contact.v3.user.list(request, None).await?; // let departments = contact.v3.department.list(request, None).await?; ``` -------------------------------- ### Rust: Group Service Usage Example Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/group/mod.rs This example demonstrates how to initialize the LarkClient and access the GroupService to perform various group-related operations like creating groups, adding members, publishing announcements, and configuring menus. ```rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // 获取群组服务 let group = &client.group; // 创建群组 // let create_request = CreateGroupRequest::builder() // .name("项目讨论组") // .description("项目开发讨论群组") // .members(vec!["user1", "user2", "user3"]) // .build(); // let new_group = group.v1.group.create(create_request, None).await?; // 添加群成员 // let add_member_request = AddGroupMemberRequest::builder() // .group_id("group_123") // .user_ids(vec!["user4", "user5"]) // .build(); // group.v1.member.add(add_member_request, None).await?; // 发布群公告 // let announcement_request = CreateAnnouncementRequest::builder() // .group_id("group_123") // .title("重要通知") // .content("项目进度更新,请大家查看") // .build(); // group.v1.announcement.create(announcement_request, None).await?; // 配置群菜单 // let menu_request = SetGroupMenuRequest::builder() // .group_id("group_123") // .menu_items(vec![ // MenuItem::new("项目文档", "https://docs.company.com"), // MenuItem::new("会议室预约", "https://meeting.company.com") // ]) // .build(); // group.v1.menu.set(menu_request, None).await?; ``` -------------------------------- ### Lark Client Initialization and Service Usage Example Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/mod.rs Demonstrates how to initialize the Lark client with application credentials and demonstrates placeholder calls to various service APIs like IM, Cloud Docs, and Contact. This example highlights the structure for accessing different service versions and methods. ```Rust use open_lark::prelude::*; # #[tokio::main] # async fn main() -> Result<(), Box> { // 创建客户端 let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // 服务调用示例(需要相应的请求对象) // let message = client.im.v1.message.create(message_request, None).await?; // let document = client.cloud_docs.drive.v1.file.create_file(file_request, None).await?; // let employee = client.contact.v3.user.get(user_request, None).await?; # Ok(()) # } ``` -------------------------------- ### Open Lark Client Initialization and Cloud Docs Usage Example Source: https://docs.rs/open-lark/0.13.0/open_lark/service/cloud_docs/index Demonstrates how to initialize the LarkClient and access various cloud document services like Drive, Wiki, Docx, Sheets, and Bitable. Includes commented-out examples for creating files, wikis, documents, spreadsheets, and bitable apps. ```Rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // 获取云文档服务 let cloud_docs = &client.cloud_docs; // 云空间操作 // let file_request = CreateFileRequest::builder() // .name("项目计划书.docx") // .parent_token("folder_123") // .file_type("docx") // .build(); // let file = cloud_docs.drive.v1.file.create(file_request, None).await?; // 创建知识库 // let wiki_request = CreateWikiRequest::builder() // .name("产品知识库") // .description("产品相关文档和资料") // .build(); // let wiki = cloud_docs.wiki.v2.space.create(wiki_request, None).await?; // 操作文档 // let docx_request = CreateDocumentRequest::builder() // .title("会议纪要") // .folder_token("folder_456") // .build(); // let document = cloud_docs.docx.v1.document.create(docx_request, None).await?; // 操作电子表格 // let sheets_request = CreateSpreadsheetRequest::builder() // .title("销售数据") // .folder_token("folder_789") // .build(); // let spreadsheet = cloud_docs.sheets.v3.spreadsheet.create(sheets_request, None).await?; // 操作多维表格 // let bitable_request = CreateBitableRequest::builder() // .name("项目管理表") // .folder_token("folder_abc") // .build(); // let bitable = cloud_docs.bitable.v1.app.create(bitable_request, None).await?; ``` -------------------------------- ### Rust: Open Lark Search Service Usage Example Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/search/mod.rs Demonstrates how to initialize the LarkClient and access the SearchService. It shows how to obtain the search client and provides commented-out examples for creating a data source and performing a search using the v2 API, highlighting the builder pattern for request objects. ```rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // 获取搜索服务 let search = &client.search; // 创建数据源(v2版本) // let data_source_request = CreateDataSourceRequest::builder() // .name("企业知识库") // .description("包含公司所有技术文档") // .build(); // let data_source = search.v2.data_source.create(data_source_request, None).await?; // 执行搜索 // let search_request = SearchRequest::builder() // .query("飞书API") // .data_source_id("ds_123") // .build(); // let results = search.v2.suite_search.search(search_request, None).await?; ``` -------------------------------- ### Rust Example: Creating a Lark Checker Source: https://docs.rs/open-lark/0.13.0/src/open_lark/card/components/interactive_components/checker.rs Demonstrates how to construct a Lark Checker component in Rust using a JSON macro. This example shows setting properties like text, buttons, styles, and callback behaviors. ```Rust use serde_json::json; fn create_checker() { let json = json!({ "tag": "checker", "name": "check_1", "checked": false, "text": { "tag": "plain_text", "content": "", "text_size": "normal", "text_color": "default", "text_align": "left" }, "overall_checkable": true, "button_area": { "pc_display_rule": "always", "buttons": [ { "tag": "button", "type": "text", "size": "small", "text": { "tag": "plain_text", "content": "text按钮" }, "icon": { "tag": "standard_icon", "token": "chat-forbidden_outlined", "color": "orange" }, "disabled": false, "behaviors": [] } ] }, "checked_style": { "show_strikethrough": true, "opacity": 1.0 }, "margin": "0px", "padding": "0px", "behaviors": [ { "type": "callback", "value": { "key": "value" } } ], "disabled": false }); // Assuming 'checker' is a variable holding a similar structure or a placeholder // assert_eq!(json!(checker), json); } // Example of using the .checked_style, .margin, .padding, .behaviors, .disabled methods // This part is illustrative of builder pattern usage, not directly part of the JSON definition. // let _ = "some_variable" // .checked_style(CheckedStyle::new().show_strikethrough(true).opacity(1.0)) // .margin("0px") // .padding("0px") // .behaviors(vec![Behaviors::Callback(CallbackBehavior::new(json!({"key": "value"})))]) // .disabled(false); ``` -------------------------------- ### FeishuCard Creation and Configuration Example Source: https://docs.rs/open-lark/0.13.0/open_lark/card/struct.FeishuCard Demonstrates how to create a new Feishu (Lark) message card, set global configurations like enabling forwarding, and add multi-language headers and elements. This example requires importing necessary types from the open_lark library. ```Rust use open_lark::card::{FeishuCard, FeishuCardConfig}; use open_lark::card::components::content_components::title::FeishuCardTitle; use open_lark::card::components::content_components::title::Title; use open_lark::card::components::CardElement; // 创建简单卡片 let card = FeishuCard::new() .config( FeishuCardConfig::new() .enable_forward(true) .update_multi(false) ) .header("zh_cn", FeishuCardTitle::new() .title(Title::new("欢迎使用飞书卡片")) )? .elements("zh_cn", vec![ /* 添加卡片元素 */ ])?; ``` -------------------------------- ### Feishu Card Table Usage Example Source: https://docs.rs/open-lark/0.13.0/src/open_lark/card/components/content_components/table.rs Demonstrates how to construct a Feishu card table using the builder pattern. This example shows setting table properties, defining multiple columns with specific formatting, and populating rows with data. ```Rust #[cfg(test)] mod test { use serde_json::json; use crate::card::components::content_components::table::{ FeishuCardTable, FeishuCardTableColumn, FeishuCardTableColumnFormat, FeishuCardTableHeaderStyle, }; #[test] fn test_table() { let table = FeishuCardTable::new() .page_zie(1) .row_height("middle") .header_style( FeishuCardTableHeaderStyle::new() .bold(true) .background_style("grey") .lines(1) .text_size("heading") .text_align("center") , ) .columns(vec![ FeishuCardTableColumn::new() .name("customer_name") .display_name("客户名称") .data_type("text"), FeishuCardTableColumn::new() .name("customer_scale") .display_name("客户规模") .data_type("options") .width("90px"), FeishuCardTableColumn::new() .name("customer_arr") .display_name("ARR(万元)") .data_type("number") .format( FeishuCardTableColumnFormat::new() .precision(2) .symbol("¥"), ) .width("120px"), FeishuCardTableColumn::new() .name("customer_year") .display_name("签约年限") .data_type("text"), ]) .rows(json!([ { "customer_name": "飞书消息卡片是飞书中的一种功能,它允许用户通过机器人或应用以结构化(JSON)的方式发送和接收消息。", "customer_scale": [ { "text": "S2", } ], "customer_arr": 10000.50, "customer_year": "2023" } ])); // Assertions would typically follow here to verify the table structure } } ``` -------------------------------- ### LarkClientBuilder Usage Example Source: https://docs.rs/open-lark/0.13.0/open_lark/client/struct.LarkClientBuilder Demonstrates how to use the LarkClientBuilder to create a configured LarkClient instance using a fluent builder pattern. This example shows setting application ID, secret, app type, token cache, and request timeout. ```rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .with_enable_token_cache(true) .with_req_timeout(Some(30.0)) .build(); ``` -------------------------------- ### Rust SDK: Create Department Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/contact/v3/department.rs Example of creating a new department using the DepartmentService. It requires a CreateDepartmentRequest object and returns a CreateDepartmentResponse. ```rust use crate::service::contact::models::CreateDepartmentRequest; // Assuming 'department_service' is an initialized DepartmentService instance let create_req = CreateDepartmentRequest { name: "Engineering".to_string(), parent_id: "12345".to_string(), // ... other fields }; match department_service.create(&create_req).await { Ok(response) => { println!("Department created successfully: {:?}", response); } Err(e) => { eprintln!("Failed to create department: {}", e); } } ``` -------------------------------- ### Rust SDK: Search Departments Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/contact/v3/department.rs Example of searching for departments using a SearchDepartmentRequest, which can include various query parameters. ```rust use crate::service::contact::models::SearchDepartmentRequest; // Assuming 'department_service' is an initialized DepartmentService instance let search_req = SearchDepartmentRequest { query: Some("Sales".to_string()), page_size: Some(50), page_token: None, // ... other search criteria }; match department_service.search(&search_req).await { Ok(response) => { println!("Departments found: {:?}", response); } Err(e) => { eprintln!("Failed to search departments: {}", e); } } ``` -------------------------------- ### Query Spreadsheet Sheets Example Source: https://docs.rs/open-lark/0.13.0/open_lark/service/cloud_docs/sheets/v3/struct.SpreadsheetSheetService Example showing how to retrieve a list of all sheets within a spreadsheet. This method is useful for getting an overview of a spreadsheet's structure, including sheet titles and their order. ```rust use open_lark::service::cloud_docs::sheets::v3::SpreadsheetSheetService; use open_lark::service::cloud_docs::sheets::v3::spreadsheet_sheet::QuerySpreadsheetSheetRequest; use open_lark::core::req_option::RequestOption; use open_lark::core::config::Config; // Assuming 'config' is an initialized Config object // let config: Config = ...; // let sheet_service = SpreadsheetSheetService::new(config); // let request: QuerySpreadsheetSheetRequest = QuerySpreadsheetSheetRequest { // spreadsheet_token: "your_spreadsheet_token".to_string(), // }; // let option: Option = None; // let result = sheet_service.query(request, option).await; // match result { // Ok(resp) => { // println!("Query sheets successful: {:?}", resp); // if let Some(sheets) = resp.data.sheets { // for sheet in sheets { // println!("Sheet ID: {}, Title: {}", sheet.sheet_id, sheet.title); // } // } // } // Err(e) => { // eprintln!("Error querying sheets: {:?}", e); // } // } ``` -------------------------------- ### Initialize and Use LarkClient Source: https://docs.rs/open-lark/0.13.0/open_lark/service/search/index Demonstrates how to initialize the LarkClient with application credentials and access the search service. It shows how to obtain a reference to the search client and includes commented-out examples for creating data sources and performing searches using the v2 API. ```Rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // 获取搜索服务 let search = &client.search; // 创建数据源(v2版本) // let data_source_request = CreateDataSourceRequest::builder() // .name("企业知识库") // .description("包含公司所有技术文档") // .build(); // let data_source = search.v2.data_source.create(data_source_request, None).await?; // 执行搜索 // let search_request = SearchRequest::builder() // .query("飞书API") // .data_source_id("ds_123") // .build(); // let results = search.v2.suite_search.search(search_request, None).await?; ``` -------------------------------- ### Get Spreadsheet Sheet Example Source: https://docs.rs/open-lark/0.13.0/open_lark/service/cloud_docs/sheets/v3/struct.SpreadsheetSheetService Example demonstrating how to fetch details of a specific spreadsheet sheet using its token and sheet ID. The response includes metadata like the sheet's title, index, and visibility status. ```rust use open_lark::service::cloud_docs::sheets::v3::SpreadsheetSheetService; use open_lark::service::cloud_docs::sheets::v3::spreadsheet_sheet::GetSpreadsheetSheetRequest; use open_lark::core::req_option::RequestOption; use open_lark::core::config::Config; // Assuming 'config' is an initialized Config object // let config: Config = ...; // let sheet_service = SpreadsheetSheetService::new(config); // let request: GetSpreadsheetSheetRequest = GetSpreadsheetSheetRequest { // spreadsheet_token: "your_spreadsheet_token".to_string(), // sheet_id: "sheet_id_to_get".to_string(), // }; // let option: Option = None; // let result = sheet_service.get(request, option).await; // match result { // Ok(resp) => { // println!("Get sheet successful: {:?}", resp); // if let Some(data) = resp.data { // println!("Sheet Title: {}", data.title); // } // } // Err(e) => { // eprintln!("Error getting sheet: {:?}", e); // } // } ``` -------------------------------- ### Rust SDK: Get Department Parent Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/contact/v3/department.rs Example of fetching the parent department information for a given department ID. ```rust // Assuming 'department_service' is an initialized DepartmentService instance let department_id = "67890"; match department_service.get_parent(department_id).await { Ok(response) => { println!("Parent department retrieved successfully: {:?}", response); } Err(e) => { eprintln!("Failed to retrieve parent department: {}", e); } } ``` -------------------------------- ### Rust SDK: Get Department Children Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/contact/v3/department.rs Example of fetching the direct child departments for a specified parent department ID. ```rust // Assuming 'department_service' is an initialized DepartmentService instance let parent_department_id = "12345"; match department_service.get_children(parent_department_id).await { Ok(response) => { println!("Child departments retrieved successfully: {:?}", response); } Err(e) => { eprintln!("Failed to retrieve child departments: {}", e); } } ``` -------------------------------- ### Rust SDK: Get Department Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/contact/v3/department.rs Example of retrieving information for a single department by its ID. It takes the department ID and an optional GetDepartmentRequest. ```rust use crate::service::contact::models::GetDepartmentRequest; // Assuming 'department_service' is an initialized DepartmentService instance let department_id = "67890"; let get_req = GetDepartmentRequest {}; // Usually empty for GET requests match department_service.get(department_id, &get_req).await { Ok(response) => { println!("Department retrieved successfully: {:?}", response); } Err(e) => { eprintln!("Failed to retrieve department: {}", e); } } ``` -------------------------------- ### Rust SDK: Get Department Tree Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/contact/v3/department.rs Example of fetching the entire department tree structure. This operation does not require specific department IDs. ```rust // Assuming 'department_service' is an initialized DepartmentService instance match department_service.get_department_tree().await { Ok(response) => { println!("Department tree retrieved successfully: {:?}", response); } Err(e) => { eprintln!("Failed to retrieve department tree: {}", e); } } ``` -------------------------------- ### Lark Drive API Quick Start Source: https://docs.rs/open-lark/0.13.0/open_lark/service/cloud_docs/drive/index Demonstrates how to initialize the Lark client and perform basic file operations using the Drive API v1. ```rust use open_lark::prelude::*; let client = LarkClient::builder("app_id", "app_secret") .with_app_type(AppType::SelfBuild) .build(); // Upload file example (commented out) // let upload_request = UploadAllRequest::builder() // .file_name("document.pdf") // .parent_type("folder") // .parent_node("folder_token") // .build(); // let result = client.drive.v1.files.upload_all(upload_request, None).await?; // Get file info example (commented out) // let file_info = client.drive.v1.file.get(file_token, None).await?; ``` -------------------------------- ### Rust WhiteboardService::new Method Source: https://docs.rs/open-lark/0.13.0/open_lark/service/cloud_docs/board/v1/whiteboard/struct.WhiteboardService The constructor for the `WhiteboardService`. It initializes the service with a configuration object. ```Rust pub fn new(config: Config) -> Self ``` -------------------------------- ### Initialize Lark Client Source: https://docs.rs/open-lark/0.13.0/open_lark/index Demonstrates how to create and configure a LarkClient instance using the SDK. It shows setting the application ID, secret, app type, and enabling token caching. ```rust use open_lark::prelude::*; #[tokio::main] async fn main() -> Result<(), Box> { // 创建客户端 let client = LarkClient::builder("your_app_id", "your_app_secret") .with_app_type(AppType::SelfBuild) .with_enable_token_cache(true) .build(); println!("飞书开放平台 Rust SDK 初始化成功"); Ok(()) } ``` -------------------------------- ### Get Reply ID from UpdateReplyResponse Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/cloud_docs/comments/update_reply.rs Retrieves the reply ID from the `UpdateReplyResponse` struct. It accesses the nested `reply` field to get the specific ID. ```rust pub fn reply_id(&self) -> &str { &self.reply.reply_id } ``` -------------------------------- ### Initialize Lark Client Source: https://docs.rs/open-lark/0.13.0/open_lark Demonstrates how to create and configure a LarkClient instance using the SDK. It shows setting the application ID, secret, app type, and enabling token caching. ```rust use open_lark::prelude::*; #[tokio::main] async fn main() -> Result<(), Box> { // 创建客户端 let client = LarkClient::builder("your_app_id", "your_app_secret") .with_app_type(AppType::SelfBuild) .with_enable_token_cache(true) .build(); println!("飞书开放平台 Rust SDK 初始化成功"); Ok(()) } ``` -------------------------------- ### Move Dimension Example Source: https://docs.rs/open-lark/0.13.0/open_lark/service/cloud_docs/sheets/v3/struct.SpreadsheetSheetService Example of how to use the move_dimension method to rearrange rows or columns in a spreadsheet. This operation requires a MoveDimensionRequest object specifying the target sheet and the desired changes. ```rust use open_lark::service::cloud_docs::sheets::v3::SpreadsheetSheetService; use open_lark::service::cloud_docs::sheets::v3::sheet_row_col::MoveDimensionRequest; use open_lark::core::req_option::RequestOption; use open_lark::core::config::Config; // Assuming 'config' is an initialized Config object // let config: Config = ...; // let sheet_service = SpreadsheetSheetService::new(config); // let request: MoveDimensionRequest = MoveDimensionRequest { // spreadsheet_token: "your_spreadsheet_token".to_string(), // dimension: open_lark::service::cloud_docs::sheets::v3::sheet_row_col::Dimension { // dimension_id: "sheet_id".to_string(), // kind: open_lark::service::cloud_docs::sheets::v3::sheet_row_col::DimensionType::ROW, // start_index: 0, // end_index: 5, // }, // to_index: 10, // // other fields as needed // }; // let option: Option = None; // let result = sheet_service.move_dimension(request, option).await; // match result { // Ok(resp) => { // println!("Move dimension successful: {:?}", resp); // } // Err(e) => { // eprintln!("Error moving dimension: {:?}", e); // } // } ``` -------------------------------- ### Get Group Detail Request Parameters Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/contact/v3/group.rs Defines the optional parameters for the Get Group Detail API request, allowing specification of user and department ID types for query resolution. ```APIDOC GetGroupRequest: user_id_type: string (optional) Description: 用户 ID 类型 (User ID type). Allowed values: "open_id", "user_id", "union_id". department_id_type: string (optional) Description: 部门 ID 类型 (Department ID type). Allowed values: "open_department_id", "department_id". Example Usage: GET /open-apis/contact/v3/groups/{group_id}/detail?user_id_type=user_id&department_id_type=department_id ``` -------------------------------- ### AppDashboardService Methods (Rust) Source: https://docs.rs/open-lark/0.13.0/open_lark/service/cloud_docs/bitable/v1/struct.AppDashboardService Documentation for the AppDashboardService within the open-lark crate. It lists available methods such as copy, list, and new, providing links to their specific implementations and details. ```APIDOC AppDashboardService: Methods: copy: Copies an app dashboard. list: Lists app dashboards. new: Creates a new app dashboard. ``` -------------------------------- ### Open-lark Crate Overview Source: https://docs.rs/open-lark/0.13.0/open_lark/service/cloud_docs/bitable/v1/app_table_record/index Provides general information about the open-lark Rust crate, including its version, license, homepage, repository, and crate.io link. It also lists project owners and dependencies. ```rust Project: /context7/rs-open-lark-0.13.0 open-lark 0.13.0 License: Apache-2.0 Homepage: https://github.com/foxzool/open-lark Repository: https://github.com/foxzool/open-lark Crates.io: https://crates.io/crates/open-lark Dependencies: - anyhow ^1.0.86 - async-trait ^0.1.83 - base64 ^0.22.1 - chrono ^0.4.38 - futures-util ^0.3.30 - hmac ^0.12.1 - lark-websocket-protobuf ^0.1.1 (optional) - log ^0.4.21 - prost ^0.13 (optional) - quick_cache ^0.6.3 - rand ^0.8 - regex ^1.10 - reqwest ^0.12.7 - serde ^1.0 - serde_json ^1.0 - serde_repr ^0.1.19 - sha2 ^0.10.8 - simd-adler32 ^0.3.7 - strum ^0.27 - strum_macros ^0.27 - thiserror ^2.0 - tokio ^1.38 - tokio-tungstenite ^0.23 (optional) - url ^2.5.0 - walkdir ^2.4 - dotenvy ^0.15.7 (dev) - env_logger ^0.11.3 (dev) - uuid ^1.8.0 (dev) ``` -------------------------------- ### RequestExecutor: GET Method Source: https://docs.rs/open-lark/0.13.0/src/open_lark/core/request_executor.rs Executes an HTTP GET request. It takes configuration, path, supported token types, optional query parameters, and request options. Returns a standard `BaseResponse`. ```Rust pub async fn get( config: &Config, path: &str, supported_tokens: Vec, query_params: Option>, option: Option, ) -> SDKResult> { Self::execute( config, Method::GET, path, supported_tokens, query_params, None::<()>, // No body for GET option, ) .await } ``` -------------------------------- ### Initialize LarkClient Source: https://docs.rs/open-lark/0.13.0/src/open_lark/lib.rs Demonstrates how to initialize the `LarkClient` for the open-lark Rust SDK. It shows setting up the client with application ID, secret, and optional configurations like app type and token caching. ```rust #![allow(rustdoc::broken_intra_doc_links)] use open_lark::prelude::*; #[tokio::main] async fn main() -> Result<(), Box> { // 创建客户端 let client = LarkClient::builder("your_app_id", "your_app_secret") .with_app_type(AppType::SelfBuild) .with_enable_token_cache(true) .build(); println!("飞书开放平台 Rust SDK 初始化成功"); Ok(()) } ``` -------------------------------- ### Get Lark Document Comment Request and Response Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/cloud_docs/comments/get.rs Defines the Rust structures for making a request to get a document comment and for parsing the response. Includes builder pattern for easy request creation. ```Rust use serde::{Deserialize, Serialize}; use crate::core::api_req::ApiRequest; use super::list::Comment; /// 获取全文评论请求 #[derive(Debug, Serialize, Default, Clone)] pub struct GetCommentRequest { #[serde(skip)] api_request: ApiRequest, /// 文档token #[serde(skip)] file_token: String, /// 文档类型:doc、docx、sheet、bitable #[serde(skip)] file_type: String, /// 评论ID #[serde(skip)] comment_id: String, /// 用户ID类型 #[serde(skip_serializing_if = "Option::is_none")] user_id_type: Option, } impl GetCommentRequest { pub fn builder() -> GetCommentRequestBuilder { GetCommentRequestBuilder::default() } pub fn new( file_token: impl ToString, file_type: impl ToString, comment_id: impl ToString, ) -> Self { Self { file_token: file_token.to_string(), file_type: file_type.to_string(), comment_id: comment_id.to_string(), ..Default::default() } } } #[derive(Default)] pub struct GetCommentRequestBuilder { request: GetCommentRequest, } impl GetCommentRequestBuilder { /// 文档token pub fn file_token(mut self, file_token: impl ToString) -> Self { self.request.file_token = file_token.to_string(); self } /// 文档类型 pub fn file_type(mut self, file_type: impl ToString) -> Self { self.request.file_type = file_type.to_string(); self } /// 设置为文档类型 pub fn with_doc_type(mut self) -> Self { self.request.file_type = "doc".to_string(); self } /// 设置为docx类型 pub fn with_docx_type(mut self) -> Self { self.request.file_type = "docx".to_string(); self } /// 设置为电子表格类型 pub fn with_sheet_type(mut self) -> Self { self.request.file_type = "sheet".to_string(); self } /// 设置为多维表格类型 pub fn with_bitable_type(mut self) -> Self { self.request.file_type = "bitable".to_string(); self } /// 评论ID pub fn comment_id(mut self, comment_id: impl ToString) -> Self { self.request.comment_id = comment_id.to_string(); self } /// 用户ID类型 pub fn user_id_type(mut self, user_id_type: impl ToString) -> Self { self.request.user_id_type = Some(user_id_type.to_string()); self } /// 使用OpenID pub fn with_open_id(mut self) -> Self { self.request.user_id_type = Some("open_id".to_string()); self } /// 使用UserID pub fn with_user_id(mut self) -> Self { self.request.user_id_type = Some("user_id".to_string()); self } /// 使用UnionID pub fn with_union_id(mut self) -> Self { self.request.user_id_type = Some("union_id".to_string()); self } pub fn build(mut self) -> GetCommentRequest { self.request.api_request.body = serde_json::to_vec(&self.request).unwrap(); self.request } } /// 获取全文评论响应 #[derive(Debug, Deserialize)] pub struct GetCommentResponse { /// 评论信息 pub comment: Comment, } impl ApiResponseTrait for GetCommentResponse { fn data_format() -> ResponseFormat { ResponseFormat::Data } } ``` -------------------------------- ### WorkCityService Methods for Work City Management Source: https://docs.rs/open-lark/0.13.0/open_lark/service/contact/v3/work_city/struct.WorkCityService This snippet details the `WorkCityService` struct and its public methods for interacting with work city data. It includes a constructor (`new`), a method to get a single work city by ID (`get`), and a method to list all work cities (`list`). The `get` and `list` methods are asynchronous and return `SDKResult` containing specific response types. ```rust pub struct WorkCityService { /* private fields */ } ``` ```rust impl WorkCityService { pub fn new(config: Config) -> Self pub async fn get(&self, work_city_id: &str) -> SDKResult pub async fn list(&self, _req: &ListWorkCitiesRequest) -> SDKResult } ``` -------------------------------- ### Get Group Detail API Request Source: https://docs.rs/open-lark/0.13.0/src/open_lark/service/contact/v3/group.rs Constructs and sends a GET request to retrieve detailed information about a specific group. It supports optional query parameters for specifying user and department ID types. ```Rust impl ContactClient { pub async fn get_group_detail( &self, group_id: &str, req: GetGroupRequest, ) -> Result { let mut query_params = reqwest::blocking::Client::new().get("").unwrap().url().query_pairs_mut(); if let Some(user_id_type) = req.user_id_type { query_params.append_pair("user_id_type", &user_id_type); } if let Some(department_id_type) = req.department_id_type { query_params.append_pair("department_id_type", &department_id_type); } let api_req = ApiRequest { http_method: reqwest::Method::GET, api_path: format!("/open-apis/contact/v3/groups/{}/detail", group_id), supported_access_token_types: vec![AccessTokenType::Tenant], body: Vec::new(), query_params: query_params.finish().into_owned().to_string(), ..Default::default() }; let resp = Transport::::request(api_req, &self.config, None).await?; Ok(resp.data.unwrap_or_default()) } } ``` -------------------------------- ### CreateApp API Documentation Source: https://docs.rs/open-lark/0.13.0/open_lark/service/cloud_docs/bitable/v1/app/create/index Documentation for the API endpoint related to creating a bitable application. This includes the request structure, builder pattern, and response structures. ```APIDOC open_lark::service::cloud_docs::bitable::v1::app::create This module provides structures for creating a bitable application. ## Structs ### CreateAppRequest Represents the request payload for creating a bitable application. ### CreateAppRequestBuilder Provides a builder pattern for constructing `CreateAppRequest` objects. ### CreateAppResponse Represents the response received after attempting to create a bitable application. ### CreateAppResponseData Contains the data payload within the `CreateAppResponse`, typically including details of the created application. ```