open_lark/service/cloud_docs/sheets/v2/data_operation/
share.rs1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4use crate::core::api_resp::{ApiResponseTrait, ResponseFormat};
5#[derive(Serialize, Debug, Default)]
6pub(crate) struct ValueRangeRequest {
7 pub(crate) range: String,
10 pub(crate) values: Value,
12}
13
14#[derive(Deserialize, Debug, Default)]
15#[allow(dead_code)]
16pub struct ValueRangeResponse {
17 #[serde(rename = "majorDimension")]
19 pub major_dimension: String,
20 pub range: String,
23 pub values: Value,
25 pub revision: i32,
27}
28
29#[derive(Deserialize, Debug)]
31#[allow(dead_code)]
32pub struct UpdateSheetDataResponse {
33 #[serde(rename = "spreadsheetToken")]
35 pub spreed_sheet_token: String,
36 #[serde(rename = "tableRange")]
38 pub table_range: String,
39 pub revision: i32,
41 pub updates: SheetDataUpdates,
43}
44
45impl ApiResponseTrait for UpdateSheetDataResponse {
46 fn data_format() -> ResponseFormat {
47 ResponseFormat::Data
48 }
49}
50
51#[derive(Deserialize, Debug)]
53#[allow(dead_code)]
54pub struct SheetDataUpdates {
55 #[serde(rename = "spreadsheetToken")]
57 pub spreed_sheet_token: String,
58 #[serde(rename = "updatedRange")]
60 pub updated_range: String,
61 #[serde(rename = "updatedRows")]
63 pub updated_rows: i32,
64 #[serde(rename = "updatedColumns")]
66 pub updated_columns: i32,
67 #[serde(rename = "updatedCells")]
69 pub updated_cells: i32,
70 pub revision: Option<i32>,
72}
73
74impl ApiResponseTrait for SheetDataUpdates {
75 fn data_format() -> ResponseFormat {
76 ResponseFormat::Data
77 }
78}
79
80#[derive(Deserialize, Debug)]
82#[allow(dead_code)]
83pub struct ReadRangeValueRange {
84 #[serde(rename = "majorDimension")]
86 pub major_dimension: String,
87 pub range: String,
89 pub revision: i32,
91 pub values: Value,
93}
94
95#[derive(Debug, Serialize, Default)]
96pub struct CellStyle {
97 pub(crate) font: StyleFont,
99 #[serde(rename = "textDecoration")]
101 pub(crate) text_decoration: Option<i32>,
102 pub(crate) formatter: Option<String>,
104 #[serde(rename = "hAlign")]
106 pub(crate) h_align: Option<i32>,
107 #[serde(rename = "vAlign")]
108 pub(crate) v_align: Option<i32>,
110 #[serde(rename = "foreColor")]
112 pub(crate) fore_color: Option<String>,
113 #[serde(rename = "backColor")]
115 pub(crate) back_color: Option<String>,
116 #[serde(rename = "borderType")]
119 pub(crate) border_type: Option<String>,
120 #[serde(rename = "borderColor")]
122 pub(crate) border_color: Option<String>,
123 pub(crate) clean: bool,
125}
126
127impl CellStyle {
128 pub fn builder() -> CellStyleBuilder {
129 CellStyleBuilder::default()
130 }
131}
132
133#[derive(Default)]
134pub struct CellStyleBuilder {
135 request: CellStyle,
136}
137
138impl CellStyleBuilder {
139 pub fn font(mut self, font: StyleFont) -> Self {
140 self.request.font = font;
141 self
142 }
143
144 pub fn text_decoration(mut self, text_decoration: i32) -> Self {
145 self.request.text_decoration = Some(text_decoration);
146 self
147 }
148
149 pub fn formatter(mut self, formatter: impl ToString) -> Self {
150 self.request.formatter = Some(formatter.to_string());
151 self
152 }
153
154 pub fn h_align(mut self, h_align: i32) -> Self {
155 self.request.h_align = Some(h_align);
156 self
157 }
158
159 pub fn v_align(mut self, v_align: i32) -> Self {
160 self.request.v_align = Some(v_align);
161 self
162 }
163
164 pub fn fore_color(mut self, fore_color: impl ToString) -> Self {
165 self.request.fore_color = Some(fore_color.to_string());
166 self
167 }
168
169 pub fn back_color(mut self, back_color: impl ToString) -> Self {
170 self.request.back_color = Some(back_color.to_string());
171 self
172 }
173
174 pub fn border_type(mut self, border_type: impl ToString) -> Self {
175 self.request.border_type = Some(border_type.to_string());
176 self
177 }
178
179 pub fn border_color(mut self, border_color: impl ToString) -> Self {
180 self.request.border_color = Some(border_color.to_string());
181 self
182 }
183
184 pub fn clean(mut self, clean: bool) -> Self {
185 self.request.clean = clean;
186 self
187 }
188
189 pub fn build(self) -> CellStyle {
190 self.request
191 }
192}
193
194#[derive(Debug, Serialize, Default)]
196pub struct StyleFont {
197 bold: Option<bool>,
199 italic: Option<bool>,
201 #[serde(rename = "fontSize")]
203 font_size: Option<String>,
204 clean: Option<bool>,
206}
207
208impl StyleFont {
209 pub fn builder() -> StyleFontBuilder {
210 StyleFontBuilder::default()
211 }
212}
213
214#[derive(Default)]
215pub struct StyleFontBuilder {
216 font: StyleFont,
217}
218
219impl StyleFontBuilder {
220 pub fn bold(mut self, bold: bool) -> Self {
221 self.font.bold = Some(bold);
222 self
223 }
224
225 pub fn italic(mut self, italic: bool) -> Self {
226 self.font.italic = Some(italic);
227 self
228 }
229
230 pub fn font_size(mut self, font_size: impl ToString) -> Self {
231 self.font.font_size = Some(font_size.to_string());
232 self
233 }
234
235 pub fn clean(mut self, clean: bool) -> Self {
236 self.font.clean = Some(clean);
237 self
238 }
239
240 pub fn build(self) -> StyleFont {
241 self.font
242 }
243}