use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AddSheetParams {
#[serde(rename = "title")]
pub title: String,
#[serde(rename = "index")]
pub index: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AddSheetResponse {
pub data: Option<AddSheetResult>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AddSheetResult {
#[serde(rename = "spreadsheet_token")]
pub spreadsheet_token: String,
#[serde(rename = "sheet_id")]
pub sheet_id: String,
#[serde(rename = "title")]
pub title: String,
#[serde(rename = "index")]
pub index: i32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GetSheetParams {
#[serde(rename = "sheet_id")]
pub sheet_id: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GetSheetResponse {
pub data: Option<SheetDetailInfo>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UpdateSheetParams {
#[serde(rename = "sheet_id")]
pub sheet_id: String,
#[serde(rename = "title")]
pub title: Option<String>,
#[serde(rename = "index")]
pub index: Option<i32>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UpdateSheetResponse {
pub data: Option<UpdateSheetResult>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UpdateSheetResult {
#[serde(rename = "spreadsheet_token")]
pub spreadsheet_token: String,
#[serde(rename = "sheet_id")]
pub sheet_id: String,
#[serde(rename = "title")]
pub title: String,
#[serde(rename = "index")]
pub index: i32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeleteSheetParams {
#[serde(rename = "sheet_id")]
pub sheet_id: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeleteSheetResponse {
pub data: Option<DeleteSheetResult>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SheetDetailInfo {
#[serde(rename = "spreadsheet_token")]
pub spreadsheet_token: String,
#[serde(rename = "sheet_id")]
pub sheet_id: String,
#[serde(rename = "title")]
pub title: String,
#[serde(rename = "sheet_type")]
pub sheet_type: String,
#[serde(rename = "row_count")]
pub row_count: i32,
#[serde(rename = "column_count")]
pub column_count: i32,
#[serde(rename = "index")]
pub index: i32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeleteSheetResult {
#[serde(rename = "spreadsheet_token")]
pub spreadsheet_token: String,
#[serde(rename = "sheet_id")]
pub sheet_id: String,
}
#[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");
}
}