diff options
author | 2022-05-18 01:02:56 -0400 | |
---|---|---|
committer | 2022-05-17 22:02:56 -0700 | |
commit | 8160fea0ffa1f074538ec5fd73b317bc9d023d6e (patch) | |
tree | ecd9288aa409051e57695b638f416540eb77cbe5 /src/models/text.rs | |
parent | a0106b557ee1af347b7c422be3364dd6d0fac945 (diff) | |
download | notion-8160fea0ffa1f074538ec5fd73b317bc9d023d6e.tar.gz notion-8160fea0ffa1f074538ec5fd73b317bc9d023d6e.tar.zst notion-8160fea0ffa1f074538ec5fd73b317bc9d023d6e.zip |
Upgrade notion version (#39)
* Upgrade constant
* Fix lint
* Change module file tree
Changed around module file tree, but module structure hasn't changed. Converted models.rs to mod.rs under models folder
* Minor refactoring
* Add MentionObject for rich text mention types
* Add new fields to BlockCommon. Modify existing field model Text. Add heading 1 test
Add created_by and last_edited_by fields to BlockCommon. Change field text to rich_text for model Text to handle breaking change in API version 2022-02-22
* Differentiate between unsupported and unknown block types
* Change text field to rich_text in paragraph block
* Add callout block. Add file and emoji object
* Fix as_id for unsupported block
* Fix lint issues
* Move quote block to follow documentation order. Add color field to TextAndChildren struct
* Add color field to ToDoFields struct
* Formatting
* Add caption field to code block
Add caption field to code block. Create enum CodeLanguage for code block. Reorder code block to reflect documentation
* Add child database block
* Create embed block
* Refactor notion file object struct name
* Create image block
* Create video block
* Create file block
* Fix video block field
* Create pdf block
* Change text field to rich_text in TodoFields for Notion API version 2022-02-22
* Create bookmark block
* Create divider block
* Create table of contents block
* Create breadcrumb block
* Create column list and column block
* Create link preview block
* Create template block
* Formatting
* Create link to page block
* Fix ColumnListFields struct
* Create table and table row block
* Fix AsIdentifier trait impl for Block
* Create synced block
Diffstat (limited to '')
-rw-r--r-- | src/models/text.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/models/text.rs b/src/models/text.rs index 16274ab..4169374 100644 --- a/src/models/text.rs +++ b/src/models/text.rs @@ -1,4 +1,7 @@ use serde::{Deserialize, Serialize}; +use crate::models::users::User; +use crate::{Database, Page}; +use crate::models::properties::DateValue; #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Copy, Clone)] #[serde(rename_all = "snake_case")] @@ -56,6 +59,33 @@ pub struct Text { pub link: Option<Link>, } +/// See https://developers.notion.com/reference/rich-text#mention-objects +#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] +#[serde(tag = "type")] +#[serde(rename_all = "snake_case")] +pub enum MentionObject { + User { + user: User + }, + // TODO: need to add tests + Page { + page: Page + }, + // TODO: need to add tests + Database { + database: Database + }, + Date { + date: DateValue + }, + // TODO: need to add LinkPreview + // LinkPreview { + // + // }, + #[serde(other)] + Unknown +} + /// Rich text objects contain data for displaying formatted text, mentions, and equations. /// A rich text object also contains annotations for style information. /// Arrays of rich text objects are used within property objects and property @@ -74,6 +104,7 @@ pub enum RichText { Mention { #[serde(flatten)] rich_text: RichTextCommon, + mention: MentionObject }, /// See <https://developers.notion.com/reference/rich-text#equation-objects> Equation { |