Skip to content

Commit cabb2b2

Browse files
authored
feat: add unseen, unread to notificationfeed response (#104)
1 parent f7599c5 commit cabb2b2

File tree

8 files changed

+227
-342
lines changed

8 files changed

+227
-342
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/io/getstream/client/NotificationFeed.java

Lines changed: 87 additions & 165 deletions
Large diffs are not rendered by default.

src/main/java/io/getstream/cloud/CloudNotificationFeed.java

Lines changed: 87 additions & 165 deletions
Large diffs are not rendered by default.

src/main/java/io/getstream/core/http/OKHTTPClientAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public void onFailure(Call call, IOException e) {
103103

104104
@Override
105105
public void onResponse(Call call, okhttp3.Response response) {
106-
io.getstream.core.http.Response httpResponse = buildResponse(response);
107-
try (InputStream ignored = httpResponse.getBody()) {
106+
try {
107+
io.getstream.core.http.Response httpResponse = buildResponse(response);
108108
result.complete(httpResponse);
109109
} catch (Exception e) {
110110
result.completeExceptionally(e);

src/main/java/io/getstream/core/models/Paginated.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public String getDuration() {
3131
}
3232

3333
@JsonCreator
34-
private Paginated(
34+
public Paginated(
3535
@JsonProperty("next") String next,
3636
@JsonProperty("results") List<T> results,
3737
@JsonProperty("duration") String duration) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.getstream.core.models;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import java.util.List;
7+
8+
@JsonIgnoreProperties(ignoreUnknown = true)
9+
public class PaginatedNotificationGroup<T> extends Paginated<NotificationGroup<T>> {
10+
private final int unread;
11+
private final int unseen;
12+
13+
@JsonCreator
14+
public PaginatedNotificationGroup(
15+
@JsonProperty("next") String next,
16+
@JsonProperty("results") List<NotificationGroup<T>> results,
17+
@JsonProperty("duration") String duration,
18+
@JsonProperty("unread") int unread,
19+
@JsonProperty("unseen") int unseen) {
20+
super(next, results, duration);
21+
22+
this.unread = unread;
23+
this.unseen = unseen;
24+
}
25+
26+
public int getUnread() {
27+
return this.unread;
28+
}
29+
30+
public int getUnseen() {
31+
return this.unseen;
32+
}
33+
}

src/test/java/io/getstream/client/NotificationFeedTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package io.getstream.client;
22

3+
import static org.junit.Assert.*;
4+
35
import io.getstream.core.http.OKHTTPClientAdapter;
46
import io.getstream.core.models.Activity;
57
import io.getstream.core.models.EnrichedActivity;
6-
import io.getstream.core.models.NotificationGroup;
7-
import java.util.List;
8+
import io.getstream.core.models.PaginatedNotificationGroup;
89
import okhttp3.OkHttpClient;
910
import org.junit.Test;
1011

@@ -26,7 +27,9 @@ public void getActivityGroups() throws Exception {
2627
.build();
2728

2829
NotificationFeed feed = client.notificationFeed("notification", "1");
29-
List<NotificationGroup<Activity>> result = feed.getActivities().join();
30+
PaginatedNotificationGroup<Activity> result = feed.getActivities().join();
31+
assertFalse(result.getResults().isEmpty());
32+
assertNotNull(result.getResults().get(0).getID());
3033
}
3134

3235
@Test
@@ -37,6 +40,8 @@ public void getEnrichedActivityGroups() throws Exception {
3740
.build();
3841

3942
NotificationFeed feed = client.notificationFeed("notification", "1");
40-
List<NotificationGroup<EnrichedActivity>> result = feed.getEnrichedActivities().join();
43+
PaginatedNotificationGroup<EnrichedActivity> result = feed.getEnrichedActivities().join();
44+
assertFalse(result.getResults().isEmpty());
45+
assertNotNull(result.getResults().get(0).getID());
4146
}
4247
}

src/test/java/io/getstream/cloud/CloudNotificationFeedTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package io.getstream.cloud;
22

3+
import static org.junit.Assert.*;
4+
35
import io.getstream.client.Client;
46
import io.getstream.core.http.Token;
57
import io.getstream.core.models.Activity;
68
import io.getstream.core.models.EnrichedActivity;
7-
import io.getstream.core.models.NotificationGroup;
9+
import io.getstream.core.models.PaginatedNotificationGroup;
810
import io.getstream.core.utils.Enrichment;
911
import java.net.MalformedURLException;
10-
import java.util.List;
1112
import org.junit.BeforeClass;
1213
import org.junit.Test;
1314

@@ -53,14 +54,16 @@ public void getActivityGroups() throws Exception {
5354
CloudClient client = CloudClient.builder(apiKey, token, userID).build();
5455

5556
CloudNotificationFeed feed = client.notificationFeed("notification", userID);
56-
List<NotificationGroup<Activity>> result = feed.getActivities().join();
57+
PaginatedNotificationGroup<Activity> result = feed.getActivities().join();
58+
assertFalse(result.getResults().isEmpty());
59+
assertNotNull(result.getResults().get(0).getID());
5760
}
5861

5962
@Test
6063
public void getEnrichedActivityGroups() throws Exception {
6164
CloudClient client = CloudClient.builder(apiKey, token, userID).build();
6265

6366
CloudNotificationFeed feed = client.notificationFeed("rich_notification", userID);
64-
List<NotificationGroup<EnrichedActivity>> result = feed.getEnrichedActivities().join();
67+
PaginatedNotificationGroup<EnrichedActivity> result = feed.getEnrichedActivities().join();
6568
}
6669
}

0 commit comments

Comments
 (0)