use std::sync::Arc;
use crate::auth::models::Secret;
use crate::bigquery_api::models::ServiceAccountKey;
use crate::column_types::models::ColumnType;
#[derive(Debug, Clone)]
pub struct SheetsClient {
pub(crate) http: reqwest::Client,
pub(crate) base_url: String,
pub(crate) key: ServiceAccountKey,
pub(crate) token: Arc<tokio::sync::Mutex<Option<(Secret, i64)>>>,
}
impl SheetsClient {
pub fn account(&self) -> &str {
&self.key.client_email
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum KeySource {
Json(Secret),
Base64(Secret),
File(std::path::PathBuf),
Environment,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NumberKind {
Plain,
Fractional,
Date,
DateTime,
Time,
}
#[derive(Debug, Clone, PartialEq)]
pub enum Cell {
Empty,
Bool(bool),
Number {
value: f64,
kind: NumberKind,
shown: String,
},
Text(String),
Error(String),
}
#[derive(Debug, Clone, PartialEq)]
pub struct Grid {
pub title: String,
pub start_row: u32,
pub start_column: u32,
pub rows: Vec<Vec<Cell>>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct HeaderRule {
pub header: bool,
pub header_row: u32,
}
impl Default for HeaderRule {
fn default() -> Self {
Self {
header: true,
header_row: 1,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SheetRead {
pub range: Option<String>,
pub rule: HeaderRule,
}
#[derive(Debug, Clone, PartialEq)]
pub struct SheetColumn {
pub name: String,
pub position: usize,
pub column_type: Result<ColumnType, String>,
pub has_values: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub struct SheetTable {
pub columns: Vec<SheetColumn>,
pub rows: usize,
pub warnings: Vec<String>,
}