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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
use derive_builder::Builder;
use http::Method;
use std::borrow::Cow;
use crate::api::{Endpoint, ReturnsJsonResponse};
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct IssuePriorityEssentials {
pub id: u64,
pub name: String,
}
impl From<IssuePriority> for IssuePriorityEssentials {
fn from(v: IssuePriority) -> Self {
IssuePriorityEssentials {
id: v.id,
name: v.name,
}
}
}
impl From<&IssuePriority> for IssuePriorityEssentials {
fn from(v: &IssuePriority) -> Self {
IssuePriorityEssentials {
id: v.id,
name: v.name.to_owned(),
}
}
}
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct IssuePriority {
pub id: u64,
pub name: String,
pub is_default: bool,
}
#[derive(Debug, Builder)]
#[builder(setter(strip_option))]
pub struct ListIssuePriorities {}
impl ReturnsJsonResponse for ListIssuePriorities {}
impl ListIssuePriorities {
#[must_use]
pub fn builder() -> ListIssuePrioritiesBuilder {
ListIssuePrioritiesBuilder::default()
}
}
impl<'a> Endpoint for ListIssuePriorities {
fn method(&self) -> Method {
Method::GET
}
fn endpoint(&self) -> Cow<'static, str> {
"enumerations/issue_priorities.json".into()
}
}
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct IssuePrioritiesWrapper<T> {
pub issue_priorities: Vec<T>,
}
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct TimeEntryActivityEssentials {
pub id: u64,
pub name: String,
}
impl From<TimeEntryActivity> for TimeEntryActivityEssentials {
fn from(v: TimeEntryActivity) -> Self {
TimeEntryActivityEssentials {
id: v.id,
name: v.name,
}
}
}
impl From<&TimeEntryActivity> for TimeEntryActivityEssentials {
fn from(v: &TimeEntryActivity) -> Self {
TimeEntryActivityEssentials {
id: v.id,
name: v.name.to_owned(),
}
}
}
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct TimeEntryActivity {
pub id: u64,
pub name: String,
pub is_default: bool,
}
#[derive(Debug, Builder)]
#[builder(setter(strip_option))]
pub struct ListTimeEntryActivities {}
impl ReturnsJsonResponse for ListTimeEntryActivities {}
impl ListTimeEntryActivities {
#[must_use]
pub fn builder() -> ListTimeEntryActivitiesBuilder {
ListTimeEntryActivitiesBuilder::default()
}
}
impl<'a> Endpoint for ListTimeEntryActivities {
fn method(&self) -> Method {
Method::GET
}
fn endpoint(&self) -> Cow<'static, str> {
"enumerations/time_entry_activities.json".into()
}
}
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct TimeEntryActivitiesWrapper<T> {
pub time_entry_activities: Vec<T>,
}
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct DocumentCategoryEssentials {
pub id: u64,
pub name: String,
}
impl From<DocumentCategory> for DocumentCategoryEssentials {
fn from(v: DocumentCategory) -> Self {
DocumentCategoryEssentials {
id: v.id,
name: v.name,
}
}
}
impl From<&DocumentCategory> for DocumentCategoryEssentials {
fn from(v: &DocumentCategory) -> Self {
DocumentCategoryEssentials {
id: v.id,
name: v.name.to_owned(),
}
}
}
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct DocumentCategory {
pub id: u64,
pub name: String,
pub is_default: bool,
}
#[derive(Debug, Builder)]
#[builder(setter(strip_option))]
pub struct ListDocumentCategories {}
impl ReturnsJsonResponse for ListDocumentCategories {}
impl ListDocumentCategories {
#[must_use]
pub fn builder() -> ListDocumentCategoriesBuilder {
ListDocumentCategoriesBuilder::default()
}
}
impl<'a> Endpoint for ListDocumentCategories {
fn method(&self) -> Method {
Method::GET
}
fn endpoint(&self) -> Cow<'static, str> {
"enumerations/document_categories.json".into()
}
}
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct DocumentCategoriesWrapper<T> {
pub document_categories: Vec<T>,
}
#[cfg(test)]
mod test {
use super::*;
use std::error::Error;
use tracing_test::traced_test;
#[traced_test]
#[test]
fn test_list_issue_priorities_no_pagination() -> Result<(), Box<dyn Error>> {
dotenv::dotenv()?;
let redmine = crate::api::Redmine::from_env()?;
let endpoint = ListIssuePriorities::builder().build()?;
redmine.json_response_body::<_, IssuePrioritiesWrapper<IssuePriority>>(&endpoint)?;
Ok(())
}
#[traced_test]
#[test]
fn test_list_time_entry_activities_no_pagination() -> Result<(), Box<dyn Error>> {
dotenv::dotenv()?;
let redmine = crate::api::Redmine::from_env()?;
let endpoint = ListTimeEntryActivities::builder().build()?;
redmine
.json_response_body::<_, TimeEntryActivitiesWrapper<TimeEntryActivity>>(&endpoint)?;
Ok(())
}
#[traced_test]
#[test]
fn test_list_document_categories_no_pagination() -> Result<(), Box<dyn Error>> {
dotenv::dotenv()?;
let redmine = crate::api::Redmine::from_env()?;
let endpoint = ListDocumentCategories::builder().build()?;
redmine.json_response_body::<_, DocumentCategoriesWrapper<DocumentCategory>>(&endpoint)?;
Ok(())
}
}