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    /// the JSON value sent in the body of [UpdateIssue] to clear the field
1239    ///
1240    /// This is `null` for most fields, but Redmine's `Issue#safe_attributes=`
1241    /// silently ignores a falsy `assigned_to_id`, so the assignee is cleared
1242    /// with an empty string instead, like the web UI does.
1243    #[must_use]
1244    pub const fn clear_value(self) -> serde_json::Value {
1245        match self {
1246            Self::AssignedTo => serde_json::Value::String(String::new()),
1247            Self::Category
1248            | Self::Version
1249            | Self::ParentIssue
1250            | Self::EstimatedHours
1251            | Self::StartDate
1252            | Self::DueDate => serde_json::Value::Null,
1253        }
1254    }
1255}
1256
1257/// The endpoint to update an existing Redmine issue
1258#[serde_with::skip_serializing_none]
1259#[derive(Debug, Clone, Builder, Serialize)]
1260#[builder(setter(strip_option), build_fn(validate = "Self::validate"))]
1261pub struct UpdateIssue<'a> {
1262    /// id of the issue to update
1263    #[serde(skip_serializing)]
1264    id: u64,
1265    /// project for the issue
1266    #[builder(default)]
1267    project_id: Option<u64>,
1268    /// tracker for the issue
1269    #[builder(default)]
1270    tracker_id: Option<u64>,
1271    /// status of the issue
1272    #[builder(default)]
1273    status_id: Option<u64>,
1274    /// issue priority
1275    #[builder(default)]
1276    priority_id: Option<u64>,
1277    /// issue subject
1278    #[builder(setter(into), default)]
1279    subject: Option<Cow<'a, str>>,
1280    /// issue description
1281    #[builder(setter(into), default)]
1282    description: Option<Cow<'a, str>>,
1283    /// issue category
1284    #[builder(default)]
1285    category_id: Option<u64>,
1286    /// ID of the Target Versions (previously called 'Fixed Version' and still referred to as such in the API)
1287    #[builder(default, setter(name = "version"))]
1288    fixed_version_id: Option<u64>,
1289    /// user/group id the issue will be assigned to
1290    #[builder(default)]
1291    assigned_to_id: Option<u64>,
1292    /// Id of the parent issue
1293    #[builder(default)]
1294    parent_issue_id: Option<u64>,
1295    /// custom field values
1296    #[builder(default)]
1297    custom_fields: Option<Vec<CustomField<'a>>>,
1298    /// user ids of watchers of the issue
1299    #[builder(default)]
1300    watcher_user_ids: Option<Vec<u64>>,
1301    /// is the issue private (only visible to roles that have the relevant permission enabled)
1302    #[builder(default)]
1303    is_private: Option<bool>,
1304    /// estimated hours it will take to implement this issue
1305    #[builder(default)]
1306    estimated_hours: Option<f64>,
1307    /// the start date for the issue
1308    #[builder(default)]
1309    start_date: Option<time::Date>,
1310    /// the due date for the issue
1311    #[builder(default)]
1312    due_date: Option<time::Date>,
1313    /// the percentage done (0-100)
1314    #[builder(default)]
1315    done_ratio: Option<u64>,
1316    /// add a comment (note)
1317    #[builder(default)]
1318    notes: Option<Cow<'a, str>>,
1319    /// is the added comment/note private
1320    #[builder(default)]
1321    private_notes: Option<bool>,
1322    /// attachments (files)
1323    #[builder(default)]
1324    uploads: Option<Vec<UploadedAttachment<'a>>>,
1325    /// fields to clear, sent as [ClearableIssueField::clear_value]; a field
1326    /// can not be both set and cleared
1327    #[serde(skip_serializing)]
1328    #[builder(default)]
1329    clear: Option<Vec<ClearableIssueField>>,
1330}
1331
1332impl UpdateIssueBuilder<'_> {
1333    /// ensures that no field is both set and cleared when [Self::build()] is called
1334    fn validate(&self) -> Result<(), String> {
1335        let Some(Some(clear)) = &self.clear else {
1336            return Ok(());
1337        };
1338        for field in clear {
1339            let set = match field {
1340                ClearableIssueField::Category => matches!(self.category_id, Some(Some(_))),
1341                ClearableIssueField::Version => matches!(self.fixed_version_id, Some(Some(_))),
1342                ClearableIssueField::AssignedTo => matches!(self.assigned_to_id, Some(Some(_))),
1343                ClearableIssueField::ParentIssue => {
1344                    matches!(self.parent_issue_id, Some(Some(_)))
1345                }
1346                ClearableIssueField::EstimatedHours => {
1347                    matches!(self.estimated_hours, Some(Some(_)))
1348                }
1349                ClearableIssueField::StartDate => matches!(self.start_date, Some(Some(_))),
1350                ClearableIssueField::DueDate => matches!(self.due_date, Some(Some(_))),
1351            };
1352            if set {
1353                return Err(format!(
1354                    "{} can not be both set and cleared",
1355                    field.json_name()
1356                ));
1357            }
1358        }
1359        Ok(())
1360    }
1361}
1362
1363impl<'a> UpdateIssue<'a> {
1364    /// Create a builder for the endpoint.
1365    #[must_use]
1366    pub fn builder() -> UpdateIssueBuilder<'a> {
1367        UpdateIssueBuilder::default()
1368    }
1369}
1370
1371impl UpdateIssue<'_> {
1372    /// the issue part of the body, with the cleared fields set to their
1373    /// [ClearableIssueField::clear_value]
1374    fn json_issue(&self) -> Result<serde_json::Value, serde_json::Error> {
1375        let mut issue = serde_json::to_value(self)?;
1376        if let (Some(clear), Some(fields)) = (&self.clear, issue.as_object_mut()) {
1377            for field in clear {
1378                fields.insert(field.json_name().to_owned(), field.clear_value());
1379            }
1380        }
1381        Ok(issue)
1382    }
1383}
1384
1385impl Endpoint for UpdateIssue<'_> {
1386    fn method(&self) -> Method {
1387        Method::PUT
1388    }
1389
1390    fn endpoint(&self) -> Cow<'static, str> {
1391        format!("issues/{}.json", self.id).into()
1392    }
1393
1394    fn body(&self) -> Result<Option<(&'static str, Vec<u8>)>, crate::Error> {
1395        Ok(Some((
1396            "application/json",
1397            serde_json::to_vec(&IssueWrapper {
1398                issue: self.json_issue()?,
1399            })?,
1400        )))
1401    }
1402}
1403
1404/// The endpoint to delete a Redmine issue
1405#[derive(Debug, Clone, Builder)]
1406#[builder(setter(strip_option))]
1407pub struct DeleteIssue {
1408    /// id of the issue to delete
1409    id: u64,
1410}
1411
1412impl DeleteIssue {
1413    /// Create a builder for the endpoint.
1414    #[must_use]
1415    pub fn builder() -> DeleteIssueBuilder {
1416        DeleteIssueBuilder::default()
1417    }
1418}
1419
1420impl Endpoint for DeleteIssue {
1421    fn method(&self) -> Method {
1422        Method::DELETE
1423    }
1424
1425    fn endpoint(&self) -> Cow<'static, str> {
1426        format!("issues/{}.json", self.id).into()
1427    }
1428}
1429
1430/// The endpoint to add a Redmine user as a watcher on a Redmine issue
1431#[derive(Debug, Clone, Builder, Serialize)]
1432#[builder(setter(strip_option))]
1433pub struct AddWatcher {
1434    /// id of the issue to add the watcher to
1435    #[serde(skip_serializing)]
1436    issue_id: u64,
1437    /// id of the user to add as a watcher
1438    user_id: u64,
1439}
1440
1441impl AddWatcher {
1442    /// Create a builder for the endpoint.
1443    #[must_use]
1444    pub fn builder() -> AddWatcherBuilder {
1445        AddWatcherBuilder::default()
1446    }
1447}
1448
1449impl Endpoint for AddWatcher {
1450    fn method(&self) -> Method {
1451        Method::POST
1452    }
1453
1454    fn endpoint(&self) -> Cow<'static, str> {
1455        format!("issues/{}/watchers.json", self.issue_id).into()
1456    }
1457
1458    fn body(&self) -> Result<Option<(&'static str, Vec<u8>)>, crate::Error> {
1459        Ok(Some(("application/json", serde_json::to_vec(self)?)))
1460    }
1461}
1462
1463/// The endpoint to remove a Redmine user from a Redmine issue as a watcher
1464#[derive(Debug, Clone, Builder)]
1465#[builder(setter(strip_option))]
1466pub struct RemoveWatcher {
1467    /// id of the issue to remove the watcher from
1468    issue_id: u64,
1469    /// id of the user to remove as a watcher
1470    user_id: u64,
1471}
1472
1473impl RemoveWatcher {
1474    /// Create a builder for the endpoint.
1475    #[must_use]
1476    pub fn builder() -> RemoveWatcherBuilder {
1477        RemoveWatcherBuilder::default()
1478    }
1479}
1480
1481impl Endpoint for RemoveWatcher {
1482    fn method(&self) -> Method {
1483        Method::DELETE
1484    }
1485
1486    fn endpoint(&self) -> Cow<'static, str> {
1487        format!("issues/{}/watchers/{}.json", self.issue_id, self.user_id).into()
1488    }
1489}
1490
1491/// helper struct for outer layers with a issues field holding the inner data
1492#[derive(Debug, Clone, PartialEq, Eq, Serialize, serde::Deserialize)]
1493pub struct IssuesWrapper<T> {
1494    /// to parse JSON with issues key
1495    pub issues: Vec<T>,
1496}
1497
1498/// A lot of APIs in Redmine wrap their data in an extra layer, this is a
1499/// helper struct for outer layers with a issue field holding the inner data
1500#[derive(Debug, Clone, PartialEq, Eq, Serialize, serde::Deserialize)]
1501pub struct IssueWrapper<T> {
1502    /// to parse JSON with an issue key
1503    pub issue: T,
1504}
1505
1506#[cfg(test)]
1507pub(crate) mod test {
1508    use super::*;
1509    use crate::api::ResponsePage;
1510    use crate::api::test_helpers::{create_issue, with_project};
1511    use pretty_assertions::assert_eq;
1512    use std::error::Error;
1513    use tokio::sync::RwLock;
1514    use tracing_test::traced_test;
1515
1516    /// needed so we do not get 404s when listing while
1517    /// creating/deleting or creating/updating/deleting
1518    pub static ISSUES_LOCK: RwLock<()> = RwLock::const_new(());
1519
1520    #[traced_test]
1521    #[test]
1522    fn test_list_issues_first_page() -> Result<(), Box<dyn Error>> {
1523        let _r_issues = ISSUES_LOCK.blocking_read();
1524        crate::api::test_helpers::setup()?;
1525        let redmine = crate::api::Redmine::from_env(
1526            reqwest::blocking::Client::builder()
1527                .tls_backend_rustls()
1528                .build()?,
1529        )?;
1530        let endpoint = ListIssues::builder().build()?;
1531        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
1532        Ok(())
1533    }
1534
1535    /// this version of the test will load all pages of issues which means it
1536    /// can take a while (a minute or more) so you need to use --include-ignored
1537    /// or --ignored to run it
1538    #[traced_test]
1539    #[test]
1540    #[ignore = "loads all pages of issues; runtime ~1m, run with --include-ignored"]
1541    fn test_list_issues_all_pages() -> Result<(), Box<dyn Error>> {
1542        let _r_issues = ISSUES_LOCK.blocking_read();
1543        crate::api::test_helpers::setup()?;
1544        let redmine = crate::api::Redmine::from_env(
1545            reqwest::blocking::Client::builder()
1546                .tls_backend_rustls()
1547                .build()?,
1548        )?;
1549        let endpoint = ListIssues::builder().build()?;
1550        redmine.json_response_body_all_pages::<_, Issue>(&endpoint)?;
1551        Ok(())
1552    }
1553
1554    /// this version of the test will load all pages of issues which means it
1555    /// can take a while (a minute or more) so you need to use --include-ignored
1556    /// or --ignored to run it
1557    #[function_name::named]
1558    #[traced_test]
1559    #[test]
1560    #[ignore = "loads all pages of issues; runtime ~1m, run with --include-ignored"]
1561    fn test_list_issues_all_pages_iter() -> Result<(), Box<dyn Error>> {
1562        let _w_issues = ISSUES_LOCK.blocking_write();
1563        let name = format!("unittest_{}", function_name!());
1564        with_project(&name, |redmine, project_id, _name| {
1565            create_issue(redmine, project_id, "Test issue for listing")?;
1566            let endpoint = ListIssues::builder().build()?;
1567            let mut i = 0;
1568            for issue in redmine.json_response_body_all_pages_iter::<_, Issue>(&endpoint) {
1569                let _issue = issue?;
1570                i += 1;
1571            }
1572            assert!(i > 0);
1573            Ok(())
1574        })?;
1575        Ok(())
1576    }
1577
1578    /// this version of the test will load all pages of issues which means it
1579    /// can take a while (a minute or more) so you need to use --include-ignored
1580    /// or --ignored to run it
1581    #[function_name::named]
1582    #[traced_test]
1583    #[test]
1584    #[ignore = "loads all pages of issues; runtime ~1m, run with --include-ignored"]
1585    fn test_list_issues_all_pages_stream() -> Result<(), Box<dyn Error>> {
1586        let _w_issues = ISSUES_LOCK.blocking_write();
1587        let name = format!("unittest_{}", function_name!());
1588        // the fixture setup uses the blocking client which can not be used
1589        // inside an async runtime so we only use the runtime for the actual
1590        // stream test
1591        with_project(&name, |redmine, project_id, _name| {
1592            create_issue(redmine, project_id, "Test issue for listing")?;
1593            tokio::runtime::Runtime::new()?.block_on(async {
1594                let redmine = crate::api::RedmineAsync::from_env(
1595                    reqwest::Client::builder().tls_backend_rustls().build()?,
1596                )?;
1597                let endpoint = ListIssues::builder().build()?;
1598                let mut i = 0;
1599                let mut stream = redmine.json_response_body_all_pages_stream::<_, Issue>(&endpoint);
1600                while let Some(issue) = <_ as futures::stream::StreamExt>::next(&mut stream).await {
1601                    let _issue = issue?;
1602                    i += 1;
1603                }
1604                assert!(i > 0);
1605                Ok::<_, Box<dyn Error>>(())
1606            })
1607        })?;
1608        Ok(())
1609    }
1610
1611    #[function_name::named]
1612    #[traced_test]
1613    #[test]
1614    fn test_get_issue() -> Result<(), Box<dyn Error>> {
1615        let _w_issues = ISSUES_LOCK.blocking_write();
1616        let name = format!("unittest_{}", function_name!());
1617        with_project(&name, |redmine, project_id, _name| {
1618            let issue = create_issue(redmine, project_id, "Test issue for get")?;
1619            let endpoint = GetIssue::builder().id(issue.id).build()?;
1620            let IssueWrapper { issue: fetched } =
1621                redmine.json_response_body::<_, IssueWrapper<Issue>>(&endpoint)?;
1622            assert_eq!(fetched.id, issue.id);
1623            Ok(())
1624        })?;
1625        Ok(())
1626    }
1627
1628    #[function_name::named]
1629    #[traced_test]
1630    #[test]
1631    fn test_create_issue() -> Result<(), Box<dyn Error>> {
1632        let _w_issues = ISSUES_LOCK.blocking_write();
1633        let name = format!("unittest_{}", function_name!());
1634        with_project(&name, |redmine, project_id, _| {
1635            let create_endpoint = super::CreateIssue::builder()
1636                .project_id(project_id)
1637                .subject("old test subject")
1638                .build()?;
1639            redmine.json_response_body::<_, IssueWrapper<Issue>>(&create_endpoint)?;
1640            Ok(())
1641        })?;
1642        Ok(())
1643    }
1644
1645    #[function_name::named]
1646    #[traced_test]
1647    #[test]
1648    fn test_update_issue() -> Result<(), Box<dyn Error>> {
1649        let _w_issues = ISSUES_LOCK.blocking_write();
1650        let name = format!("unittest_{}", function_name!());
1651        with_project(&name, |redmine, project_id, _name| {
1652            let create_endpoint = super::CreateIssue::builder()
1653                .project_id(project_id)
1654                .subject("old test subject")
1655                .build()?;
1656            let IssueWrapper { issue }: IssueWrapper<Issue> =
1657                redmine.json_response_body::<_, _>(&create_endpoint)?;
1658            let update_endpoint = super::UpdateIssue::builder()
1659                .id(issue.id)
1660                .subject("New test subject")
1661                .build()?;
1662            redmine.ignore_response_body::<_>(&update_endpoint)?;
1663            Ok(())
1664        })?;
1665        Ok(())
1666    }
1667
1668    #[function_name::named]
1669    #[traced_test]
1670    #[test]
1671    fn test_create_and_update_issue_dates_and_done_ratio() -> Result<(), Box<dyn Error>> {
1672        let _w_issues = ISSUES_LOCK.blocking_write();
1673        let name = format!("unittest_{}", function_name!());
1674        with_project(&name, |redmine, project_id, _name| {
1675            let create_endpoint = super::CreateIssue::builder()
1676                .project_id(project_id)
1677                .subject("test subject")
1678                .start_date(time::macros::date!(2026 - 01 - 05))
1679                .due_date(time::macros::date!(2026 - 01 - 30))
1680                .done_ratio(20)
1681                .build()?;
1682            let IssueWrapper { issue }: IssueWrapper<Issue> =
1683                redmine.json_response_body::<_, _>(&create_endpoint)?;
1684            assert_eq!(issue.start_date, Some(time::macros::date!(2026 - 01 - 05)));
1685            assert_eq!(issue.due_date, Some(time::macros::date!(2026 - 01 - 30)));
1686            assert_eq!(issue.done_ratio, 20);
1687            let update_endpoint = super::UpdateIssue::builder()
1688                .id(issue.id)
1689                .start_date(time::macros::date!(2026 - 02 - 02))
1690                .due_date(time::macros::date!(2026 - 02 - 27))
1691                .done_ratio(60)
1692                .build()?;
1693            redmine.ignore_response_body::<_>(&update_endpoint)?;
1694            let get_endpoint = GetIssue::builder().id(issue.id).build()?;
1695            let IssueWrapper { issue }: IssueWrapper<Issue> =
1696                redmine.json_response_body::<_, _>(&get_endpoint)?;
1697            assert_eq!(issue.start_date, Some(time::macros::date!(2026 - 02 - 02)));
1698            assert_eq!(issue.due_date, Some(time::macros::date!(2026 - 02 - 27)));
1699            assert_eq!(issue.done_ratio, 60);
1700            Ok(())
1701        })?;
1702        Ok(())
1703    }
1704
1705    #[test]
1706    fn test_update_issue_clear_fields_body() -> Result<(), Box<dyn Error>> {
1707        let endpoint = super::UpdateIssue::builder()
1708            .id(1)
1709            .subject("new subject")
1710            .clear(vec![
1711                ClearableIssueField::Category,
1712                ClearableIssueField::AssignedTo,
1713                ClearableIssueField::DueDate,
1714            ])
1715            .build()?;
1716        let Some((_, body)) = endpoint.body()? else {
1717            return Err("update issue has no body".into());
1718        };
1719        let body: serde_json::Value = serde_json::from_slice(&body)?;
1720        assert_eq!(
1721            body,
1722            serde_json::json!({
1723                "issue": {
1724                    "subject": "new subject",
1725                    "category_id": null,
1726                    "assigned_to_id": "",
1727                    "due_date": null,
1728                }
1729            })
1730        );
1731        Ok(())
1732    }
1733
1734    #[test]
1735    fn test_update_issue_set_and_clear_same_field() {
1736        let result = super::UpdateIssue::builder()
1737            .id(1)
1738            .category_id(3)
1739            .clear(vec![ClearableIssueField::Category])
1740            .build();
1741        assert_eq!(
1742            result.map_err(|e| e.to_string()).err(),
1743            Some("category_id can not be both set and cleared".to_owned())
1744        );
1745    }
1746
1747    #[function_name::named]
1748    #[traced_test]
1749    #[test]
1750    fn test_update_issue_clear_fields() -> Result<(), Box<dyn Error>> {
1751        let _w_issues = ISSUES_LOCK.blocking_write();
1752        let name = format!("unittest_{}", function_name!());
1753        with_project(&name, |redmine, project_id, name| {
1754            let category_endpoint = crate::api::issue_categories::CreateIssueCategory::builder()
1755                .project_id_or_name(name)
1756                .name("Unittest Issue Category")
1757                .build()?;
1758            let crate::api::issue_categories::IssueCategoryWrapper { issue_category } =
1759                redmine
1760                    .json_response_body::<_, crate::api::issue_categories::IssueCategoryWrapper<
1761                        crate::api::issue_categories::IssueCategory,
1762                    >>(&category_endpoint)?;
1763            let version_endpoint = crate::api::versions::CreateVersion::builder()
1764                .project_id_or_name(name)
1765                .name("Unittest Version")
1766                .build()?;
1767            let crate::api::versions::VersionWrapper { version } = redmine
1768                .json_response_body::<_, crate::api::versions::VersionWrapper<
1769                    crate::api::versions::Version,
1770                >>(&version_endpoint)?;
1771            let parent_endpoint = super::CreateIssue::builder()
1772                .project_id(project_id)
1773                .subject("parent")
1774                .build()?;
1775            let IssueWrapper { issue: parent }: IssueWrapper<Issue> =
1776                redmine.json_response_body::<_, _>(&parent_endpoint)?;
1777            let my_account_endpoint = crate::api::my_account::GetMyAccount::builder().build()?;
1778            let crate::api::users::UserWrapper { user: my_account } = redmine
1779                .json_response_body::<_, crate::api::users::UserWrapper<
1780                    crate::api::my_account::MyAccount,
1781                >>(&my_account_endpoint)?;
1782            let create_endpoint = super::CreateIssue::builder()
1783                .project_id(project_id)
1784                .subject("test subject")
1785                .assigned_to_id(my_account.id)
1786                .category_id(issue_category.id)
1787                .version(version.id)
1788                .parent_issue_id(parent.id)
1789                .estimated_hours(2.5)
1790                .start_date(time::macros::date!(2026 - 01 - 05))
1791                .due_date(time::macros::date!(2026 - 01 - 30))
1792                .build()?;
1793            let IssueWrapper { issue }: IssueWrapper<Issue> =
1794                redmine.json_response_body::<_, _>(&create_endpoint)?;
1795            assert!(issue.category.is_some());
1796            assert!(issue.version.is_some());
1797            assert!(issue.assigned_to.is_some());
1798            assert!(issue.parent.is_some());
1799            assert_eq!(issue.estimated_hours, Some(2.5));
1800            let update_endpoint = super::UpdateIssue::builder()
1801                .id(issue.id)
1802                .clear(vec![
1803                    ClearableIssueField::Category,
1804                    ClearableIssueField::Version,
1805                    ClearableIssueField::AssignedTo,
1806                    ClearableIssueField::ParentIssue,
1807                    ClearableIssueField::EstimatedHours,
1808                    ClearableIssueField::StartDate,
1809                    ClearableIssueField::DueDate,
1810                ])
1811                .build()?;
1812            redmine.ignore_response_body::<_>(&update_endpoint)?;
1813            let get_endpoint = GetIssue::builder().id(issue.id).build()?;
1814            let IssueWrapper { issue }: IssueWrapper<Issue> =
1815                redmine.json_response_body::<_, _>(&get_endpoint)?;
1816            assert!(issue.category.is_none());
1817            assert!(issue.version.is_none());
1818            assert!(issue.assigned_to.is_none());
1819            assert!(issue.parent.is_none());
1820            assert_eq!(issue.estimated_hours, None);
1821            assert_eq!(issue.start_date, None);
1822            assert_eq!(issue.due_date, None);
1823            Ok(())
1824        })?;
1825        Ok(())
1826    }
1827
1828    #[function_name::named]
1829    #[traced_test]
1830    #[test]
1831    fn test_delete_issue() -> Result<(), Box<dyn Error>> {
1832        let _w_issues = ISSUES_LOCK.blocking_write();
1833        let name = format!("unittest_{}", function_name!());
1834        with_project(&name, |redmine, project_id, _name| {
1835            let create_endpoint = super::CreateIssue::builder()
1836                .project_id(project_id)
1837                .subject("test subject")
1838                .build()?;
1839            let IssueWrapper { issue }: IssueWrapper<Issue> =
1840                redmine.json_response_body::<_, _>(&create_endpoint)?;
1841            let delete_endpoint = super::DeleteIssue::builder().id(issue.id).build()?;
1842            redmine.ignore_response_body::<_>(&delete_endpoint)?;
1843            Ok(())
1844        })?;
1845        Ok(())
1846    }
1847
1848    /// this tests if any of the results contain a field we are not deserializing
1849    ///
1850    /// this will only catch fields we missed if they are part of the response but
1851    /// it is better than nothing
1852    #[traced_test]
1853    #[test]
1854    fn test_completeness_issue_type_first_page() -> Result<(), Box<dyn Error>> {
1855        let _r_issues = ISSUES_LOCK.blocking_read();
1856        crate::api::test_helpers::setup()?;
1857        let redmine = crate::api::Redmine::from_env(
1858            reqwest::blocking::Client::builder()
1859                .tls_backend_rustls()
1860                .build()?,
1861        )?;
1862        let endpoint = ListIssues::builder()
1863            .include(vec![
1864                IssueListInclude::TimeEntries,
1865                IssueListInclude::Relations,
1866            ])
1867            .build()?;
1868        let ResponsePage {
1869            values,
1870            total_count: _,
1871            offset: _,
1872            limit: _,
1873        } = redmine.json_response_body_page::<_, serde_json::Value>(&endpoint, 0, 100)?;
1874        for value in values {
1875            let o: Issue = serde_json::from_value(value.clone())?;
1876            let reserialized = serde_json::to_value(o)?;
1877            let expected_value = if let serde_json::Value::Object(obj) = value {
1878                let mut expected_obj = obj.clone();
1879                if obj
1880                    .get("total_estimated_hours")
1881                    .is_some_and(|v| *v == serde_json::Value::Null)
1882                {
1883                    expected_obj.remove("total_estimated_hours");
1884                }
1885                serde_json::Value::Object(expected_obj)
1886            } else {
1887                value
1888            };
1889            assert_eq!(expected_value, reserialized);
1890        }
1891        Ok(())
1892    }
1893
1894    /// this tests if any of the results contain a field we are not deserializing
1895    ///
1896    /// this will only catch fields we missed if they are part of the response but
1897    /// it is better than nothing
1898    ///
1899    /// this version of the test will load all pages of issues which means it
1900    /// can take a while (a minute or more) so you need to use --include-ignored
1901    /// or --ignored to run it
1902    #[traced_test]
1903    #[test]
1904    #[ignore = "loads all pages of issues; runtime ~1m, run with --include-ignored"]
1905    fn test_completeness_issue_type_all_pages() -> Result<(), Box<dyn Error>> {
1906        let _r_issues = ISSUES_LOCK.blocking_read();
1907        crate::api::test_helpers::setup()?;
1908        let redmine = crate::api::Redmine::from_env(
1909            reqwest::blocking::Client::builder()
1910                .tls_backend_rustls()
1911                .build()?,
1912        )?;
1913        let endpoint = ListIssues::builder()
1914            .include(vec![
1915                IssueListInclude::TimeEntries,
1916                IssueListInclude::Relations,
1917            ])
1918            .build()?;
1919        let values = redmine.json_response_body_all_pages::<_, serde_json::Value>(&endpoint)?;
1920        for value in values {
1921            let o: Issue = serde_json::from_value(value.clone())?;
1922            let reserialized = serde_json::to_value(o)?;
1923            let expected_value = if let serde_json::Value::Object(obj) = value {
1924                let mut expected_obj = obj.clone();
1925                if obj
1926                    .get("total_estimated_hours")
1927                    .is_some_and(|v| *v == serde_json::Value::Null)
1928                {
1929                    expected_obj.remove("total_estimated_hours");
1930                }
1931                serde_json::Value::Object(expected_obj)
1932            } else {
1933                value
1934            };
1935            assert_eq!(expected_value, reserialized);
1936        }
1937        Ok(())
1938    }
1939
1940    /// this tests if any of the results contain a field we are not deserializing
1941    ///
1942    /// this will only catch fields we missed if they are part of the response but
1943    /// it is better than nothing
1944    ///
1945    /// this version of the test will load all pages of issues and the individual
1946    /// issues for each via GetIssue which means it
1947    /// can take a while (about 400 seconds) so you need to use --include-ignored
1948    /// or --ignored to run it
1949    #[traced_test]
1950    #[test]
1951    #[ignore = "fetches every issue via GetIssue; runtime ~400s, run with --include-ignored"]
1952    fn test_completeness_issue_type_all_pages_all_issue_details() -> Result<(), Box<dyn Error>> {
1953        let _r_issues = ISSUES_LOCK.blocking_read();
1954        crate::api::test_helpers::setup()?;
1955        let redmine = crate::api::Redmine::from_env(
1956            reqwest::blocking::Client::builder()
1957                .tls_backend_rustls()
1958                .build()?,
1959        )?;
1960        let endpoint = ListIssues::builder()
1961            .include(vec![
1962                IssueListInclude::TimeEntries,
1963                IssueListInclude::Relations,
1964            ])
1965            .build()?;
1966        let issues = redmine.json_response_body_all_pages::<_, Issue>(&endpoint)?;
1967        for issue in issues {
1968            let get_endpoint = GetIssue::builder()
1969                .id(issue.id)
1970                .include(vec![
1971                    IssueInclude::Attachments,
1972                    IssueInclude::Children,
1973                    IssueInclude::Changesets,
1974                    IssueInclude::Relations,
1975                    IssueInclude::Journals,
1976                    IssueInclude::Watchers,
1977                ])
1978                .build()?;
1979            let IssueWrapper { issue: mut value } =
1980                redmine.json_response_body::<_, IssueWrapper<serde_json::Value>>(&get_endpoint)?;
1981            let o: Issue = serde_json::from_value(value.clone())?;
1982            // workaround for the fact that the field total_estimated_hours is put into the result
1983            // when its null in the GetIssue endpoint but not in the ListIssues one
1984            // we can only do one or the other in our JSON serialization unless we want to add
1985            // extra fields just to keep track of the missing field vs. field with null value
1986            // difference
1987            let value_object = value.as_object_mut().unwrap();
1988            if value_object.get("total_estimated_hours") == Some(&serde_json::Value::Null) {
1989                value_object.remove("total_estimated_hours");
1990            }
1991            let reserialized = serde_json::to_value(o)?;
1992            assert_eq!(value, reserialized);
1993        }
1994        Ok(())
1995    }
1996
1997    #[traced_test]
1998    #[test]
1999    fn test_list_issues_created_on_filter_exact_match() -> Result<(), Box<dyn Error>> {
2000        let _r_issues = ISSUES_LOCK.blocking_read();
2001        crate::api::test_helpers::setup()?;
2002        let redmine = crate::api::Redmine::from_env(
2003            reqwest::blocking::Client::builder()
2004                .tls_backend_rustls()
2005                .build()?,
2006        )?;
2007
2008        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
2009        let endpoint = ListIssues::builder()
2010            .created_on(DateTimeFilterPast::ExactMatch(dt))
2011            .build()?;
2012        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2013
2014        Ok(())
2015    }
2016
2017    #[traced_test]
2018    #[test]
2019    fn test_list_issues_created_on_filter_range() -> Result<(), Box<dyn Error>> {
2020        let _r_issues = ISSUES_LOCK.blocking_read();
2021        crate::api::test_helpers::setup()?;
2022        let redmine = crate::api::Redmine::from_env(
2023            reqwest::blocking::Client::builder()
2024                .tls_backend_rustls()
2025                .build()?,
2026        )?;
2027
2028        let dt_start = time::macros::datetime!(2023-01-01 00:00:00 UTC);
2029        let dt_end = time::macros::datetime!(2023-01-31 23:59:59 UTC);
2030        let endpoint = ListIssues::builder()
2031            .created_on(DateTimeFilterPast::Range(dt_start, dt_end))
2032            .build()?;
2033        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2034
2035        Ok(())
2036    }
2037
2038    #[traced_test]
2039    #[test]
2040    fn test_list_issues_created_on_filter_less_than_or_equal() -> Result<(), Box<dyn Error>> {
2041        let _r_issues = ISSUES_LOCK.blocking_read();
2042        crate::api::test_helpers::setup()?;
2043        let redmine = crate::api::Redmine::from_env(
2044            reqwest::blocking::Client::builder()
2045                .tls_backend_rustls()
2046                .build()?,
2047        )?;
2048
2049        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
2050        let endpoint = ListIssues::builder()
2051            .created_on(DateTimeFilterPast::LessThanOrEqual(dt))
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_greater_than_or_equal() -> Result<(), Box<dyn Error>> {
2061        let _r_issues = ISSUES_LOCK.blocking_read();
2062        crate::api::test_helpers::setup()?;
2063        let redmine = crate::api::Redmine::from_env(
2064            reqwest::blocking::Client::builder()
2065                .tls_backend_rustls()
2066                .build()?,
2067        )?;
2068
2069        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
2070        let endpoint = ListIssues::builder()
2071            .created_on(DateTimeFilterPast::GreaterThanOrEqual(dt))
2072            .build()?;
2073        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2074
2075        Ok(())
2076    }
2077
2078    #[traced_test]
2079    #[test]
2080    fn test_list_issues_created_on_filter_less_than_days_ago() -> Result<(), Box<dyn Error>> {
2081        let _r_issues = ISSUES_LOCK.blocking_read();
2082        crate::api::test_helpers::setup()?;
2083        let redmine = crate::api::Redmine::from_env(
2084            reqwest::blocking::Client::builder()
2085                .tls_backend_rustls()
2086                .build()?,
2087        )?;
2088
2089        let endpoint = ListIssues::builder()
2090            .created_on(DateTimeFilterPast::LessThanDaysAgo(5))
2091            .build()?;
2092        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2093
2094        Ok(())
2095    }
2096
2097    #[traced_test]
2098    #[test]
2099    fn test_list_issues_created_on_filter_more_than_days_ago() -> Result<(), Box<dyn Error>> {
2100        let _r_issues = ISSUES_LOCK.blocking_read();
2101        crate::api::test_helpers::setup()?;
2102        let redmine = crate::api::Redmine::from_env(
2103            reqwest::blocking::Client::builder()
2104                .tls_backend_rustls()
2105                .build()?,
2106        )?;
2107
2108        let endpoint = ListIssues::builder()
2109            .created_on(DateTimeFilterPast::MoreThanDaysAgo(10))
2110            .build()?;
2111        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2112
2113        Ok(())
2114    }
2115
2116    #[traced_test]
2117    #[test]
2118    fn test_list_issues_created_on_filter_within_past_days() -> Result<(), Box<dyn Error>> {
2119        let _r_issues = ISSUES_LOCK.blocking_read();
2120        crate::api::test_helpers::setup()?;
2121        let redmine = crate::api::Redmine::from_env(
2122            reqwest::blocking::Client::builder()
2123                .tls_backend_rustls()
2124                .build()?,
2125        )?;
2126
2127        let endpoint = ListIssues::builder()
2128            .created_on(DateTimeFilterPast::WithinPastDays(7))
2129            .build()?;
2130        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2131
2132        Ok(())
2133    }
2134
2135    #[traced_test]
2136    #[test]
2137    fn test_list_issues_created_on_filter_exact_days_ago() -> Result<(), Box<dyn Error>> {
2138        let _r_issues = ISSUES_LOCK.blocking_read();
2139        crate::api::test_helpers::setup()?;
2140        let redmine = crate::api::Redmine::from_env(
2141            reqwest::blocking::Client::builder()
2142                .tls_backend_rustls()
2143                .build()?,
2144        )?;
2145
2146        let endpoint = ListIssues::builder()
2147            .created_on(DateTimeFilterPast::ExactDaysAgo(3))
2148            .build()?;
2149        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2150
2151        Ok(())
2152    }
2153
2154    #[traced_test]
2155    #[test]
2156    fn test_list_issues_created_on_filter_today() -> Result<(), Box<dyn Error>> {
2157        let _r_issues = ISSUES_LOCK.blocking_read();
2158        crate::api::test_helpers::setup()?;
2159        let redmine = crate::api::Redmine::from_env(
2160            reqwest::blocking::Client::builder()
2161                .tls_backend_rustls()
2162                .build()?,
2163        )?;
2164
2165        let endpoint = ListIssues::builder()
2166            .created_on(DateTimeFilterPast::Today)
2167            .build()?;
2168        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2169
2170        Ok(())
2171    }
2172
2173    #[traced_test]
2174    #[test]
2175    fn test_list_issues_created_on_filter_yesterday() -> Result<(), Box<dyn Error>> {
2176        let _r_issues = ISSUES_LOCK.blocking_read();
2177        crate::api::test_helpers::setup()?;
2178        let redmine = crate::api::Redmine::from_env(
2179            reqwest::blocking::Client::builder()
2180                .tls_backend_rustls()
2181                .build()?,
2182        )?;
2183
2184        let endpoint = ListIssues::builder()
2185            .created_on(DateTimeFilterPast::Yesterday)
2186            .build()?;
2187        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2188
2189        Ok(())
2190    }
2191
2192    #[traced_test]
2193    #[test]
2194    fn test_list_issues_created_on_filter_this_week() -> Result<(), Box<dyn Error>> {
2195        let _r_issues = ISSUES_LOCK.blocking_read();
2196        crate::api::test_helpers::setup()?;
2197        let redmine = crate::api::Redmine::from_env(
2198            reqwest::blocking::Client::builder()
2199                .tls_backend_rustls()
2200                .build()?,
2201        )?;
2202
2203        let endpoint = ListIssues::builder()
2204            .created_on(DateTimeFilterPast::ThisWeek)
2205            .build()?;
2206        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2207
2208        Ok(())
2209    }
2210
2211    #[traced_test]
2212    #[test]
2213    fn test_list_issues_created_on_filter_last_week() -> Result<(), Box<dyn Error>> {
2214        let _r_issues = ISSUES_LOCK.blocking_read();
2215        crate::api::test_helpers::setup()?;
2216        let redmine = crate::api::Redmine::from_env(
2217            reqwest::blocking::Client::builder()
2218                .tls_backend_rustls()
2219                .build()?,
2220        )?;
2221
2222        let endpoint = ListIssues::builder()
2223            .created_on(DateTimeFilterPast::LastWeek)
2224            .build()?;
2225        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2226
2227        Ok(())
2228    }
2229
2230    #[traced_test]
2231    #[test]
2232    fn test_list_issues_created_on_filter_last_two_weeks() -> Result<(), Box<dyn Error>> {
2233        let _r_issues = ISSUES_LOCK.blocking_read();
2234        crate::api::test_helpers::setup()?;
2235        let redmine = crate::api::Redmine::from_env(
2236            reqwest::blocking::Client::builder()
2237                .tls_backend_rustls()
2238                .build()?,
2239        )?;
2240
2241        let endpoint = ListIssues::builder()
2242            .created_on(DateTimeFilterPast::LastTwoWeeks)
2243            .build()?;
2244        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2245
2246        Ok(())
2247    }
2248
2249    #[traced_test]
2250    #[test]
2251    fn test_list_issues_created_on_filter_this_month() -> Result<(), Box<dyn Error>> {
2252        let _r_issues = ISSUES_LOCK.blocking_read();
2253        crate::api::test_helpers::setup()?;
2254        let redmine = crate::api::Redmine::from_env(
2255            reqwest::blocking::Client::builder()
2256                .tls_backend_rustls()
2257                .build()?,
2258        )?;
2259
2260        let endpoint = ListIssues::builder()
2261            .created_on(DateTimeFilterPast::ThisMonth)
2262            .build()?;
2263        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2264
2265        Ok(())
2266    }
2267
2268    #[traced_test]
2269    #[test]
2270    fn test_list_issues_created_on_filter_last_month() -> Result<(), Box<dyn Error>> {
2271        let _r_issues = ISSUES_LOCK.blocking_read();
2272        crate::api::test_helpers::setup()?;
2273        let redmine = crate::api::Redmine::from_env(
2274            reqwest::blocking::Client::builder()
2275                .tls_backend_rustls()
2276                .build()?,
2277        )?;
2278
2279        let endpoint = ListIssues::builder()
2280            .created_on(DateTimeFilterPast::LastMonth)
2281            .build()?;
2282        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2283
2284        Ok(())
2285    }
2286
2287    #[traced_test]
2288    #[test]
2289    fn test_list_issues_created_on_filter_this_year() -> Result<(), Box<dyn Error>> {
2290        let _r_issues = ISSUES_LOCK.blocking_read();
2291        crate::api::test_helpers::setup()?;
2292        let redmine = crate::api::Redmine::from_env(
2293            reqwest::blocking::Client::builder()
2294                .tls_backend_rustls()
2295                .build()?,
2296        )?;
2297
2298        let endpoint = ListIssues::builder()
2299            .created_on(DateTimeFilterPast::ThisYear)
2300            .build()?;
2301        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2302
2303        Ok(())
2304    }
2305
2306    #[traced_test]
2307    #[test]
2308    fn test_list_issues_created_on_filter_unset() -> Result<(), Box<dyn Error>> {
2309        let _r_issues = ISSUES_LOCK.blocking_read();
2310        crate::api::test_helpers::setup()?;
2311        let redmine = crate::api::Redmine::from_env(
2312            reqwest::blocking::Client::builder()
2313                .tls_backend_rustls()
2314                .build()?,
2315        )?;
2316
2317        let endpoint = ListIssues::builder()
2318            .created_on(DateTimeFilterPast::Unset)
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_created_on_filter_any() -> Result<(), Box<dyn Error>> {
2328        let _r_issues = ISSUES_LOCK.blocking_read();
2329        crate::api::test_helpers::setup()?;
2330        let redmine = crate::api::Redmine::from_env(
2331            reqwest::blocking::Client::builder()
2332                .tls_backend_rustls()
2333                .build()?,
2334        )?;
2335
2336        let endpoint = ListIssues::builder()
2337            .created_on(DateTimeFilterPast::Any)
2338            .build()?;
2339        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2340
2341        Ok(())
2342    }
2343
2344    #[traced_test]
2345    #[test]
2346    fn test_list_issues_updated_on_filter_exact_match() -> Result<(), Box<dyn Error>> {
2347        let _r_issues = ISSUES_LOCK.blocking_read();
2348        crate::api::test_helpers::setup()?;
2349        let redmine = crate::api::Redmine::from_env(
2350            reqwest::blocking::Client::builder()
2351                .tls_backend_rustls()
2352                .build()?,
2353        )?;
2354
2355        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
2356        let endpoint = ListIssues::builder()
2357            .updated_on(DateTimeFilterPast::ExactMatch(dt))
2358            .build()?;
2359        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2360
2361        Ok(())
2362    }
2363
2364    #[traced_test]
2365    #[test]
2366    fn test_list_issues_updated_on_filter_range() -> Result<(), Box<dyn Error>> {
2367        let _r_issues = ISSUES_LOCK.blocking_read();
2368        crate::api::test_helpers::setup()?;
2369        let redmine = crate::api::Redmine::from_env(
2370            reqwest::blocking::Client::builder()
2371                .tls_backend_rustls()
2372                .build()?,
2373        )?;
2374
2375        let dt_start = time::macros::datetime!(2023-01-01 00:00:00 UTC);
2376        let dt_end = time::macros::datetime!(2023-01-31 23:59:59 UTC);
2377        let endpoint = ListIssues::builder()
2378            .updated_on(DateTimeFilterPast::Range(dt_start, dt_end))
2379            .build()?;
2380        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2381
2382        Ok(())
2383    }
2384
2385    #[traced_test]
2386    #[test]
2387    fn test_list_issues_updated_on_filter_less_than_or_equal() -> Result<(), Box<dyn Error>> {
2388        let _r_issues = ISSUES_LOCK.blocking_read();
2389        crate::api::test_helpers::setup()?;
2390        let redmine = crate::api::Redmine::from_env(
2391            reqwest::blocking::Client::builder()
2392                .tls_backend_rustls()
2393                .build()?,
2394        )?;
2395
2396        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
2397        let endpoint = ListIssues::builder()
2398            .updated_on(DateTimeFilterPast::LessThanOrEqual(dt))
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_greater_than_or_equal() -> Result<(), Box<dyn Error>> {
2408        let _r_issues = ISSUES_LOCK.blocking_read();
2409        crate::api::test_helpers::setup()?;
2410        let redmine = crate::api::Redmine::from_env(
2411            reqwest::blocking::Client::builder()
2412                .tls_backend_rustls()
2413                .build()?,
2414        )?;
2415
2416        let dt = time::macros::datetime!(2023-01-15 10:30:00 UTC);
2417        let endpoint = ListIssues::builder()
2418            .updated_on(DateTimeFilterPast::GreaterThanOrEqual(dt))
2419            .build()?;
2420        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2421
2422        Ok(())
2423    }
2424
2425    #[traced_test]
2426    #[test]
2427    fn test_list_issues_updated_on_filter_less_than_days_ago() -> Result<(), Box<dyn Error>> {
2428        let _r_issues = ISSUES_LOCK.blocking_read();
2429        crate::api::test_helpers::setup()?;
2430        let redmine = crate::api::Redmine::from_env(
2431            reqwest::blocking::Client::builder()
2432                .tls_backend_rustls()
2433                .build()?,
2434        )?;
2435
2436        let endpoint = ListIssues::builder()
2437            .updated_on(DateTimeFilterPast::LessThanDaysAgo(5))
2438            .build()?;
2439        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2440
2441        Ok(())
2442    }
2443
2444    #[traced_test]
2445    #[test]
2446    fn test_list_issues_updated_on_filter_more_than_days_ago() -> Result<(), Box<dyn Error>> {
2447        let _r_issues = ISSUES_LOCK.blocking_read();
2448        crate::api::test_helpers::setup()?;
2449        let redmine = crate::api::Redmine::from_env(
2450            reqwest::blocking::Client::builder()
2451                .tls_backend_rustls()
2452                .build()?,
2453        )?;
2454
2455        let endpoint = ListIssues::builder()
2456            .updated_on(DateTimeFilterPast::MoreThanDaysAgo(10))
2457            .build()?;
2458        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2459
2460        Ok(())
2461    }
2462
2463    #[traced_test]
2464    #[test]
2465    fn test_list_issues_updated_on_filter_within_past_days() -> Result<(), Box<dyn Error>> {
2466        let _r_issues = ISSUES_LOCK.blocking_read();
2467        crate::api::test_helpers::setup()?;
2468        let redmine = crate::api::Redmine::from_env(
2469            reqwest::blocking::Client::builder()
2470                .tls_backend_rustls()
2471                .build()?,
2472        )?;
2473
2474        let endpoint = ListIssues::builder()
2475            .updated_on(DateTimeFilterPast::WithinPastDays(7))
2476            .build()?;
2477        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2478
2479        Ok(())
2480    }
2481
2482    #[traced_test]
2483    #[test]
2484    fn test_list_issues_updated_on_filter_exact_days_ago() -> Result<(), Box<dyn Error>> {
2485        let _r_issues = ISSUES_LOCK.blocking_read();
2486        crate::api::test_helpers::setup()?;
2487        let redmine = crate::api::Redmine::from_env(
2488            reqwest::blocking::Client::builder()
2489                .tls_backend_rustls()
2490                .build()?,
2491        )?;
2492
2493        let endpoint = ListIssues::builder()
2494            .updated_on(DateTimeFilterPast::ExactDaysAgo(3))
2495            .build()?;
2496        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2497
2498        Ok(())
2499    }
2500
2501    #[traced_test]
2502    #[test]
2503    fn test_list_issues_updated_on_filter_today() -> Result<(), Box<dyn Error>> {
2504        let _r_issues = ISSUES_LOCK.blocking_read();
2505        crate::api::test_helpers::setup()?;
2506        let redmine = crate::api::Redmine::from_env(
2507            reqwest::blocking::Client::builder()
2508                .tls_backend_rustls()
2509                .build()?,
2510        )?;
2511
2512        let endpoint = ListIssues::builder()
2513            .updated_on(DateTimeFilterPast::Today)
2514            .build()?;
2515        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2516
2517        Ok(())
2518    }
2519
2520    #[traced_test]
2521    #[test]
2522    fn test_list_issues_updated_on_filter_yesterday() -> Result<(), Box<dyn Error>> {
2523        let _r_issues = ISSUES_LOCK.blocking_read();
2524        crate::api::test_helpers::setup()?;
2525        let redmine = crate::api::Redmine::from_env(
2526            reqwest::blocking::Client::builder()
2527                .tls_backend_rustls()
2528                .build()?,
2529        )?;
2530
2531        let endpoint = ListIssues::builder()
2532            .updated_on(DateTimeFilterPast::Yesterday)
2533            .build()?;
2534        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2535
2536        Ok(())
2537    }
2538
2539    #[traced_test]
2540    #[test]
2541    fn test_list_issues_updated_on_filter_this_week() -> Result<(), Box<dyn Error>> {
2542        let _r_issues = ISSUES_LOCK.blocking_read();
2543        crate::api::test_helpers::setup()?;
2544        let redmine = crate::api::Redmine::from_env(
2545            reqwest::blocking::Client::builder()
2546                .tls_backend_rustls()
2547                .build()?,
2548        )?;
2549
2550        let endpoint = ListIssues::builder()
2551            .updated_on(DateTimeFilterPast::ThisWeek)
2552            .build()?;
2553        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2554
2555        Ok(())
2556    }
2557
2558    #[traced_test]
2559    #[test]
2560    fn test_list_issues_updated_on_filter_last_week() -> Result<(), Box<dyn Error>> {
2561        let _r_issues = ISSUES_LOCK.blocking_read();
2562        crate::api::test_helpers::setup()?;
2563        let redmine = crate::api::Redmine::from_env(
2564            reqwest::blocking::Client::builder()
2565                .tls_backend_rustls()
2566                .build()?,
2567        )?;
2568
2569        let endpoint = ListIssues::builder()
2570            .updated_on(DateTimeFilterPast::LastWeek)
2571            .build()?;
2572        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2573
2574        Ok(())
2575    }
2576
2577    #[traced_test]
2578    #[test]
2579    fn test_list_issues_updated_on_filter_last_two_weeks() -> Result<(), Box<dyn Error>> {
2580        let _r_issues = ISSUES_LOCK.blocking_read();
2581        crate::api::test_helpers::setup()?;
2582        let redmine = crate::api::Redmine::from_env(
2583            reqwest::blocking::Client::builder()
2584                .tls_backend_rustls()
2585                .build()?,
2586        )?;
2587
2588        let endpoint = ListIssues::builder()
2589            .updated_on(DateTimeFilterPast::LastTwoWeeks)
2590            .build()?;
2591        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2592
2593        Ok(())
2594    }
2595
2596    #[traced_test]
2597    #[test]
2598    fn test_list_issues_updated_on_filter_this_month() -> Result<(), Box<dyn Error>> {
2599        let _r_issues = ISSUES_LOCK.blocking_read();
2600        crate::api::test_helpers::setup()?;
2601        let redmine = crate::api::Redmine::from_env(
2602            reqwest::blocking::Client::builder()
2603                .tls_backend_rustls()
2604                .build()?,
2605        )?;
2606
2607        let endpoint = ListIssues::builder()
2608            .updated_on(DateTimeFilterPast::ThisMonth)
2609            .build()?;
2610        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2611
2612        Ok(())
2613    }
2614
2615    #[traced_test]
2616    #[test]
2617    fn test_list_issues_updated_on_filter_last_month() -> Result<(), Box<dyn Error>> {
2618        let _r_issues = ISSUES_LOCK.blocking_read();
2619        crate::api::test_helpers::setup()?;
2620        let redmine = crate::api::Redmine::from_env(
2621            reqwest::blocking::Client::builder()
2622                .tls_backend_rustls()
2623                .build()?,
2624        )?;
2625
2626        let endpoint = ListIssues::builder()
2627            .updated_on(DateTimeFilterPast::LastMonth)
2628            .build()?;
2629        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2630
2631        Ok(())
2632    }
2633
2634    #[traced_test]
2635    #[test]
2636    fn test_list_issues_updated_on_filter_this_year() -> Result<(), Box<dyn Error>> {
2637        let _r_issues = ISSUES_LOCK.blocking_read();
2638        crate::api::test_helpers::setup()?;
2639        let redmine = crate::api::Redmine::from_env(
2640            reqwest::blocking::Client::builder()
2641                .tls_backend_rustls()
2642                .build()?,
2643        )?;
2644
2645        let endpoint = ListIssues::builder()
2646            .updated_on(DateTimeFilterPast::ThisYear)
2647            .build()?;
2648        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2649
2650        Ok(())
2651    }
2652
2653    #[traced_test]
2654    #[test]
2655    fn test_list_issues_updated_on_filter_unset() -> Result<(), Box<dyn Error>> {
2656        let _r_issues = ISSUES_LOCK.blocking_read();
2657        crate::api::test_helpers::setup()?;
2658        let redmine = crate::api::Redmine::from_env(
2659            reqwest::blocking::Client::builder()
2660                .tls_backend_rustls()
2661                .build()?,
2662        )?;
2663
2664        let endpoint = ListIssues::builder()
2665            .updated_on(DateTimeFilterPast::Unset)
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_updated_on_filter_any() -> Result<(), Box<dyn Error>> {
2675        let _r_issues = ISSUES_LOCK.blocking_read();
2676        crate::api::test_helpers::setup()?;
2677        let redmine = crate::api::Redmine::from_env(
2678            reqwest::blocking::Client::builder()
2679                .tls_backend_rustls()
2680                .build()?,
2681        )?;
2682
2683        let endpoint = ListIssues::builder()
2684            .updated_on(DateTimeFilterPast::Any)
2685            .build()?;
2686        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2687
2688        Ok(())
2689    }
2690
2691    #[traced_test]
2692    #[test]
2693    fn test_list_issues_start_date_filter_exact_match() -> Result<(), Box<dyn Error>> {
2694        let _r_issues = ISSUES_LOCK.blocking_read();
2695        crate::api::test_helpers::setup()?;
2696        let redmine = crate::api::Redmine::from_env(
2697            reqwest::blocking::Client::builder()
2698                .tls_backend_rustls()
2699                .build()?,
2700        )?;
2701
2702        let dt = time::macros::date!(2023 - 01 - 15);
2703        let endpoint = ListIssues::builder()
2704            .start_date(DateFilter::ExactMatch(dt))
2705            .build()?;
2706        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2707
2708        Ok(())
2709    }
2710
2711    #[traced_test]
2712    #[test]
2713    fn test_list_issues_start_date_filter_range() -> Result<(), Box<dyn Error>> {
2714        let _r_issues = ISSUES_LOCK.blocking_read();
2715        crate::api::test_helpers::setup()?;
2716        let redmine = crate::api::Redmine::from_env(
2717            reqwest::blocking::Client::builder()
2718                .tls_backend_rustls()
2719                .build()?,
2720        )?;
2721
2722        let dt_start = time::macros::date!(2023 - 01 - 01);
2723        let dt_end = time::macros::date!(2023 - 01 - 31);
2724        let endpoint = ListIssues::builder()
2725            .start_date(DateFilter::Range(dt_start, dt_end))
2726            .build()?;
2727        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2728
2729        Ok(())
2730    }
2731
2732    #[traced_test]
2733    #[test]
2734    fn test_list_issues_start_date_filter_less_than_or_equal() -> Result<(), Box<dyn Error>> {
2735        let _r_issues = ISSUES_LOCK.blocking_read();
2736        crate::api::test_helpers::setup()?;
2737        let redmine = crate::api::Redmine::from_env(
2738            reqwest::blocking::Client::builder()
2739                .tls_backend_rustls()
2740                .build()?,
2741        )?;
2742
2743        let dt = time::macros::date!(2023 - 01 - 15);
2744        let endpoint = ListIssues::builder()
2745            .start_date(DateFilter::LessThanOrEqual(dt))
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_greater_than_or_equal() -> Result<(), Box<dyn Error>> {
2755        let _r_issues = ISSUES_LOCK.blocking_read();
2756        crate::api::test_helpers::setup()?;
2757        let redmine = crate::api::Redmine::from_env(
2758            reqwest::blocking::Client::builder()
2759                .tls_backend_rustls()
2760                .build()?,
2761        )?;
2762
2763        let dt = time::macros::date!(2023 - 01 - 15);
2764        let endpoint = ListIssues::builder()
2765            .start_date(DateFilter::GreaterThanOrEqual(dt))
2766            .build()?;
2767        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2768
2769        Ok(())
2770    }
2771
2772    #[traced_test]
2773    #[test]
2774    fn test_list_issues_start_date_filter_less_than_days_ago() -> Result<(), Box<dyn Error>> {
2775        let _r_issues = ISSUES_LOCK.blocking_read();
2776        crate::api::test_helpers::setup()?;
2777        let redmine = crate::api::Redmine::from_env(
2778            reqwest::blocking::Client::builder()
2779                .tls_backend_rustls()
2780                .build()?,
2781        )?;
2782
2783        let endpoint = ListIssues::builder()
2784            .start_date(DateFilter::LessThanDaysAgo(5))
2785            .build()?;
2786        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2787
2788        Ok(())
2789    }
2790
2791    #[traced_test]
2792    #[test]
2793    fn test_list_issues_start_date_filter_more_than_days_ago() -> Result<(), Box<dyn Error>> {
2794        let _r_issues = ISSUES_LOCK.blocking_read();
2795        crate::api::test_helpers::setup()?;
2796        let redmine = crate::api::Redmine::from_env(
2797            reqwest::blocking::Client::builder()
2798                .tls_backend_rustls()
2799                .build()?,
2800        )?;
2801
2802        let endpoint = ListIssues::builder()
2803            .start_date(DateFilter::MoreThanDaysAgo(10))
2804            .build()?;
2805        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2806
2807        Ok(())
2808    }
2809
2810    #[traced_test]
2811    #[test]
2812    fn test_list_issues_start_date_filter_within_past_days() -> Result<(), Box<dyn Error>> {
2813        let _r_issues = ISSUES_LOCK.blocking_read();
2814        crate::api::test_helpers::setup()?;
2815        let redmine = crate::api::Redmine::from_env(
2816            reqwest::blocking::Client::builder()
2817                .tls_backend_rustls()
2818                .build()?,
2819        )?;
2820
2821        let endpoint = ListIssues::builder()
2822            .start_date(DateFilter::WithinPastDays(7))
2823            .build()?;
2824        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2825
2826        Ok(())
2827    }
2828
2829    #[traced_test]
2830    #[test]
2831    fn test_list_issues_start_date_filter_exact_days_ago() -> Result<(), Box<dyn Error>> {
2832        let _r_issues = ISSUES_LOCK.blocking_read();
2833        crate::api::test_helpers::setup()?;
2834        let redmine = crate::api::Redmine::from_env(
2835            reqwest::blocking::Client::builder()
2836                .tls_backend_rustls()
2837                .build()?,
2838        )?;
2839
2840        let endpoint = ListIssues::builder()
2841            .start_date(DateFilter::ExactDaysAgo(3))
2842            .build()?;
2843        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2844
2845        Ok(())
2846    }
2847
2848    #[traced_test]
2849    #[test]
2850    fn test_list_issues_start_date_filter_in_less_than_days() -> Result<(), Box<dyn Error>> {
2851        let _r_issues = ISSUES_LOCK.blocking_read();
2852        crate::api::test_helpers::setup()?;
2853        let redmine = crate::api::Redmine::from_env(
2854            reqwest::blocking::Client::builder()
2855                .tls_backend_rustls()
2856                .build()?,
2857        )?;
2858
2859        let endpoint = ListIssues::builder()
2860            .start_date(DateFilter::InLessThanDays(5))
2861            .build()?;
2862        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2863
2864        Ok(())
2865    }
2866
2867    #[traced_test]
2868    #[test]
2869    fn test_list_issues_start_date_filter_in_more_than_days() -> Result<(), Box<dyn Error>> {
2870        let _r_issues = ISSUES_LOCK.blocking_read();
2871        crate::api::test_helpers::setup()?;
2872        let redmine = crate::api::Redmine::from_env(
2873            reqwest::blocking::Client::builder()
2874                .tls_backend_rustls()
2875                .build()?,
2876        )?;
2877
2878        let endpoint = ListIssues::builder()
2879            .start_date(DateFilter::InMoreThanDays(10))
2880            .build()?;
2881        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2882
2883        Ok(())
2884    }
2885
2886    #[traced_test]
2887    #[test]
2888    fn test_list_issues_start_date_filter_within_future_days() -> Result<(), Box<dyn Error>> {
2889        let _r_issues = ISSUES_LOCK.blocking_read();
2890        crate::api::test_helpers::setup()?;
2891        let redmine = crate::api::Redmine::from_env(
2892            reqwest::blocking::Client::builder()
2893                .tls_backend_rustls()
2894                .build()?,
2895        )?;
2896
2897        let endpoint = ListIssues::builder()
2898            .start_date(DateFilter::WithinFutureDays(7))
2899            .build()?;
2900        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2901
2902        Ok(())
2903    }
2904
2905    #[traced_test]
2906    #[test]
2907    fn test_list_issues_start_date_filter_in_exact_days() -> Result<(), Box<dyn Error>> {
2908        let _r_issues = ISSUES_LOCK.blocking_read();
2909        crate::api::test_helpers::setup()?;
2910        let redmine = crate::api::Redmine::from_env(
2911            reqwest::blocking::Client::builder()
2912                .tls_backend_rustls()
2913                .build()?,
2914        )?;
2915
2916        let endpoint = ListIssues::builder()
2917            .start_date(DateFilter::InExactDays(3))
2918            .build()?;
2919        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2920
2921        Ok(())
2922    }
2923
2924    #[traced_test]
2925    #[test]
2926    fn test_list_issues_start_date_filter_today() -> Result<(), Box<dyn Error>> {
2927        let _r_issues = ISSUES_LOCK.blocking_read();
2928        crate::api::test_helpers::setup()?;
2929        let redmine = crate::api::Redmine::from_env(
2930            reqwest::blocking::Client::builder()
2931                .tls_backend_rustls()
2932                .build()?,
2933        )?;
2934
2935        let endpoint = ListIssues::builder()
2936            .start_date(DateFilter::Today)
2937            .build()?;
2938        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2939
2940        Ok(())
2941    }
2942
2943    #[traced_test]
2944    #[test]
2945    fn test_list_issues_start_date_filter_yesterday() -> Result<(), Box<dyn Error>> {
2946        let _r_issues = ISSUES_LOCK.blocking_read();
2947        crate::api::test_helpers::setup()?;
2948        let redmine = crate::api::Redmine::from_env(
2949            reqwest::blocking::Client::builder()
2950                .tls_backend_rustls()
2951                .build()?,
2952        )?;
2953
2954        let endpoint = ListIssues::builder()
2955            .start_date(DateFilter::Yesterday)
2956            .build()?;
2957        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2958
2959        Ok(())
2960    }
2961
2962    #[traced_test]
2963    #[test]
2964    fn test_list_issues_start_date_filter_tomorrow() -> Result<(), Box<dyn Error>> {
2965        let _r_issues = ISSUES_LOCK.blocking_read();
2966        crate::api::test_helpers::setup()?;
2967        let redmine = crate::api::Redmine::from_env(
2968            reqwest::blocking::Client::builder()
2969                .tls_backend_rustls()
2970                .build()?,
2971        )?;
2972
2973        let endpoint = ListIssues::builder()
2974            .start_date(DateFilter::Tomorrow)
2975            .build()?;
2976        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2977
2978        Ok(())
2979    }
2980
2981    #[traced_test]
2982    #[test]
2983    fn test_list_issues_start_date_filter_this_week() -> Result<(), Box<dyn Error>> {
2984        let _r_issues = ISSUES_LOCK.blocking_read();
2985        crate::api::test_helpers::setup()?;
2986        let redmine = crate::api::Redmine::from_env(
2987            reqwest::blocking::Client::builder()
2988                .tls_backend_rustls()
2989                .build()?,
2990        )?;
2991
2992        let endpoint = ListIssues::builder()
2993            .start_date(DateFilter::ThisWeek)
2994            .build()?;
2995        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
2996
2997        Ok(())
2998    }
2999
3000    #[traced_test]
3001    #[test]
3002    fn test_list_issues_start_date_filter_last_week() -> Result<(), Box<dyn Error>> {
3003        let _r_issues = ISSUES_LOCK.blocking_read();
3004        crate::api::test_helpers::setup()?;
3005        let redmine = crate::api::Redmine::from_env(
3006            reqwest::blocking::Client::builder()
3007                .tls_backend_rustls()
3008                .build()?,
3009        )?;
3010
3011        let endpoint = ListIssues::builder()
3012            .start_date(DateFilter::LastWeek)
3013            .build()?;
3014        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3015
3016        Ok(())
3017    }
3018
3019    #[traced_test]
3020    #[test]
3021    fn test_list_issues_start_date_filter_last_two_weeks() -> Result<(), Box<dyn Error>> {
3022        let _r_issues = ISSUES_LOCK.blocking_read();
3023        crate::api::test_helpers::setup()?;
3024        let redmine = crate::api::Redmine::from_env(
3025            reqwest::blocking::Client::builder()
3026                .tls_backend_rustls()
3027                .build()?,
3028        )?;
3029
3030        let endpoint = ListIssues::builder()
3031            .start_date(DateFilter::LastTwoWeeks)
3032            .build()?;
3033        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3034
3035        Ok(())
3036    }
3037
3038    #[traced_test]
3039    #[test]
3040    fn test_list_issues_start_date_filter_next_week() -> Result<(), Box<dyn Error>> {
3041        let _r_issues = ISSUES_LOCK.blocking_read();
3042        crate::api::test_helpers::setup()?;
3043        let redmine = crate::api::Redmine::from_env(
3044            reqwest::blocking::Client::builder()
3045                .tls_backend_rustls()
3046                .build()?,
3047        )?;
3048
3049        let endpoint = ListIssues::builder()
3050            .start_date(DateFilter::NextWeek)
3051            .build()?;
3052        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3053
3054        Ok(())
3055    }
3056
3057    #[traced_test]
3058    #[test]
3059    fn test_list_issues_start_date_filter_this_month() -> Result<(), Box<dyn Error>> {
3060        let _r_issues = ISSUES_LOCK.blocking_read();
3061        crate::api::test_helpers::setup()?;
3062        let redmine = crate::api::Redmine::from_env(
3063            reqwest::blocking::Client::builder()
3064                .tls_backend_rustls()
3065                .build()?,
3066        )?;
3067
3068        let endpoint = ListIssues::builder()
3069            .start_date(DateFilter::ThisMonth)
3070            .build()?;
3071        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3072
3073        Ok(())
3074    }
3075
3076    #[traced_test]
3077    #[test]
3078    fn test_list_issues_start_date_filter_last_month() -> Result<(), Box<dyn Error>> {
3079        let _r_issues = ISSUES_LOCK.blocking_read();
3080        crate::api::test_helpers::setup()?;
3081        let redmine = crate::api::Redmine::from_env(
3082            reqwest::blocking::Client::builder()
3083                .tls_backend_rustls()
3084                .build()?,
3085        )?;
3086
3087        let endpoint = ListIssues::builder()
3088            .start_date(DateFilter::LastMonth)
3089            .build()?;
3090        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3091
3092        Ok(())
3093    }
3094
3095    #[traced_test]
3096    #[test]
3097    fn test_list_issues_start_date_filter_next_month() -> Result<(), Box<dyn Error>> {
3098        let _r_issues = ISSUES_LOCK.blocking_read();
3099        crate::api::test_helpers::setup()?;
3100        let redmine = crate::api::Redmine::from_env(
3101            reqwest::blocking::Client::builder()
3102                .tls_backend_rustls()
3103                .build()?,
3104        )?;
3105
3106        let endpoint = ListIssues::builder()
3107            .start_date(DateFilter::NextMonth)
3108            .build()?;
3109        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3110
3111        Ok(())
3112    }
3113
3114    #[traced_test]
3115    #[test]
3116    fn test_list_issues_start_date_filter_this_year() -> Result<(), Box<dyn Error>> {
3117        let _r_issues = ISSUES_LOCK.blocking_read();
3118        crate::api::test_helpers::setup()?;
3119        let redmine = crate::api::Redmine::from_env(
3120            reqwest::blocking::Client::builder()
3121                .tls_backend_rustls()
3122                .build()?,
3123        )?;
3124
3125        let endpoint = ListIssues::builder()
3126            .start_date(DateFilter::ThisYear)
3127            .build()?;
3128        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3129
3130        Ok(())
3131    }
3132
3133    #[traced_test]
3134    #[test]
3135    fn test_list_issues_start_date_filter_unset() -> Result<(), Box<dyn Error>> {
3136        let _r_issues = ISSUES_LOCK.blocking_read();
3137        crate::api::test_helpers::setup()?;
3138        let redmine = crate::api::Redmine::from_env(
3139            reqwest::blocking::Client::builder()
3140                .tls_backend_rustls()
3141                .build()?,
3142        )?;
3143
3144        let endpoint = ListIssues::builder()
3145            .start_date(DateFilter::Unset)
3146            .build()?;
3147        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3148
3149        Ok(())
3150    }
3151
3152    #[traced_test]
3153    #[test]
3154    fn test_list_issues_start_date_filter_any() -> Result<(), Box<dyn Error>> {
3155        let _r_issues = ISSUES_LOCK.blocking_read();
3156        crate::api::test_helpers::setup()?;
3157        let redmine = crate::api::Redmine::from_env(
3158            reqwest::blocking::Client::builder()
3159                .tls_backend_rustls()
3160                .build()?,
3161        )?;
3162
3163        let endpoint = ListIssues::builder().start_date(DateFilter::Any).build()?;
3164        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3165
3166        Ok(())
3167    }
3168
3169    #[traced_test]
3170    #[test]
3171    fn test_list_issues_due_date_filter_exact_match() -> Result<(), Box<dyn Error>> {
3172        let _r_issues = ISSUES_LOCK.blocking_read();
3173        crate::api::test_helpers::setup()?;
3174        let redmine = crate::api::Redmine::from_env(
3175            reqwest::blocking::Client::builder()
3176                .tls_backend_rustls()
3177                .build()?,
3178        )?;
3179
3180        let dt = time::macros::date!(2023 - 01 - 15);
3181        let endpoint = ListIssues::builder()
3182            .due_date(DateFilter::ExactMatch(dt))
3183            .build()?;
3184        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3185
3186        Ok(())
3187    }
3188
3189    #[traced_test]
3190    #[test]
3191    fn test_list_issues_due_date_filter_range() -> Result<(), Box<dyn Error>> {
3192        let _r_issues = ISSUES_LOCK.blocking_read();
3193        crate::api::test_helpers::setup()?;
3194        let redmine = crate::api::Redmine::from_env(
3195            reqwest::blocking::Client::builder()
3196                .tls_backend_rustls()
3197                .build()?,
3198        )?;
3199
3200        let dt_start = time::macros::date!(2023 - 01 - 01);
3201        let dt_end = time::macros::date!(2023 - 01 - 31);
3202        let endpoint = ListIssues::builder()
3203            .due_date(DateFilter::Range(dt_start, dt_end))
3204            .build()?;
3205        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3206
3207        Ok(())
3208    }
3209
3210    #[traced_test]
3211    #[test]
3212    fn test_list_issues_due_date_filter_less_than_or_equal() -> Result<(), Box<dyn Error>> {
3213        let _r_issues = ISSUES_LOCK.blocking_read();
3214        crate::api::test_helpers::setup()?;
3215        let redmine = crate::api::Redmine::from_env(
3216            reqwest::blocking::Client::builder()
3217                .tls_backend_rustls()
3218                .build()?,
3219        )?;
3220
3221        let dt = time::macros::date!(2023 - 01 - 15);
3222        let endpoint = ListIssues::builder()
3223            .due_date(DateFilter::LessThanOrEqual(dt))
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_greater_than_or_equal() -> Result<(), Box<dyn Error>> {
3233        let _r_issues = ISSUES_LOCK.blocking_read();
3234        crate::api::test_helpers::setup()?;
3235        let redmine = crate::api::Redmine::from_env(
3236            reqwest::blocking::Client::builder()
3237                .tls_backend_rustls()
3238                .build()?,
3239        )?;
3240
3241        let dt = time::macros::date!(2023 - 01 - 15);
3242        let endpoint = ListIssues::builder()
3243            .due_date(DateFilter::GreaterThanOrEqual(dt))
3244            .build()?;
3245        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3246
3247        Ok(())
3248    }
3249
3250    #[traced_test]
3251    #[test]
3252    fn test_list_issues_due_date_filter_less_than_days_ago() -> Result<(), Box<dyn Error>> {
3253        let _r_issues = ISSUES_LOCK.blocking_read();
3254        crate::api::test_helpers::setup()?;
3255        let redmine = crate::api::Redmine::from_env(
3256            reqwest::blocking::Client::builder()
3257                .tls_backend_rustls()
3258                .build()?,
3259        )?;
3260
3261        let endpoint = ListIssues::builder()
3262            .due_date(DateFilter::LessThanDaysAgo(5))
3263            .build()?;
3264        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3265
3266        Ok(())
3267    }
3268
3269    #[traced_test]
3270    #[test]
3271    fn test_list_issues_due_date_filter_more_than_days_ago() -> Result<(), Box<dyn Error>> {
3272        let _r_issues = ISSUES_LOCK.blocking_read();
3273        crate::api::test_helpers::setup()?;
3274        let redmine = crate::api::Redmine::from_env(
3275            reqwest::blocking::Client::builder()
3276                .tls_backend_rustls()
3277                .build()?,
3278        )?;
3279
3280        let endpoint = ListIssues::builder()
3281            .due_date(DateFilter::MoreThanDaysAgo(10))
3282            .build()?;
3283        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3284
3285        Ok(())
3286    }
3287
3288    #[traced_test]
3289    #[test]
3290    fn test_list_issues_due_date_filter_within_past_days() -> Result<(), Box<dyn Error>> {
3291        let _r_issues = ISSUES_LOCK.blocking_read();
3292        crate::api::test_helpers::setup()?;
3293        let redmine = crate::api::Redmine::from_env(
3294            reqwest::blocking::Client::builder()
3295                .tls_backend_rustls()
3296                .build()?,
3297        )?;
3298
3299        let endpoint = ListIssues::builder()
3300            .due_date(DateFilter::WithinPastDays(7))
3301            .build()?;
3302        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3303
3304        Ok(())
3305    }
3306
3307    #[traced_test]
3308    #[test]
3309    fn test_list_issues_due_date_filter_exact_days_ago() -> Result<(), Box<dyn Error>> {
3310        let _r_issues = ISSUES_LOCK.blocking_read();
3311        crate::api::test_helpers::setup()?;
3312        let redmine = crate::api::Redmine::from_env(
3313            reqwest::blocking::Client::builder()
3314                .tls_backend_rustls()
3315                .build()?,
3316        )?;
3317
3318        let endpoint = ListIssues::builder()
3319            .due_date(DateFilter::ExactDaysAgo(3))
3320            .build()?;
3321        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3322
3323        Ok(())
3324    }
3325
3326    #[traced_test]
3327    #[test]
3328    fn test_list_issues_due_date_filter_in_less_than_days() -> Result<(), Box<dyn Error>> {
3329        let _r_issues = ISSUES_LOCK.blocking_read();
3330        crate::api::test_helpers::setup()?;
3331        let redmine = crate::api::Redmine::from_env(
3332            reqwest::blocking::Client::builder()
3333                .tls_backend_rustls()
3334                .build()?,
3335        )?;
3336
3337        let endpoint = ListIssues::builder()
3338            .due_date(DateFilter::InLessThanDays(5))
3339            .build()?;
3340        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3341
3342        Ok(())
3343    }
3344
3345    #[traced_test]
3346    #[test]
3347    fn test_list_issues_due_date_filter_in_more_than_days() -> Result<(), Box<dyn Error>> {
3348        let _r_issues = ISSUES_LOCK.blocking_read();
3349        crate::api::test_helpers::setup()?;
3350        let redmine = crate::api::Redmine::from_env(
3351            reqwest::blocking::Client::builder()
3352                .tls_backend_rustls()
3353                .build()?,
3354        )?;
3355
3356        let endpoint = ListIssues::builder()
3357            .due_date(DateFilter::InMoreThanDays(10))
3358            .build()?;
3359        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3360
3361        Ok(())
3362    }
3363
3364    #[traced_test]
3365    #[test]
3366    fn test_list_issues_due_date_filter_within_future_days() -> Result<(), Box<dyn Error>> {
3367        let _r_issues = ISSUES_LOCK.blocking_read();
3368        crate::api::test_helpers::setup()?;
3369        let redmine = crate::api::Redmine::from_env(
3370            reqwest::blocking::Client::builder()
3371                .tls_backend_rustls()
3372                .build()?,
3373        )?;
3374
3375        let endpoint = ListIssues::builder()
3376            .due_date(DateFilter::WithinFutureDays(7))
3377            .build()?;
3378        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3379
3380        Ok(())
3381    }
3382
3383    #[traced_test]
3384    #[test]
3385    fn test_list_issues_due_date_filter_in_exact_days() -> Result<(), Box<dyn Error>> {
3386        let _r_issues = ISSUES_LOCK.blocking_read();
3387        crate::api::test_helpers::setup()?;
3388        let redmine = crate::api::Redmine::from_env(
3389            reqwest::blocking::Client::builder()
3390                .tls_backend_rustls()
3391                .build()?,
3392        )?;
3393
3394        let endpoint = ListIssues::builder()
3395            .due_date(DateFilter::InExactDays(3))
3396            .build()?;
3397        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3398
3399        Ok(())
3400    }
3401
3402    #[traced_test]
3403    #[test]
3404    fn test_list_issues_due_date_filter_today() -> Result<(), Box<dyn Error>> {
3405        let _r_issues = ISSUES_LOCK.blocking_read();
3406        crate::api::test_helpers::setup()?;
3407        let redmine = crate::api::Redmine::from_env(
3408            reqwest::blocking::Client::builder()
3409                .tls_backend_rustls()
3410                .build()?,
3411        )?;
3412
3413        let endpoint = ListIssues::builder().due_date(DateFilter::Today).build()?;
3414        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3415
3416        Ok(())
3417    }
3418
3419    #[traced_test]
3420    #[test]
3421    fn test_list_issues_due_date_filter_yesterday() -> Result<(), Box<dyn Error>> {
3422        let _r_issues = ISSUES_LOCK.blocking_read();
3423        crate::api::test_helpers::setup()?;
3424        let redmine = crate::api::Redmine::from_env(
3425            reqwest::blocking::Client::builder()
3426                .tls_backend_rustls()
3427                .build()?,
3428        )?;
3429
3430        let endpoint = ListIssues::builder()
3431            .due_date(DateFilter::Yesterday)
3432            .build()?;
3433        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3434
3435        Ok(())
3436    }
3437
3438    #[traced_test]
3439    #[test]
3440    fn test_list_issues_due_date_filter_tomorrow() -> Result<(), Box<dyn Error>> {
3441        let _r_issues = ISSUES_LOCK.blocking_read();
3442        crate::api::test_helpers::setup()?;
3443        let redmine = crate::api::Redmine::from_env(
3444            reqwest::blocking::Client::builder()
3445                .tls_backend_rustls()
3446                .build()?,
3447        )?;
3448
3449        let endpoint = ListIssues::builder()
3450            .due_date(DateFilter::Tomorrow)
3451            .build()?;
3452        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3453
3454        Ok(())
3455    }
3456
3457    #[traced_test]
3458    #[test]
3459    fn test_list_issues_due_date_filter_this_week() -> Result<(), Box<dyn Error>> {
3460        let _r_issues = ISSUES_LOCK.blocking_read();
3461        crate::api::test_helpers::setup()?;
3462        let redmine = crate::api::Redmine::from_env(
3463            reqwest::blocking::Client::builder()
3464                .tls_backend_rustls()
3465                .build()?,
3466        )?;
3467
3468        let endpoint = ListIssues::builder()
3469            .due_date(DateFilter::ThisWeek)
3470            .build()?;
3471        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3472
3473        Ok(())
3474    }
3475
3476    #[traced_test]
3477    #[test]
3478    fn test_list_issues_due_date_filter_last_week() -> Result<(), Box<dyn Error>> {
3479        let _r_issues = ISSUES_LOCK.blocking_read();
3480        crate::api::test_helpers::setup()?;
3481        let redmine = crate::api::Redmine::from_env(
3482            reqwest::blocking::Client::builder()
3483                .tls_backend_rustls()
3484                .build()?,
3485        )?;
3486
3487        let endpoint = ListIssues::builder()
3488            .due_date(DateFilter::LastWeek)
3489            .build()?;
3490        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3491
3492        Ok(())
3493    }
3494
3495    #[traced_test]
3496    #[test]
3497    fn test_list_issues_due_date_filter_last_two_weeks() -> Result<(), Box<dyn Error>> {
3498        let _r_issues = ISSUES_LOCK.blocking_read();
3499        crate::api::test_helpers::setup()?;
3500        let redmine = crate::api::Redmine::from_env(
3501            reqwest::blocking::Client::builder()
3502                .tls_backend_rustls()
3503                .build()?,
3504        )?;
3505
3506        let endpoint = ListIssues::builder()
3507            .due_date(DateFilter::LastTwoWeeks)
3508            .build()?;
3509        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3510
3511        Ok(())
3512    }
3513
3514    #[traced_test]
3515    #[test]
3516    fn test_list_issues_due_date_filter_next_week() -> Result<(), Box<dyn Error>> {
3517        let _r_issues = ISSUES_LOCK.blocking_read();
3518        crate::api::test_helpers::setup()?;
3519        let redmine = crate::api::Redmine::from_env(
3520            reqwest::blocking::Client::builder()
3521                .tls_backend_rustls()
3522                .build()?,
3523        )?;
3524
3525        let endpoint = ListIssues::builder()
3526            .due_date(DateFilter::NextWeek)
3527            .build()?;
3528        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3529
3530        Ok(())
3531    }
3532
3533    #[traced_test]
3534    #[test]
3535    fn test_list_issues_due_date_filter_this_month() -> Result<(), Box<dyn Error>> {
3536        let _r_issues = ISSUES_LOCK.blocking_read();
3537        crate::api::test_helpers::setup()?;
3538        let redmine = crate::api::Redmine::from_env(
3539            reqwest::blocking::Client::builder()
3540                .tls_backend_rustls()
3541                .build()?,
3542        )?;
3543
3544        let endpoint = ListIssues::builder()
3545            .due_date(DateFilter::ThisMonth)
3546            .build()?;
3547        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3548
3549        Ok(())
3550    }
3551
3552    #[traced_test]
3553    #[test]
3554    fn test_list_issues_due_date_filter_last_month() -> Result<(), Box<dyn Error>> {
3555        let _r_issues = ISSUES_LOCK.blocking_read();
3556        crate::api::test_helpers::setup()?;
3557        let redmine = crate::api::Redmine::from_env(
3558            reqwest::blocking::Client::builder()
3559                .tls_backend_rustls()
3560                .build()?,
3561        )?;
3562
3563        let endpoint = ListIssues::builder()
3564            .due_date(DateFilter::LastMonth)
3565            .build()?;
3566        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3567
3568        Ok(())
3569    }
3570
3571    #[traced_test]
3572    #[test]
3573    fn test_list_issues_due_date_filter_next_month() -> Result<(), Box<dyn Error>> {
3574        let _r_issues = ISSUES_LOCK.blocking_read();
3575        crate::api::test_helpers::setup()?;
3576        let redmine = crate::api::Redmine::from_env(
3577            reqwest::blocking::Client::builder()
3578                .tls_backend_rustls()
3579                .build()?,
3580        )?;
3581
3582        let endpoint = ListIssues::builder()
3583            .due_date(DateFilter::NextMonth)
3584            .build()?;
3585        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3586
3587        Ok(())
3588    }
3589
3590    #[traced_test]
3591    #[test]
3592    fn test_list_issues_due_date_filter_this_year() -> Result<(), Box<dyn Error>> {
3593        let _r_issues = ISSUES_LOCK.blocking_read();
3594        crate::api::test_helpers::setup()?;
3595        let redmine = crate::api::Redmine::from_env(
3596            reqwest::blocking::Client::builder()
3597                .tls_backend_rustls()
3598                .build()?,
3599        )?;
3600
3601        let endpoint = ListIssues::builder()
3602            .due_date(DateFilter::ThisYear)
3603            .build()?;
3604        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3605
3606        Ok(())
3607    }
3608
3609    #[traced_test]
3610    #[test]
3611    fn test_list_issues_due_date_filter_unset() -> Result<(), Box<dyn Error>> {
3612        let _r_issues = ISSUES_LOCK.blocking_read();
3613        crate::api::test_helpers::setup()?;
3614        let redmine = crate::api::Redmine::from_env(
3615            reqwest::blocking::Client::builder()
3616                .tls_backend_rustls()
3617                .build()?,
3618        )?;
3619
3620        let endpoint = ListIssues::builder().due_date(DateFilter::Unset).build()?;
3621        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3622
3623        Ok(())
3624    }
3625
3626    #[traced_test]
3627    #[test]
3628    fn test_list_issues_due_date_filter_any() -> Result<(), Box<dyn Error>> {
3629        let _r_issues = ISSUES_LOCK.blocking_read();
3630        crate::api::test_helpers::setup()?;
3631        let redmine = crate::api::Redmine::from_env(
3632            reqwest::blocking::Client::builder()
3633                .tls_backend_rustls()
3634                .build()?,
3635        )?;
3636
3637        let endpoint = ListIssues::builder().due_date(DateFilter::Any).build()?;
3638        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3639
3640        Ok(())
3641    }
3642
3643    #[traced_test]
3644    #[test]
3645    fn test_list_issues_child_id_filter() -> Result<(), Box<dyn Error>> {
3646        let _r_issues = ISSUES_LOCK.blocking_read();
3647        crate::api::test_helpers::setup()?;
3648        let redmine = crate::api::Redmine::from_env(
3649            reqwest::blocking::Client::builder()
3650                .tls_backend_rustls()
3651                .build()?,
3652        )?;
3653
3654        let endpoint = ListIssues::builder().child_id(vec![123, 456]).build()?;
3655        redmine.json_response_body_page::<_, Issue>(&endpoint, 0, 25)?;
3656
3657        Ok(())
3658    }
3659}