1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
use participants::ParticipantId;
use tournaments::TournamentId;
use videos::VideoCategory;
use common::Date;
use std::fmt;
#[derive(Debug, Clone)]
pub enum DateSortFilter {
DateAscending,
DateDescending,
}
impl fmt::Display for DateSortFilter {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
DateSortFilter::DateAscending => fmt.write_str("date_asc"),
DateSortFilter::DateDescending => fmt.write_str("date_desc"),
}
}
}
#[derive(Debug, Clone)]
pub enum CreateDateSortFilter {
CreatedAscending,
CreatedDescending,
}
impl fmt::Display for CreateDateSortFilter {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
CreateDateSortFilter::CreatedAscending => fmt.write_str("created_asc"),
CreateDateSortFilter::CreatedDescending => fmt.write_str("created_desc"),
}
}
}
#[derive(Debug, Clone)]
pub struct MatchFilter {
pub featured: Option<bool>,
pub has_result: Option<bool>,
pub sort: Option<DateSortFilter>,
pub participant_id: Option<ParticipantId>,
pub tournament_ids: Option<Vec<TournamentId>>,
pub with_games: bool,
pub before_date: Option<Date>,
pub after_date: Option<Date>,
pub page: Option<i64>,
}
impl Default for MatchFilter {
fn default() -> MatchFilter {
MatchFilter {
featured: None,
has_result: None,
sort: Some(DateSortFilter::DateAscending),
participant_id: None,
tournament_ids: None,
with_games: false,
before_date: None,
after_date: None,
page: Some(1i64),
}
}
}
impl MatchFilter {
builder_o!(featured, bool);
builder_o!(has_result, bool);
builder_o!(sort, DateSortFilter);
builder_o!(participant_id, ParticipantId);
builder_o!(tournament_ids, Vec<TournamentId>);
builder!(with_games, bool);
builder_o!(before_date, Date);
builder_o!(after_date, Date);
builder_o!(page, i64);
}
#[derive(Debug, Clone)]
pub struct TournamentParticipantsFilter {
pub with_lineup: bool,
pub with_custom_fields: bool,
pub sort: DateSortFilter,
pub page: i64,
}
impl Default for TournamentParticipantsFilter {
fn default() -> TournamentParticipantsFilter {
TournamentParticipantsFilter {
with_lineup: false,
sort: DateSortFilter::DateAscending,
with_custom_fields: false,
page: 1i64,
}
}
}
impl TournamentParticipantsFilter {
builder!(with_lineup, bool);
builder!(sort, DateSortFilter);
builder!(with_custom_fields, bool);
builder!(page, i64);
}
#[derive(Debug, Clone)]
pub struct TournamentVideosFilter {
pub category: Option<VideoCategory>,
pub sort: CreateDateSortFilter,
pub page: Option<i64>,
}
impl Default for TournamentVideosFilter {
fn default() -> TournamentVideosFilter {
TournamentVideosFilter {
category: None,
sort: CreateDateSortFilter::CreatedAscending,
page: None,
}
}
}
impl TournamentVideosFilter {
builder_o!(category, VideoCategory);
builder!(sort, CreateDateSortFilter);
builder_o!(page, i64);
}