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