1#[derive(Debug, Default, Clone)]
7pub struct TopHeadlinesParams {
8 pub(crate) country: Option<String>,
9 pub(crate) category: Option<String>,
10 pub(crate) sources: Option<String>,
11 pub(crate) q: Option<String>,
12 pub(crate) page_size: Option<u32>,
13 pub(crate) page: Option<u32>,
14}
15
16impl TopHeadlinesParams {
17 pub fn new() -> Self {
19 Self::default()
20 }
21
22 pub fn country(mut self, country: impl Into<String>) -> Self {
24 self.country = Some(country.into());
25 self
26 }
27
28 pub fn category(mut self, category: impl Into<String>) -> Self {
30 self.category = Some(category.into());
31 self
32 }
33
34 pub fn sources(mut self, sources: impl Into<String>) -> Self {
36 self.sources = Some(sources.into());
37 self
38 }
39
40 pub fn q(mut self, query: impl Into<String>) -> Self {
42 self.q = Some(query.into());
43 self
44 }
45
46 pub fn page(mut self, page: u32) -> Self {
48 self.page = Some(page.max(1));
49 self
50 }
51
52 pub fn page_size(mut self, size: u32) -> Self {
54 self.page_size = Some(size.min(100));
55 self
56 }
57}
58
59#[derive(Debug, Clone, Default)]
63pub struct EverythingParams {
64 pub(crate) q: Option<String>,
65 pub(crate) q_in_title: Option<String>,
66 pub(crate) sources: Option<String>,
67 pub(crate) domains: Option<String>,
68 pub(crate) from: Option<String>,
69 pub(crate) to: Option<String>,
70 pub(crate) language: Option<String>,
71 pub(crate) sort_by: Option<String>,
72 pub(crate) page_size: Option<u32>,
73 pub(crate) page: Option<u32>,
74}
75
76impl EverythingParams {
77 pub fn new() -> Self {
79 Self::default()
80 }
81
82 pub fn q(mut self, query: impl Into<String>) -> Self {
84 self.q = Some(query.into());
85 self
86 }
87
88 pub fn q_in_title(mut self, query: impl Into<String>) -> Self {
90 self.q_in_title = Some(query.into());
91 self
92 }
93
94 pub fn sources(mut self, sources: impl Into<String>) -> Self {
96 self.sources = Some(sources.into());
97 self
98 }
99
100 pub fn from(mut self, from: impl Into<String>) -> Self {
102 self.from = Some(from.into());
103 self
104 }
105
106 pub fn to(mut self, to: impl Into<String>) -> Self {
108 self.to = Some(to.into());
109 self
110 }
111
112 pub fn domains(mut self, domains: impl Into<String>) -> Self {
114 self.domains = Some(domains.into());
115 self
116 }
117
118 pub fn language(mut self, lang: impl Into<String>) -> Self {
120 self.language = Some(lang.into());
121 self
122 }
123
124 pub fn sort_by(mut self, sort: impl Into<String>) -> Self {
126 self.sort_by = Some(sort.into());
127 self
128 }
129
130 pub fn page_size(mut self, size: u32) -> Self {
132 self.page_size = Some(size.min(100));
133 self
134 }
135
136 pub fn page(mut self, page: u32) -> Self {
138 self.page = Some(page.max(1));
139 self
140 }
141}
142
143#[derive(Debug, Clone, Default)]
147pub struct SourceParams {
148 pub(crate) category: Option<String>,
149 pub(crate) language: Option<String>,
150 pub(crate) country: Option<String>,
151}
152
153impl SourceParams {
154 pub fn new() -> Self {
156 Self::default()
157 }
158
159 pub fn category(mut self, category: impl Into<String>) -> Self {
161 self.category = Some(category.into());
162 self
163 }
164
165 pub fn language(mut self, lang: impl Into<String>) -> Self {
167 self.language = Some(lang.into());
168 self
169 }
170
171 pub fn country(mut self, country: impl Into<String>) -> Self {
173 self.country = Some(country.into());
174 self
175 }
176}