1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Deserialize)]
5#[serde(rename_all = "camelCase")]
6pub struct Board {
7 pub id: String,
8 pub name: String,
9 pub desc: String,
10 pub closed: bool,
11 pub url: String,
12 pub short_url: String,
13}
14
15#[derive(Debug, Clone, Deserialize)]
17#[serde(rename_all = "camelCase")]
18pub struct List {
19 pub id: String,
20 pub name: String,
21 pub closed: bool,
22 pub id_board: String,
23 pub pos: f64,
24}
25
26#[derive(Debug, Clone, Deserialize)]
28#[serde(rename_all = "camelCase")]
29pub struct Card {
30 pub id: String,
31 pub name: String,
32 pub desc: String,
33 pub closed: bool,
34 pub id_board: String,
35 pub id_list: String,
36 pub pos: f64,
37 pub url: String,
38 pub short_url: String,
39 pub due: Option<String>,
40 pub due_complete: bool,
41 pub labels: Vec<Label>,
42 pub id_members: Vec<String>,
43}
44
45#[derive(Debug, Clone, Deserialize)]
47#[serde(rename_all = "camelCase")]
48pub struct Label {
49 pub id: String,
50 pub name: String,
51 pub color: Option<String>,
52}
53
54#[derive(Debug, Clone, Deserialize)]
56#[serde(rename_all = "camelCase")]
57pub struct Member {
58 pub id: String,
59 pub username: String,
60 pub full_name: String,
61 pub avatar_url: Option<String>,
62}
63
64#[derive(Debug, Clone, Deserialize)]
66#[serde(rename_all = "camelCase")]
67pub struct Checklist {
68 pub id: String,
69 pub name: String,
70 pub id_card: String,
71 pub check_items: Vec<CheckItem>,
72}
73
74#[derive(Debug, Clone, Deserialize)]
76#[serde(rename_all = "camelCase")]
77pub struct CheckItem {
78 pub id: String,
79 pub name: String,
80 pub state: String,
81 pub pos: f64,
82}
83
84#[derive(Debug, Clone, Default, Serialize)]
86#[serde(rename_all = "camelCase")]
87pub struct CreateCardInput {
88 pub name: String,
89 pub id_list: String,
90 #[serde(skip_serializing_if = "Option::is_none")]
91 pub desc: Option<String>,
92 #[serde(skip_serializing_if = "Option::is_none")]
93 pub pos: Option<String>,
94 #[serde(skip_serializing_if = "Option::is_none")]
95 pub due: Option<String>,
96 #[serde(skip_serializing_if = "Option::is_none")]
97 pub id_labels: Option<String>,
98 #[serde(skip_serializing_if = "Option::is_none")]
99 pub id_members: Option<String>,
100}
101
102impl CreateCardInput {
103 pub fn new(list_id: impl Into<String>, name: impl Into<String>) -> Self {
104 Self {
105 id_list: list_id.into(),
106 name: name.into(),
107 ..Default::default()
108 }
109 }
110
111 pub fn desc(mut self, desc: impl Into<String>) -> Self {
112 self.desc = Some(desc.into());
113 self
114 }
115
116 pub fn due(mut self, due: impl Into<String>) -> Self {
117 self.due = Some(due.into());
118 self
119 }
120
121 pub fn pos(mut self, pos: impl Into<String>) -> Self {
122 self.pos = Some(pos.into());
123 self
124 }
125}
126
127#[derive(Debug, Clone, Default, Serialize)]
129#[serde(rename_all = "camelCase")]
130pub struct UpdateCardInput {
131 #[serde(skip_serializing_if = "Option::is_none")]
132 pub name: Option<String>,
133 #[serde(skip_serializing_if = "Option::is_none")]
134 pub desc: Option<String>,
135 #[serde(skip_serializing_if = "Option::is_none")]
136 pub closed: Option<bool>,
137 #[serde(skip_serializing_if = "Option::is_none")]
138 pub id_list: Option<String>,
139 #[serde(skip_serializing_if = "Option::is_none")]
140 pub pos: Option<String>,
141 #[serde(skip_serializing_if = "Option::is_none")]
142 pub due: Option<String>,
143 #[serde(skip_serializing_if = "Option::is_none")]
144 pub due_complete: Option<bool>,
145}
146
147impl UpdateCardInput {
148 pub fn new() -> Self {
149 Self::default()
150 }
151
152 pub fn name(mut self, name: impl Into<String>) -> Self {
153 self.name = Some(name.into());
154 self
155 }
156
157 pub fn desc(mut self, desc: impl Into<String>) -> Self {
158 self.desc = Some(desc.into());
159 self
160 }
161
162 pub fn closed(mut self, closed: bool) -> Self {
163 self.closed = Some(closed);
164 self
165 }
166
167 pub fn id_list(mut self, list_id: impl Into<String>) -> Self {
168 self.id_list = Some(list_id.into());
169 self
170 }
171
172 pub fn due(mut self, due: impl Into<String>) -> Self {
173 self.due = Some(due.into());
174 self
175 }
176
177 pub fn due_complete(mut self, complete: bool) -> Self {
178 self.due_complete = Some(complete);
179 self
180 }
181}
182
183#[derive(Debug, Clone, Serialize)]
185#[serde(rename_all = "camelCase")]
186pub struct CreateListInput {
187 pub name: String,
188 pub id_board: String,
189 #[serde(skip_serializing_if = "Option::is_none")]
190 pub pos: Option<String>,
191}
192
193impl CreateListInput {
194 pub fn new(board_id: impl Into<String>, name: impl Into<String>) -> Self {
195 Self {
196 id_board: board_id.into(),
197 name: name.into(),
198 pos: None,
199 }
200 }
201}
202
203#[derive(Debug, Clone, Serialize)]
205#[serde(rename_all = "camelCase")]
206pub struct CreateBoardInput {
207 pub name: String,
208 #[serde(skip_serializing_if = "Option::is_none")]
209 pub desc: Option<String>,
210 #[serde(skip_serializing_if = "Option::is_none")]
211 pub default_lists: Option<bool>,
212}
213
214impl CreateBoardInput {
215 pub fn new(name: impl Into<String>) -> Self {
216 Self {
217 name: name.into(),
218 desc: None,
219 default_lists: Some(false),
220 }
221 }
222
223 pub fn desc(mut self, desc: impl Into<String>) -> Self {
224 self.desc = Some(desc.into());
225 self
226 }
227
228 pub fn with_default_lists(mut self) -> Self {
229 self.default_lists = Some(true);
230 self
231 }
232}