1use chrono::offset::Utc;
2use chrono::DateTime;
3
4#[derive(Debug)]
6pub struct Page {
7 pub id: i64,
9 pub space: String,
11 pub parent_id: i64,
13 pub title: String,
15 pub url: String,
17 pub version: i32,
19 pub content: String,
21 pub created: DateTime<Utc>,
23 pub creator: String,
25 pub modified: DateTime<Utc>,
27 pub modifier: String,
29 pub home_page: bool,
31 pub content_status: String,
33 pub current: bool,
35}
36
37#[derive(Debug)]
39pub struct PageSummary {
40 pub id: i64,
42 pub space: String,
44 pub parent_id: i64,
46 pub title: String,
48 pub url: String,
50}
51
52#[derive(Debug)]
54pub struct UpdatePage {
55 pub id: Option<i64>,
57 pub space: String,
59 pub title: String,
61 pub content: String,
63 pub version: Option<i32>,
65 pub parent_id: Option<i64>,
67}
68
69#[derive(Debug)]
71pub struct PageUpdateOptions {
72 pub version_comment: Option<String>,
74 pub minor_edit: bool,
76}
77
78impl PageUpdateOptions {
79 pub fn new_minor() -> PageUpdateOptions {
80 PageUpdateOptions {
81 version_comment: None,
82 minor_edit: true,
83 }
84 }
85
86 pub fn new_minor_with_comment<S: Into<String>>(comment: S) -> PageUpdateOptions {
87 PageUpdateOptions {
88 version_comment: Some(comment.into()),
89 minor_edit: true,
90 }
91 }
92}
93
94impl UpdatePage {
95 pub fn with_create_fields<S: Into<String>>(
96 parent_id: Option<i64>,
97 space: &str,
98 title: &str,
99 content: S,
100 ) -> UpdatePage {
101 UpdatePage {
102 id: None,
103 space: space.into(),
104 title: title.into(),
105 content: content.into(),
106 version: None,
107 parent_id,
108 }
109 }
110}
111
112impl From<Page> for UpdatePage {
113 fn from(other: Page) -> UpdatePage {
114 UpdatePage {
115 id: Some(other.id),
116 space: other.space,
117 title: other.title,
118 content: other.content,
119 version: Some(other.version),
120 parent_id: if other.parent_id == 0 {
121 None
122 } else {
123 Some(other.parent_id)
124 },
125 }
126 }
127}