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
6#[derive(Serialize, Debug, Default)]
7pub(crate) struct ValueRangeRequest {
8 pub(crate) range: String,
11 pub(crate) values: Value,
13}
14
15#[derive(Deserialize, Debug, Default)]
16#[allow(dead_code)]
17pub struct ValueRangeResponse {
18 #[serde(rename = "majorDimension")]
20 pub major_dimension: String,
21 pub range: String,
24 pub values: Value,
26 pub revision: i32,
28}
29
30#[derive(Deserialize, Debug)]
32#[allow(dead_code)]
33pub struct UpdateSheetDataResponse {
34 #[serde(rename = "spreadsheetToken")]
36 pub spreed_sheet_token: String,
37 #[serde(rename = "tableRange")]
39 pub table_range: String,
40 pub revision: i32,
42 pub updates: SheetDataUpdates,
44}
45
46impl ApiResponseTrait for UpdateSheetDataResponse {
47 fn data_format() -> ResponseFormat {
48 ResponseFormat::Data
49 }
50}
51
52#[derive(Deserialize, Debug)]
54#[allow(dead_code)]
55pub struct SheetDataUpdates {
56 #[serde(rename = "spreadsheetToken")]
58 pub spreed_sheet_token: String,
59 #[serde(rename = "updatedRange")]
61 pub updated_range: String,
62 #[serde(rename = "updatedRows")]
64 pub updated_rows: i32,
65 #[serde(rename = "updatedColumns")]
67 pub updated_columns: i32,
68 #[serde(rename = "updatedCells")]
70 pub updated_cells: i32,
71 pub revision: Option<i32>,
73}
74
75impl ApiResponseTrait for SheetDataUpdates {
76 fn data_format() -> ResponseFormat {
77 ResponseFormat::Data
78 }
79}
80
81#[derive(Deserialize, Debug)]
83#[allow(dead_code)]
84pub struct ReadRangeValueRange {
85 #[serde(rename = "majorDimension")]
87 pub major_dimension: String,
88 pub range: String,
90 pub revision: i32,
92 pub values: Value,
94}
95
96#[derive(Debug, Serialize, Default)]
97pub struct CellStyle {
98 pub(crate) font: StyleFont,
100 #[serde(rename = "textDecoration")]
102 pub(crate) text_decoration: Option<i32>,
103 pub(crate) formatter: Option<String>,
105 #[serde(rename = "hAlign")]
107 pub(crate) h_align: Option<i32>,
108 #[serde(rename = "vAlign")]
109 pub(crate) v_align: Option<i32>,
111 #[serde(rename = "foreColor")]
113 pub(crate) fore_color: Option<String>,
114 #[serde(rename = "backColor")]
116 pub(crate) back_color: Option<String>,
117 #[serde(rename = "borderType")]
120 pub(crate) border_type: Option<String>,
121 #[serde(rename = "borderColor")]
123 pub(crate) border_color: Option<String>,
124 pub(crate) clean: bool,
126}
127
128impl CellStyle {
129 pub fn builder() -> CellStyleBuilder {
130 CellStyleBuilder::default()
131 }
132}
133
134#[derive(Default)]
135pub struct CellStyleBuilder {
136 request: CellStyle,
137}
138
139impl CellStyleBuilder {
140 pub fn font(mut self, font: StyleFont) -> Self {
141 self.request.font = font;
142 self
143 }
144
145 pub fn text_decoration(mut self, text_decoration: i32) -> Self {
146 self.request.text_decoration = Some(text_decoration);
147 self
148 }
149
150 pub fn formatter(mut self, formatter: impl ToString) -> Self {
151 self.request.formatter = Some(formatter.to_string());
152 self
153 }
154
155 pub fn h_align(mut self, h_align: i32) -> Self {
156 self.request.h_align = Some(h_align);
157 self
158 }
159
160 pub fn v_align(mut self, v_align: i32) -> Self {
161 self.request.v_align = Some(v_align);
162 self
163 }
164
165 pub fn fore_color(mut self, fore_color: impl ToString) -> Self {
166 self.request.fore_color = Some(fore_color.to_string());
167 self
168 }
169
170 pub fn back_color(mut self, back_color: impl ToString) -> Self {
171 self.request.back_color = Some(back_color.to_string());
172 self
173 }
174
175 pub fn border_type(mut self, border_type: impl ToString) -> Self {
176 self.request.border_type = Some(border_type.to_string());
177 self
178 }
179
180 pub fn border_color(mut self, border_color: impl ToString) -> Self {
181 self.request.border_color = Some(border_color.to_string());
182 self
183 }
184
185 pub fn clean(mut self, clean: bool) -> Self {
186 self.request.clean = clean;
187 self
188 }
189
190 pub fn build(self) -> CellStyle {
191 self.request
192 }
193}
194
195#[derive(Debug, Serialize, Default)]
197pub struct StyleFont {
198 bold: Option<bool>,
200 italic: Option<bool>,
202 #[serde(rename = "fontSize")]
204 font_size: Option<String>,
205 clean: Option<bool>,
207}
208
209impl StyleFont {
210 pub fn builder() -> StyleFontBuilder {
211 StyleFontBuilder::default()
212 }
213}
214
215#[derive(Default)]
216pub struct StyleFontBuilder {
217 font: StyleFont,
218}
219
220impl StyleFontBuilder {
221 pub fn bold(mut self, bold: bool) -> Self {
222 self.font.bold = Some(bold);
223 self
224 }
225
226 pub fn italic(mut self, italic: bool) -> Self {
227 self.font.italic = Some(italic);
228 self
229 }
230
231 pub fn font_size(mut self, font_size: impl ToString) -> Self {
232 self.font.font_size = Some(font_size.to_string());
233 self
234 }
235
236 pub fn clean(mut self, clean: bool) -> Self {
237 self.font.clean = Some(clean);
238 self
239 }
240
241 pub fn build(self) -> StyleFont {
242 self.font
243 }
244}