use openlark_core::{
SDKResult,
api::{ApiRequest, ApiResponseTrait, ResponseFormat},
config::Config,
http::Transport,
req_option::RequestOption,
};
use super::super::models::*;
use crate::common::{api_endpoints::SheetsApiV3, api_utils::*};
impl ApiResponseTrait for GetSheetResponse {
fn data_format() -> ResponseFormat {
ResponseFormat::Data
}
}
pub async fn get_sheet(
config: &Config,
spreadsheet_token: &str,
sheet_id: &str,
) -> SDKResult<GetSheetResponse> {
get_sheet_with_options(
config,
spreadsheet_token,
sheet_id,
RequestOption::default(),
)
.await
}
pub async fn get_sheet_with_options(
config: &Config,
spreadsheet_token: &str,
sheet_id: &str,
option: RequestOption,
) -> SDKResult<GetSheetResponse> {
let api_endpoint = SheetsApiV3::GetSheet(spreadsheet_token.to_string(), sheet_id.to_string());
let api_request: ApiRequest<GetSheetResponse> = ApiRequest::get(&api_endpoint.to_url());
let response = Transport::request(api_request, config, Some(option)).await?;
extract_response_data(response, "获取工作表信息")
}