1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use chrono::{DateTime, Utc};
use monostate::MustBe;
use serde::{Deserialize, Serialize};

use crate::object::{Object, Parent};
use crate::rich_text::RichText;
use crate::user::User;

/// Refer to:
/// - [Comment](https://developers.notion.com/reference/comment-object)
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Comment {
    object: MustBe!("comment"),
    pub id: String,
    pub parent: Parent,

    pub created_time: DateTime<Utc>,
    pub created_by: User,
    pub last_edited_time: DateTime<Utc>,

    pub discussion_id: String,
    pub rich_text: Vec<RichText>,
    // pub rich_text: Vec<Value>,
}

impl Object for Comment {
    fn id(&self) -> &str {
        &self.id
    }

    fn object_type(&self) -> crate::object::ObjectType {
        crate::object::ObjectType::Comment
    }
}