use openlark_core::{
api::{ApiRequest, ApiResponseTrait, ResponseFormat},
config::Config,
http::Transport,
req_option::RequestOption,
SDKResult,
};
use serde::{Deserialize, Serialize};
use crate::common::{api_endpoints::SheetsApiV3, api_utils::*};
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DeleteFloatImageResponse {}
impl ApiResponseTrait for DeleteFloatImageResponse {
fn data_format() -> ResponseFormat {
ResponseFormat::Data
}
}
pub async fn delete_float_image(
config: &Config,
spreadsheet_token: &str,
sheet_id: &str,
float_image_id: &str,
) -> SDKResult<DeleteFloatImageResponse> {
delete_float_image_with_options(
config,
spreadsheet_token,
sheet_id,
float_image_id,
RequestOption::default(),
)
.await
}
pub async fn delete_float_image_with_options(
config: &Config,
spreadsheet_token: &str,
sheet_id: &str,
float_image_id: &str,
option: RequestOption,
) -> SDKResult<DeleteFloatImageResponse> {
let api_endpoint = SheetsApiV3::DeleteFloatImage(
spreadsheet_token.to_string(),
sheet_id.to_string(),
float_image_id.to_string(),
);
let api_request: ApiRequest<DeleteFloatImageResponse> =
ApiRequest::delete(&api_endpoint.to_url());
let response = Transport::request(api_request, config, Some(option)).await?;
extract_response_data(response, "删除浮动图片")
}
#[cfg(test)]
mod tests {
use serde_json;
#[test]
fn test_serialization_roundtrip() {
let json = r#"{"test": "value"}"#;
assert!(serde_json::from_str::<serde_json::Value>(json).is_ok());
}
#[test]
fn test_deserialization_from_json() {
let json = r#"{"field": "data"}"#;
let value: serde_json::Value = serde_json::from_str(json).unwrap();
assert_eq!(value["field"], "data");
}
}