diff options
author | 2021-05-16 22:23:37 -0700 | |
---|---|---|
committer | 2021-05-17 05:23:37 +0000 | |
commit | 19d87e6ee3ae44c5b1c853adf00329a894778b06 (patch) | |
tree | 35f2880295c3f2563f06cbbcb17dd774c3be08aa /src/models | |
parent | a2dc79a5079d6286ebd148cf25a00e5dd013efdc (diff) | |
download | notion-19d87e6ee3ae44c5b1c853adf00329a894778b06.tar.gz notion-19d87e6ee3ae44c5b1c853adf00329a894778b06.tar.zst notion-19d87e6ee3ae44c5b1c853adf00329a894778b06.zip |
feat: adding proper error type with snafu (#8)
Diffstat (limited to 'src/models')
-rw-r--r-- | src/models/properties.rs | 4 | ||||
-rw-r--r-- | src/models/search.rs | 26 |
2 files changed, 15 insertions, 15 deletions
diff --git a/src/models/properties.rs b/src/models/properties.rs index c55ce1a..22689e9 100644 --- a/src/models/properties.rs +++ b/src/models/properties.rs @@ -157,7 +157,7 @@ pub enum PropertyConfiguration { Checkbox { id: PropertyId }, /// Represents a URL Property /// See https://developers.notion.com/reference/database#url-configuration - URL { id: PropertyId }, + Url { id: PropertyId }, /// Represents a Email Property /// See https://developers.notion.com/reference/database#email-configuration Email { id: PropertyId }, @@ -292,7 +292,7 @@ pub enum PropertyValue { id: PropertyId, checkbox: bool, }, - URL { + Url { id: PropertyId, url: String, }, diff --git a/src/models/search.rs b/src/models/search.rs index 6acf847..6de3c8a 100644 --- a/src/models/search.rs +++ b/src/models/search.rs @@ -19,13 +19,6 @@ pub enum SortTimestamp { #[derive(Serialize, Debug, Eq, PartialEq, Hash, Copy, Clone)] #[serde(rename_all = "snake_case")] -pub enum DatabaseSortTimestamp { - CreatedTime, - LastEditedTime, -} - -#[derive(Serialize, Debug, Eq, PartialEq, Hash, Copy, Clone)] -#[serde(rename_all = "snake_case")] pub enum FilterValue { Page, Database, @@ -276,15 +269,22 @@ pub struct FilterCondition { pub condition: PropertyCondition, } +#[derive(Serialize, Debug, Eq, PartialEq, Hash, Copy, Clone)] +#[serde(rename_all = "snake_case")] +pub enum DatabaseSortTimestamp { + CreatedTime, + LastEditedTime, +} + #[derive(Serialize, Debug, Eq, PartialEq, Clone)] pub struct DatabaseSort { // Todo: Should property and timestamp be mutually exclusive? (i.e a flattened enum?) // the documentation is not clear: // https://developers.notion.com/reference/post-database-query#post-database-query-sort - property: Option<String>, + pub property: Option<String>, /// The name of the timestamp to sort against. - timestamp: Option<SortTimestamp>, - direction: SortDirection, + pub timestamp: Option<DatabaseSortTimestamp>, + pub direction: SortDirection, } #[derive(Serialize, Debug, Eq, PartialEq, Default)] @@ -322,13 +322,13 @@ impl From<NotionSearch> for SearchRequest { timestamp, } => SearchRequest { sort: Some(Sort { - direction, timestamp, + direction, }), ..Default::default() }, - NotionSearch::Filter { value, property } => SearchRequest { - filter: Some(Filter { value, property }), + NotionSearch::Filter { property, value } => SearchRequest { + filter: Some(Filter { property, value }), ..Default::default() }, } |