Skip to main content

redmine_api/api/
issues.rs

1//! Issues Rest API Endpoint definitions
2//! [Redmine Documentation](https://www.redmine.org/projects/redmine/wiki/Rest_Issues)
3//!
4//! [Redmine Documentation Journals](https://www.redmine.org/projects/redmine/wiki/Rest_IssueJournals)
5//! (Journals in Redmine terminology are notes/comments and change histories for an issue)
6//!
7//! - [ ] all issues endpoint
8//!   - [x] sort
9//!     - [ ] limit sort to the existing columns only instead of a string value
10//!   - [x] query_id parameter
11//!   - [x] pagination
12//!   - [x] issue_id filter
13//!     - [x] issue id (multiple are possible, comma separated)
14//!   - [x] project_id filter
15//!     - [x] project id (multiple are possible, comma separated)
16//!   - [x] subproject_id filter
17//!     - [x] !* filter to only get parent project issues
18//!   - [x] tracker_id filter
19//!     - [x] tracker id (multiple are possible, comma separated)
20//!   - [x] status_id filter
21//!     - [x] open (default)
22//!     - [x] closed
23//!     - [x] for both
24//!     - [x] status id (multiple are possible, comma separated)
25//!   - [x] category_id filter
26//!     - [x] category id (multiple are possible, comma separated)
27//!   - [x] priority_id filter
28//!     - [x] priority id (multiple are possible, comma separated)
29//!   - [x] author_id filter
30//!     - [x] any
31//!     - [x] me
32//!     - [x] !me
33//!     - [x] user/group id (multiple are possible, comma separated)
34//!     - [x] negation of list
35//!   - [x] assigned_to_id filter
36//!     - [x] any
37//!     - [x] me
38//!     - [x] !me
39//!     - [x] user/group id (multiple are possible, comma separated)
40//!     - [x] negation of list
41//!     - [x] none (!*)
42//!   - [x] fixed_version_id filter (Target version, API uses old name)
43//!     - [x] version id (multiple are possible, comma separated)
44//!   - [x] is_private filter
45//!   - [x] parent_id filter
46//!     - [x] issue id (multiple are possible, comma separated)
47//!   - [x] custom field filter
48//!     - [x] exact match
49//!     - [ ] substring match
50//!     - [ ] what about multiple value custom fields?
51//!   - [x] subject filter
52//!     - [x] exact match
53//!     - [x] substring match
54//!   - [x] description filter
55//!     - [x] exact match
56//!     - [x] substring match
57//!   - [x] done_ratio filter
58//!     - [x] exact match
59//!     - [x] less than, greater than ?
60//!     - [x] range?
61//!   - [x] estimated_hours filter
62//!     - [x] exact match
63//!     - [x] less than, greater than ?
64//!     - [x] range?
65//!   - [x] created_on filter
66//!     - [x] exact match
67//!     - [x] less than, greater than
68//!     - [x] date range
69//!   - [x] updated_on filter
70//!     - [x] exact match
71//!     - [x] less than, greater than
72//!     - [x] date range
73//!   - [x] start_date filter
74//!     - [x] exact match
75//!     - [x] less than, greater than
76//!     - [x] date range
77//!   - [x] due_date filter
78//!     - [x] exact match
79//!     - [x] less than, greater than
80//!     - [x] date range
81//! - [x] specific issue endpoint
82//! - [x] create issue endpoint
83//!   - [ ] attachments
84//! - [x] update issue endpoint
85//!   - [ ] attachments
86//! - [x] delete issue endpoint
87//! - [x] add watcher endpoint
88//! - [x] remove watcher endpoint
89//! - [ ] fields for issue changesets
90//!
91use derive_builder::Builder;
92use reqwest::Method;
93use std::borrow::Cow;
94
95use crate::api::attachments::Attachment;
96use crate::api::custom_fields::{CustomField, CustomFieldEssentialsWithValue};
97use crate::api::enumerations::IssuePriorityEssentials;
98use crate::api::groups::{Group, GroupEssentials};
99use crate::api::issue_categories::IssueCategoryEssentials;
100use crate::api::issue_relations::IssueRelation;
101use crate::api::issue_statuses::IssueStatusEssentials;
102use crate::api::projects::ProjectEssentials;
103use crate::api::projects::ProjectStatusFilter;
104use crate::api::trackers::TrackerEssentials;
105use crate::api::users::UserEssentials;
106use crate::api::versions::VersionEssentials;
107use crate::api::{
108    CustomFieldFilter, DateFilter, DateTimeFilterPast, Endpoint, FloatFilter, IntegerFilter,
109    NoPagination, Pageable, QueryParams, ReturnsJsonResponse, StringFieldFilter,
110};
111use serde::Serialize;
112
113/// a minimal type for Redmine users or groups used in lists of assignees included in
114/// other Redmine objects
115#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
116pub struct AssigneeEssentials {
117    /// numeric id
118    pub id: u64,
119    /// display name
120    pub name: String,
121}
122
123impl From<UserEssentials> for AssigneeEssentials {
124    fn from(v: UserEssentials) -> Self {
125        Self {
126            id: v.id,
127            name: v.name,
128        }
129    }
130}
131
132impl From<&UserEssentials> for AssigneeEssentials {
133    fn from(v: &UserEssentials) -> Self {
134        Self {
135            id: v.id,
136            name: v.name.to_owned(),
137        }
138    }
139}
140
141impl From<GroupEssentials> for AssigneeEssentials {
142    fn from(v: GroupEssentials) -> Self {
143        Self {
144            id: v.id,
145            name: v.name,
146        }
147    }
148}
149
150impl From<&GroupEssentials> for AssigneeEssentials {
151    fn from(v: &GroupEssentials) -> Self {
152        Self {
153            id: v.id,
154            name: v.name.to_owned(),
155        }
156    }
157}
158
159impl From<Group> for AssigneeEssentials {
160    fn from(v: Group) -> Self {
161        Self {
162            id: v.id,
163            name: v.name,
164        }
165    }
166}
167
168impl From<&Group> for AssigneeEssentials {
169    fn from(v: &Group) -> Self {
170        Self {
171            id: v.id,
172            name: v.name.to_owned(),
173        }
174    }
175}
176
177/// a minimal type for Redmine issues included in
178/// other Redmine objects
179#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
180pub struct IssueEssentials {
181    /// numeric id
182    pub id: u64,
183}
184
185impl From<Issue> for IssueEssentials {
186    fn from(v: Issue) -> Self {
187        Self { id: v.id }
188    }
189}
190
191impl From<&Issue> for IssueEssentials {
192    fn from(v: &Issue) -> Self {
193        Self { id: v.id }
194    }
195}
196
197/// the minimal data about a code repository included in other
198/// redmine objects
199#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
200pub struct RepositoryEssentials {
201    /// numeric id
202    pub id: u64,
203    /// the textual identifier
204    pub identifier: String,
205}
206
207/// the type of issue changesets
208#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
209pub struct IssueChangeset {
210    /// the revision of the changeset (e.g. commit id or number depending on VCS)
211    revision: String,
212    /// the committer
213    user: UserEssentials,
214    /// the commit message
215    comments: String,
216    /// the timestamp when this was committed
217    #[serde(
218        serialize_with = "crate::api::serialize_rfc3339",
219        deserialize_with = "crate::api::deserialize_rfc3339"
220    )]
221    committed_on: time::OffsetDateTime,
222}
223
224/// the type of journal change
225#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
226pub enum ChangePropertyType {
227    /// issue attribute change
228    #[serde(rename = "attr")]
229    Attr,
230    /// Custom field change
231    #[serde(rename = "cf")]
232    Cf,
233    /// change in issue relations
234    #[serde(rename = "relation")]
235    Relation,
236    /// change in attachments
237    #[serde(rename = "attachment")]
238    Attachment,
239}
240
241/// a changed attribute entry in a journal entry
242#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
243pub struct JournalChange {
244    /// name of the attribute
245    pub name: String,
246    /// old value
247    pub old_value: Option<String>,
248    /// new value
249    pub new_value: Option<String>,
250    /// what kind of property we are dealing with
251    pub property: ChangePropertyType,
252}
253
254/// journals (issue comments and changes)
255#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
256pub struct Journal {
257    /// numeric id
258    pub id: u64,
259    /// the author of the journal entry
260    pub user: UserEssentials,
261    /// the comment content
262    pub notes: Option<String>,
263    /// is this a private comment
264    pub private_notes: bool,
265    /// The time when this comment/change was created
266    #[serde(
267        serialize_with = "crate::api::serialize_rfc3339",
268        deserialize_with = "crate::api::deserialize_rfc3339"
269    )]
270    pub created_on: time::OffsetDateTime,
271    /// The time when this comment/change was last updated
272    #[serde(
273        serialize_with = "crate::api::serialize_rfc3339",
274        deserialize_with = "crate::api::deserialize_rfc3339"
275    )]
276    pub updated_on: time::OffsetDateTime,
277    /// The user who updated the comment/change if it differs from the author
278    #[serde(default, skip_serializing_if = "Option::is_none")]
279    pub updated_by: Option<UserEssentials>,
280    /// changed issue attributes
281    pub details: Vec<JournalChange>,
282}
283
284/// minimal issue used e.g. in child issues
285#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
286pub struct ChildIssue {
287    /// numeric id
288    pub id: u64,
289    /// subject
290    pub subject: String,
291    /// tracker
292    pub tracker: TrackerEssentials,
293    /// children
294    #[serde(default, skip_serializing_if = "Option::is_none")]
295    pub children: Option<Vec<Self>>,
296}
297
298/// a type for issue to use as an API return type
299///
300/// alternatively you can use your own type limited to the fields you need
301#[derive(Debug, Clone, Serialize, serde::Deserialize)]
302pub struct Issue {
303    /// numeric id
304    pub id: u64,
305    /// parent issue
306    #[serde(skip_serializing_if = "Option::is_none")]
307    pub parent: Option<IssueEssentials>,
308    /// the project of the issue
309    pub project: ProjectEssentials,
310    /// the tracker of the issue
311    pub tracker: TrackerEssentials,
312    /// the issue status
313    pub status: IssueStatusEssentials,
314    /// the issue priority
315    pub priority: IssuePriorityEssentials,
316    /// the issue author
317    pub author: UserEssentials,
318    /// the user or group the issue is assigned to
319    #[serde(skip_serializing_if = "Option::is_none")]
320    pub assigned_to: Option<AssigneeEssentials>,
321    /// the issue category
322    #[serde(skip_serializing_if = "Option::is_none")]
323    pub category: Option<IssueCategoryEssentials>,
324    /// the version the issue is assigned to
325    #[serde(rename = "fixed_version", skip_serializing_if = "Option::is_none")]
326    pub version: Option<VersionEssentials>,
327    /// the issue subject
328    #[serde(skip_serializing_if = "Option::is_none")]
329    pub subject: Option<String>,
330    /// the issue description
331    pub description: Option<String>,
332    /// is the issue private (only visible to roles that have the relevant permission enabled)
333    is_private: Option<bool>,
334    /// the start date for the issue
335    pub start_date: Option<time::Date>,
336    /// the due date for the issue
337    pub due_date: Option<time::Date>,
338    /// the time when the issue was closed
339    #[serde(
340        serialize_with = "crate::api::serialize_optional_rfc3339",
341        deserialize_with = "crate::api::deserialize_optional_rfc3339"
342    )]
343    pub closed_on: Option<time::OffsetDateTime>,
344    /// the percentage done
345    pub done_ratio: u64,
346    /// custom fields with values
347    #[serde(default, skip_serializing_if = "Option::is_none")]
348    pub custom_fields: Option<Vec<CustomFieldEssentialsWithValue>>,
349    /// estimated hours it will take to implement this issue
350    pub estimated_hours: Option<f64>,
351    /// The time when this issue was created
352    #[serde(
353        serialize_with = "crate::api::serialize_rfc3339",
354        deserialize_with = "crate::api::deserialize_rfc3339"
355    )]
356    pub created_on: time::OffsetDateTime,
357    /// The time when this issue was last updated
358    #[serde(
359        serialize_with = "crate::api::serialize_rfc3339",
360        deserialize_with = "crate::api::deserialize_rfc3339"
361    )]
362    pub updated_on: time::OffsetDateTime,
363    /// issue attachments (only when include parameter is used)
364    #[serde(default, skip_serializing_if = "Option::is_none")]
365    pub attachments: Option<Vec<Attachment>>,
366    /// issue relations (only when include parameter is used)
367    #[serde(default, skip_serializing_if = "Option::is_none")]
368    pub relations: Option<Vec<IssueRelation>>,
369    /// issue changesets (only when include parameter is used)
370    #[serde(default, skip_serializing_if = "Option::is_none")]
371    pub changesets: Option<Vec<IssueChangeset>>,
372    /// journal entries (comments and changes), only when include parameter is used
373    #[serde(default, skip_serializing_if = "Option::is_none")]
374    pub journals: Option<Vec<Journal>>,
375    /// child issues (only when include parameter is used)
376    #[serde(default, skip_serializing_if = "Option::is_none")]
377    pub children: Option<Vec<ChildIssue>>,
378    /// watchers
379    #[serde(default, skip_serializing_if = "Option::is_none")]
380    pub watchers: Option<Vec<UserEssentials>>,
381    /// the hours spent
382    #[serde(default, skip_serializing_if = "Option::is_none")]
383    pub spent_hours: Option<f64>,
384    /// the total hours spent on this and sub-tasks
385    #[serde(default, skip_serializing_if = "Option::is_none")]
386    pub total_spent_hours: Option<f64>,
387    /// the total hours estimated on this and sub-tasks
388    #[serde(default, skip_serializing_if = "Option::is_none")]
389    pub total_estimated_hours: Option<f64>,
390}
391
392/// ways to filter for subproject
393#[derive(Debug, Clone)]
394pub enum SubProjectFilter {
395    /// return no issues from subjects
396    OnlyParentProject,
397    /// return issues from a specific list of sub project ids
398    TheseSubProjects(Vec<u64>),
399    /// return issues from any but a specific list of sub project ids
400    NotTheseSubProjects(Vec<u64>),
401}
402
403impl std::fmt::Display for SubProjectFilter {
404    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
405        match self {
406            Self::OnlyParentProject => {
407                write!(f, "!*")
408            }
409            Self::TheseSubProjects(ids) => {
410                let s: String = ids
411                    .iter()
412                    .map(|e| e.to_string())
413                    .collect::<Vec<_>>()
414                    .join(",");
415                write!(f, "{s}")
416            }
417            Self::NotTheseSubProjects(ids) => {
418                let s: String = ids
419                    .iter()
420                    .map(|e| format!("!{e}"))
421                    .collect::<Vec<_>>()
422                    .join(",");
423                write!(f, "{s}")
424            }
425        }
426    }
427}
428
429/// ways to filter for issue status
430#[derive(Debug, Clone)]
431pub enum IssueStatusFilter {
432    /// match all open statuses (default if no status filter is specified
433    Open,
434    /// match all closed statuses
435    Closed,
436    /// match both open and closed statuses
437    All,
438    /// match a specific list of statuses
439    TheseStatuses(Vec<u64>),
440    /// match any status but a specific list of statuses
441    NotTheseStatuses(Vec<u64>),
442}
443
444impl std::fmt::Display for IssueStatusFilter {
445    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
446        match self {
447            Self::Open => {
448                write!(f, "open")
449            }
450            Self::Closed => {
451                write!(f, "closed")
452            }
453            Self::All => {
454                write!(f, "*")
455            }
456            Self::TheseStatuses(ids) => {
457                let s: String = ids
458                    .iter()
459                    .map(|e| e.to_string())
460                    .collect::<Vec<_>>()
461                    .join(",");
462                write!(f, "{s}")
463            }
464            Self::NotTheseStatuses(ids) => {
465                let s: String = ids
466                    .iter()
467                    .map(|e| format!("!{e}"))
468                    .collect::<Vec<_>>()
469                    .join(",");
470                write!(f, "{s}")
471            }
472        }
473    }
474}
475
476/// ways to filter for users in author (always a user (not group), never !*)
477#[derive(Debug, Clone)]
478pub enum UserFilter {
479    /// match any user
480    AnyUser,
481    /// match the current API user
482    Me,
483    /// match any user but the current API user
484    NotMe,
485    /// match a specific list of users
486    TheseUsers(Vec<u64>),
487    /// match a negated specific list of users
488    NotTheseUsers(Vec<u64>),
489}
490
491impl std::fmt::Display for UserFilter {
492    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
493        match self {
494            Self::AnyUser => {
495                write!(f, "*")
496            }
497            Self::Me => {
498                write!(f, "me")
499            }
500            Self::NotMe => {
501                write!(f, "!me")
502            }
503            Self::TheseUsers(ids) => {
504                let s: String = ids
505                    .iter()
506                    .map(|e| e.to_string())
507                    .collect::<Vec<_>>()
508                    .join(",");
509                write!(f, "{s}")
510            }
511            Self::NotTheseUsers(ids) => {
512                let s: String = ids
513                    .iter()
514                    .map(|e| format!("!{e}"))
515                    .collect::<Vec<_>>()
516                    .join(",");
517                write!(f, "{s}")
518            }
519        }
520    }
521}
522
523/// ways to filter for roles
524#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
525pub enum RoleFilter {
526    /// match any role
527    AnyRole,
528    /// match a specific list of role ids
529    TheseRoles(Vec<u64>),
530    /// match any role but a specific list of role ids
531    NotTheseRoles(Vec<u64>),
532}
533
534impl std::fmt::Display for RoleFilter {
535    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
536        match self {
537            Self::AnyRole => {
538                write!(f, "*")
539            }
540            Self::TheseRoles(ids) => {
541                let s: String = ids
542                    .iter()
543                    .map(|e| e.to_string())
544                    .collect::<Vec<_>>()
545                    .join(",");
546                write!(f, "{s}")
547            }
548            Self::NotTheseRoles(ids) => {
549                let s: String = ids
550                    .iter()
551                    .map(|e| format!("!{e}"))
552                    .collect::<Vec<_>>()
553                    .join(",");
554                write!(f, "{s}")
555            }
556        }
557    }
558}
559
560/// ways to filter for groups the assignee is a member of
561#[derive(Debug, Clone)]
562pub enum MemberOfGroupFilter {
563    /// match any group
564    AnyGroup,
565    /// match a specific list of group ids
566    TheseGroups(Vec<u64>),
567    /// match any group but a specific list of group ids
568    NotTheseGroups(Vec<u64>),
569}
570
571impl std::fmt::Display for MemberOfGroupFilter {
572    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
573        match self {
574            Self::AnyGroup => {
575                write!(f, "*")
576            }
577            Self::TheseGroups(ids) => {
578                let s: String = ids
579                    .iter()
580                    .map(|e| e.to_string())
581                    .collect::<Vec<_>>()
582                    .join(",");
583                write!(f, "{s}")
584            }
585            Self::NotTheseGroups(ids) => {
586                let s: String = ids
587                    .iter()
588                    .map(|e| format!("!{e}"))
589                    .collect::<Vec<_>>()
590                    .join(",");
591                write!(f, "{s}")
592            }
593        }
594    }
595}
596
597/// ways to filter for users or groups in assignee
598#[derive(Debug, Clone)]
599pub enum FixedVersionStatusFilter {
600    /// match open versions
601    Open,
602    /// match locked versions
603    Locked,
604    /// match closed versions
605    Closed,
606}
607
608impl std::fmt::Display for FixedVersionStatusFilter {
609    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
610        match self {
611            Self::Open => {
612                write!(f, "open")
613            }
614            Self::Locked => {
615                write!(f, "locked")
616            }
617            Self::Closed => {
618                write!(f, "closed")
619            }
620        }
621    }
622}
623
624/// ways to filter for users or groups in assignee
625#[derive(Debug, Clone)]
626pub enum AssigneeFilter {
627    /// match any user or group
628    AnyAssignee,
629    /// match the current API user
630    Me,
631    /// match any assignee but the current API user
632    NotMe,
633    /// match a specific list of users or groups
634    TheseAssignees(Vec<u64>),
635    /// match a negated specific list of users or groups
636    NotTheseAssignees(Vec<u64>),
637    /// match unassigned
638    NoAssignee,
639}
640
641impl std::fmt::Display for AssigneeFilter {
642    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
643        match self {
644            Self::AnyAssignee => {
645                write!(f, "*")
646            }
647            Self::Me => {
648                write!(f, "me")
649            }
650            Self::NotMe => {
651                write!(f, "!me")
652            }
653            Self::TheseAssignees(ids) => {
654                let s: String = ids
655                    .iter()
656                    .map(|e| e.to_string())
657                    .collect::<Vec<_>>()
658                    .join(",");
659                write!(f, "{s}")
660            }
661            Self::NotTheseAssignees(ids) => {
662                let s: String = ids
663                    .iter()
664                    .map(|e| format!("!{e}"))
665                    .collect::<Vec<_>>()
666                    .join(",");
667                write!(f, "{s}")
668            }
669            Self::NoAssignee => {
670                write!(f, "!*")
671            }
672        }
673    }
674}
675
676/// Filter for a custom field, consisting of its ID and a StringFieldFilter for its value.
677#[derive(Debug, Clone)]
678pub enum SortByColumn {
679    /// Sort in an ascending direction
680    Forward {
681        /// the column to sort by
682        column_name: String,
683    },
684    /// Sort in a descending direction
685    Reverse {
686        /// the column to sort by
687        column_name: String,
688    },
689}
690
691impl std::fmt::Display for SortByColumn {
692    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
693        match self {
694            Self::Forward { column_name } => {
695                write!(f, "{column_name}")
696            }
697            Self::Reverse { column_name } => {
698                write!(f, "{column_name}:desc")
699            }
700        }
701    }
702}
703
704/// The types of associated data which can be fetched along with a issue
705#[derive(Debug, Clone)]
706pub enum IssueListInclude {
707    /// Issue relations
708    Relations,
709    /// Issue time entries
710    TimeEntries,
711}
712
713impl std::fmt::Display for IssueListInclude {
714    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
715        match self {
716            Self::Relations => {
717                write!(f, "relations")
718            }
719            Self::TimeEntries => {
720                write!(f, "time_entries")
721            }
722        }
723    }
724}
725
726/// The endpoint for all Redmine issues
727#[derive(Debug, Clone, Builder)]
728#[builder(setter(strip_option))]
729pub struct ListIssues {
730    /// Include associated data
731    #[builder(default)]
732    include: Option<Vec<IssueListInclude>>,
733    /// Sort by column
734    #[builder(default)]
735    sort: Option<Vec<SortByColumn>>,
736    /// Filter by issue id(s)
737    #[builder(default)]
738    issue_id: Option<Vec<u64>>,
739    /// Filter by project id
740    #[builder(default)]
741    project_id: Option<Vec<u64>>,
742    /// Filter by subproject
743    #[builder(default)]
744    subproject_id: Option<SubProjectFilter>,
745    /// Filter by tracker id
746    #[builder(default)]
747    tracker_id: Option<Vec<u64>>,
748    /// Filter by priority id
749    #[builder(default)]
750    priority_id: Option<Vec<u64>>,
751    /// Filter by parent issue id
752    #[builder(default)]
753    parent_id: Option<Vec<u64>>,
754    /// Filter by issue category id
755    #[builder(default)]
756    category_id: Option<Vec<u64>>,
757    /// Filter by issue status
758    #[builder(default)]
759    status_id: Option<IssueStatusFilter>,
760    /// Filter by subject
761    #[builder(default)]
762    subject: Option<StringFieldFilter>,
763    /// Filter by description
764    #[builder(default)]
765    description: Option<StringFieldFilter>,
766    /// Filter by notes (journal content)
767    #[builder(default)]
768    notes: Option<StringFieldFilter>,
769    /// Filter by watcher id
770    #[builder(default)]
771    watcher_id: Option<Vec<u64>>,
772    /// Filter by author
773    #[builder(default)]
774    author: Option<UserFilter>,
775    /// Filter by updated_by
776    #[builder(default)]
777    updated_by: Option<UserFilter>,
778    /// Filter by last_updated_by
779    #[builder(default)]
780    last_updated_by: Option<UserFilter>,
781    /// Filter by attachment
782    #[builder(default)]
783    attachment: Option<bool>,
784    /// Filter by attachment description
785    #[builder(default)]
786    attachment_description: Option<StringFieldFilter>,
787    /// Filter by project status
788    #[builder(default)]
789    project_status: Option<ProjectStatusFilter>,
790    /// Filter by any searchable field (free-text search)
791    #[builder(default)]
792    any_searchable: Option<StringFieldFilter>,
793    /// Filter by custom fields
794    #[builder(default)]
795    custom_field_filters: Option<Vec<CustomFieldFilter>>,
796    /// Filter by assignee
797    #[builder(default)]
798    assignee: Option<AssigneeFilter>,
799    /// Filter by a saved query
800    #[builder(default)]
801    query_id: Option<u64>,
802    /// Filter by target version
803    #[builder(default)]
804    version_id: Option<Vec<u64>>,
805    /// Filter by creation time
806    #[builder(default)]
807    created_on: Option<DateTimeFilterPast>,
808    /// Filter by update time
809    #[builder(default)]
810    updated_on: Option<DateTimeFilterPast>,
811    /// Filter by start date
812    #[builder(default)]
813    start_date: Option<DateFilter>,
814    /// Filter by due date
815    #[builder(default)]
816    due_date: Option<DateFilter>,
817    /// Filter by spent time
818    #[builder(default)]
819    spent_time: Option<FloatFilter>,
820    /// Filter by closed on date
821    #[builder(default)]
822    closed_on: Option<DateTimeFilterPast>,
823    /// Filter by estimated hours
824    #[builder(default)]
825    estimated_hours: Option<FloatFilter>,
826    /// Filter by done ratio
827    #[builder(default)]
828    done_ratio: Option<IntegerFilter>,
829    /// Filter by author group
830    #[builder(default)]
831    author_group: Option<MemberOfGroupFilter>,
832    /// Filter by author role
833    #[builder(default)]
834    author_role: Option<RoleFilter>,
835    /// Filter by groups the assignee is a member of
836    #[builder(default)]
837    member_of_group: Option<MemberOfGroupFilter>,
838    /// Filter by roles the assignee has
839    #[builder(default)]
840    assigned_to_role: Option<RoleFilter>,
841    /// Filter by fixed version due date
842    #[builder(default)]
843    fixed_version_due_date: Option<DateFilter>,
844    /// Filter by fixed version status
845    #[builder(default)]
846    fixed_version_status: Option<FixedVersionStatusFilter>,
847    /// Filter by child issue id
848    #[builder(default)]
849    child_id: Option<Vec<u64>>,
850    /// Filter by private status
851    #[builder(default)]
852    is_private: Option<bool>,
853}
854
855impl ReturnsJsonResponse for ListIssues {}
856
857impl Pageable for ListIssues {
858    fn response_wrapper_key(&self) -> String {
859        "issues".to_string()
860    }
861}
862
863impl ListIssues {
864    /// Create a builder for the endpoint.
865    #[must_use]
866    pub fn builder() -> ListIssuesBuilder {
867        ListIssuesBuilder::default()
868    }
869}
870
871impl Endpoint for ListIssues {
872    fn method(&self) -> Method {
873        Method::GET
874    }
875
876    fn endpoint(&self) -> Cow<'static, str> {
877        "issues.json".into()
878    }
879
880    fn parameters(&self) -> QueryParams<'_> {
881        let mut params = QueryParams::default();
882        params.push_opt("include", self.include.as_ref());
883        params.push_opt("sort", self.sort.as_ref());
884        params.push_opt("issue_id", self.issue_id.as_ref());
885        params.push_opt("project_id", self.project_id.as_ref());
886        params.push_opt(
887            "subproject_id",
888            self.subproject_id.as_ref().map(|s| s.to_string()),
889        );
890        params.push_opt("tracker_id", self.tracker_id.as_ref());
891        params.push_opt("priority_id", self.priority_id.as_ref());
892        params.push_opt("parent_id", self.parent_id.as_ref());
893        params.push_opt("category_id", self.category_id.as_ref());
894        params.push_opt("status_id", self.status_id.as_ref().map(|s| s.to_string()));
895        params.push_opt("subject", self.subject.as_ref().map(|s| s.to_string()));
896        params.push_opt(
897            "description",
898            self.description.as_ref().map(|s| s.to_string()),
899        );
900        params.push_opt("notes", self.notes.as_ref().map(|s| s.to_string()));
901        params.push_opt("author_id", self.author.as_ref().map(|s| s.to_string()));
902        params.push_opt(
903            "updated_by_id",
904            self.updated_by.as_ref().map(|s| s.to_string()),
905        );
906        params.push_opt(
907            "last_updated_by_id",
908            self.last_updated_by.as_ref().map(|s| s.to_string()),
909        );
910        params.push_opt("attachment", self.attachment);
911        params.push_opt(
912            "attachment_description",
913            self.attachment_description.as_ref().map(|s| s.to_string()),
914        );
915        params.push_opt(
916            "project_status",
917            self.project_status.as_ref().map(|s| s.to_string()),
918        );
919        params.push_opt(
920            "any_searchable",
921            self.any_searchable.as_ref().map(|s| s.to_string()),
922        );
923        if let Some(filters) = self.custom_field_filters.as_ref() {
924            for filter in filters {
925                params.push(format!("cf_{}", filter.id), filter.value.to_string());
926            }
927        }
928        params.push_opt(
929            "assigned_to_id",
930            self.assignee.as_ref().map(|s| s.to_string()),
931        );
932        params.push_opt("query_id", self.query_id);
933        params.push_opt("fixed_version_id", self.version_id.as_ref());
934        params.push_opt(
935            "created_on",
936            self.created_on.as_ref().map(|s| s.to_string()),
937        );
938        params.push_opt(
939            "updated_on",
940            self.updated_on.as_ref().map(|s| s.to_string()),
941        );
942        params.push_opt(
943            "start_date",
944            self.start_date.as_ref().map(|s| s.to_string()),
945        );
946        params.push_opt("due_date", self.due_date.as_ref().map(|s| s.to_string()));
947        params.push_opt(
948            "spent_time",
949            self.spent_time.as_ref().map(|s| s.to_string()),
950        );
951        params.push_opt("closed_on", self.closed_on.as_ref().map(|s| s.to_string()));
952        params.push_opt(
953            "estimated_hours",
954            self.estimated_hours.as_ref().map(|s| s.to_string()),
955        );
956        params.push_opt(
957            "done_ratio",
958            self.done_ratio.as_ref().map(|s| s.to_string()),
959        );
960        params.push_opt(
961            "author.group",
962            self.author_group.as_ref().map(|s| s.to_string()),
963        );
964        params.push_opt(
965            "author.role",
966            self.author_role.as_ref().map(|s| s.to_string()),
967        );
968        params.push_opt(
969            "member_of_group",
970            self.member_of_group.as_ref().map(|s| s.to_string()),
971        );
972        params.push_opt(
973            "assigned_to_role",
974            self.assigned_to_role.as_ref().map(|s| s.to_string()),
975        );
976        params.push_opt(
977            "fixed_version.due_date",
978            self.fixed_version_due_date.as_ref().map(|s| s.to_string()),
979        );
980        params.push_opt(
981            "fixed_version.status",
982            self.fixed_version_status.as_ref().map(|s| s.to_string()),
983        );
984        params.push_opt("child_id", self.child_id.as_ref());
985        params.push_opt("is_private", self.is_private);
986        params.push_opt(
987            "watcher_id",
988            self.watcher_id.as_ref().map(|ids| {
989                ids.iter()
990                    .map(std::string::ToString::to_string)
991                    .collect::<Vec<String>>()
992                    .join(",")
993            }),
994        );
995        params
996    }
997}
998
999/// The types of associated data which can be fetched along with a issue
1000#[derive(Debug, Clone)]
1001pub enum IssueInclude {
1002    /// Child issues
1003    Children,
1004    /// Issue attachments
1005    Attachments,
1006    /// Issue relations
1007    Relations,
1008    /// VCS changesets
1009    Changesets,
1010    /// the notes and changes to the issue
1011    Journals,
1012    /// Users watching the issue
1013    Watchers,
1014    /// The statuses this issue can transition to
1015    ///
1016    /// This can be influenced by
1017    ///
1018    /// - the defined workflow
1019    ///   - the issue's current tracker
1020    ///   - the issue's current status
1021    ///   - the member's role
1022    /// - the existence of any open subtask(s)
1023    /// - the existence of any open blocking issue(s)
1024    /// - the existence of a closed parent issue
1025    ///
1026    AllowedStatuses,
1027}
1028
1029impl std::fmt::Display for IssueInclude {
1030    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1031        match self {
1032            Self::Children => {
1033                write!(f, "children")
1034            }
1035            Self::Attachments => {
1036                write!(f, "attachments")
1037            }
1038            Self::Relations => {
1039                write!(f, "relations")
1040            }
1041            Self::Changesets => {
1042                write!(f, "changesets")
1043            }
1044            Self::Journals => {
1045                write!(f, "journals")
1046            }
1047            Self::Watchers => {
1048                write!(f, "watchers")
1049            }
1050            Self::AllowedStatuses => {
1051                write!(f, "allowed_statuses")
1052            }
1053        }
1054    }
1055}
1056
1057/// The endpoint for a specific Redmine issue
1058#[derive(Debug, Clone, Builder)]
1059#[builder(setter(strip_option))]
1060pub struct GetIssue {
1061    /// id of the issue to retrieve
1062    id: u64,
1063    /// associated data to include
1064    #[builder(default)]
1065    include: Option<Vec<IssueInclude>>,
1066}
1067
1068impl ReturnsJsonResponse for GetIssue {}
1069impl NoPagination for GetIssue {}
1070
1071impl GetIssue {
1072    /// Create a builder for the endpoint.
1073    #[must_use]
1074    pub fn builder() -> GetIssueBuilder {
1075        GetIssueBuilder::default()
1076    }
1077}
1078
1079impl Endpoint for GetIssue {
1080    fn method(&self) -> Method {
1081        Method::GET
1082    }
1083
1084    fn endpoint(&self) -> Cow<'static, str> {
1085        format!("issues/{}.json", self.id).into()
1086    }
1087
1088    fn parameters(&self) -> QueryParams<'_> {
1089        let mut params = QueryParams::default();
1090        params.push_opt("include", self.include.as_ref());
1091        params
1092    }
1093}
1094
1095/// the information the uploader needs to supply for an attachment
1096/// in [CreateIssue] or [UpdateIssue]
1097#[derive(Debug, Clone, Serialize)]
1098pub struct UploadedAttachment<'a> {
1099    /// the upload token from [UploadFile|crate::api::uploads::UploadFile]
1100    pub token: Cow<'a, str>,
1101    /// the filename
1102    pub filename: Cow<'a, str>,
1103    /// a description for the file
1104    #[serde(skip_serializing_if = "Option::is_none")]
1105    pub description: Option<Cow<'a, str>>,
1106    /// the MIME content type of the file
1107    pub content_type: Cow<'a, str>,
1108}
1109
1110/// The endpoint to create a Redmine issue
1111#[serde_with::skip_serializing_none]
1112#[derive(Debug, Clone, Builder, Serialize)]
1113#[builder(setter(strip_option))]
1114pub struct CreateIssue<'a> {
1115    /// project for the issue
1116    project_id: u64,
1117    /// tracker for the issue
1118    #[builder(default)]
1119    tracker_id: Option<u64>,
1120    /// status of the issue
1121    #[builder(default)]
1122    status_id: Option<u64>,
1123    /// issue priority
1124    #[builder(default)]
1125    priority_id: Option<u64>,
1126    /// issue subject
1127    #[builder(setter(into), default)]
1128    subject: Option<Cow<'a, str>>,
1129    /// issue description
1130    #[builder(setter(into), default)]
1131    description: Option<Cow<'a, str>>,
1132    /// issue category
1133    #[builder(default)]
1134    category_id: Option<u64>,
1135    /// ID of the Target Versions (previously called 'Fixed Version' and still referred to as such in the API)
1136    #[builder(default, setter(name = "version"))]
1137    fixed_version_id: Option<u64>,
1138    /// user/group id the issue will be assigned to
1139    #[builder(default)]
1140    assigned_to_id: Option<u64>,
1141    /// Id of the parent issue
1142    #[builder(default)]
1143    parent_issue_id: Option<u64>,
1144    /// custom field values
1145    #[builder(default)]
1146    custom_fields: Option<Vec<CustomField<'a>>>,
1147    /// user ids of watchers of the issue
1148    #[builder(default)]
1149    watcher_user_ids: Option<Vec<u64>>,
1150    /// is the issue private (only visible to roles that have the relevant permission enabled)
1151    #[builder(default)]
1152    is_private: Option<bool>,
1153    /// estimated hours it will take to implement this issue
1154    #[builder(default)]
1155    estimated_hours: Option<f64>,
1156    /// the start date for the issue
1157    #[builder(default)]
1158    start_date: Option<time::Date>,
1159    /// the due date for the issue
1160    #[builder(default)]
1161    due_date: Option<time::Date>,
1162    /// the percentage done (0-100)
1163    #[builder(default)]
1164    done_ratio: Option<u64>,
1165    /// attachments (files)
1166    #[builder(default)]
1167    uploads: Option<Vec<UploadedAttachment<'a>>>,
1168}
1169
1170impl<'a> CreateIssue<'a> {
1171    /// Create a builder for the endpoint.
1172    #[must_use]
1173    pub fn builder() -> CreateIssueBuilder<'a> {
1174        CreateIssueBuilder::default()
1175    }
1176}
1177
1178impl ReturnsJsonResponse for CreateIssue<'_> {}
1179impl NoPagination for CreateIssue<'_> {}
1180
1181impl Endpoint for CreateIssue<'_> {
1182    fn method(&self) -> Method {
1183        Method::POST
1184    }
1185
1186    fn endpoint(&self) -> Cow<'static, str> {
1187        "issues.json".into()
1188    }
1189
1190    fn body(&self) -> Result<Option<(&'static str, Vec<u8>)>, crate::Error> {
1191        Ok(Some((
1192            "application/json",
1193            serde_json::to_vec(&IssueWrapper::<CreateIssue> {
1194                issue: (*self).to_owned(),
1195            })?,
1196        )))
1197    }
1198}
1199
1200/// An issue field which [UpdateIssue] can clear (set to no value)
1201///
1202/// Fields not listed here can be emptied by setting them to an empty value
1203/// instead, e.g. an empty description or a done ratio of 0.
1204#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1205#[non_exhaustive]
1206pub enum ClearableIssueField {
1207    /// the issue category
1208    Category,
1209    /// the target version
1210    Version,
1211    /// the assignee
1212    AssignedTo,
1213    /// the parent issue
1214    ParentIssue,
1215    /// the estimated hours
1216    EstimatedHours,
1217    /// the start date
1218    StartDate,
1219    /// the due date
1220    DueDate,
1221}
1222
1223impl ClearableIssueField {
1224    /// the name of the field in the JSON body of [UpdateIssue]
1225    #[must_use]
1226    pub const fn json_name(self) -> &'static str {
1227        match self {
1228            Self::Category => "category_id",
1229            Self::Version => "fixed_version_id",
1230            Self::AssignedTo => "assigned_to_id",
1231            Self::ParentIssue => "parent_issue_id",
1232            Self::EstimatedHours => "estimated_hours",
1233            Self::StartDate => "start_date",
1234            Self::DueDate => "due_date",
1235        }
1236    }
1237}
1238
1239/// The endpoint to update an existing Redmine issue
1240#[serde_with::skip_serializing_none]
1241#[derive(Debug, Clone, Builder, Serialize)]
1242#[builder(setter(strip_option), build_fn(validate = "Self::validate"))]
1243pub struct UpdateIssue<'a> {
1244    /// id of the issue to update
1245    #[serde(skip_serializing)]
1246    id: u64,
1247    /// project for the issue
1248    #[builder(default)]
1249    project_id: Option<u64>,
1250    /// tracker for the issue
1251    #[builder(default)]
1252    tracker_id: Option<u64>,
1253    /// status of the issue
1254    #[builder(default)]
1255    status_id: Option<u64>,
1256    /// issue priority
1257    #[builder(default)]
1258    priority_id: Option<u64>,
1259    /// issue subject
1260    #[builder(setter(into), default)]
1261    subject: Option<Cow<'a, str>>,
1262    /// issue description
1263    #[builder(setter(into), default)]
1264    description: Option<Cow<'a, str>>,
1265    /// issue category
1266    #[builder(default)]
1267    category_id: Option<u64>,
1268    /// ID of the Target Versions (previously called 'Fixed Version' and still referred to as such in the API)
1269    #[builder(default, setter(name = "version"))]
1270    fixed_version_id: Option<u64>,
1271    /// user/group id the issue will be assigned to
1272    #[builder(default)]
1273    assigned_to_id: Option<u64>,
1274    /// Id of the parent issue
1275    #[builder(default)]
1276    parent_issue_id: Option<u64>,
1277    /// custom field values
1278    #[builder(default)]
1279    custom_fields: Option<Vec<CustomField<'a>>>,
1280    /// user ids of watchers of the issue
1281    #[builder(default)]
1282    watcher_user_ids: Option<Vec<u64>>,
1283    /// is the issue private (only visible to roles that have the relevant permission enabled)
1284    #[builder(default)]
1285    is_private: Option<bool>,
1286    /// estimated hours it will take to implement this issue
1287    #[builder(default)]
1288    estimated_hours: Option<f64>,
1289    /// the start date for the issue
1290    #[builder(default)]
1291    start_date: Option<time::Date>,
1292    /// the due date for the issue
1293    #[builder(default)]
1294    due_date: Option<time::Date>,
1295    /// the percentage done (0-100)
1296    #[builder(default)]
1297    done_ratio: Option<u64>,
1298    /// add a comment (note)
1299    #[builder(default)]
1300    notes: Option<Cow<'a, str>>,
1301    /// is the added comment/note private
1302    #[builder(default)]
1303    private_notes: Option<bool>,
1304    /// attachments (files)
1305    #[builder(default)]
1306    uploads: Option<Vec<UploadedAttachment<'a>>>,
1307    /// fields to clear, sent as `null`; a field can not be both set and cleared
1308    #[serde(skip_serializing)]
1309    #[builder(default)]
1310    clear: Option<Vec<ClearableIssueField>>,
1311}
1312
1313impl UpdateIssueBuilder<'_> {
1314    /// ensures that no field is both set and cleared when [Self::build()] is called
1315    fn validate(&self) -> Result<(), String> {
1316        let Some(Some(clear)) = &self.clear else {
1317            return Ok(());
1318        };
1319        for field in clear {
1320            let set = match field {
1321                ClearableIssueField::Category => matches!(self.category_id, Some(Some(_))),
1322                ClearableIssueField::Version => matches!(self.fixed_version_id, Some(Some(_))),
1323                ClearableIssueField::AssignedTo => matches!(self.assigned_to_id, Some(Some(_))),
1324                ClearableIssueField::ParentIssue => {
1325                    matches!(self.parent_issue_id, Some(Some(_)))
1326                }
1327                ClearableIssueField::EstimatedHours => {
1328                    matches!(self.estimated_hours, Some(Some(_)))
1329                }
1330                ClearableIssueField::StartDate => matches!(self.start_date, Some(Some(_))),
1331                ClearableIssueField::DueDate => matches!(self.due_date, Some(Some(_))),
1332            };
1333            if set {
1334                return Err(format!(
1335                    "{} can not be both set and cleared",
1336                    field.json_name()
1337                ));
1338            }
1339        }
1340        Ok(())
1341    }
1342}
1343
1344impl<'a> UpdateIssue<'a> {
1345    /// Create a builder for the endpoint.
1346    #[must_use]
1347    pub fn builder() -> UpdateIssueBuilder<'a> {
1348        UpdateIssueBuilder::default()
1349    }
1350}
1351
1352impl UpdateIssue<'_> {
1353    /// the issue part of the body, with the cleared fields set to `null`
1354    fn json_issue(&self) -> Result<serde_json::Value, serde_json::Error> {
1355        let mut issue = serde_json::to_value(self)?;
1356        if let (Some(clear), Some(fields)) = (&self.clear, issue.as_object_mut()) {
1357            for field in clear {
1358                fields.insert(field.json_name().to_owned(), serde_json::Value::Null);
1359            }
1360        }
1361        Ok(issue)
1362    }
1363}
1364
1365impl Endpoint for UpdateIssue<'_> {
1366    fn method(&self) -> Method {
1367        Method::PUT
1368    }
1369
1370    fn endpoint(&self) -> Cow<'static, str> {
1371        format!("issues/{}.json", self.id).into()
1372    }
1373
1374    fn body(&self) -> Result<Option<(&'static str, Vec<u8>)>, crate::Error> {
1375        Ok(Some((
1376            "application/json",
1377            serde_json::to_vec(&IssueWrapper {
1378                issue: self.json_issue()?,
1379            })?,
1380        )))
1381    }
1382}
1383
1384/// The endpoint to delete a Redmine issue
1385#[derive(Debug, Clone, Builder)]
1386#[builder(setter(strip_option))]
1387pub struct DeleteIssue {
1388    /// id of the issue to delete
1389    id: u64,
1390}
1391
1392impl DeleteIssue {
1393    /// Create a builder for the endpoint.
1394    #[must_use]
1395    pub fn builder() -> DeleteIssueBuilder {
1396        DeleteIssueBuilder::default()
1397    }
1398}
1399
1400impl Endpoint for DeleteIssue {
1401    fn method(&self) -> Method {
1402        Method::DELETE
1403    }
1404
1405    fn endpoint(&self) -> Cow<'static, str> {
1406        format!("issues/{}.json", self.id).into()
1407    }
1408}
1409
1410/// The endpoint to add a Redmine user as a watcher on a Redmine issue
1411#[derive(Debug, Clone, Builder, Serialize)]
1412#[builder(setter(strip_option))]
1413pub struct AddWatcher {
1414    /// id of the issue to add the watcher to
1415    #[serde(skip_serializing)]
1416    issue_id: u64,
1417    /// id of the user to add as a watcher
1418    user_id: u64,
1419}
1420
1421impl AddWatcher {
1422    /// Create a builder for the endpoint.
1423    #[must_use]
1424    pub fn builder() -> AddWatcherBuilder {
1425        AddWatcherBuilder::default()
1426    }
1427}
1428
1429impl Endpoint for AddWatcher {
1430    fn method(&self) -> Method {
1431        Method::POST
1432    }
1433
1434    fn endpoint(&self) -> Cow<'static, str> {
1435        format!("issues/{}/watchers.json", self.issue_id).into()
1436    }
1437
1438    fn body(&self) -> Result<Option<(&'static str, Vec<u8>)>, crate::Error> {
1439        Ok(Some(("application/json", serde_json::to_vec(self)?)))
1440    }
1441}
1442
1443/// The endpoint to remove a Redmine user from a Redmine issue as a watcher
1444#[derive(Debug, Clone, Builder)]
1445#[builder(setter(strip_option))]
1446pub struct RemoveWatcher {
1447    /// id of the issue to remove the watcher from
1448    issue_id: u64,
1449    /// id of the user to remove as a watcher
1450    user_id: u64,
1451}
1452
1453impl RemoveWatcher {
1454    /// Create a builder for the endpoint.
1455    #[must_use]
1456    pub fn builder() -> RemoveWatcherBuilder {
1457        RemoveWatcherBuilder::default()
1458    }
1459}
1460
1461impl Endpoint for RemoveWatcher {
1462    fn method(&self) -> Method {
1463        Method::DELETE
1464    }
1465
1466    fn endpoint(&self) -> Cow<'static, str> {
1467        format!("issues/{}/watchers/{}.json", self.issue_id, self.user_id).into()
1468    }
1469}
1470
1471/// helper struct for outer layers with a issues field holding the inner data
1472#[derive(Debug, Clone, PartialEq, Eq, Serialize, serde::Deserialize)]
1473pub struct IssuesWrapper<T> {
1474    /// to parse JSON with issues key
1475    pub issues: Vec<T>,
1476}
1477
1478/// A lot of APIs in Redmine wrap their data in an extra layer, this is a
1479/// helper struct for outer layers with a issue field holding the inner data
1480#[derive(Debug, Clone, PartialEq, Eq, Serialize, serde::Deserialize)]
1481pub struct IssueWrapper<T> {
1482    /// to parse JSON with an issue key
1483    pub issue: T,
1484}
1485
1486#[cfg(test)]
1487pub(crate) mod test {
1488    use super::*;
1489    use crate::api::ResponsePage;
1490    use crate::api::test_helpers::with_project;
1491    use pretty_assertions::assert_eq;
1492    use std::error::Error;
1493    use tokio::sync::RwLock;
1494    use tracing_test::traced_test;
1495
1496    /// needed so we do not get 404s when listing while
1497    /// creating/deleting or creating/updating/deleting
1498    pub static ISSUES_LOCK: RwLock<()> = RwLock::const_new(());
1499
1500    #[traced_test]
1501    #[test]
1502    fn test_list_issues_first_page() -> Result<(), Box<dyn Error>> {
1503        let _r_issues = ISSUES_LOCK.blocking_read();
1504        dotenvy::dotenv()?;
1505        let redmine = crate::api::Redmine::from_env(
1506            reqwest::blocking::Client::builder()
1507                .tls_backend_rustls()
1508                .build()?,
1509        )?;
1510        let endpoint = ListIssues::builder().build()?;
1511        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
1512        Ok(())
1513    }
1514
1515    /// this version of the test will load all pages of issues which means it
1516    /// can take a while (a minute or more) so you need to use --include-ignored
1517    /// or --ignored to run it
1518    #[traced_test]
1519    #[test]
1520    #[ignore = "loads all pages of issues; runtime ~1m, run with --include-ignored"]
1521    fn test_list_issues_all_pages() -> Result<(), Box<dyn Error>> {
1522        let _r_issues = ISSUES_LOCK.blocking_read();
1523        dotenvy::dotenv()?;
1524        let redmine = crate::api::Redmine::from_env(
1525            reqwest::blocking::Client::builder()
1526                .tls_backend_rustls()
1527                .build()?,
1528        )?;
1529        let endpoint = ListIssues::builder().build()?;
1530        redmine.json_response_body_all_pages::<_, Issue>(&endpoint)?;
1531        Ok(())
1532    }
1533
1534    /// this version of the test will load all pages of issues which means it
1535    /// can take a while (a minute or more) so you need to use --include-ignored
1536    /// or --ignored to run it
1537    #[traced_test]
1538    #[test]
1539    #[ignore = "loads all pages of issues; runtime ~1m, run with --include-ignored"]
1540    fn test_list_issues_all_pages_iter() -> Result<(), Box<dyn Error>> {
1541        let _r_issues = ISSUES_LOCK.blocking_read();
1542        dotenvy::dotenv()?;
1543        let redmine = crate::api::Redmine::from_env(
1544            reqwest::blocking::Client::builder()
1545                .tls_backend_rustls()
1546                .build()?,
1547        )?;
1548        let endpoint = ListIssues::builder().build()?;
1549        let mut i = 0;
1550        for issue in redmine.json_response_body_all_pages_iter::<_, Issue>(&endpoint) {
1551            let _issue = issue?;
1552            i += 1;
1553        }
1554        assert!(i > 0);
1555
1556        Ok(())
1557    }
1558
1559    /// this version of the test will load all pages of issues which means it
1560    /// can take a while (a minute or more) so you need to use --include-ignored
1561    /// or --ignored to run it
1562    #[traced_test]
1563    #[tokio::test]
1564    #[ignore = "loads all pages of issues; runtime ~1m, run with --include-ignored"]
1565    async fn test_list_issues_all_pages_stream() -> Result<(), Box<dyn Error>> {
1566        let _r_issues = ISSUES_LOCK.read().await;
1567        dotenvy::dotenv()?;
1568        let redmine = crate::api::RedmineAsync::from_env(
1569            reqwest::Client::builder().tls_backend_rustls().build()?,
1570        )?;
1571        let endpoint = ListIssues::builder().build()?;
1572        let mut i = 0;
1573        let mut stream = redmine.json_response_body_all_pages_stream::<_, Issue>(&endpoint);
1574        while let Some(issue) = <_ as futures::stream::StreamExt>::next(&mut stream).await {
1575            let _issue = issue?;
1576            i += 1;
1577        }
1578        assert!(i > 0);
1579
1580        Ok(())
1581    }
1582
1583    #[traced_test]
1584    #[test]
1585    fn test_get_issue() -> Result<(), Box<dyn Error>> {
1586        let _r_issues = ISSUES_LOCK.blocking_read();
1587        dotenvy::dotenv()?;
1588        let redmine = crate::api::Redmine::from_env(
1589            reqwest::blocking::Client::builder()
1590                .tls_backend_rustls()
1591                .build()?,
1592        )?;
1593        let endpoint = GetIssue::builder().id(40000).build()?;
1594        redmine.json_response_body::<_, IssueWrapper<Issue>>(&endpoint)?;
1595        Ok(())
1596    }
1597
1598    #[function_name::named]
1599    #[traced_test]
1600    #[test]
1601    fn test_create_issue() -> Result<(), Box<dyn Error>> {
1602        let _w_issues = ISSUES_LOCK.blocking_write();
1603        let name = format!("unittest_{}", function_name!());
1604        with_project(&name, |redmine, project_id, _| {
1605            let create_endpoint = super::CreateIssue::builder()
1606                .project_id(project_id)
1607                .subject("old test subject")
1608                .build()?;
1609            redmine.json_response_body::<_, IssueWrapper<Issue>>(&create_endpoint)?;
1610            Ok(())
1611        })?;
1612        Ok(())
1613    }
1614
1615    #[function_name::named]
1616    #[traced_test]
1617    #[test]
1618    fn test_update_issue() -> Result<(), Box<dyn Error>> {
1619        let _w_issues = ISSUES_LOCK.blocking_write();
1620        let name = format!("unittest_{}", function_name!());
1621        with_project(&name, |redmine, project_id, _name| {
1622            let create_endpoint = super::CreateIssue::builder()
1623                .project_id(project_id)
1624                .subject("old test subject")
1625                .build()?;
1626            let IssueWrapper { issue }: IssueWrapper<Issue> =
1627                redmine.json_response_body::<_, _>(&create_endpoint)?;
1628            let update_endpoint = super::UpdateIssue::builder()
1629                .id(issue.id)
1630                .subject("New test subject")
1631                .build()?;
1632            redmine.ignore_response_body::<_>(&update_endpoint)?;
1633            Ok(())
1634        })?;
1635        Ok(())
1636    }
1637
1638    #[function_name::named]
1639    #[traced_test]
1640    #[test]
1641    fn test_create_and_update_issue_dates_and_done_ratio() -> Result<(), Box<dyn Error>> {
1642        let _w_issues = ISSUES_LOCK.blocking_write();
1643        let name = format!("unittest_{}", function_name!());
1644        with_project(&name, |redmine, project_id, _name| {
1645            let create_endpoint = super::CreateIssue::builder()
1646                .project_id(project_id)
1647                .subject("test subject")
1648                .start_date(time::macros::date!(2026 - 01 - 05))
1649                .due_date(time::macros::date!(2026 - 01 - 30))
1650                .done_ratio(20)
1651                .build()?;
1652            let IssueWrapper { issue }: IssueWrapper<Issue> =
1653                redmine.json_response_body::<_, _>(&create_endpoint)?;
1654            assert_eq!(issue.start_date, Some(time::macros::date!(2026 - 01 - 05)));
1655            assert_eq!(issue.due_date, Some(time::macros::date!(2026 - 01 - 30)));
1656            assert_eq!(issue.done_ratio, 20);
1657            let update_endpoint = super::UpdateIssue::builder()
1658                .id(issue.id)
1659                .start_date(time::macros::date!(2026 - 02 - 02))
1660                .due_date(time::macros::date!(2026 - 02 - 27))
1661                .done_ratio(60)
1662                .build()?;
1663            redmine.ignore_response_body::<_>(&update_endpoint)?;
1664            let get_endpoint = GetIssue::builder().id(issue.id).build()?;
1665            let IssueWrapper { issue }: IssueWrapper<Issue> =
1666                redmine.json_response_body::<_, _>(&get_endpoint)?;
1667            assert_eq!(issue.start_date, Some(time::macros::date!(2026 - 02 - 02)));
1668            assert_eq!(issue.due_date, Some(time::macros::date!(2026 - 02 - 27)));
1669            assert_eq!(issue.done_ratio, 60);
1670            Ok(())
1671        })?;
1672        Ok(())
1673    }
1674
1675    #[test]
1676    fn test_update_issue_clear_fields_body() -> Result<(), Box<dyn Error>> {
1677        let endpoint = super::UpdateIssue::builder()
1678            .id(1)
1679            .subject("new subject")
1680            .clear(vec![
1681                ClearableIssueField::Category,
1682                ClearableIssueField::DueDate,
1683            ])
1684            .build()?;
1685        let Some((_, body)) = endpoint.body()? else {
1686            return Err("update issue has no body".into());
1687        };
1688        let body: serde_json::Value = serde_json::from_slice(&body)?;
1689        assert_eq!(
1690            body,
1691            serde_json::json!({
1692                "issue": {
1693                    "subject": "new subject",
1694                    "category_id": null,
1695                    "due_date": null,
1696                }
1697            })
1698        );
1699        Ok(())
1700    }
1701
1702    #[test]
1703    fn test_update_issue_set_and_clear_same_field() {
1704        let result = super::UpdateIssue::builder()
1705            .id(1)
1706            .category_id(3)
1707            .clear(vec![ClearableIssueField::Category])
1708            .build();
1709        assert_eq!(
1710            result.map_err(|e| e.to_string()).err(),
1711            Some("category_id can not be both set and cleared".to_owned())
1712        );
1713    }
1714
1715    #[function_name::named]
1716    #[traced_test]
1717    #[test]
1718    fn test_update_issue_clear_fields() -> Result<(), Box<dyn Error>> {
1719        let _w_issues = ISSUES_LOCK.blocking_write();
1720        let name = format!("unittest_{}", function_name!());
1721        with_project(&name, |redmine, project_id, name| {
1722            let category_endpoint = crate::api::issue_categories::CreateIssueCategory::builder()
1723                .project_id_or_name(name)
1724                .name("Unittest Issue Category")
1725                .build()?;
1726            let crate::api::issue_categories::IssueCategoryWrapper { issue_category } =
1727                redmine
1728                    .json_response_body::<_, crate::api::issue_categories::IssueCategoryWrapper<
1729                        crate::api::issue_categories::IssueCategory,
1730                    >>(&category_endpoint)?;
1731            let version_endpoint = crate::api::versions::CreateVersion::builder()
1732                .project_id_or_name(name)
1733                .name("Unittest Version")
1734                .build()?;
1735            let crate::api::versions::VersionWrapper { version } = redmine
1736                .json_response_body::<_, crate::api::versions::VersionWrapper<
1737                    crate::api::versions::Version,
1738                >>(&version_endpoint)?;
1739            let parent_endpoint = super::CreateIssue::builder()
1740                .project_id(project_id)
1741                .subject("parent")
1742                .build()?;
1743            let IssueWrapper { issue: parent }: IssueWrapper<Issue> =
1744                redmine.json_response_body::<_, _>(&parent_endpoint)?;
1745            let create_endpoint = super::CreateIssue::builder()
1746                .project_id(project_id)
1747                .subject("test subject")
1748                .category_id(issue_category.id)
1749                .version(version.id)
1750                .parent_issue_id(parent.id)
1751                .estimated_hours(2.5)
1752                .start_date(time::macros::date!(2026 - 01 - 05))
1753                .due_date(time::macros::date!(2026 - 01 - 30))
1754                .build()?;
1755            let IssueWrapper { issue }: IssueWrapper<Issue> =
1756                redmine.json_response_body::<_, _>(&create_endpoint)?;
1757            assert!(issue.category.is_some());
1758            assert!(issue.version.is_some());
1759            assert!(issue.parent.is_some());
1760            assert_eq!(issue.estimated_hours, Some(2.5));
1761            let update_endpoint = super::UpdateIssue::builder()
1762                .id(issue.id)
1763                .clear(vec![
1764                    ClearableIssueField::Category,
1765                    ClearableIssueField::Version,
1766                    ClearableIssueField::AssignedTo,
1767                    ClearableIssueField::ParentIssue,
1768                    ClearableIssueField::EstimatedHours,
1769                    ClearableIssueField::StartDate,
1770                    ClearableIssueField::DueDate,
1771                ])
1772                .build()?;
1773            redmine.ignore_response_body::<_>(&update_endpoint)?;
1774            let get_endpoint = GetIssue::builder().id(issue.id).build()?;
1775            let IssueWrapper { issue }: IssueWrapper<Issue> =
1776                redmine.json_response_body::<_, _>(&get_endpoint)?;
1777            assert!(issue.category.is_none());
1778            assert!(issue.version.is_none());
1779            assert!(issue.assigned_to.is_none());
1780            assert!(issue.parent.is_none());
1781            assert_eq!(issue.estimated_hours, None);
1782            assert_eq!(issue.start_date, None);
1783            assert_eq!(issue.due_date, None);
1784            Ok(())
1785        })?;
1786        Ok(())
1787    }
1788
1789    #[function_name::named]
1790    #[traced_test]
1791    #[test]
1792    fn test_delete_issue() -> Result<(), Box<dyn Error>> {
1793        let _w_issues = ISSUES_LOCK.blocking_write();
1794        let name = format!("unittest_{}", function_name!());
1795        with_project(&name, |redmine, project_id, _name| {
1796            let create_endpoint = super::CreateIssue::builder()
1797                .project_id(project_id)
1798                .subject("test subject")
1799                .build()?;
1800            let IssueWrapper { issue }: IssueWrapper<Issue> =
1801                redmine.json_response_body::<_, _>(&create_endpoint)?;
1802            let delete_endpoint = super::DeleteIssue::builder().id(issue.id).build()?;
1803            redmine.ignore_response_body::<_>(&delete_endpoint)?;
1804            Ok(())
1805        })?;
1806        Ok(())
1807    }
1808
1809    /// this tests if any of the results contain a field we are not deserializing
1810    ///
1811    /// this will only catch fields we missed if they are part of the response but
1812    /// it is better than nothing
1813    #[traced_test]
1814    #[test]
1815    fn test_completeness_issue_type_first_page() -> Result<(), Box<dyn Error>> {
1816        let _r_issues = ISSUES_LOCK.blocking_read();
1817        dotenvy::dotenv()?;
1818        let redmine = crate::api::Redmine::from_env(
1819            reqwest::blocking::Client::builder()
1820                .tls_backend_rustls()
1821                .build()?,
1822        )?;
1823        let endpoint = ListIssues::builder()
1824            .include(vec![
1825                IssueListInclude::TimeEntries,
1826                IssueListInclude::Relations,
1827            ])
1828            .build()?;
1829        let ResponsePage {
1830            values,
1831            total_count: _,
1832            offset: _,
1833            limit: _,
1834        } = redmine.json_response_body_page::<_, serde_json::Value>(&endpoint, 0, 100)?;
1835        for value in values {
1836            let o: Issue = serde_json::from_value(value.clone())?;
1837            let reserialized = serde_json::to_value(o)?;
1838            let expected_value = if let serde_json::Value::Object(obj) = value {
1839                let mut expected_obj = obj.clone();
1840                if obj
1841                    .get("total_estimated_hours")
1842                    .is_some_and(|v| *v == serde_json::Value::Null)
1843                {
1844                    expected_obj.remove("total_estimated_hours");
1845                }
1846                serde_json::Value::Object(expected_obj)
1847            } else {
1848                value
1849            };
1850            assert_eq!(expected_value, reserialized);
1851        }
1852        Ok(())
1853    }
1854
1855    /// this tests if any of the results contain a field we are not deserializing
1856    ///
1857    /// this will only catch fields we missed if they are part of the response but
1858    /// it is better than nothing
1859    ///
1860    /// this version of the test will load all pages of issues which means it
1861    /// can take a while (a minute or more) so you need to use --include-ignored
1862    /// or --ignored to run it
1863    #[traced_test]
1864    #[test]
1865    #[ignore = "loads all pages of issues; runtime ~1m, run with --include-ignored"]
1866    fn test_completeness_issue_type_all_pages() -> Result<(), Box<dyn Error>> {
1867        let _r_issues = ISSUES_LOCK.blocking_read();
1868        dotenvy::dotenv()?;
1869        let redmine = crate::api::Redmine::from_env(
1870            reqwest::blocking::Client::builder()
1871                .tls_backend_rustls()
1872                .build()?,
1873        )?;
1874        let endpoint = ListIssues::builder()
1875            .include(vec![
1876                IssueListInclude::TimeEntries,
1877                IssueListInclude::Relations,
1878            ])
1879            .build()?;
1880        let values = redmine.json_response_body_all_pages::<_, serde_json::Value>(&endpoint)?;
1881        for value in values {
1882            let o: Issue = serde_json::from_value(value.clone())?;
1883            let reserialized = serde_json::to_value(o)?;
1884            let expected_value = if let serde_json::Value::Object(obj) = value {
1885                let mut expected_obj = obj.clone();
1886                if obj
1887                    .get("total_estimated_hours")
1888                    .is_some_and(|v| *v == serde_json::Value::Null)
1889                {
1890                    expected_obj.remove("total_estimated_hours");
1891                }
1892                serde_json::Value::Object(expected_obj)
1893            } else {
1894                value
1895            };
1896            assert_eq!(expected_value, reserialized);
1897        }
1898        Ok(())
1899    }
1900
1901    /// this tests if any of the results contain a field we are not deserializing
1902    ///
1903    /// this will only catch fields we missed if they are part of the response but
1904    /// it is better than nothing
1905    ///
1906    /// this version of the test will load all pages of issues and the individual
1907    /// issues for each via GetIssue which means it
1908    /// can take a while (about 400 seconds) so you need to use --include-ignored
1909    /// or --ignored to run it
1910    #[traced_test]
1911    #[test]
1912    #[ignore = "fetches every issue via GetIssue; runtime ~400s, run with --include-ignored"]
1913    fn test_completeness_issue_type_all_pages_all_issue_details() -> Result<(), Box<dyn Error>> {
1914        let _r_issues = ISSUES_LOCK.blocking_read();
1915        dotenvy::dotenv()?;
1916        let redmine = crate::api::Redmine::from_env(
1917            reqwest::blocking::Client::builder()
1918                .tls_backend_rustls()
1919                .build()?,
1920        )?;
1921        let endpoint = ListIssues::builder()
1922            .include(vec![
1923                IssueListInclude::TimeEntries,
1924                IssueListInclude::Relations,
1925            ])
1926            .build()?;
1927        let issues = redmine.json_response_body_all_pages::<_, Issue>(&endpoint)?;
1928        for issue in issues {
1929            let get_endpoint = GetIssue::builder()
1930                .id(issue.id)
1931                .include(vec![
1932                    IssueInclude::Attachments,
1933                    IssueInclude::Children,
1934                    IssueInclude::Changesets,
1935                    IssueInclude::Relations,
1936                    IssueInclude::Journals,
1937                    IssueInclude::Watchers,
1938                ])
1939                .build()?;
1940            let IssueWrapper { issue: mut value } =
1941                redmine.json_response_body::<_, IssueWrapper<serde_json::Value>>(&get_endpoint)?;
1942            let o: Issue = serde_json::from_value(value.clone())?;
1943            // workaround for the fact that the field total_estimated_hours is put into the result
1944            // when its null in the GetIssue endpoint but not in the ListIssues one
1945            // we can only do one or the other in our JSON serialization unless we want to add
1946            // extra fields just to keep track of the missing field vs. field with null value
1947            // difference
1948            let value_object = value.as_object_mut().unwrap();
1949            if value_object.get("total_estimated_hours") == Some(&serde_json::Value::Null) {
1950                value_object.remove("total_estimated_hours");
1951            }
1952            let reserialized = serde_json::to_value(o)?;
1953            assert_eq!(value, reserialized);
1954        }
1955        Ok(())
1956    }
1957
1958    #[traced_test]
1959    #[test]
1960    fn test_list_issues_created_on_filter_exact_match() -> Result<(), Box<dyn Error>> {
1961        let _r_issues = ISSUES_LOCK.blocking_read();
1962        dotenvy::dotenv()?;
1963        let redmine = crate::api::Redmine::from_env(
1964            reqwest::blocking::Client::builder()
1965                .tls_backend_rustls()
1966                .build()?,
1967        )?;
1968
1969        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
1970        let endpoint = ListIssues::builder()
1971            .created_on(DateTimeFilterPast::ExactMatch(dt))
1972            .build()?;
1973        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
1974
1975        Ok(())
1976    }
1977
1978    #[traced_test]
1979    #[test]
1980    fn test_list_issues_created_on_filter_range() -> Result<(), Box<dyn Error>> {
1981        let _r_issues = ISSUES_LOCK.blocking_read();
1982        dotenvy::dotenv()?;
1983        let redmine = crate::api::Redmine::from_env(
1984            reqwest::blocking::Client::builder()
1985                .tls_backend_rustls()
1986                .build()?,
1987        )?;
1988
1989        let dt_start = time::macros::datetime!(2023-01-01 00:00:00 UTC);
1990        let dt_end = time::macros::datetime!(2023-01-31 23:59:59 UTC);
1991        let endpoint = ListIssues::builder()
1992            .created_on(DateTimeFilterPast::Range(dt_start, dt_end))
1993            .build()?;
1994        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
1995
1996        Ok(())
1997    }
1998
1999    #[traced_test]
2000    #[test]
2001    fn test_list_issues_created_on_filter_less_than_or_equal() -> Result<(), Box<dyn Error>> {
2002        let _r_issues = ISSUES_LOCK.blocking_read();
2003        dotenvy::dotenv()?;
2004        let redmine = crate::api::Redmine::from_env(
2005            reqwest::blocking::Client::builder()
2006                .tls_backend_rustls()
2007                .build()?,
2008        )?;
2009
2010        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
2011        let endpoint = ListIssues::builder()
2012            .created_on(DateTimeFilterPast::LessThanOrEqual(dt))
2013            .build()?;
2014        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2015
2016        Ok(())
2017    }
2018
2019    #[traced_test]
2020    #[test]
2021    fn test_list_issues_created_on_filter_greater_than_or_equal() -> Result<(), Box<dyn Error>> {
2022        let _r_issues = ISSUES_LOCK.blocking_read();
2023        dotenvy::dotenv()?;
2024        let redmine = crate::api::Redmine::from_env(
2025            reqwest::blocking::Client::builder()
2026                .tls_backend_rustls()
2027                .build()?,
2028        )?;
2029
2030        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
2031        let endpoint = ListIssues::builder()
2032            .created_on(DateTimeFilterPast::GreaterThanOrEqual(dt))
2033            .build()?;
2034        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2035
2036        Ok(())
2037    }
2038
2039    #[traced_test]
2040    #[test]
2041    fn test_list_issues_created_on_filter_less_than_days_ago() -> Result<(), Box<dyn Error>> {
2042        let _r_issues = ISSUES_LOCK.blocking_read();
2043        dotenvy::dotenv()?;
2044        let redmine = crate::api::Redmine::from_env(
2045            reqwest::blocking::Client::builder()
2046                .tls_backend_rustls()
2047                .build()?,
2048        )?;
2049
2050        let endpoint = ListIssues::builder()
2051            .created_on(DateTimeFilterPast::LessThanDaysAgo(5))
2052            .build()?;
2053        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2054
2055        Ok(())
2056    }
2057
2058    #[traced_test]
2059    #[test]
2060    fn test_list_issues_created_on_filter_more_than_days_ago() -> Result<(), Box<dyn Error>> {
2061        let _r_issues = ISSUES_LOCK.blocking_read();
2062        dotenvy::dotenv()?;
2063        let redmine = crate::api::Redmine::from_env(
2064            reqwest::blocking::Client::builder()
2065                .tls_backend_rustls()
2066                .build()?,
2067        )?;
2068
2069        let endpoint = ListIssues::builder()
2070            .created_on(DateTimeFilterPast::MoreThanDaysAgo(10))
2071            .build()?;
2072        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2073
2074        Ok(())
2075    }
2076
2077    #[traced_test]
2078    #[test]
2079    fn test_list_issues_created_on_filter_within_past_days() -> Result<(), Box<dyn Error>> {
2080        let _r_issues = ISSUES_LOCK.blocking_read();
2081        dotenvy::dotenv()?;
2082        let redmine = crate::api::Redmine::from_env(
2083            reqwest::blocking::Client::builder()
2084                .tls_backend_rustls()
2085                .build()?,
2086        )?;
2087
2088        let endpoint = ListIssues::builder()
2089            .created_on(DateTimeFilterPast::WithinPastDays(7))
2090            .build()?;
2091        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2092
2093        Ok(())
2094    }
2095
2096    #[traced_test]
2097    #[test]
2098    fn test_list_issues_created_on_filter_exact_days_ago() -> Result<(), Box<dyn Error>> {
2099        let _r_issues = ISSUES_LOCK.blocking_read();
2100        dotenvy::dotenv()?;
2101        let redmine = crate::api::Redmine::from_env(
2102            reqwest::blocking::Client::builder()
2103                .tls_backend_rustls()
2104                .build()?,
2105        )?;
2106
2107        let endpoint = ListIssues::builder()
2108            .created_on(DateTimeFilterPast::ExactDaysAgo(3))
2109            .build()?;
2110        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2111
2112        Ok(())
2113    }
2114
2115    #[traced_test]
2116    #[test]
2117    fn test_list_issues_created_on_filter_today() -> Result<(), Box<dyn Error>> {
2118        let _r_issues = ISSUES_LOCK.blocking_read();
2119        dotenvy::dotenv()?;
2120        let redmine = crate::api::Redmine::from_env(
2121            reqwest::blocking::Client::builder()
2122                .tls_backend_rustls()
2123                .build()?,
2124        )?;
2125
2126        let endpoint = ListIssues::builder()
2127            .created_on(DateTimeFilterPast::Today)
2128            .build()?;
2129        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2130
2131        Ok(())
2132    }
2133
2134    #[traced_test]
2135    #[test]
2136    fn test_list_issues_created_on_filter_yesterday() -> Result<(), Box<dyn Error>> {
2137        let _r_issues = ISSUES_LOCK.blocking_read();
2138        dotenvy::dotenv()?;
2139        let redmine = crate::api::Redmine::from_env(
2140            reqwest::blocking::Client::builder()
2141                .tls_backend_rustls()
2142                .build()?,
2143        )?;
2144
2145        let endpoint = ListIssues::builder()
2146            .created_on(DateTimeFilterPast::Yesterday)
2147            .build()?;
2148        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2149
2150        Ok(())
2151    }
2152
2153    #[traced_test]
2154    #[test]
2155    fn test_list_issues_created_on_filter_this_week() -> Result<(), Box<dyn Error>> {
2156        let _r_issues = ISSUES_LOCK.blocking_read();
2157        dotenvy::dotenv()?;
2158        let redmine = crate::api::Redmine::from_env(
2159            reqwest::blocking::Client::builder()
2160                .tls_backend_rustls()
2161                .build()?,
2162        )?;
2163
2164        let endpoint = ListIssues::builder()
2165            .created_on(DateTimeFilterPast::ThisWeek)
2166            .build()?;
2167        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2168
2169        Ok(())
2170    }
2171
2172    #[traced_test]
2173    #[test]
2174    fn test_list_issues_created_on_filter_last_week() -> Result<(), Box<dyn Error>> {
2175        let _r_issues = ISSUES_LOCK.blocking_read();
2176        dotenvy::dotenv()?;
2177        let redmine = crate::api::Redmine::from_env(
2178            reqwest::blocking::Client::builder()
2179                .tls_backend_rustls()
2180                .build()?,
2181        )?;
2182
2183        let endpoint = ListIssues::builder()
2184            .created_on(DateTimeFilterPast::LastWeek)
2185            .build()?;
2186        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2187
2188        Ok(())
2189    }
2190
2191    #[traced_test]
2192    #[test]
2193    fn test_list_issues_created_on_filter_last_two_weeks() -> Result<(), Box<dyn Error>> {
2194        let _r_issues = ISSUES_LOCK.blocking_read();
2195        dotenvy::dotenv()?;
2196        let redmine = crate::api::Redmine::from_env(
2197            reqwest::blocking::Client::builder()
2198                .tls_backend_rustls()
2199                .build()?,
2200        )?;
2201
2202        let endpoint = ListIssues::builder()
2203            .created_on(DateTimeFilterPast::LastTwoWeeks)
2204            .build()?;
2205        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2206
2207        Ok(())
2208    }
2209
2210    #[traced_test]
2211    #[test]
2212    fn test_list_issues_created_on_filter_this_month() -> Result<(), Box<dyn Error>> {
2213        let _r_issues = ISSUES_LOCK.blocking_read();
2214        dotenvy::dotenv()?;
2215        let redmine = crate::api::Redmine::from_env(
2216            reqwest::blocking::Client::builder()
2217                .tls_backend_rustls()
2218                .build()?,
2219        )?;
2220
2221        let endpoint = ListIssues::builder()
2222            .created_on(DateTimeFilterPast::ThisMonth)
2223            .build()?;
2224        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2225
2226        Ok(())
2227    }
2228
2229    #[traced_test]
2230    #[test]
2231    fn test_list_issues_created_on_filter_last_month() -> Result<(), Box<dyn Error>> {
2232        let _r_issues = ISSUES_LOCK.blocking_read();
2233        dotenvy::dotenv()?;
2234        let redmine = crate::api::Redmine::from_env(
2235            reqwest::blocking::Client::builder()
2236                .tls_backend_rustls()
2237                .build()?,
2238        )?;
2239
2240        let endpoint = ListIssues::builder()
2241            .created_on(DateTimeFilterPast::LastMonth)
2242            .build()?;
2243        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2244
2245        Ok(())
2246    }
2247
2248    #[traced_test]
2249    #[test]
2250    fn test_list_issues_created_on_filter_this_year() -> Result<(), Box<dyn Error>> {
2251        let _r_issues = ISSUES_LOCK.blocking_read();
2252        dotenvy::dotenv()?;
2253        let redmine = crate::api::Redmine::from_env(
2254            reqwest::blocking::Client::builder()
2255                .tls_backend_rustls()
2256                .build()?,
2257        )?;
2258
2259        let endpoint = ListIssues::builder()
2260            .created_on(DateTimeFilterPast::ThisYear)
2261            .build()?;
2262        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2263
2264        Ok(())
2265    }
2266
2267    #[traced_test]
2268    #[test]
2269    fn test_list_issues_created_on_filter_unset() -> Result<(), Box<dyn Error>> {
2270        let _r_issues = ISSUES_LOCK.blocking_read();
2271        dotenvy::dotenv()?;
2272        let redmine = crate::api::Redmine::from_env(
2273            reqwest::blocking::Client::builder()
2274                .tls_backend_rustls()
2275                .build()?,
2276        )?;
2277
2278        let endpoint = ListIssues::builder()
2279            .created_on(DateTimeFilterPast::Unset)
2280            .build()?;
2281        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2282
2283        Ok(())
2284    }
2285
2286    #[traced_test]
2287    #[test]
2288    fn test_list_issues_created_on_filter_any() -> Result<(), Box<dyn Error>> {
2289        let _r_issues = ISSUES_LOCK.blocking_read();
2290        dotenvy::dotenv()?;
2291        let redmine = crate::api::Redmine::from_env(
2292            reqwest::blocking::Client::builder()
2293                .tls_backend_rustls()
2294                .build()?,
2295        )?;
2296
2297        let endpoint = ListIssues::builder()
2298            .created_on(DateTimeFilterPast::Any)
2299            .build()?;
2300        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2301
2302        Ok(())
2303    }
2304
2305    #[traced_test]
2306    #[test]
2307    fn test_list_issues_updated_on_filter_exact_match() -> Result<(), Box<dyn Error>> {
2308        let _r_issues = ISSUES_LOCK.blocking_read();
2309        dotenvy::dotenv()?;
2310        let redmine = crate::api::Redmine::from_env(
2311            reqwest::blocking::Client::builder()
2312                .tls_backend_rustls()
2313                .build()?,
2314        )?;
2315
2316        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
2317        let endpoint = ListIssues::builder()
2318            .updated_on(DateTimeFilterPast::ExactMatch(dt))
2319            .build()?;
2320        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2321
2322        Ok(())
2323    }
2324
2325    #[traced_test]
2326    #[test]
2327    fn test_list_issues_updated_on_filter_range() -> Result<(), Box<dyn Error>> {
2328        let _r_issues = ISSUES_LOCK.blocking_read();
2329        dotenvy::dotenv()?;
2330        let redmine = crate::api::Redmine::from_env(
2331            reqwest::blocking::Client::builder()
2332                .tls_backend_rustls()
2333                .build()?,
2334        )?;
2335
2336        let dt_start = time::macros::datetime!(2023-01-01 00:00:00 UTC);
2337        let dt_end = time::macros::datetime!(2023-01-31 23:59:59 UTC);
2338        let endpoint = ListIssues::builder()
2339            .updated_on(DateTimeFilterPast::Range(dt_start, dt_end))
2340            .build()?;
2341        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2342
2343        Ok(())
2344    }
2345
2346    #[traced_test]
2347    #[test]
2348    fn test_list_issues_updated_on_filter_less_than_or_equal() -> Result<(), Box<dyn Error>> {
2349        let _r_issues = ISSUES_LOCK.blocking_read();
2350        dotenvy::dotenv()?;
2351        let redmine = crate::api::Redmine::from_env(
2352            reqwest::blocking::Client::builder()
2353                .tls_backend_rustls()
2354                .build()?,
2355        )?;
2356
2357        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
2358        let endpoint = ListIssues::builder()
2359            .updated_on(DateTimeFilterPast::LessThanOrEqual(dt))
2360            .build()?;
2361        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2362
2363        Ok(())
2364    }
2365
2366    #[traced_test]
2367    #[test]
2368    fn test_list_issues_updated_on_filter_greater_than_or_equal() -> Result<(), Box<dyn Error>> {
2369        let _r_issues = ISSUES_LOCK.blocking_read();
2370        dotenvy::dotenv()?;
2371        let redmine = crate::api::Redmine::from_env(
2372            reqwest::blocking::Client::builder()
2373                .tls_backend_rustls()
2374                .build()?,
2375        )?;
2376
2377        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
2378        let endpoint = ListIssues::builder()
2379            .updated_on(DateTimeFilterPast::GreaterThanOrEqual(dt))
2380            .build()?;
2381        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2382
2383        Ok(())
2384    }
2385
2386    #[traced_test]
2387    #[test]
2388    fn test_list_issues_updated_on_filter_less_than_days_ago() -> Result<(), Box<dyn Error>> {
2389        let _r_issues = ISSUES_LOCK.blocking_read();
2390        dotenvy::dotenv()?;
2391        let redmine = crate::api::Redmine::from_env(
2392            reqwest::blocking::Client::builder()
2393                .tls_backend_rustls()
2394                .build()?,
2395        )?;
2396
2397        let endpoint = ListIssues::builder()
2398            .updated_on(DateTimeFilterPast::LessThanDaysAgo(5))
2399            .build()?;
2400        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2401
2402        Ok(())
2403    }
2404
2405    #[traced_test]
2406    #[test]
2407    fn test_list_issues_updated_on_filter_more_than_days_ago() -> Result<(), Box<dyn Error>> {
2408        let _r_issues = ISSUES_LOCK.blocking_read();
2409        dotenvy::dotenv()?;
2410        let redmine = crate::api::Redmine::from_env(
2411            reqwest::blocking::Client::builder()
2412                .tls_backend_rustls()
2413                .build()?,
2414        )?;
2415
2416        let endpoint = ListIssues::builder()
2417            .updated_on(DateTimeFilterPast::MoreThanDaysAgo(10))
2418            .build()?;
2419        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2420
2421        Ok(())
2422    }
2423
2424    #[traced_test]
2425    #[test]
2426    fn test_list_issues_updated_on_filter_within_past_days() -> Result<(), Box<dyn Error>> {
2427        let _r_issues = ISSUES_LOCK.blocking_read();
2428        dotenvy::dotenv()?;
2429        let redmine = crate::api::Redmine::from_env(
2430            reqwest::blocking::Client::builder()
2431                .tls_backend_rustls()
2432                .build()?,
2433        )?;
2434
2435        let endpoint = ListIssues::builder()
2436            .updated_on(DateTimeFilterPast::WithinPastDays(7))
2437            .build()?;
2438        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2439
2440        Ok(())
2441    }
2442
2443    #[traced_test]
2444    #[test]
2445    fn test_list_issues_updated_on_filter_exact_days_ago() -> Result<(), Box<dyn Error>> {
2446        let _r_issues = ISSUES_LOCK.blocking_read();
2447        dotenvy::dotenv()?;
2448        let redmine = crate::api::Redmine::from_env(
2449            reqwest::blocking::Client::builder()
2450                .tls_backend_rustls()
2451                .build()?,
2452        )?;
2453
2454        let endpoint = ListIssues::builder()
2455            .updated_on(DateTimeFilterPast::ExactDaysAgo(3))
2456            .build()?;
2457        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2458
2459        Ok(())
2460    }
2461
2462    #[traced_test]
2463    #[test]
2464    fn test_list_issues_updated_on_filter_today() -> Result<(), Box<dyn Error>> {
2465        let _r_issues = ISSUES_LOCK.blocking_read();
2466        dotenvy::dotenv()?;
2467        let redmine = crate::api::Redmine::from_env(
2468            reqwest::blocking::Client::builder()
2469                .tls_backend_rustls()
2470                .build()?,
2471        )?;
2472
2473        let endpoint = ListIssues::builder()
2474            .updated_on(DateTimeFilterPast::Today)
2475            .build()?;
2476        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2477
2478        Ok(())
2479    }
2480
2481    #[traced_test]
2482    #[test]
2483    fn test_list_issues_updated_on_filter_yesterday() -> Result<(), Box<dyn Error>> {
2484        let _r_issues = ISSUES_LOCK.blocking_read();
2485        dotenvy::dotenv()?;
2486        let redmine = crate::api::Redmine::from_env(
2487            reqwest::blocking::Client::builder()
2488                .tls_backend_rustls()
2489                .build()?,
2490        )?;
2491
2492        let endpoint = ListIssues::builder()
2493            .updated_on(DateTimeFilterPast::Yesterday)
2494            .build()?;
2495        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2496
2497        Ok(())
2498    }
2499
2500    #[traced_test]
2501    #[test]
2502    fn test_list_issues_updated_on_filter_this_week() -> Result<(), Box<dyn Error>> {
2503        let _r_issues = ISSUES_LOCK.blocking_read();
2504        dotenvy::dotenv()?;
2505        let redmine = crate::api::Redmine::from_env(
2506            reqwest::blocking::Client::builder()
2507                .tls_backend_rustls()
2508                .build()?,
2509        )?;
2510
2511        let endpoint = ListIssues::builder()
2512            .updated_on(DateTimeFilterPast::ThisWeek)
2513            .build()?;
2514        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2515
2516        Ok(())
2517    }
2518
2519    #[traced_test]
2520    #[test]
2521    fn test_list_issues_updated_on_filter_last_week() -> Result<(), Box<dyn Error>> {
2522        let _r_issues = ISSUES_LOCK.blocking_read();
2523        dotenvy::dotenv()?;
2524        let redmine = crate::api::Redmine::from_env(
2525            reqwest::blocking::Client::builder()
2526                .tls_backend_rustls()
2527                .build()?,
2528        )?;
2529
2530        let endpoint = ListIssues::builder()
2531            .updated_on(DateTimeFilterPast::LastWeek)
2532            .build()?;
2533        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2534
2535        Ok(())
2536    }
2537
2538    #[traced_test]
2539    #[test]
2540    fn test_list_issues_updated_on_filter_last_two_weeks() -> Result<(), Box<dyn Error>> {
2541        let _r_issues = ISSUES_LOCK.blocking_read();
2542        dotenvy::dotenv()?;
2543        let redmine = crate::api::Redmine::from_env(
2544            reqwest::blocking::Client::builder()
2545                .tls_backend_rustls()
2546                .build()?,
2547        )?;
2548
2549        let endpoint = ListIssues::builder()
2550            .updated_on(DateTimeFilterPast::LastTwoWeeks)
2551            .build()?;
2552        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2553
2554        Ok(())
2555    }
2556
2557    #[traced_test]
2558    #[test]
2559    fn test_list_issues_updated_on_filter_this_month() -> Result<(), Box<dyn Error>> {
2560        let _r_issues = ISSUES_LOCK.blocking_read();
2561        dotenvy::dotenv()?;
2562        let redmine = crate::api::Redmine::from_env(
2563            reqwest::blocking::Client::builder()
2564                .tls_backend_rustls()
2565                .build()?,
2566        )?;
2567
2568        let endpoint = ListIssues::builder()
2569            .updated_on(DateTimeFilterPast::ThisMonth)
2570            .build()?;
2571        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2572
2573        Ok(())
2574    }
2575
2576    #[traced_test]
2577    #[test]
2578    fn test_list_issues_updated_on_filter_last_month() -> Result<(), Box<dyn Error>> {
2579        let _r_issues = ISSUES_LOCK.blocking_read();
2580        dotenvy::dotenv()?;
2581        let redmine = crate::api::Redmine::from_env(
2582            reqwest::blocking::Client::builder()
2583                .tls_backend_rustls()
2584                .build()?,
2585        )?;
2586
2587        let endpoint = ListIssues::builder()
2588            .updated_on(DateTimeFilterPast::LastMonth)
2589            .build()?;
2590        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2591
2592        Ok(())
2593    }
2594
2595    #[traced_test]
2596    #[test]
2597    fn test_list_issues_updated_on_filter_this_year() -> Result<(), Box<dyn Error>> {
2598        let _r_issues = ISSUES_LOCK.blocking_read();
2599        dotenvy::dotenv()?;
2600        let redmine = crate::api::Redmine::from_env(
2601            reqwest::blocking::Client::builder()
2602                .tls_backend_rustls()
2603                .build()?,
2604        )?;
2605
2606        let endpoint = ListIssues::builder()
2607            .updated_on(DateTimeFilterPast::ThisYear)
2608            .build()?;
2609        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2610
2611        Ok(())
2612    }
2613
2614    #[traced_test]
2615    #[test]
2616    fn test_list_issues_updated_on_filter_unset() -> Result<(), Box<dyn Error>> {
2617        let _r_issues = ISSUES_LOCK.blocking_read();
2618        dotenvy::dotenv()?;
2619        let redmine = crate::api::Redmine::from_env(
2620            reqwest::blocking::Client::builder()
2621                .tls_backend_rustls()
2622                .build()?,
2623        )?;
2624
2625        let endpoint = ListIssues::builder()
2626            .updated_on(DateTimeFilterPast::Unset)
2627            .build()?;
2628        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2629
2630        Ok(())
2631    }
2632
2633    #[traced_test]
2634    #[test]
2635    fn test_list_issues_updated_on_filter_any() -> Result<(), Box<dyn Error>> {
2636        let _r_issues = ISSUES_LOCK.blocking_read();
2637        dotenvy::dotenv()?;
2638        let redmine = crate::api::Redmine::from_env(
2639            reqwest::blocking::Client::builder()
2640                .tls_backend_rustls()
2641                .build()?,
2642        )?;
2643
2644        let endpoint = ListIssues::builder()
2645            .updated_on(DateTimeFilterPast::Any)
2646            .build()?;
2647        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2648
2649        Ok(())
2650    }
2651
2652    #[traced_test]
2653    #[test]
2654    fn test_list_issues_start_date_filter_exact_match() -> Result<(), Box<dyn Error>> {
2655        let _r_issues = ISSUES_LOCK.blocking_read();
2656        dotenvy::dotenv()?;
2657        let redmine = crate::api::Redmine::from_env(
2658            reqwest::blocking::Client::builder()
2659                .tls_backend_rustls()
2660                .build()?,
2661        )?;
2662
2663        let dt = time::macros::date!(2023 - 01 - 15);
2664        let endpoint = ListIssues::builder()
2665            .start_date(DateFilter::ExactMatch(dt))
2666            .build()?;
2667        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2668
2669        Ok(())
2670    }
2671
2672    #[traced_test]
2673    #[test]
2674    fn test_list_issues_start_date_filter_range() -> Result<(), Box<dyn Error>> {
2675        let _r_issues = ISSUES_LOCK.blocking_read();
2676        dotenvy::dotenv()?;
2677        let redmine = crate::api::Redmine::from_env(
2678            reqwest::blocking::Client::builder()
2679                .tls_backend_rustls()
2680                .build()?,
2681        )?;
2682
2683        let dt_start = time::macros::date!(2023 - 01 - 01);
2684        let dt_end = time::macros::date!(2023 - 01 - 31);
2685        let endpoint = ListIssues::builder()
2686            .start_date(DateFilter::Range(dt_start, dt_end))
2687            .build()?;
2688        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2689
2690        Ok(())
2691    }
2692
2693    #[traced_test]
2694    #[test]
2695    fn test_list_issues_start_date_filter_less_than_or_equal() -> Result<(), Box<dyn Error>> {
2696        let _r_issues = ISSUES_LOCK.blocking_read();
2697        dotenvy::dotenv()?;
2698        let redmine = crate::api::Redmine::from_env(
2699            reqwest::blocking::Client::builder()
2700                .tls_backend_rustls()
2701                .build()?,
2702        )?;
2703
2704        let dt = time::macros::date!(2023 - 01 - 15);
2705        let endpoint = ListIssues::builder()
2706            .start_date(DateFilter::LessThanOrEqual(dt))
2707            .build()?;
2708        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2709
2710        Ok(())
2711    }
2712
2713    #[traced_test]
2714    #[test]
2715    fn test_list_issues_start_date_filter_greater_than_or_equal() -> Result<(), Box<dyn Error>> {
2716        let _r_issues = ISSUES_LOCK.blocking_read();
2717        dotenvy::dotenv()?;
2718        let redmine = crate::api::Redmine::from_env(
2719            reqwest::blocking::Client::builder()
2720                .tls_backend_rustls()
2721                .build()?,
2722        )?;
2723
2724        let dt = time::macros::date!(2023 - 01 - 15);
2725        let endpoint = ListIssues::builder()
2726            .start_date(DateFilter::GreaterThanOrEqual(dt))
2727            .build()?;
2728        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2729
2730        Ok(())
2731    }
2732
2733    #[traced_test]
2734    #[test]
2735    fn test_list_issues_start_date_filter_less_than_days_ago() -> Result<(), Box<dyn Error>> {
2736        let _r_issues = ISSUES_LOCK.blocking_read();
2737        dotenvy::dotenv()?;
2738        let redmine = crate::api::Redmine::from_env(
2739            reqwest::blocking::Client::builder()
2740                .tls_backend_rustls()
2741                .build()?,
2742        )?;
2743
2744        let endpoint = ListIssues::builder()
2745            .start_date(DateFilter::LessThanDaysAgo(5))
2746            .build()?;
2747        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2748
2749        Ok(())
2750    }
2751
2752    #[traced_test]
2753    #[test]
2754    fn test_list_issues_start_date_filter_more_than_days_ago() -> Result<(), Box<dyn Error>> {
2755        let _r_issues = ISSUES_LOCK.blocking_read();
2756        dotenvy::dotenv()?;
2757        let redmine = crate::api::Redmine::from_env(
2758            reqwest::blocking::Client::builder()
2759                .tls_backend_rustls()
2760                .build()?,
2761        )?;
2762
2763        let endpoint = ListIssues::builder()
2764            .start_date(DateFilter::MoreThanDaysAgo(10))
2765            .build()?;
2766        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2767
2768        Ok(())
2769    }
2770
2771    #[traced_test]
2772    #[test]
2773    fn test_list_issues_start_date_filter_within_past_days() -> Result<(), Box<dyn Error>> {
2774        let _r_issues = ISSUES_LOCK.blocking_read();
2775        dotenvy::dotenv()?;
2776        let redmine = crate::api::Redmine::from_env(
2777            reqwest::blocking::Client::builder()
2778                .tls_backend_rustls()
2779                .build()?,
2780        )?;
2781
2782        let endpoint = ListIssues::builder()
2783            .start_date(DateFilter::WithinPastDays(7))
2784            .build()?;
2785        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2786
2787        Ok(())
2788    }
2789
2790    #[traced_test]
2791    #[test]
2792    fn test_list_issues_start_date_filter_exact_days_ago() -> Result<(), Box<dyn Error>> {
2793        let _r_issues = ISSUES_LOCK.blocking_read();
2794        dotenvy::dotenv()?;
2795        let redmine = crate::api::Redmine::from_env(
2796            reqwest::blocking::Client::builder()
2797                .tls_backend_rustls()
2798                .build()?,
2799        )?;
2800
2801        let endpoint = ListIssues::builder()
2802            .start_date(DateFilter::ExactDaysAgo(3))
2803            .build()?;
2804        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2805
2806        Ok(())
2807    }
2808
2809    #[traced_test]
2810    #[test]
2811    fn test_list_issues_start_date_filter_in_less_than_days() -> Result<(), Box<dyn Error>> {
2812        let _r_issues = ISSUES_LOCK.blocking_read();
2813        dotenvy::dotenv()?;
2814        let redmine = crate::api::Redmine::from_env(
2815            reqwest::blocking::Client::builder()
2816                .tls_backend_rustls()
2817                .build()?,
2818        )?;
2819
2820        let endpoint = ListIssues::builder()
2821            .start_date(DateFilter::InLessThanDays(5))
2822            .build()?;
2823        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2824
2825        Ok(())
2826    }
2827
2828    #[traced_test]
2829    #[test]
2830    fn test_list_issues_start_date_filter_in_more_than_days() -> Result<(), Box<dyn Error>> {
2831        let _r_issues = ISSUES_LOCK.blocking_read();
2832        dotenvy::dotenv()?;
2833        let redmine = crate::api::Redmine::from_env(
2834            reqwest::blocking::Client::builder()
2835                .tls_backend_rustls()
2836                .build()?,
2837        )?;
2838
2839        let endpoint = ListIssues::builder()
2840            .start_date(DateFilter::InMoreThanDays(10))
2841            .build()?;
2842        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2843
2844        Ok(())
2845    }
2846
2847    #[traced_test]
2848    #[test]
2849    fn test_list_issues_start_date_filter_within_future_days() -> Result<(), Box<dyn Error>> {
2850        let _r_issues = ISSUES_LOCK.blocking_read();
2851        dotenvy::dotenv()?;
2852        let redmine = crate::api::Redmine::from_env(
2853            reqwest::blocking::Client::builder()
2854                .tls_backend_rustls()
2855                .build()?,
2856        )?;
2857
2858        let endpoint = ListIssues::builder()
2859            .start_date(DateFilter::WithinFutureDays(7))
2860            .build()?;
2861        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2862
2863        Ok(())
2864    }
2865
2866    #[traced_test]
2867    #[test]
2868    fn test_list_issues_start_date_filter_in_exact_days() -> Result<(), Box<dyn Error>> {
2869        let _r_issues = ISSUES_LOCK.blocking_read();
2870        dotenvy::dotenv()?;
2871        let redmine = crate::api::Redmine::from_env(
2872            reqwest::blocking::Client::builder()
2873                .tls_backend_rustls()
2874                .build()?,
2875        )?;
2876
2877        let endpoint = ListIssues::builder()
2878            .start_date(DateFilter::InExactDays(3))
2879            .build()?;
2880        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2881
2882        Ok(())
2883    }
2884
2885    #[traced_test]
2886    #[test]
2887    fn test_list_issues_start_date_filter_today() -> Result<(), Box<dyn Error>> {
2888        let _r_issues = ISSUES_LOCK.blocking_read();
2889        dotenvy::dotenv()?;
2890        let redmine = crate::api::Redmine::from_env(
2891            reqwest::blocking::Client::builder()
2892                .tls_backend_rustls()
2893                .build()?,
2894        )?;
2895
2896        let endpoint = ListIssues::builder()
2897            .start_date(DateFilter::Today)
2898            .build()?;
2899        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2900
2901        Ok(())
2902    }
2903
2904    #[traced_test]
2905    #[test]
2906    fn test_list_issues_start_date_filter_yesterday() -> Result<(), Box<dyn Error>> {
2907        let _r_issues = ISSUES_LOCK.blocking_read();
2908        dotenvy::dotenv()?;
2909        let redmine = crate::api::Redmine::from_env(
2910            reqwest::blocking::Client::builder()
2911                .tls_backend_rustls()
2912                .build()?,
2913        )?;
2914
2915        let endpoint = ListIssues::builder()
2916            .start_date(DateFilter::Yesterday)
2917            .build()?;
2918        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2919
2920        Ok(())
2921    }
2922
2923    #[traced_test]
2924    #[test]
2925    fn test_list_issues_start_date_filter_tomorrow() -> Result<(), Box<dyn Error>> {
2926        let _r_issues = ISSUES_LOCK.blocking_read();
2927        dotenvy::dotenv()?;
2928        let redmine = crate::api::Redmine::from_env(
2929            reqwest::blocking::Client::builder()
2930                .tls_backend_rustls()
2931                .build()?,
2932        )?;
2933
2934        let endpoint = ListIssues::builder()
2935            .start_date(DateFilter::Tomorrow)
2936            .build()?;
2937        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2938
2939        Ok(())
2940    }
2941
2942    #[traced_test]
2943    #[test]
2944    fn test_list_issues_start_date_filter_this_week() -> Result<(), Box<dyn Error>> {
2945        let _r_issues = ISSUES_LOCK.blocking_read();
2946        dotenvy::dotenv()?;
2947        let redmine = crate::api::Redmine::from_env(
2948            reqwest::blocking::Client::builder()
2949                .tls_backend_rustls()
2950                .build()?,
2951        )?;
2952
2953        let endpoint = ListIssues::builder()
2954            .start_date(DateFilter::ThisWeek)
2955            .build()?;
2956        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2957
2958        Ok(())
2959    }
2960
2961    #[traced_test]
2962    #[test]
2963    fn test_list_issues_start_date_filter_last_week() -> Result<(), Box<dyn Error>> {
2964        let _r_issues = ISSUES_LOCK.blocking_read();
2965        dotenvy::dotenv()?;
2966        let redmine = crate::api::Redmine::from_env(
2967            reqwest::blocking::Client::builder()
2968                .tls_backend_rustls()
2969                .build()?,
2970        )?;
2971
2972        let endpoint = ListIssues::builder()
2973            .start_date(DateFilter::LastWeek)
2974            .build()?;
2975        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2976
2977        Ok(())
2978    }
2979
2980    #[traced_test]
2981    #[test]
2982    fn test_list_issues_start_date_filter_last_two_weeks() -> Result<(), Box<dyn Error>> {
2983        let _r_issues = ISSUES_LOCK.blocking_read();
2984        dotenvy::dotenv()?;
2985        let redmine = crate::api::Redmine::from_env(
2986            reqwest::blocking::Client::builder()
2987                .tls_backend_rustls()
2988                .build()?,
2989        )?;
2990
2991        let endpoint = ListIssues::builder()
2992            .start_date(DateFilter::LastTwoWeeks)
2993            .build()?;
2994        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2995
2996        Ok(())
2997    }
2998
2999    #[traced_test]
3000    #[test]
3001    fn test_list_issues_start_date_filter_next_week() -> Result<(), Box<dyn Error>> {
3002        let _r_issues = ISSUES_LOCK.blocking_read();
3003        dotenvy::dotenv()?;
3004        let redmine = crate::api::Redmine::from_env(
3005            reqwest::blocking::Client::builder()
3006                .tls_backend_rustls()
3007                .build()?,
3008        )?;
3009
3010        let endpoint = ListIssues::builder()
3011            .start_date(DateFilter::NextWeek)
3012            .build()?;
3013        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3014
3015        Ok(())
3016    }
3017
3018    #[traced_test]
3019    #[test]
3020    fn test_list_issues_start_date_filter_this_month() -> Result<(), Box<dyn Error>> {
3021        let _r_issues = ISSUES_LOCK.blocking_read();
3022        dotenvy::dotenv()?;
3023        let redmine = crate::api::Redmine::from_env(
3024            reqwest::blocking::Client::builder()
3025                .tls_backend_rustls()
3026                .build()?,
3027        )?;
3028
3029        let endpoint = ListIssues::builder()
3030            .start_date(DateFilter::ThisMonth)
3031            .build()?;
3032        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3033
3034        Ok(())
3035    }
3036
3037    #[traced_test]
3038    #[test]
3039    fn test_list_issues_start_date_filter_last_month() -> Result<(), Box<dyn Error>> {
3040        let _r_issues = ISSUES_LOCK.blocking_read();
3041        dotenvy::dotenv()?;
3042        let redmine = crate::api::Redmine::from_env(
3043            reqwest::blocking::Client::builder()
3044                .tls_backend_rustls()
3045                .build()?,
3046        )?;
3047
3048        let endpoint = ListIssues::builder()
3049            .start_date(DateFilter::LastMonth)
3050            .build()?;
3051        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3052
3053        Ok(())
3054    }
3055
3056    #[traced_test]
3057    #[test]
3058    fn test_list_issues_start_date_filter_next_month() -> Result<(), Box<dyn Error>> {
3059        let _r_issues = ISSUES_LOCK.blocking_read();
3060        dotenvy::dotenv()?;
3061        let redmine = crate::api::Redmine::from_env(
3062            reqwest::blocking::Client::builder()
3063                .tls_backend_rustls()
3064                .build()?,
3065        )?;
3066
3067        let endpoint = ListIssues::builder()
3068            .start_date(DateFilter::NextMonth)
3069            .build()?;
3070        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3071
3072        Ok(())
3073    }
3074
3075    #[traced_test]
3076    #[test]
3077    fn test_list_issues_start_date_filter_this_year() -> Result<(), Box<dyn Error>> {
3078        let _r_issues = ISSUES_LOCK.blocking_read();
3079        dotenvy::dotenv()?;
3080        let redmine = crate::api::Redmine::from_env(
3081            reqwest::blocking::Client::builder()
3082                .tls_backend_rustls()
3083                .build()?,
3084        )?;
3085
3086        let endpoint = ListIssues::builder()
3087            .start_date(DateFilter::ThisYear)
3088            .build()?;
3089        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3090
3091        Ok(())
3092    }
3093
3094    #[traced_test]
3095    #[test]
3096    fn test_list_issues_start_date_filter_unset() -> Result<(), Box<dyn Error>> {
3097        let _r_issues = ISSUES_LOCK.blocking_read();
3098        dotenvy::dotenv()?;
3099        let redmine = crate::api::Redmine::from_env(
3100            reqwest::blocking::Client::builder()
3101                .tls_backend_rustls()
3102                .build()?,
3103        )?;
3104
3105        let endpoint = ListIssues::builder()
3106            .start_date(DateFilter::Unset)
3107            .build()?;
3108        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3109
3110        Ok(())
3111    }
3112
3113    #[traced_test]
3114    #[test]
3115    fn test_list_issues_start_date_filter_any() -> Result<(), Box<dyn Error>> {
3116        let _r_issues = ISSUES_LOCK.blocking_read();
3117        dotenvy::dotenv()?;
3118        let redmine = crate::api::Redmine::from_env(
3119            reqwest::blocking::Client::builder()
3120                .tls_backend_rustls()
3121                .build()?,
3122        )?;
3123
3124        let endpoint = ListIssues::builder().start_date(DateFilter::Any).build()?;
3125        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3126
3127        Ok(())
3128    }
3129
3130    #[traced_test]
3131    #[test]
3132    fn test_list_issues_due_date_filter_exact_match() -> Result<(), Box<dyn Error>> {
3133        let _r_issues = ISSUES_LOCK.blocking_read();
3134        dotenvy::dotenv()?;
3135        let redmine = crate::api::Redmine::from_env(
3136            reqwest::blocking::Client::builder()
3137                .tls_backend_rustls()
3138                .build()?,
3139        )?;
3140
3141        let dt = time::macros::date!(2023 - 01 - 15);
3142        let endpoint = ListIssues::builder()
3143            .due_date(DateFilter::ExactMatch(dt))
3144            .build()?;
3145        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3146
3147        Ok(())
3148    }
3149
3150    #[traced_test]
3151    #[test]
3152    fn test_list_issues_due_date_filter_range() -> Result<(), Box<dyn Error>> {
3153        let _r_issues = ISSUES_LOCK.blocking_read();
3154        dotenvy::dotenv()?;
3155        let redmine = crate::api::Redmine::from_env(
3156            reqwest::blocking::Client::builder()
3157                .tls_backend_rustls()
3158                .build()?,
3159        )?;
3160
3161        let dt_start = time::macros::date!(2023 - 01 - 01);
3162        let dt_end = time::macros::date!(2023 - 01 - 31);
3163        let endpoint = ListIssues::builder()
3164            .due_date(DateFilter::Range(dt_start, dt_end))
3165            .build()?;
3166        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3167
3168        Ok(())
3169    }
3170
3171    #[traced_test]
3172    #[test]
3173    fn test_list_issues_due_date_filter_less_than_or_equal() -> Result<(), Box<dyn Error>> {
3174        let _r_issues = ISSUES_LOCK.blocking_read();
3175        dotenvy::dotenv()?;
3176        let redmine = crate::api::Redmine::from_env(
3177            reqwest::blocking::Client::builder()
3178                .tls_backend_rustls()
3179                .build()?,
3180        )?;
3181
3182        let dt = time::macros::date!(2023 - 01 - 15);
3183        let endpoint = ListIssues::builder()
3184            .due_date(DateFilter::LessThanOrEqual(dt))
3185            .build()?;
3186        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3187
3188        Ok(())
3189    }
3190
3191    #[traced_test]
3192    #[test]
3193    fn test_list_issues_due_date_filter_greater_than_or_equal() -> Result<(), Box<dyn Error>> {
3194        let _r_issues = ISSUES_LOCK.blocking_read();
3195        dotenvy::dotenv()?;
3196        let redmine = crate::api::Redmine::from_env(
3197            reqwest::blocking::Client::builder()
3198                .tls_backend_rustls()
3199                .build()?,
3200        )?;
3201
3202        let dt = time::macros::date!(2023 - 01 - 15);
3203        let endpoint = ListIssues::builder()
3204            .due_date(DateFilter::GreaterThanOrEqual(dt))
3205            .build()?;
3206        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3207
3208        Ok(())
3209    }
3210
3211    #[traced_test]
3212    #[test]
3213    fn test_list_issues_due_date_filter_less_than_days_ago() -> Result<(), Box<dyn Error>> {
3214        let _r_issues = ISSUES_LOCK.blocking_read();
3215        dotenvy::dotenv()?;
3216        let redmine = crate::api::Redmine::from_env(
3217            reqwest::blocking::Client::builder()
3218                .tls_backend_rustls()
3219                .build()?,
3220        )?;
3221
3222        let endpoint = ListIssues::builder()
3223            .due_date(DateFilter::LessThanDaysAgo(5))
3224            .build()?;
3225        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3226
3227        Ok(())
3228    }
3229
3230    #[traced_test]
3231    #[test]
3232    fn test_list_issues_due_date_filter_more_than_days_ago() -> Result<(), Box<dyn Error>> {
3233        let _r_issues = ISSUES_LOCK.blocking_read();
3234        dotenvy::dotenv()?;
3235        let redmine = crate::api::Redmine::from_env(
3236            reqwest::blocking::Client::builder()
3237                .tls_backend_rustls()
3238                .build()?,
3239        )?;
3240
3241        let endpoint = ListIssues::builder()
3242            .due_date(DateFilter::MoreThanDaysAgo(10))
3243            .build()?;
3244        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3245
3246        Ok(())
3247    }
3248
3249    #[traced_test]
3250    #[test]
3251    fn test_list_issues_due_date_filter_within_past_days() -> Result<(), Box<dyn Error>> {
3252        let _r_issues = ISSUES_LOCK.blocking_read();
3253        dotenvy::dotenv()?;
3254        let redmine = crate::api::Redmine::from_env(
3255            reqwest::blocking::Client::builder()
3256                .tls_backend_rustls()
3257                .build()?,
3258        )?;
3259
3260        let endpoint = ListIssues::builder()
3261            .due_date(DateFilter::WithinPastDays(7))
3262            .build()?;
3263        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3264
3265        Ok(())
3266    }
3267
3268    #[traced_test]
3269    #[test]
3270    fn test_list_issues_due_date_filter_exact_days_ago() -> Result<(), Box<dyn Error>> {
3271        let _r_issues = ISSUES_LOCK.blocking_read();
3272        dotenvy::dotenv()?;
3273        let redmine = crate::api::Redmine::from_env(
3274            reqwest::blocking::Client::builder()
3275                .tls_backend_rustls()
3276                .build()?,
3277        )?;
3278
3279        let endpoint = ListIssues::builder()
3280            .due_date(DateFilter::ExactDaysAgo(3))
3281            .build()?;
3282        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3283
3284        Ok(())
3285    }
3286
3287    #[traced_test]
3288    #[test]
3289    fn test_list_issues_due_date_filter_in_less_than_days() -> Result<(), Box<dyn Error>> {
3290        let _r_issues = ISSUES_LOCK.blocking_read();
3291        dotenvy::dotenv()?;
3292        let redmine = crate::api::Redmine::from_env(
3293            reqwest::blocking::Client::builder()
3294                .tls_backend_rustls()
3295                .build()?,
3296        )?;
3297
3298        let endpoint = ListIssues::builder()
3299            .due_date(DateFilter::InLessThanDays(5))
3300            .build()?;
3301        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3302
3303        Ok(())
3304    }
3305
3306    #[traced_test]
3307    #[test]
3308    fn test_list_issues_due_date_filter_in_more_than_days() -> Result<(), Box<dyn Error>> {
3309        let _r_issues = ISSUES_LOCK.blocking_read();
3310        dotenvy::dotenv()?;
3311        let redmine = crate::api::Redmine::from_env(
3312            reqwest::blocking::Client::builder()
3313                .tls_backend_rustls()
3314                .build()?,
3315        )?;
3316
3317        let endpoint = ListIssues::builder()
3318            .due_date(DateFilter::InMoreThanDays(10))
3319            .build()?;
3320        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3321
3322        Ok(())
3323    }
3324
3325    #[traced_test]
3326    #[test]
3327    fn test_list_issues_due_date_filter_within_future_days() -> Result<(), Box<dyn Error>> {
3328        let _r_issues = ISSUES_LOCK.blocking_read();
3329        dotenvy::dotenv()?;
3330        let redmine = crate::api::Redmine::from_env(
3331            reqwest::blocking::Client::builder()
3332                .tls_backend_rustls()
3333                .build()?,
3334        )?;
3335
3336        let endpoint = ListIssues::builder()
3337            .due_date(DateFilter::WithinFutureDays(7))
3338            .build()?;
3339        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3340
3341        Ok(())
3342    }
3343
3344    #[traced_test]
3345    #[test]
3346    fn test_list_issues_due_date_filter_in_exact_days() -> Result<(), Box<dyn Error>> {
3347        let _r_issues = ISSUES_LOCK.blocking_read();
3348        dotenvy::dotenv()?;
3349        let redmine = crate::api::Redmine::from_env(
3350            reqwest::blocking::Client::builder()
3351                .tls_backend_rustls()
3352                .build()?,
3353        )?;
3354
3355        let endpoint = ListIssues::builder()
3356            .due_date(DateFilter::InExactDays(3))
3357            .build()?;
3358        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3359
3360        Ok(())
3361    }
3362
3363    #[traced_test]
3364    #[test]
3365    fn test_list_issues_due_date_filter_today() -> Result<(), Box<dyn Error>> {
3366        let _r_issues = ISSUES_LOCK.blocking_read();
3367        dotenvy::dotenv()?;
3368        let redmine = crate::api::Redmine::from_env(
3369            reqwest::blocking::Client::builder()
3370                .tls_backend_rustls()
3371                .build()?,
3372        )?;
3373
3374        let endpoint = ListIssues::builder().due_date(DateFilter::Today).build()?;
3375        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3376
3377        Ok(())
3378    }
3379
3380    #[traced_test]
3381    #[test]
3382    fn test_list_issues_due_date_filter_yesterday() -> Result<(), Box<dyn Error>> {
3383        let _r_issues = ISSUES_LOCK.blocking_read();
3384        dotenvy::dotenv()?;
3385        let redmine = crate::api::Redmine::from_env(
3386            reqwest::blocking::Client::builder()
3387                .tls_backend_rustls()
3388                .build()?,
3389        )?;
3390
3391        let endpoint = ListIssues::builder()
3392            .due_date(DateFilter::Yesterday)
3393            .build()?;
3394        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3395
3396        Ok(())
3397    }
3398
3399    #[traced_test]
3400    #[test]
3401    fn test_list_issues_due_date_filter_tomorrow() -> Result<(), Box<dyn Error>> {
3402        let _r_issues = ISSUES_LOCK.blocking_read();
3403        dotenvy::dotenv()?;
3404        let redmine = crate::api::Redmine::from_env(
3405            reqwest::blocking::Client::builder()
3406                .tls_backend_rustls()
3407                .build()?,
3408        )?;
3409
3410        let endpoint = ListIssues::builder()
3411            .due_date(DateFilter::Tomorrow)
3412            .build()?;
3413        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3414
3415        Ok(())
3416    }
3417
3418    #[traced_test]
3419    #[test]
3420    fn test_list_issues_due_date_filter_this_week() -> Result<(), Box<dyn Error>> {
3421        let _r_issues = ISSUES_LOCK.blocking_read();
3422        dotenvy::dotenv()?;
3423        let redmine = crate::api::Redmine::from_env(
3424            reqwest::blocking::Client::builder()
3425                .tls_backend_rustls()
3426                .build()?,
3427        )?;
3428
3429        let endpoint = ListIssues::builder()
3430            .due_date(DateFilter::ThisWeek)
3431            .build()?;
3432        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3433
3434        Ok(())
3435    }
3436
3437    #[traced_test]
3438    #[test]
3439    fn test_list_issues_due_date_filter_last_week() -> Result<(), Box<dyn Error>> {
3440        let _r_issues = ISSUES_LOCK.blocking_read();
3441        dotenvy::dotenv()?;
3442        let redmine = crate::api::Redmine::from_env(
3443            reqwest::blocking::Client::builder()
3444                .tls_backend_rustls()
3445                .build()?,
3446        )?;
3447
3448        let endpoint = ListIssues::builder()
3449            .due_date(DateFilter::LastWeek)
3450            .build()?;
3451        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3452
3453        Ok(())
3454    }
3455
3456    #[traced_test]
3457    #[test]
3458    fn test_list_issues_due_date_filter_last_two_weeks() -> Result<(), Box<dyn Error>> {
3459        let _r_issues = ISSUES_LOCK.blocking_read();
3460        dotenvy::dotenv()?;
3461        let redmine = crate::api::Redmine::from_env(
3462            reqwest::blocking::Client::builder()
3463                .tls_backend_rustls()
3464                .build()?,
3465        )?;
3466
3467        let endpoint = ListIssues::builder()
3468            .due_date(DateFilter::LastTwoWeeks)
3469            .build()?;
3470        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3471
3472        Ok(())
3473    }
3474
3475    #[traced_test]
3476    #[test]
3477    fn test_list_issues_due_date_filter_next_week() -> Result<(), Box<dyn Error>> {
3478        let _r_issues = ISSUES_LOCK.blocking_read();
3479        dotenvy::dotenv()?;
3480        let redmine = crate::api::Redmine::from_env(
3481            reqwest::blocking::Client::builder()
3482                .tls_backend_rustls()
3483                .build()?,
3484        )?;
3485
3486        let endpoint = ListIssues::builder()
3487            .due_date(DateFilter::NextWeek)
3488            .build()?;
3489        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3490
3491        Ok(())
3492    }
3493
3494    #[traced_test]
3495    #[test]
3496    fn test_list_issues_due_date_filter_this_month() -> Result<(), Box<dyn Error>> {
3497        let _r_issues = ISSUES_LOCK.blocking_read();
3498        dotenvy::dotenv()?;
3499        let redmine = crate::api::Redmine::from_env(
3500            reqwest::blocking::Client::builder()
3501                .tls_backend_rustls()
3502                .build()?,
3503        )?;
3504
3505        let endpoint = ListIssues::builder()
3506            .due_date(DateFilter::ThisMonth)
3507            .build()?;
3508        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3509
3510        Ok(())
3511    }
3512
3513    #[traced_test]
3514    #[test]
3515    fn test_list_issues_due_date_filter_last_month() -> Result<(), Box<dyn Error>> {
3516        let _r_issues = ISSUES_LOCK.blocking_read();
3517        dotenvy::dotenv()?;
3518        let redmine = crate::api::Redmine::from_env(
3519            reqwest::blocking::Client::builder()
3520                .tls_backend_rustls()
3521                .build()?,
3522        )?;
3523
3524        let endpoint = ListIssues::builder()
3525            .due_date(DateFilter::LastMonth)
3526            .build()?;
3527        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3528
3529        Ok(())
3530    }
3531
3532    #[traced_test]
3533    #[test]
3534    fn test_list_issues_due_date_filter_next_month() -> Result<(), Box<dyn Error>> {
3535        let _r_issues = ISSUES_LOCK.blocking_read();
3536        dotenvy::dotenv()?;
3537        let redmine = crate::api::Redmine::from_env(
3538            reqwest::blocking::Client::builder()
3539                .tls_backend_rustls()
3540                .build()?,
3541        )?;
3542
3543        let endpoint = ListIssues::builder()
3544            .due_date(DateFilter::NextMonth)
3545            .build()?;
3546        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3547
3548        Ok(())
3549    }
3550
3551    #[traced_test]
3552    #[test]
3553    fn test_list_issues_due_date_filter_this_year() -> Result<(), Box<dyn Error>> {
3554        let _r_issues = ISSUES_LOCK.blocking_read();
3555        dotenvy::dotenv()?;
3556        let redmine = crate::api::Redmine::from_env(
3557            reqwest::blocking::Client::builder()
3558                .tls_backend_rustls()
3559                .build()?,
3560        )?;
3561
3562        let endpoint = ListIssues::builder()
3563            .due_date(DateFilter::ThisYear)
3564            .build()?;
3565        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3566
3567        Ok(())
3568    }
3569
3570    #[traced_test]
3571    #[test]
3572    fn test_list_issues_due_date_filter_unset() -> Result<(), Box<dyn Error>> {
3573        let _r_issues = ISSUES_LOCK.blocking_read();
3574        dotenvy::dotenv()?;
3575        let redmine = crate::api::Redmine::from_env(
3576            reqwest::blocking::Client::builder()
3577                .tls_backend_rustls()
3578                .build()?,
3579        )?;
3580
3581        let endpoint = ListIssues::builder().due_date(DateFilter::Unset).build()?;
3582        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3583
3584        Ok(())
3585    }
3586
3587    #[traced_test]
3588    #[test]
3589    fn test_list_issues_due_date_filter_any() -> Result<(), Box<dyn Error>> {
3590        let _r_issues = ISSUES_LOCK.blocking_read();
3591        dotenvy::dotenv()?;
3592        let redmine = crate::api::Redmine::from_env(
3593            reqwest::blocking::Client::builder()
3594                .tls_backend_rustls()
3595                .build()?,
3596        )?;
3597
3598        let endpoint = ListIssues::builder().due_date(DateFilter::Any).build()?;
3599        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3600
3601        Ok(())
3602    }
3603
3604    #[traced_test]
3605    #[test]
3606    fn test_list_issues_child_id_filter() -> Result<(), Box<dyn Error>> {
3607        let _r_issues = ISSUES_LOCK.blocking_read();
3608        dotenvy::dotenv()?;
3609        let redmine = crate::api::Redmine::from_env(
3610            reqwest::blocking::Client::builder()
3611                .tls_backend_rustls()
3612                .build()?,
3613        )?;
3614
3615        let endpoint = ListIssues::builder().child_id(vec![123, 456]).build()?;
3616        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3617
3618        Ok(())
3619    }
3620}