From 5df6d0f7d9a52c5414331dd61ce8e0fa67df2b49 Mon Sep 17 00:00:00 2001 From: Bram Dingelstad Date: Fri, 14 Mar 2025 14:29:03 +0100 Subject: [PATCH] feat: implemented missing data types --- src/lib.rs | 133 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 118 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bb0dc6b..0c2ed0a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -801,7 +801,7 @@ pub enum DatabaseProperty { Relation { id: String, name: String, - // relation: Relation, + relation: DatabaseRelation, }, RichText { id: String, @@ -810,7 +810,11 @@ pub enum DatabaseProperty { Rollup { id: String, name: String, - // TODO: Implement Rollup + function: RollupFunction, + relation_property_id: String, + relation_property_name: String, + rollup_property_id: String, + rollup_property_name: String, }, Select { id: String, @@ -820,7 +824,7 @@ pub enum DatabaseProperty { Status { id: String, name: String, - // TODO: Implement Status + options: DatabaseSelectOptions, }, Title { id: String, @@ -927,16 +931,101 @@ where #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct Number { - // TODO: Implement NumberFormat - // pub format: NumberFormat + pub format: NumberFormat, +} + +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +pub enum NumberFormat { + ArgentinePeso, + Baht, + AustralianDollar, + CanadianDollar, + ChileanPeso, + ColombianPeso, + DanishKrone, + Dirham, + Dollar, + Euro, + Forint, + Franc, + HongKongDollar, + Koruna, + Krona, + Leu, + Lira, + MexicanPeso, + NewTaiwanDollar, + NewZealandDollar, + NorwegianKrone, + Number, + NumberWithCommas, + Percent, + PhilippinePeso, + Pound, + PeruvianSol, + Rand, + Real, + Ringgit, + Riyal, + Ruble, + Rupee, + Rupiah, + Shekel, + SingaporeDollar, + UruguayanPeso, + Yen, + Yuan, + Won, + Zloty, +} + +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +pub struct DatabaseRelation { + database_id: String, + synced_property_name: String, + synced_property_id: String, } #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct Relation { - // #[serde(alias = "database_id")] - // id: String, - // synced_property_name: String, - // synced_property_id: String, + id: String, +} + +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +pub enum RollupFunction { + Average, + Checked, + CountPerGroup, + Count, + CountValues, + DateRange, + EarliestDate, + Empty, + LatestDate, + Max, + Median, + Min, + NotEmpty, + PercentChecked, + PercentEmpty, + PercentNotEmpty, + PercentPerGroup, + PercentUnchecked, + Range, + Unchecked, + Unique, + ShowOriginal, + ShowUnique, + Sum, +} + +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +pub enum RollupValue { + Array, + Date, + Incomplete, + Number, + Unsupported, } // TODO: Paginate all possible responses @@ -1022,7 +1111,8 @@ pub enum Property { }, LastEditedBy { id: String, - }, // TODO: Implement LastEditedBy + last_edited_by: User, + }, LastEditedTime { id: String, last_edited_time: DateValue, @@ -1047,18 +1137,23 @@ pub enum Property { }, Relation { id: String, - // relation: Vec, + has_more: bool, + relation: Vec, }, Rollup { id: String, - }, // TODO: Implement Rollup + function: RollupFunction, + // TODO: This will not parse properly and needs custom deserializer code + value: RollupValue, + }, RichText { id: String, rich_text: Vec, }, Status { id: String, - }, // TODO: Implement Status + status: SelectOption, + }, Title { id: String, title: Vec, @@ -1068,7 +1163,10 @@ pub enum Property { url: Option, }, Verification { - id: String, // TODO: Implement + id: String, + state: VerificationState, + verified_by: Option, + date: Option, }, UniqueId { id: String, @@ -1191,6 +1289,11 @@ where }) .collect::>()) } +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +pub enum VerificationState { + Verified, + Unverified, +} #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[serde(tag = "type")] @@ -1355,7 +1458,7 @@ pub struct PartialBlock { pub struct Date { pub start: DateValue, pub end: Option, - // TODO: Implement for setting + // TODO: Implement for updating with timezone in the future? pub time_zone: Option, }