feat: implemented missing data types

This commit is contained in:
Bram Dingelstad 2025-03-14 14:29:03 +01:00
parent 43a48f6655
commit 5df6d0f7d9

View file

@ -801,7 +801,7 @@ pub enum DatabaseProperty {
Relation { Relation {
id: String, id: String,
name: String, name: String,
// relation: Relation, relation: DatabaseRelation,
}, },
RichText { RichText {
id: String, id: String,
@ -810,7 +810,11 @@ pub enum DatabaseProperty {
Rollup { Rollup {
id: String, id: String,
name: 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 { Select {
id: String, id: String,
@ -820,7 +824,7 @@ pub enum DatabaseProperty {
Status { Status {
id: String, id: String,
name: String, name: String,
// TODO: Implement Status options: DatabaseSelectOptions,
}, },
Title { Title {
id: String, id: String,
@ -927,16 +931,101 @@ where
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct Number { 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)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct Relation { pub struct Relation {
// #[serde(alias = "database_id")] id: String,
// id: String, }
// synced_property_name: String,
// synced_property_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 // TODO: Paginate all possible responses
@ -1022,7 +1111,8 @@ pub enum Property {
}, },
LastEditedBy { LastEditedBy {
id: String, id: String,
}, // TODO: Implement LastEditedBy last_edited_by: User,
},
LastEditedTime { LastEditedTime {
id: String, id: String,
last_edited_time: DateValue, last_edited_time: DateValue,
@ -1047,18 +1137,23 @@ pub enum Property {
}, },
Relation { Relation {
id: String, id: String,
// relation: Vec<Relation>, has_more: bool,
relation: Vec<Relation>,
}, },
Rollup { Rollup {
id: String, id: String,
}, // TODO: Implement Rollup function: RollupFunction,
// TODO: This will not parse properly and needs custom deserializer code
value: RollupValue,
},
RichText { RichText {
id: String, id: String,
rich_text: Vec<RichText>, rich_text: Vec<RichText>,
}, },
Status { Status {
id: String, id: String,
}, // TODO: Implement Status status: SelectOption,
},
Title { Title {
id: String, id: String,
title: Vec<RichText>, title: Vec<RichText>,
@ -1068,7 +1163,10 @@ pub enum Property {
url: Option<String>, url: Option<String>,
}, },
Verification { Verification {
id: String, // TODO: Implement id: String,
state: VerificationState,
verified_by: Option<User>,
date: Option<Date>,
}, },
UniqueId { UniqueId {
id: String, id: String,
@ -1191,6 +1289,11 @@ where
}) })
.collect::<HashMap<String, Property>>()) .collect::<HashMap<String, Property>>())
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub enum VerificationState {
Verified,
Unverified,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(tag = "type")] #[serde(tag = "type")]
@ -1355,7 +1458,7 @@ pub struct PartialBlock {
pub struct Date { pub struct Date {
pub start: DateValue, pub start: DateValue,
pub end: Option<DateValue>, pub end: Option<DateValue>,
// TODO: Implement for setting // TODO: Implement for updating with timezone in the future?
pub time_zone: Option<String>, pub time_zone: Option<String>,
} }