1use crate::{Orientation, Size};
2
3#[derive(Debug, Clone, Default)]
4pub struct SearchParams {
5 pub page: Option<u32>,
6 pub per_page: Option<u32>,
7 pub orientation: Option<Orientation>,
8 pub size: Option<Size>,
9 pub color: Option<String>,
10 pub locale: Option<String>,
11}
12
13impl SearchParams {
14 pub fn new() -> Self {
15 Self::default()
16 }
17
18 pub fn page(mut self, page: u32) -> Self {
19 self.page = Some(page);
20 self
21 }
22
23 pub fn per_page(mut self, per_page: u32) -> Self {
24 self.per_page = Some(per_page);
25 self
26 }
27
28 pub fn orientation(mut self, orientation: Orientation) -> Self {
29 self.orientation = Some(orientation);
30 self
31 }
32
33 pub fn size(mut self, size: Size) -> Self {
34 self.size = Some(size);
35 self
36 }
37
38 pub fn color(mut self, color: impl Into<String>) -> Self {
39 self.color = Some(color.into());
40 self
41 }
42
43 pub fn locale(mut self, locale: impl Into<String>) -> Self {
44 self.locale = Some(locale.into());
45 self
46 }
47
48 pub fn to_query_params(&self) -> Vec<(String, String)> {
49 let mut params = Vec::new();
50
51 if let Some(page) = self.page {
52 params.push(("page".to_string(), page.to_string()));
53 }
54
55 if let Some(per_page) = self.per_page {
56 params.push(("per_page".to_string(), per_page.to_string()));
57 }
58
59 if let Some(orientation) = &self.orientation {
60 params.push(("orientation".to_string(), orientation.to_string()));
61 }
62
63 if let Some(size) = &self.size {
64 params.push(("size".to_string(), size.to_string()));
65 }
66
67 if let Some(color) = &self.color {
68 params.push(("color".to_string(), color.clone()));
69 }
70
71 if let Some(locale) = &self.locale {
72 params.push(("locale".to_string(), locale.clone()));
73 }
74
75 params
76 }
77}
78
79#[derive(Debug, Clone, Default)]
81pub struct PaginationParams {
82 pub page: Option<u32>,
84
85 pub per_page: Option<u32>,
87}
88
89impl PaginationParams {
90 pub fn new() -> Self {
92 Self::default()
93 }
94
95 pub fn page(mut self, page: u32) -> Self {
97 self.page = Some(page);
98 self
99 }
100
101 pub fn per_page(mut self, per_page: u32) -> Self {
103 self.per_page = Some(per_page);
104 self
105 }
106}
107
108#[derive(Debug, Clone, Default)]
110pub struct VideoSearchParams {
111 pub page: Option<u32>,
113
114 pub per_page: Option<u32>,
116
117 pub orientation: Option<String>,
119
120 pub size: Option<String>,
122
123 pub locale: Option<String>,
125}
126
127impl VideoSearchParams {
128 pub fn new() -> Self {
130 Self::default()
131 }
132
133 pub fn page(mut self, page: u32) -> Self {
135 self.page = Some(page);
136 self
137 }
138
139 pub fn per_page(mut self, per_page: u32) -> Self {
141 self.per_page = Some(per_page);
142 self
143 }
144
145 pub fn orientation(mut self, orientation: impl Into<String>) -> Self {
147 self.orientation = Some(orientation.into());
148 self
149 }
150
151 pub fn size(mut self, size: impl Into<String>) -> Self {
153 self.size = Some(size.into());
154 self
155 }
156
157 pub fn locale(mut self, locale: impl Into<String>) -> Self {
159 self.locale = Some(locale.into());
160 self
161 }
162}