Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
RtNotifications |
|
| 1.3333333333333333;1.333 | ||||
RtNotifications$1 |
|
| 1.3333333333333333;1.333 |
1 | 2 | /** |
2 | * Copyright (c) 2013-2017, jcabi.com | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: 1) Redistributions of source code must retain the above | |
8 | * copyright notice, this list of conditions and the following | |
9 | * disclaimer. 2) Redistributions in binary form must reproduce the above | |
10 | * copyright notice, this list of conditions and the following | |
11 | * disclaimer in the documentation and/or other materials provided | |
12 | * with the distribution. 3) Neither the name of the jcabi.com nor | |
13 | * the names of its contributors may be used to endorse or promote | |
14 | * products derived from this software without specific prior written | |
15 | * permission. | |
16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | |
19 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
20 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
21 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
28 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | */ | |
30 | package com.jcabi.github; | |
31 | ||
32 | import com.jcabi.aspects.Immutable; | |
33 | import com.jcabi.http.Request; | |
34 | import javax.json.JsonObject; | |
35 | import org.apache.commons.lang3.NotImplementedException; | |
36 | ||
37 | /** | |
38 | * Github Notifications. | |
39 | * | |
40 | * @author Giang Le (lthuangiang@gmail.com) | |
41 | * @author Paul Polishchuk (ppol@ua.fm) | |
42 | * @version $Id: 3fb1e08a98592dcc17e5eb46a0d3cfee6a39254b $ | |
43 | * @since 0.15 | |
44 | * @see <a href="https://developer.github.com/v3/activity/notifications/">Notifications API</a> | |
45 | * @todo #913:30min Implement markAsRead(), thread(final int number) operations | |
46 | * in RtNotifications. Don't forget about unit tests. | |
47 | */ | |
48 | @Immutable | |
49 | final class RtNotifications implements Notifications { | |
50 | /** | |
51 | * RESTful request. | |
52 | */ | |
53 | private final transient Request request; | |
54 | ||
55 | /** | |
56 | * Ctor. | |
57 | * @param req The request for this notifications. | |
58 | */ | |
59 | 4 | RtNotifications(final Request req) { |
60 | 4 | this.request = req; |
61 | 4 | } |
62 | ||
63 | @Override | |
64 | public Iterable<Notification> iterate() { | |
65 | 4 | return new RtPagination<Notification>( |
66 | 2 | this.request.uri() |
67 | 2 | .queryParam("all", "true") |
68 | 2 | .queryParam("since", "1970-01-01T00:00:00Z") |
69 | 2 | .back(), |
70 | 2 | new RtValuePagination.Mapping<Notification, JsonObject>() { |
71 | @Override | |
72 | public Notification map(final JsonObject json) { | |
73 | 0 | return new RtNotification( |
74 | 0 | Long.valueOf(json.getString("id")) |
75 | ); | |
76 | } | |
77 | } | |
78 | ); | |
79 | } | |
80 | ||
81 | @Override | |
82 | public Notification get(final int number) { | |
83 | 0 | return new RtNotification(number); |
84 | } | |
85 | ||
86 | @Override | |
87 | public void markAsRead() { | |
88 | 0 | throw new NotImplementedException("RtNotifications#markAsRead"); |
89 | } | |
90 | ||
91 | @Override | |
92 | public GitHubThread thread(final int number) { | |
93 | 0 | throw new NotImplementedException("RtNotifications#thread"); |
94 | } | |
95 | } |