|
9 | 9 | import seatsio.util.PageFetcher;
|
10 | 10 |
|
11 | 11 | import java.io.InputStream;
|
12 |
| -import java.util.HashMap; |
13 | 12 | import java.util.List;
|
14 | 13 | import java.util.Map;
|
15 | 14 | import java.util.stream.Stream;
|
@@ -189,57 +188,39 @@ public List<String> listAllTags() {
|
189 | 188 | }
|
190 | 189 |
|
191 | 190 | public Stream<Chart> listAll() {
|
192 |
| - return listAll(null, null, null); |
| 191 | + return listAll(new ChartListParams()); |
193 | 192 | }
|
194 | 193 |
|
195 |
| - public Stream<Chart> listAll(String filter, String tag, Boolean expandEvents) { |
196 |
| - return list().all(chartListParams(filter, tag, expandEvents)); |
| 194 | + public Stream<Chart> listAll(ChartListParams chartListParams) { |
| 195 | + return list().all(chartListParams.asMap()); |
197 | 196 | }
|
198 | 197 |
|
199 | 198 | public Page<Chart> listFirstPage() {
|
200 |
| - return listFirstPage(null, null, null, null); |
| 199 | + return listFirstPage(new ChartListParams(), null); |
201 | 200 | }
|
202 | 201 |
|
203 |
| - public Page<Chart> listFirstPage(String filter, String tag, Boolean expandEvents, Integer pageSize) { |
204 |
| - return list().firstPage(chartListParams(filter, tag, expandEvents), pageSize); |
| 202 | + public Page<Chart> listFirstPage(ChartListParams chartListParams, Integer pageSize) { |
| 203 | + return list().firstPage(chartListParams.asMap(), pageSize); |
205 | 204 | }
|
206 | 205 |
|
207 | 206 | public Page<Chart> listPageAfter(long id) {
|
208 |
| - return listPageAfter(id, null, null, null, null); |
| 207 | + return listPageAfter(id, new ChartListParams(), null); |
209 | 208 | }
|
210 | 209 |
|
211 |
| - public Page<Chart> listPageAfter(long id, String filter, String tag, Boolean expandEvents, Integer pageSize) { |
212 |
| - return list().pageAfter(id, chartListParams(filter, tag, expandEvents), pageSize); |
| 210 | + public Page<Chart> listPageAfter(long id, ChartListParams chartListParams, Integer pageSize) { |
| 211 | + return list().pageAfter(id, chartListParams.asMap(), pageSize); |
213 | 212 | }
|
214 | 213 |
|
215 | 214 | public Page<Chart> listPageBefore(long id) {
|
216 |
| - return listPageBefore(id, null, null, null, null); |
| 215 | + return listPageBefore(id, new ChartListParams(), null); |
217 | 216 | }
|
218 | 217 |
|
219 |
| - public Page<Chart> listPageBefore(long id, String filter, String tag, Boolean expandEvents, Integer pageSize) { |
220 |
| - return list().pageBefore(id, chartListParams(filter, tag, expandEvents), pageSize); |
| 218 | + public Page<Chart> listPageBefore(long id, ChartListParams chartListParams, Integer pageSize) { |
| 219 | + return list().pageBefore(id, chartListParams.asMap(), pageSize); |
221 | 220 | }
|
222 | 221 |
|
223 | 222 | private Lister<Chart> list() {
|
224 | 223 | return new Lister<>(new PageFetcher<>(baseUrl, "/charts", secretKey, Chart.class));
|
225 | 224 | }
|
226 | 225 |
|
227 |
| - private Map<String, Object> chartListParams(String filter, String tag, Boolean expandEvents) { |
228 |
| - Map<String, Object> chartListParams = new HashMap<>(); |
229 |
| - |
230 |
| - if (filter != null) { |
231 |
| - chartListParams.put("filter", filter); |
232 |
| - } |
233 |
| - |
234 |
| - if (tag != null) { |
235 |
| - chartListParams.put("tag", tag); |
236 |
| - } |
237 |
| - |
238 |
| - if (expandEvents != null && expandEvents) { |
239 |
| - chartListParams.put("expand", "events"); |
240 |
| - } |
241 |
| - |
242 |
| - return chartListParams; |
243 |
| - } |
244 |
| - |
245 | 226 | }
|
0 commit comments