1use super::CatalogEndpoint;
4use openlark_core::api::{ApiRequest, HttpMethod};
5
6#[derive(Debug, Clone, PartialEq)]
9#[cfg_attr(test, derive(strum_macros::EnumIter))]
10pub enum CcmSheetApiOld {
11 OperateSheets(String), UpdateSheetProperties(String), DimensionRange(String), InsertDimensionRange(String), DimensionRangeUpdate(String), DimensionRangeDelete(String), MergeCells(String), UnmergeCells(String), Style(String), StylesBatchUpdate(String), ValuesPrepend(String), ValuesAppend(String), ValuesImage(String), ValuesRange(String, String), ValuesBatchGet(String), Values(String), ValuesBatchUpdate(String), ProtectedDimension(String), ProtectedRangeBatchUpdate(String), ProtectedRangeBatchGet(String), ProtectedRangeBatchDel(String), Metainfo(String), Properties(String), Import,
59 ImportResult,
61 ConditionFormats(String), ConditionFormatsBatchCreate(String), ConditionFormatsBatchDelete(String), ConditionFormatsBatchUpdate(String), DataValidation(String), DataValidationCreate(String), DataValidationUpdate(String, String), DataValidationDelete(String), ReadSingleRange(String, String), ReadMultipleRanges(String), WriteSingleRange(String), BatchWriteRanges(String), AppendValues(String), InsertValues(String), GetSpreadsheet(String), CreateSpreadsheet,
93 UpdateSpreadsheet(String), AddSheet(String), GetSheet(String, String), UpdateSheet(String), DeleteSheet(String), CreateFilter(String), GetFilter(String), UpdateFilter(String), DeleteFilter(String), CreateFilterView(String, String), UpdateFilterView(String, String, String), QueryFilterViews(String, String), GetFilterView(String, String, String), DeleteFilterView(String, String, String), CreateFilterCondition(String, String, String), UpdateFilterCondition(String, String, String, String), QueryFilterConditions(String, String, String), GetFilterCondition(String, String, String, String), DeleteFilterCondition(String, String, String, String), CreateFloatImage(String, String), UpdateFloatImage(String, String, String), GetFloatImage(String, String, String), QueryFloatImages(String, String), DeleteFloatImage(String, String, String), DeleteRange(String), InsertDimension(String), MoveDimension(String), ReplaceRange(String), FindReplace(String), }
152
153impl CcmSheetApiOld {
154 pub fn to_url(&self) -> String {
156 match self {
157 CcmSheetApiOld::OperateSheets(spreadsheet_token) => {
158 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/sheets_batch_update")
159 }
160 CcmSheetApiOld::UpdateSheetProperties(spreadsheet_token) => {
161 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/sheets_batch_update")
162 }
163 CcmSheetApiOld::Style(spreadsheet_token) => {
164 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/style")
165 }
166 CcmSheetApiOld::StylesBatchUpdate(spreadsheet_token) => {
167 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/styles_batch_update")
168 }
169 CcmSheetApiOld::ValuesPrepend(spreadsheet_token) => {
170 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values_prepend")
171 }
172 CcmSheetApiOld::ValuesAppend(spreadsheet_token) => {
173 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values_append")
174 }
175 CcmSheetApiOld::ValuesImage(spreadsheet_token) => {
176 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values_image")
177 }
178 CcmSheetApiOld::ValuesRange(spreadsheet_token, range) => {
179 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values/{range}")
180 }
181 CcmSheetApiOld::ValuesBatchGet(spreadsheet_token) => {
182 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values_batch_get")
183 }
184 CcmSheetApiOld::Values(spreadsheet_token) => {
185 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values")
186 }
187 CcmSheetApiOld::ValuesBatchUpdate(spreadsheet_token) => {
188 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values_batch_update")
189 }
190 CcmSheetApiOld::DimensionRange(spreadsheet_token) => {
191 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/dimension_range")
192 }
193 CcmSheetApiOld::InsertDimensionRange(spreadsheet_token) => {
194 format!(
195 "/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/insert_dimension_range"
196 )
197 }
198 CcmSheetApiOld::DimensionRangeUpdate(spreadsheet_token) => {
199 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/dimension_range")
200 }
201 CcmSheetApiOld::DimensionRangeDelete(spreadsheet_token) => {
202 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/dimension_range")
203 }
204 CcmSheetApiOld::MergeCells(spreadsheet_token) => {
205 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/merge_cells")
206 }
207 CcmSheetApiOld::UnmergeCells(spreadsheet_token) => {
208 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/unmerge_cells")
209 }
210 CcmSheetApiOld::ProtectedDimension(spreadsheet_token) => {
211 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/protected_dimension")
212 }
213 CcmSheetApiOld::ProtectedRangeBatchUpdate(spreadsheet_token) => {
214 format!(
215 "/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/protected_range_batch_update"
216 )
217 }
218 CcmSheetApiOld::ProtectedRangeBatchGet(spreadsheet_token) => {
219 format!(
220 "/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/protected_range_batch_get"
221 )
222 }
223 CcmSheetApiOld::ProtectedRangeBatchDel(spreadsheet_token) => {
224 format!(
225 "/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/protected_range_batch_del"
226 )
227 }
228 CcmSheetApiOld::Metainfo(spreadsheet_token) => {
229 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/metainfo")
230 }
231 CcmSheetApiOld::Properties(spreadsheet_token) => {
232 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/properties")
233 }
234 CcmSheetApiOld::Import => "/open-apis/sheets/v2/import".to_string(),
235 CcmSheetApiOld::ImportResult => "/open-apis/sheets/v2/import/result".to_string(),
236 CcmSheetApiOld::ConditionFormats(spreadsheet_token) => {
237 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/condition_formats")
238 }
239 CcmSheetApiOld::ConditionFormatsBatchCreate(spreadsheet_token) => {
240 format!(
241 "/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/condition_formats/batch_create"
242 )
243 }
244 CcmSheetApiOld::ConditionFormatsBatchDelete(spreadsheet_token) => {
245 format!(
246 "/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/condition_formats/batch_delete"
247 )
248 }
249 CcmSheetApiOld::ConditionFormatsBatchUpdate(spreadsheet_token) => {
250 format!(
251 "/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/condition_formats/batch_update"
252 )
253 }
254 CcmSheetApiOld::DataValidation(spreadsheet_token) => {
255 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/dataValidation")
256 }
257 CcmSheetApiOld::DataValidationCreate(spreadsheet_token) => {
258 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/dataValidation")
259 }
260 CcmSheetApiOld::DataValidationUpdate(spreadsheet_token, sheet_id) => {
261 format!(
262 "/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/dataValidation/{sheet_id}"
263 )
264 }
265 CcmSheetApiOld::DataValidationDelete(spreadsheet_token) => {
266 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/dataValidation")
267 }
268 CcmSheetApiOld::ReadSingleRange(spreadsheet_token, range) => {
269 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values/{range}")
270 }
271 CcmSheetApiOld::ReadMultipleRanges(spreadsheet_token) => {
272 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values_batch_get")
273 }
274 CcmSheetApiOld::WriteSingleRange(spreadsheet_token) => {
275 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values")
276 }
277 CcmSheetApiOld::BatchWriteRanges(spreadsheet_token) => {
278 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values_batch_update")
279 }
280 CcmSheetApiOld::AppendValues(spreadsheet_token) => {
281 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values_append")
282 }
283 CcmSheetApiOld::InsertValues(spreadsheet_token) => {
284 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/values_prepend")
285 }
286 CcmSheetApiOld::GetSpreadsheet(spreadsheet_token) => {
287 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}")
288 }
289 CcmSheetApiOld::CreateSpreadsheet => "/open-apis/sheets/v3/spreadsheets".to_string(),
290 CcmSheetApiOld::UpdateSpreadsheet(spreadsheet_token) => {
291 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}")
292 }
293 CcmSheetApiOld::AddSheet(spreadsheet_token) => {
294 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/sheets_batch_update")
295 }
296 CcmSheetApiOld::GetSheet(spreadsheet_token, sheet_id) => {
297 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}")
298 }
299 CcmSheetApiOld::UpdateSheet(spreadsheet_token) => {
300 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/sheets_batch_update")
301 }
302 CcmSheetApiOld::DeleteSheet(spreadsheet_token) => {
303 format!("/open-apis/sheets/v2/spreadsheets/{spreadsheet_token}/sheets_batch_update")
304 }
305 CcmSheetApiOld::CreateFilter(spreadsheet_token) => {
306 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/filterViews")
307 }
308 CcmSheetApiOld::GetFilter(spreadsheet_token) => {
309 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/filterViews/query")
310 }
311 CcmSheetApiOld::UpdateFilter(spreadsheet_token) => {
312 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/filterViews")
313 }
314 CcmSheetApiOld::DeleteFilter(spreadsheet_token) => {
315 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/filterViews")
316 }
317 CcmSheetApiOld::CreateFilterView(spreadsheet_token, sheet_id) => {
318 format!(
319 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views"
320 )
321 }
322 CcmSheetApiOld::UpdateFilterView(spreadsheet_token, sheet_id, filter_view_id) => {
323 format!(
324 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}"
325 )
326 }
327 CcmSheetApiOld::QueryFilterViews(spreadsheet_token, sheet_id) => {
328 format!(
329 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/query"
330 )
331 }
332 CcmSheetApiOld::GetFilterView(spreadsheet_token, sheet_id, filter_view_id) => {
333 format!(
334 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}"
335 )
336 }
337 CcmSheetApiOld::DeleteFilterView(spreadsheet_token, sheet_id, filter_view_id) => {
338 format!(
339 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}"
340 )
341 }
342 CcmSheetApiOld::CreateFilterCondition(spreadsheet_token, sheet_id, filter_view_id) => {
343 format!(
344 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}/conditions"
345 )
346 }
347 CcmSheetApiOld::UpdateFilterCondition(
348 spreadsheet_token,
349 sheet_id,
350 filter_view_id,
351 condition_id,
352 ) => {
353 format!(
354 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}/conditions/{condition_id}"
355 )
356 }
357 CcmSheetApiOld::QueryFilterConditions(spreadsheet_token, sheet_id, filter_view_id) => {
358 format!(
359 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}/conditions/query"
360 )
361 }
362 CcmSheetApiOld::GetFilterCondition(
363 spreadsheet_token,
364 sheet_id,
365 filter_view_id,
366 condition_id,
367 ) => {
368 format!(
369 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}/conditions/{condition_id}"
370 )
371 }
372 CcmSheetApiOld::DeleteFilterCondition(
373 spreadsheet_token,
374 sheet_id,
375 filter_view_id,
376 condition_id,
377 ) => {
378 format!(
379 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}/conditions/{condition_id}"
380 )
381 }
382 CcmSheetApiOld::CreateFloatImage(spreadsheet_token, sheet_id) => {
383 format!(
384 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/float_images"
385 )
386 }
387 CcmSheetApiOld::UpdateFloatImage(spreadsheet_token, sheet_id, float_image_id) => {
388 format!(
389 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/float_images/{float_image_id}"
390 )
391 }
392 CcmSheetApiOld::GetFloatImage(spreadsheet_token, sheet_id, float_image_id) => {
393 format!(
394 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/float_images/{float_image_id}"
395 )
396 }
397 CcmSheetApiOld::QueryFloatImages(spreadsheet_token, sheet_id) => {
398 format!(
399 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/float_images/query"
400 )
401 }
402 CcmSheetApiOld::DeleteFloatImage(spreadsheet_token, sheet_id, float_image_id) => {
403 format!(
404 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/float_images/{float_image_id}"
405 )
406 }
407 CcmSheetApiOld::DeleteRange(spreadsheet_token) => {
408 format!(
409 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/dimensionRange/delete"
410 )
411 }
412 CcmSheetApiOld::InsertDimension(spreadsheet_token) => {
413 format!(
414 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/dimensionRange/insert"
415 )
416 }
417 CcmSheetApiOld::MoveDimension(spreadsheet_token) => {
418 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/dimensionRange/move")
419 }
420 CcmSheetApiOld::ReplaceRange(spreadsheet_token) => {
421 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/values/batchReplace")
422 }
423 CcmSheetApiOld::FindReplace(spreadsheet_token) => {
424 format!(
425 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/values/batchFindReplace"
426 )
427 }
428 }
429 }
430
431 pub fn to_request<R>(&self) -> ApiRequest<R> {
433 <Self as CatalogEndpoint>::to_request(self)
434 }
435}
436
437impl CatalogEndpoint for CcmSheetApiOld {
438 fn to_url(&self) -> String {
439 CcmSheetApiOld::to_url(self)
440 }
441
442 fn method(&self) -> HttpMethod {
444 match self {
445 Self::ValuesRange(_, _)
446 | Self::ValuesBatchGet(_)
447 | Self::ProtectedRangeBatchGet(_)
448 | Self::Metainfo(_)
449 | Self::ImportResult
450 | Self::ConditionFormats(_)
451 | Self::DataValidation(_)
452 | Self::ReadSingleRange(_, _)
453 | Self::ReadMultipleRanges(_)
454 | Self::GetSpreadsheet(_)
455 | Self::GetSheet(_, _)
456 | Self::QueryFilterViews(_, _)
457 | Self::GetFilterView(_, _, _)
458 | Self::QueryFilterConditions(_, _, _)
459 | Self::GetFilterCondition(_, _, _, _)
460 | Self::QueryFloatImages(_, _) => HttpMethod::Get,
461 Self::Values(_)
462 | Self::WriteSingleRange(_)
463 | Self::DataValidationUpdate(_, _)
464 | Self::DimensionRangeUpdate(_)
465 | Self::Properties(_) => HttpMethod::Put,
466 Self::UpdateSpreadsheet(_) | Self::UpdateFilterView(_, _, _) => HttpMethod::Patch,
467 Self::DimensionRangeDelete(_)
468 | Self::DataValidationDelete(_)
469 | Self::DeleteFilterView(_, _, _)
470 | Self::DeleteFilterCondition(_, _, _, _) => HttpMethod::Delete,
471 Self::OperateSheets(_)
472 | Self::UpdateSheetProperties(_)
473 | Self::DimensionRange(_)
474 | Self::InsertDimensionRange(_)
475 | Self::MergeCells(_)
476 | Self::UnmergeCells(_)
477 | Self::Style(_)
478 | Self::StylesBatchUpdate(_)
479 | Self::ValuesPrepend(_)
480 | Self::ValuesAppend(_)
481 | Self::ValuesImage(_)
482 | Self::ValuesBatchUpdate(_)
483 | Self::ProtectedDimension(_)
484 | Self::ProtectedRangeBatchUpdate(_)
485 | Self::ProtectedRangeBatchDel(_)
486 | Self::Import
487 | Self::ConditionFormatsBatchCreate(_)
488 | Self::ConditionFormatsBatchDelete(_)
489 | Self::ConditionFormatsBatchUpdate(_)
490 | Self::DataValidationCreate(_)
491 | Self::BatchWriteRanges(_)
492 | Self::AppendValues(_)
493 | Self::InsertValues(_)
494 | Self::CreateSpreadsheet
495 | Self::AddSheet(_)
496 | Self::UpdateSheet(_)
497 | Self::DeleteSheet(_)
498 | Self::CreateFilter(_)
499 | Self::GetFilter(_)
500 | Self::UpdateFilter(_)
501 | Self::DeleteFilter(_)
502 | Self::CreateFilterView(_, _)
503 | Self::CreateFilterCondition(_, _, _)
504 | Self::UpdateFilterCondition(_, _, _, _)
505 | Self::CreateFloatImage(_, _)
506 | Self::UpdateFloatImage(_, _, _)
507 | Self::GetFloatImage(_, _, _)
508 | Self::DeleteFloatImage(_, _, _)
509 | Self::DeleteRange(_)
510 | Self::InsertDimension(_)
511 | Self::MoveDimension(_)
512 | Self::ReplaceRange(_)
513 | Self::FindReplace(_) => HttpMethod::Post,
514 }
515 }
516}
517
518#[derive(Debug, Clone, PartialEq)]
521#[cfg_attr(test, derive(strum_macros::EnumIter))]
522pub enum SheetsApiV3 {
523 CreateSpreadsheet,
528 GetSpreadsheet(String), PatchSpreadsheet(String), QuerySheets(String), GetSheet(String, String), MoveDimension(String, String), FindCells(String, String), ReplaceCells(String, String), CreateFilter(String, String), UpdateFilter(String, String), GetFilter(String, String), DeleteFilter(String, String), CreateFilterView(String, String), QueryFilterViews(String, String), GetFilterView(String, String, String), PatchFilterView(String, String, String), DeleteFilterView(String, String, String), CreateFilterCondition(String, String, String), QueryFilterConditions(String, String, String), GetFilterCondition(String, String, String, String), UpdateFilterCondition(String, String, String, String), DeleteFilterCondition(String, String, String, String), CreateFloatImage(String, String), QueryFloatImages(String, String), GetFloatImage(String, String, String), PatchFloatImage(String, String, String), DeleteFloatImage(String, String, String), }
601
602impl SheetsApiV3 {
603 pub fn to_url(&self) -> String {
605 match self {
606 SheetsApiV3::CreateSpreadsheet => "/open-apis/sheets/v3/spreadsheets".to_string(),
607 SheetsApiV3::GetSpreadsheet(spreadsheet_token) => {
608 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}")
609 }
610 SheetsApiV3::PatchSpreadsheet(spreadsheet_token) => {
611 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}")
612 }
613
614 SheetsApiV3::QuerySheets(spreadsheet_token) => {
615 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/query")
616 }
617 SheetsApiV3::GetSheet(spreadsheet_token, sheet_id) => {
618 format!("/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}")
619 }
620 SheetsApiV3::MoveDimension(spreadsheet_token, sheet_id) => format!(
621 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/move_dimension"
622 ),
623 SheetsApiV3::FindCells(spreadsheet_token, sheet_id) => format!(
624 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/find"
625 ),
626 SheetsApiV3::ReplaceCells(spreadsheet_token, sheet_id) => format!(
627 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/replace"
628 ),
629
630 SheetsApiV3::CreateFilter(spreadsheet_token, sheet_id)
631 | SheetsApiV3::UpdateFilter(spreadsheet_token, sheet_id)
632 | SheetsApiV3::GetFilter(spreadsheet_token, sheet_id)
633 | SheetsApiV3::DeleteFilter(spreadsheet_token, sheet_id) => format!(
634 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter"
635 ),
636
637 SheetsApiV3::CreateFilterView(spreadsheet_token, sheet_id) => format!(
638 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views"
639 ),
640 SheetsApiV3::QueryFilterViews(spreadsheet_token, sheet_id) => format!(
641 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/query"
642 ),
643 SheetsApiV3::GetFilterView(spreadsheet_token, sheet_id, filter_view_id)
644 | SheetsApiV3::PatchFilterView(spreadsheet_token, sheet_id, filter_view_id)
645 | SheetsApiV3::DeleteFilterView(spreadsheet_token, sheet_id, filter_view_id) => {
646 format!(
647 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}"
648 )
649 }
650
651 SheetsApiV3::CreateFilterCondition(spreadsheet_token, sheet_id, filter_view_id) => {
652 format!(
653 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}/conditions"
654 )
655 }
656 SheetsApiV3::QueryFilterConditions(spreadsheet_token, sheet_id, filter_view_id) => {
657 format!(
658 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}/conditions/query"
659 )
660 }
661 SheetsApiV3::GetFilterCondition(
662 spreadsheet_token,
663 sheet_id,
664 filter_view_id,
665 condition_id,
666 )
667 | SheetsApiV3::UpdateFilterCondition(
668 spreadsheet_token,
669 sheet_id,
670 filter_view_id,
671 condition_id,
672 )
673 | SheetsApiV3::DeleteFilterCondition(
674 spreadsheet_token,
675 sheet_id,
676 filter_view_id,
677 condition_id,
678 ) => format!(
679 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/filter_views/{filter_view_id}/conditions/{condition_id}"
680 ),
681
682 SheetsApiV3::CreateFloatImage(spreadsheet_token, sheet_id) => format!(
683 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/float_images"
684 ),
685 SheetsApiV3::QueryFloatImages(spreadsheet_token, sheet_id) => format!(
686 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/float_images/query"
687 ),
688 SheetsApiV3::GetFloatImage(spreadsheet_token, sheet_id, float_image_id)
689 | SheetsApiV3::PatchFloatImage(spreadsheet_token, sheet_id, float_image_id)
690 | SheetsApiV3::DeleteFloatImage(spreadsheet_token, sheet_id, float_image_id) => {
691 format!(
692 "/open-apis/sheets/v3/spreadsheets/{spreadsheet_token}/sheets/{sheet_id}/float_images/{float_image_id}"
693 )
694 }
695 }
696 }
697
698 pub fn to_request<R>(&self) -> ApiRequest<R> {
700 <Self as CatalogEndpoint>::to_request(self)
701 }
702}
703
704impl CatalogEndpoint for SheetsApiV3 {
705 fn to_url(&self) -> String {
706 SheetsApiV3::to_url(self)
707 }
708
709 fn method(&self) -> HttpMethod {
710 match self {
711 Self::GetSpreadsheet(_)
712 | Self::QuerySheets(_)
713 | Self::GetSheet(_, _)
714 | Self::GetFilter(_, _)
715 | Self::QueryFilterViews(_, _)
716 | Self::GetFilterView(_, _, _)
717 | Self::QueryFilterConditions(_, _, _)
718 | Self::GetFilterCondition(_, _, _, _)
719 | Self::QueryFloatImages(_, _)
720 | Self::GetFloatImage(_, _, _) => HttpMethod::Get,
721 Self::CreateSpreadsheet
722 | Self::CreateFilter(_, _)
723 | Self::CreateFilterView(_, _)
724 | Self::CreateFilterCondition(_, _, _)
725 | Self::CreateFloatImage(_, _) => HttpMethod::Post,
726 Self::MoveDimension(_, _) | Self::FindCells(_, _) | Self::ReplaceCells(_, _) => {
727 HttpMethod::Post
728 }
729 Self::PatchSpreadsheet(_)
730 | Self::PatchFilterView(_, _, _)
731 | Self::PatchFloatImage(_, _, _) => HttpMethod::Patch,
732 Self::UpdateFilter(_, _) | Self::UpdateFilterCondition(_, _, _, _) => HttpMethod::Put,
733 Self::DeleteFilter(_, _)
734 | Self::DeleteFilterView(_, _, _)
735 | Self::DeleteFilterCondition(_, _, _, _)
736 | Self::DeleteFloatImage(_, _, _) => HttpMethod::Delete,
737 }
738 }
739
740 }
742
743#[cfg(test)]
744mod tests {
745 use super::*;
746 use crate::common::api_endpoints::test_support::catalog_semantics_snapshot;
747
748 #[test]
749 fn sheets_catalog_semantics_snapshots() {
750 insta::assert_snapshot!(
751 "ccm_sheet_old_catalog_semantics",
752 catalog_semantics_snapshot::<CcmSheetApiOld>()
753 );
754 insta::assert_snapshot!(
755 "sheets_v3_catalog_semantics",
756 catalog_semantics_snapshot::<SheetsApiV3>()
757 );
758 }
759}